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 an action to the home section header #49

Merged
merged 1 commit into from
Jan 18, 2025
Merged
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
9 changes: 8 additions & 1 deletion Sources/BadaApp/Equipment/EquipmentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,25 @@ import BadaCore
import BadaUI

struct EquipmentView: View {
@ObservedObject private var navigationStore = NavigationStore.shared
@StateObject private var store = ViewStore(
reducer: EquipmentReducer(),
state: EquipmentReducer.State()
)

var body: some View {
NavigationStack {
NavigationStack(
path: navigationStore.binding(
\.equipmentPaths,
send: { .setEquipmentPaths($0) })
) {
ScrollView(.vertical) {

}
.background(.background.secondary)
.navigationTitle(L10n.Equipment.title)
.navigationDestination(for: NavigationState.EquipmentPath.self) { path in
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,23 @@ import BadaCore
import BadaUI

struct HomeView: View {
@ObservedObject private var navigationStore = NavigationStore.shared
@StateObject private var store = ViewStore(
reducer: HomeReducer(),
state: HomeReducer.State()
)

var body: some View {
NavigationStack {
NavigationStack(
path: navigationStore.binding(
\.homePaths,
send: { .setHomePaths($0) })
) {
ScrollView(.vertical) {
VStack(alignment: .leading, spacing: 16) {
SectionHeader(title: "Bio")
VStack(spacing: 16) {
SectionHeader(title: "Bio") {
// TODO: Move to the bio edit page
}
VStack(spacing: 16) {
InfoRow(
title: "License",
Expand All @@ -33,7 +40,9 @@ struct HomeView: View {
.padding(16)
.background(.background.quaternary)
.clipShape(.rect(cornerRadius: 8))
SectionHeader(title: "Summary")
SectionHeader(title: "Summary") {
navigationStore.send(.logbook(.root))
}
VStack(spacing: 16) {
InfoRow(
title: "Logs",
Expand Down Expand Up @@ -63,6 +72,8 @@ struct HomeView: View {
}
.background(.background.secondary)
.navigationTitle(L10n.Home.title)
.navigationDestination(for: NavigationState.HomePath.self) { path in
}
.onAppear(perform: onAppear)
}
}
Expand All @@ -75,12 +86,23 @@ struct HomeView: View {
extension HomeView {
private struct SectionHeader: View {
let title: String
let action: () -> Void

var body: some View {
Text(title)
.font(.title2)
.fontWeight(.bold)
.foregroundStyle(.foreground)
HStack(spacing: 0) {
Text(title)
.font(.title2)
.fontWeight(.bold)
.foregroundStyle(.foreground)
Spacer()
Image(systemImage: .chevronRight)
.font(.footnote)
.foregroundStyle(.secondary)
}
.contentShape(Rectangle())
.onTapGesture {
action()
}
}
}

Expand Down
21 changes: 19 additions & 2 deletions Sources/BadaApp/Navigation/NavigationStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,25 @@ struct NavigationReducer: Reducer {
state.logbookPaths = paths
return .none
case let .home(home):
return .none
state.mainTab = .home
switch home {
case .root:
state.homePaths = []
return .none
}
case let .equipment(equipment):
return .none
state.mainTab = .equipment
switch equipment {
case .root:
state.equipmentPaths = []
return .none
}
case let .logbook(logbook):
state.mainTab = .logbook
switch logbook {
case .root:
state.logbookPaths = []
return .none
case let .detail(id):
state.logbookPaths = [.logDetail(id: id)]
return .none
Expand All @@ -68,12 +82,15 @@ struct NavigationReducer: Reducer {

extension NavigationReducer.Action {
enum Home {
case root
}

enum Equipment {
case root
}

enum Logbook {
case root
case detail(id: DiveLogID)
}
}
Expand Down
1 change: 1 addition & 0 deletions Sources/BadaUI/SystemImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package enum SystemImage: String {
case plus = "plus"
case chevronUp = "chevron.up"
case chevronDown = "chevron.down"
case chevronRight = "chevron.right"
case sunMax = "sun.max"
case cloud = "cloud"
case cloudSun = "cloud.sun"
Expand Down