Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shendy/feedback list view #6

Merged
merged 5 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 39 additions & 4 deletions Sources/FeedbackKit/Feedback.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,43 @@
import Foundation

struct Feedback: Codable, Identifiable {
let id: UUID
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
}
7 changes: 0 additions & 7 deletions Sources/FeedbackKit/FeedbackView.swift

This file was deleted.

49 changes: 49 additions & 0 deletions Sources/FeedbackKit/View/FeedbackItem.swift
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)
}
}
23 changes: 23 additions & 0 deletions Sources/FeedbackKit/View/FeedbackLabel.swift
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))
}
}

27 changes: 27 additions & 0 deletions Sources/FeedbackKit/View/FeedbackStateIcon.swift
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))
}
}

17 changes: 17 additions & 0 deletions Sources/FeedbackKit/View/FeedbackTitle.swift
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)
}
}
29 changes: 29 additions & 0 deletions Sources/FeedbackKit/View/FeedbackView.swift
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
)
)
}
}
Loading
Loading