NeuProgressBarTitle 📦

進度條的「標題部分」。

進度條的「標題部分」
import SwiftUI

// ⭐️ `NeuProgressBar2` 的「標題」部分
public struct NeuProgressBarTitle: View {
    
    var            title: String
    @Binding var percent: CGFloat
    
    public init(title: String, percent: Binding<CGFloat>) {
        self._percent = percent  // ⭐️ 傳進 @Binding 變數的方式
        self.title    = title
    }
    
    public var body: some View {
        HStack {
            
            // title
            Text(self.title)
                .foregroundColor(Neu.color.text)
                .bold()
            
            Spacer()
                
            // percentage
            Text("\(Int(self.percent * 100))%")
                .foregroundColor(Neu.color.text)
                .bold()
        }
    }
}

Last updated

Was this helpful?