// // TextRatingView.swift // Jel // // Created by zerocool on 1/9/24. // import SwiftUI enum TextRatingViewStyle { case stroke case fill } struct TextRatingView: View { var text: String var fillStyle: TextRatingViewStyle init(_ text: String, fillStyle: TextRatingViewStyle = .stroke) { self.text = text self.fillStyle = fillStyle } var body: some View { switch (fillStyle) { case .stroke: Text(text) .font(.caption) .bold() .padding(EdgeInsets(top: 1, leading: 4, bottom: 1, trailing: 4)) .overlay { RoundedRectangle(cornerRadius: 2, style: .continuous) .stroke(.gray, lineWidth: 1.5) } .foregroundStyle(.gray) case .fill: Text(text) .font(.caption) .bold() .padding(EdgeInsets(top: 1, leading: 4, bottom: 1, trailing: 4)) .hidden() .background { Color(.gray) .clipShape(RoundedRectangle(cornerRadius: 2, style: .continuous)) .inverseMask( Text(text) .font(.caption) .bold() .padding(EdgeInsets(top: 1, leading: 4, bottom: 1, trailing: 4)) ) } } } } //#Preview { // TextRatingView() //}