59 lines
1.7 KiB
Swift
59 lines
1.7 KiB
Swift
import SwiftUI
|
|
|
|
struct FollowAllButton: View {
|
|
let isCompleted: Bool
|
|
let isLoading: Bool
|
|
let action: () -> Void
|
|
|
|
init(
|
|
isCompleted: Bool,
|
|
isLoading: Bool = false,
|
|
action: @escaping () -> Void
|
|
) {
|
|
self.isCompleted = isCompleted
|
|
self.isLoading = isLoading
|
|
self.action = action
|
|
}
|
|
|
|
var body: some View {
|
|
Button {
|
|
if !isCompleted && !isLoading {
|
|
action()
|
|
}
|
|
} label: {
|
|
HStack(spacing: SodaSpacing.s6) {
|
|
if isCompleted {
|
|
Image("ic_new_following")
|
|
.resizable()
|
|
.renderingMode(.template)
|
|
.foregroundColor(.white)
|
|
.frame(width: 16, height: 16)
|
|
}
|
|
|
|
Text(isCompleted ? I18n.HomeRecommendation.followAllCompleted : I18n.HomeRecommendation.followAll)
|
|
.appFont(.body5)
|
|
.foregroundColor(.white)
|
|
}
|
|
.padding(.horizontal, SodaSpacing.s16)
|
|
.frame(height: 36)
|
|
.background(isCompleted ? Color.gray700 : Color.button)
|
|
.clipShape(Capsule())
|
|
.opacity(isLoading ? 0.6 : 1)
|
|
}
|
|
.buttonStyle(.plain)
|
|
.disabled(isCompleted || isLoading)
|
|
}
|
|
}
|
|
|
|
struct FollowAllButton_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
VStack(spacing: SodaSpacing.s12) {
|
|
FollowAllButton(isCompleted: false) {}
|
|
FollowAllButton(isCompleted: true) {}
|
|
}
|
|
.padding(SodaSpacing.s20)
|
|
.background(Color.black)
|
|
.previewLayout(.sizeThatFits)
|
|
}
|
|
}
|