Refactor Navigation Toolbar into Separate View

This commit is contained in:
Sebastian Lenzlinger 2023-07-11 18:22:58 +02:00
parent 379d3c8a0e
commit 5e199f41f8
2 changed files with 39 additions and 41 deletions

View File

@ -29,16 +29,12 @@ struct ContentView: View {
FeedListView(feeds: []) FeedListView(feeds: [])
.environmentObject(dataStore) .environmentObject(dataStore)
} }
} HStack {
.padding()
.toolbar {
ToolbarItemGroup(placement: .bottomBar) {
Button(action: { Button(action: {
self.currentView = 0 self.currentView = 0
}) { }) {
VStack { VStack {
Label("Discovery", systemImage: "dot.radiowaves.left.and.right") Label("Discovery", systemImage: "dot.radiowaves.left.and.right")
Text("Discovery")
} }
} }
Spacer() Spacer()
@ -47,7 +43,6 @@ struct ContentView: View {
}) { }) {
VStack { VStack {
Label("Feeds", systemImage: "person.2") Label("Feeds", systemImage: "person.2")
Text("Feeds")
} }
} }
Spacer() Spacer()
@ -55,12 +50,14 @@ struct ContentView: View {
self.currentView = 2 self.currentView = 2
}) { }) {
VStack { VStack {
Label("Settings", systemImage: "gear") Label("Settings",systemImage: "gear")
Text("Settings")
} }
} }
} }
.frame(height: UIScreen.main.bounds.height * 0.05)
} }
.padding()
} }
} }

View File

@ -12,48 +12,49 @@ struct SettingsView: View {
@EnvironmentObject var dataStore: DataStore @EnvironmentObject var dataStore: DataStore
@State private var isPresentingEditView = false @State private var isPresentingEditView = false
var body: some View { var body: some View {
List { List {
HStack { Section(header: Text("Personal Feed ID")) {
Spacer() Label(dataStore.personalID, systemImage: "person.crop.circle")
Button("Edit") { }
isPresentingEditView = true Section(header: Text("Friends")) {
} ForEach(dataStore.friends) { friend in
} Label(friend, systemImage: "person")
Section(header: Text("Personal Feed ID")) {
Label(dataStore.personalID, systemImage: "person.crop.circle")
}
Section(header: Text("Friends")) {
ForEach(dataStore.friends) { friend in
Label(friend, systemImage: "person")
}
} }
} }
.navigationTitle("Settings") }
.sheet(isPresented: $isPresentingEditView) { .navigationTitle("Settings")
NavigationStack { .toolbar {
SettingsEditView() ToolbarItem(placement: .confirmationAction) {
.navigationTitle("Settings") Button("Edit") {
.toolbar { isPresentingEditView = true
ToolbarItem(placement: .cancellationAction){ }
Button("Cancel") { }
isPresentingEditView = false }
} .sheet(isPresented: $isPresentingEditView) {
} NavigationStack {
ToolbarItem(placement: .confirmationAction) { SettingsEditView()
Button("Done") { .navigationTitle("Settings")
isPresentingEditView = false .toolbar {
} ToolbarItem(placement: .cancellationAction){
Button("Cancel") {
isPresentingEditView = false
} }
} }
} ToolbarItem(placement: .confirmationAction) {
Button("Done") {
isPresentingEditView = false
}
}
}
}
} }
} }
} }