feat(main-home): 추천 홈 공용 컴포넌트를 추가한다
This commit is contained in:
58
SodaLive/Sources/V2/Component/Button/FollowAllButton.swift
Normal file
58
SodaLive/Sources/V2/Component/Button/FollowAllButton.swift
Normal file
@@ -0,0 +1,58 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user