summaryrefslogtreecommitdiff
path: root/Jel/Views/Utility/TextRatingView.swift
diff options
context:
space:
mode:
authorShav Kinderlehrer <[email protected]>2024-01-09 12:32:06 -0500
committerShav Kinderlehrer <[email protected]>2024-01-09 12:32:06 -0500
commit6edc39791a577a500c92f32361cf1e7d2590ec37 (patch)
tree776de4bae461836f8cba5ff673fc4ccfabd6df55 /Jel/Views/Utility/TextRatingView.swift
parent4ec0f962b2a175ae5f1e3e55a720f9534618a4ad (diff)
downloadjel-6edc39791a577a500c92f32361cf1e7d2590ec37.tar.gz
jel-6edc39791a577a500c92f32361cf1e7d2590ec37.zip
Implement ItemPeopleView
Diffstat (limited to 'Jel/Views/Utility/TextRatingView.swift')
-rw-r--r--Jel/Views/Utility/TextRatingView.swift58
1 files changed, 58 insertions, 0 deletions
diff --git a/Jel/Views/Utility/TextRatingView.swift b/Jel/Views/Utility/TextRatingView.swift
new file mode 100644
index 0000000..760d251
--- /dev/null
+++ b/Jel/Views/Utility/TextRatingView.swift
@@ -0,0 +1,58 @@
+//
+// 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()
+//}