diff --git a/Sources/FeedbackKit/Feedback.swift b/Sources/FeedbackKit/Feedback.swift index b9d09a4..5674730 100644 --- a/Sources/FeedbackKit/Feedback.swift +++ b/Sources/FeedbackKit/Feedback.swift @@ -1,5 +1,44 @@ -struct Feedback { +struct Feedback: Identifiable, Hashable { + var id: String { title } + let type: FeedbackType let title: String let description: String + let state: FeedbackState +} + +extension Feedback { + static var samples: [Feedback] { + [ + .init( + type: .bug, + title: "We need an alternative when failed to create SQLite database using GRDB", + description: "", + state: .open + ), + .init( + type: .feature, + title: "[FEATURE]: Hook up search screen and favoriting functionality", + description: "", + state: .closed + ), + .init( + type: .feature, + title: "[FEATURE]: Sort search locations by distance from a location", + description: "", + state: .open + ), + .init( + type: .feature, + title: "[FEATURE]: Enhance weather information for detail view of a location", + description: "", + state: .open + ), + ] + } +} + +enum FeedbackState { + case open + case closed } diff --git a/Sources/FeedbackKit/FeedbackView.swift b/Sources/FeedbackKit/FeedbackView.swift deleted file mode 100644 index 831deef..0000000 --- a/Sources/FeedbackKit/FeedbackView.swift +++ /dev/null @@ -1,7 +0,0 @@ -import SwiftUI - -struct FeedbackView: View { - var body: some View { - Text("FeedbackKit Root View") - } -} diff --git a/Sources/FeedbackKit/View/FeedbackItem.swift b/Sources/FeedbackKit/View/FeedbackItem.swift new file mode 100644 index 0000000..205d37c --- /dev/null +++ b/Sources/FeedbackKit/View/FeedbackItem.swift @@ -0,0 +1,49 @@ +// +// File.swift +// +// +// Created by Ahmed Shendy on 30/04/2024. +// + +import SwiftUI + +public struct FeedbackItem: View { + let feedback: Feedback + + init(_ feedback: Feedback) { + self.feedback = feedback + } + + public var body: some View { + HStack(alignment: .top) { + + FeedbackStateIcon(state: feedback.state) + Spacer().frame(width: 5) + + VStack(spacing: 0) { + HStack(spacing: 0) { + FeedbackTitle(text: feedback.title) + Spacer() + HStack(spacing: 0) { + Image(systemName: "message") + Text("2") + } + .font(.subheadline) + .foregroundColor(.init(red: 0.518, green: 0.553, blue: 0.592)) + } + + Spacer().frame(height: 8) + + HStack(spacing: 0) { + Text("opened on May 18, 2023") + .font(.caption) + .foregroundColor(Color.gray) + Spacer() + FeedbackLabel(text: feedback.type.rawValue) + } + } + } + .padding(.horizontal, 15) + .padding(.vertical, 10) + } +} diff --git a/Sources/FeedbackKit/View/FeedbackLabel.swift b/Sources/FeedbackKit/View/FeedbackLabel.swift new file mode 100644 index 0000000..6244673 --- /dev/null +++ b/Sources/FeedbackKit/View/FeedbackLabel.swift @@ -0,0 +1,23 @@ +// +// File.swift +// +// +// Created by Ahmed Shendy on 30/04/2024. +// + +import SwiftUI + +public struct FeedbackLabel: View { + let text: String + + public var body: some View { + Text(text) + .font(.caption2) + .fontWeight(.light) + .foregroundColor(.white) + .padding(.horizontal, 6) + .background(Color.gray.opacity(0.5)) + .clipShape(Capsule(style: .continuous)) + } +} + diff --git a/Sources/FeedbackKit/View/FeedbackStateIcon.swift b/Sources/FeedbackKit/View/FeedbackStateIcon.swift new file mode 100644 index 0000000..8836f91 --- /dev/null +++ b/Sources/FeedbackKit/View/FeedbackStateIcon.swift @@ -0,0 +1,27 @@ +// +// File.swift +// +// +// Created by Ahmed Shendy on 30/04/2024. +// + +import SwiftUI + +public struct FeedbackStateIcon: View { + let state: FeedbackState + + public var body: some View { + Group { + switch state { + case .open: + Image(systemName: "smallcircle.filled.circle") + .foregroundColor(.green) + case .closed: + Image(systemName: "checkmark.circle") + .foregroundColor(.blue) + } + } + .font(.body.weight(.bold)) + } +} + diff --git a/Sources/FeedbackKit/View/FeedbackTitle.swift b/Sources/FeedbackKit/View/FeedbackTitle.swift new file mode 100644 index 0000000..11d4d62 --- /dev/null +++ b/Sources/FeedbackKit/View/FeedbackTitle.swift @@ -0,0 +1,17 @@ +// +// File.swift +// +// +// Created by Ahmed Shendy on 30/04/2024. +// + +import SwiftUI + +public struct FeedbackTitle: View { + let text: String + + public var body: some View { + Text(text) + .font(.headline) + } +} diff --git a/Sources/FeedbackKit/View/FeedbackView.swift b/Sources/FeedbackKit/View/FeedbackView.swift new file mode 100644 index 0000000..a2efaa0 --- /dev/null +++ b/Sources/FeedbackKit/View/FeedbackView.swift @@ -0,0 +1,29 @@ +import SwiftUI + +public struct FeedbackView: View { + public init() { } + public var body: some View { + ScrollView { + LazyVStack(spacing: 0) { + ForEach(Feedback.samples) { item in + FeedbackItem(item) + + if item != Feedback.samples.last { + Divider() + } + } + } + } + .fixedSize(horizontal: false, vertical: true) + .clipShape(RoundedRectangle(cornerRadius: 5)) + .overlay( + RoundedRectangle(cornerRadius: 5) + .inset(by: 1) + .strokeBorder( + Color(red: 0.255, green: 0.255, blue: 0.255), + lineWidth: 1, + antialiased: true + ) + ) + } +} diff --git a/playground/FeedbackKitPlayground/ContentView.swift b/playground/FeedbackKitPlayground/ContentView.swift index 2652d3c..5c0db2d 100644 --- a/playground/FeedbackKitPlayground/ContentView.swift +++ b/playground/FeedbackKitPlayground/ContentView.swift @@ -6,14 +6,14 @@ // import SwiftUI +import FeedbackKit struct ContentView: View { var body: some View { VStack { - Image(systemName: "globe") - .imageScale(.large) - .foregroundStyle(.tint) - Text("Hello, world!") + FeedbackView() + Spacer() + .background(Color.yellow) } .padding() }