feat(creator): 오디오 탭을 추가한다
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
|
||||
struct CreatorChannelAudioOwnershipRateView: View {
|
||||
let purchasedAudioContentRate: Double
|
||||
let purchasedAudioContentCount: Int
|
||||
let paidAudioContentCount: Int
|
||||
|
||||
private var progress: CGFloat {
|
||||
CGFloat(max(0, min(purchasedAudioContentRate / 100, 1)))
|
||||
}
|
||||
|
||||
private var rateText: String {
|
||||
let rounded = purchasedAudioContentRate.rounded()
|
||||
if rounded == purchasedAudioContentRate {
|
||||
return "\(Int(rounded))%"
|
||||
}
|
||||
return String(format: "%.1f%%", purchasedAudioContentRate)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: SodaSpacing.s14) {
|
||||
HStack(alignment: .center, spacing: SodaSpacing.s4) {
|
||||
(
|
||||
Text(I18n.CreatorChannelAudio.ownershipPrefix)
|
||||
.foregroundColor(.white)
|
||||
+ Text(rateText)
|
||||
.foregroundColor(Color.soda400)
|
||||
+ Text(I18n.CreatorChannelAudio.ownershipSuffix)
|
||||
.foregroundColor(.white)
|
||||
)
|
||||
.appFont(size: 14, weight: .medium)
|
||||
.lineLimit(1)
|
||||
|
||||
Spacer(minLength: SodaSpacing.s8)
|
||||
|
||||
(
|
||||
Text(purchasedAudioContentCount.comma())
|
||||
.foregroundColor(.white)
|
||||
+ Text("/\(paidAudioContentCount.comma())\(I18n.CreatorChannelAudio.countUnit)")
|
||||
.foregroundColor(Color.gray500)
|
||||
)
|
||||
.appFont(size: 14, weight: .medium)
|
||||
.lineLimit(1)
|
||||
}
|
||||
|
||||
GeometryReader { proxy in
|
||||
ZStack(alignment: .leading) {
|
||||
Capsule()
|
||||
.fill(Color.gray800)
|
||||
|
||||
Capsule()
|
||||
.fill(Color.soda400)
|
||||
.frame(width: proxy.size.width * progress)
|
||||
}
|
||||
}
|
||||
.frame(height: 4)
|
||||
}
|
||||
.padding(SodaSpacing.s14)
|
||||
.background(Color.gray900)
|
||||
.clipShape(RoundedRectangle(cornerRadius: SodaSpacing.s14, style: .continuous))
|
||||
.padding(.horizontal, SodaSpacing.s14)
|
||||
}
|
||||
}
|
||||
|
||||
struct CreatorChannelAudioOwnershipRateView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
CreatorChannelAudioOwnershipRateView(
|
||||
purchasedAudioContentRate: 58,
|
||||
purchasedAudioContentCount: 12,
|
||||
paidAudioContentCount: 43
|
||||
)
|
||||
.background(Color.black)
|
||||
.previewLayout(.sizeThatFits)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user