Post

Replies

Boosts

Views

Activity

Reply to Problem with NavigationLink
Here the part on the start View: TabView(selection: $selection) { NavigationView(){ List { ForEach(alarmList, id: \.self) { alarm in NavigationLink(destination: AlarmDetailView(alarm: alarm)){ HStack(){ SingleAlaramView(isAlarmOn: alarm.state, name: alarm.name, time: alarm.time) } .cornerRadius(5.0) } } .onDelete(perform: self.deleteItem) } .navigationBarTitle("Wecker") .navigationBarItems(leading: EditButton()) .accentColor(Color("accent")) } .tabItem { Image(systemName: "alarm") }.tag(1) The SingleAlarmViews are shown in the NavigationLinks, here is the code: struct SingleAlaramView: View { @State var isAlarmOn:Bool = false let name: String? let time: String var body: some View { HStack(){ VStack(){ Text(name ?? "Wecker") .frame(width: 200, height: 20, alignment: .leading) .font(.system(size: 22, weight: .semibold)) .lineLimit(1) Text(time) .frame(width: 200, height: 20, alignment: .leading) .font(.system(size: 15, weight: .light)) .foregroundColor(.gray) } } Spacer() Toggle("Alarm", isOn: $isAlarmOn).labelsHidden().padding(.trailing) } } Tapping a NavigationLink shows the following View: struct AlarmDetailView: View { @State var alarm:AlarmItem @State var selectedTime:Date = Date() @State var isOn:Bool = true let settings = ["Bezeichnung", "Ton", "Wiederholen", "Schlummern"] var body: some View { let title = alarm.name let navTitle = title + " Details" NavigationView() { VStack() { DatePicker("Time", selection: $selectedTime, displayedComponents: .hourAndMinute) .labelsHidden() .datePickerStyle(.wheel) List { NavigationLink(destination: NameSettingsView(title: "Bezeichnung")){ HStack() { Text("Bezeichnung") Spacer() Text(title) .font(.system(size: 15, weight: .light)) .foregroundColor(.gray) } } NavigationLink(destination: ReoccurSettingsView(title: "Wiederholung")) { HStack() { Text("Wiederholung") Spacer() Text(alarm.reoccur) .font(.system(size: 15, weight: .light)) .foregroundColor(.gray) } } NavigationLink(destination: SoundSettingsView(title: "Ton")) { HStack() { Text("Ton") Spacer() if (alarm.fadeIn){ Image(systemName: "lessthan") .foregroundColor(.gray) } Text(alarm.sound) .font(.system(size: 15, weight: .light)) .foregroundColor(.gray) } } HStack() { Text("Schlummern") Spacer() Toggle("Schlummern", isOn: $isOn).labelsHidden() } } } } .navigationTitle(navTitle) .accentColor(Color("accent")) } } This AlarmDetailView is shown fullscreen (would like to have it displayed like with "Show()" in Storyboard). Now when tapping let's say "Bezeichnung" which is the name of the Alarm, it is shown with the previous NavigationBar still visible, like stacked. Here the code for the "settings": struct NameSettingsView: View { let title:String var body: some View { NavigationView() { Text("Setting") } .navigationTitle(title) } } This View doesn't do much right now, I first would like to solve the presentation issue.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’21
Reply to Problem with NavigationLink
Here the part on the start View: TabView(selection: $selection) { NavigationView(){ List { ForEach(alarmList, id: \.self) { alarm in NavigationLink(destination: AlarmDetailView(alarm: alarm)){ HStack(){ SingleAlaramView(isAlarmOn: alarm.state, name: alarm.name, time: alarm.time) } .cornerRadius(5.0) } } .onDelete(perform: self.deleteItem) } .navigationBarTitle("Wecker") .navigationBarItems(leading: EditButton()) .accentColor(Color("accent")) } .tabItem { Image(systemName: "alarm") }.tag(1) The SingleAlarmViews are shown in the NavigationLinks, here is the code: struct SingleAlaramView: View { @State var isAlarmOn:Bool = false let name: String? let time: String var body: some View { HStack(){ VStack(){ Text(name ?? "Wecker") .frame(width: 200, height: 20, alignment: .leading) .font(.system(size: 22, weight: .semibold)) .lineLimit(1) Text(time) .frame(width: 200, height: 20, alignment: .leading) .font(.system(size: 15, weight: .light)) .foregroundColor(.gray) } } Spacer() Toggle("Alarm", isOn: $isAlarmOn).labelsHidden().padding(.trailing) } } Tapping a NavigationLink shows the following View: struct AlarmDetailView: View { @State var alarm:AlarmItem @State var selectedTime:Date = Date() @State var isOn:Bool = true let settings = ["Bezeichnung", "Ton", "Wiederholen", "Schlummern"] var body: some View { let title = alarm.name let navTitle = title + " Details" NavigationView() { VStack() { DatePicker("Time", selection: $selectedTime, displayedComponents: .hourAndMinute) .labelsHidden() .datePickerStyle(.wheel) List { NavigationLink(destination: NameSettingsView(title: "Bezeichnung")){ HStack() { Text("Bezeichnung") Spacer() Text(title) .font(.system(size: 15, weight: .light)) .foregroundColor(.gray) } } NavigationLink(destination: ReoccurSettingsView(title: "Wiederholung")) { HStack() { Text("Wiederholung") Spacer() Text(alarm.reoccur) .font(.system(size: 15, weight: .light)) .foregroundColor(.gray) } } NavigationLink(destination: SoundSettingsView(title: "Ton")) { HStack() { Text("Ton") Spacer() if (alarm.fadeIn){ Image(systemName: "lessthan") .foregroundColor(.gray) } Text(alarm.sound) .font(.system(size: 15, weight: .light)) .foregroundColor(.gray) } } HStack() { Text("Schlummern") Spacer() Toggle("Schlummern", isOn: $isOn).labelsHidden() } } } } .navigationTitle(navTitle) .accentColor(Color("accent")) } } This AlarmDetailView is shown fullscreen (would like to have it displayed like with "Show()" in Storyboard). Now when tapping let's say "Bezeichnung" which is the name of the Alarm, it is shown with the previous NavigationBar still visible, like stacked. Here the code for the "settings": struct NameSettingsView: View { let title:String var body: some View { NavigationView() { Text("Setting") } .navigationTitle(title) } } This View doesn't do much right now, I first would like to solve the presentation issue.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’21