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

Add tap gesture to provide additional feature info #86

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion Example/RoadmapExample/RoadmapExample/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct ContentView: View {
allowSearching: true,
allowsFilterByStatus: true
)

var body: some View {
#if os(macOS)
roadmapView
Expand Down
5 changes: 3 additions & 2 deletions Sources/Roadmap/Models/RoadmapFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@

import Foundation

public struct RoadmapFeature: Codable, Identifiable {
public struct RoadmapFeature: Codable, Identifiable, Equatable {
public let id: String
public let title: String?
public var status: String? = nil
public var url: URL? = nil
private var description : String? = nil
private var localizedTitle: [LocalizedItem]? = nil
private var localizedStatus: [LocalizedItem]? = nil
Expand Down Expand Up @@ -52,7 +53,7 @@ public struct RoadmapFeature: Codable, Identifiable {
}
}

struct LocalizedItem: Codable {
struct LocalizedItem: Codable, Equatable {
let language: String
let value: String
}
Expand Down
20 changes: 12 additions & 8 deletions Sources/Roadmap/RoadmapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public struct RoadmapView<Header: View, Footer: View>: View {
let header: Header
let footer: Footer
@State private var selectedFilter: String
@Binding var selectedFeature: RoadmapFeature?

private var filterHorizontalPadding: CGFloat {
#if os(macOS)
Expand Down Expand Up @@ -64,6 +65,9 @@ public struct RoadmapView<Header: View, Footer: View>: View {
RoadmapFeatureView(viewModel: viewModel.featureViewModel(for: feature))
.macOSListRowSeparatorHidden()
.listRowBackground(Color.clear)
.onTapGesture {
selectedFeature = feature
}
}
footer
}
Expand All @@ -72,26 +76,26 @@ public struct RoadmapView<Header: View, Footer: View>: View {
}

public extension RoadmapView where Header == EmptyView, Footer == EmptyView {
init(configuration: RoadmapConfiguration) {
self.init(viewModel: .init(configuration: configuration), header: EmptyView(), footer: EmptyView(), selectedFilter: "")
init(configuration: RoadmapConfiguration, selectedFeature: Binding<RoadmapFeature?> = .constant(nil)) {
self.init(viewModel: .init(configuration: configuration), header: EmptyView(), footer: EmptyView(), selectedFilter: "", selectedFeature: selectedFeature)
}
}

public extension RoadmapView where Header: View, Footer == EmptyView {
init(configuration: RoadmapConfiguration, @ViewBuilder header: () -> Header) {
self.init(viewModel: .init(configuration: configuration), header: header(), footer: EmptyView(), selectedFilter: "")
init(configuration: RoadmapConfiguration, @ViewBuilder header: () -> Header, selectedFeature: Binding<RoadmapFeature?> = .constant(nil)) {
self.init(viewModel: .init(configuration: configuration), header: header(), footer: EmptyView(), selectedFilter: "", selectedFeature: selectedFeature)
}
}

public extension RoadmapView where Header == EmptyView, Footer: View {
init(configuration: RoadmapConfiguration, @ViewBuilder footer: () -> Footer) {
self.init(viewModel: .init(configuration: configuration), header: EmptyView(), footer: footer(), selectedFilter: "")
init(configuration: RoadmapConfiguration, @ViewBuilder footer: () -> Footer, selectedFeature: Binding<RoadmapFeature?> = .constant(nil)) {
self.init(viewModel: .init(configuration: configuration), header: EmptyView(), footer: footer(), selectedFilter: "", selectedFeature: selectedFeature)
}
}

public extension RoadmapView where Header: View, Footer: View {
init(configuration: RoadmapConfiguration, @ViewBuilder header: () -> Header, @ViewBuilder footer: () -> Footer) {
self.init(viewModel: .init(configuration: configuration), header: header(), footer: footer(), selectedFilter: "")
init(configuration: RoadmapConfiguration, @ViewBuilder header: () -> Header, @ViewBuilder footer: () -> Footer, selectedFeature: Binding<RoadmapFeature?> = .constant(nil)) {
self.init(viewModel: .init(configuration: configuration), header: header(), footer: footer(), selectedFilter: "", selectedFeature: selectedFeature)
}
}

Expand Down