-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update: build FeedbackView inspired by github ui
- Loading branch information
1 parent
863e152
commit 0d00f63
Showing
8 changed files
with
189 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
) | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters