summaryrefslogtreecommitdiff
path: root/Jel/Views/Utility
diff options
context:
space:
mode:
Diffstat (limited to 'Jel/Views/Utility')
-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()
+//}