swiftui-navigationlink

SwiftUI - how to avoid navigation hardcoded into the view?

不打扰是莪最后的温柔 提交于 2020-05-09 17:58:30
问题 I try to do the architecture for a bigger, production ready SwiftUI App. I am running all the time into the same problem which points to a major design flaw in SwiftUI. Still nobody could give me a full working, production ready answer. How to do reusable Views in SwiftUI which contain navigation? As the SwiftUI NavigationLink is strongly bound to the view this is simply not possible in such a way that it scales also in bigger Apps. NavigationLink in those small sample Apps works, yes - but

SwiftUI doesn't update second NavigationLink destination

。_饼干妹妹 提交于 2020-04-18 05:48:11
问题 I have a List with rows which push a View. That view has another List which pushing another View. The original List, and the first pushed List will update when the data changes. However, the last view does not update when pushed. And when I swipe back the view no longer updates, even though it used to. HomeView > UserView > ItemView User and Item are structs which are Identifiable. I've tried making them Hashable and using id: \.self , but that didn't seem to work either. class App:

NavigationLink freezes when trying to revisit previously clicked NavigationLink in SwiftUI

房东的猫 提交于 2020-03-17 08:44:20
问题 I am designing an app that includes the function of retrieving JSON data and displaying a list of retrieved items in a FileBrowser type view. In this view, a user should be able to click on a folder to dive deeper into the file tree or click on a file to view some metadata about said file. I've observed that while this is working, when I click on a file or folder then go back and click on it again, the NavigationLink is not triggered and I am stuck on the view until I click into a different

ObervableObject being init multiple time, and not refreshing my view

安稳与你 提交于 2020-03-04 23:08:13
问题 i have a structure like that contentView { navigationView{ foreach { NavigationLink(ViewA(id: id)) } } } ///where View A contain an request trigger in view Appear struct ViewA: View { @State var filterString: String = "" var id: String! @ObservedObject var model: ListObj = ListObj() init(id: String) { self.id = id } var body: some View { VStack { SearchBarView(searchText: $filterString) List { ForEach(model.items.filter({ filterString.isEmpty || $0.id.contains(filterString) || $0.name

Horizontal scrollview is not working swiftUI

╄→尐↘猪︶ㄣ 提交于 2020-02-25 05:25:11
问题 i'm trying to show some horizontal view but it's not working. below are the code i'm using. @State var userDataList = [UserModel]() var body: some View{ VStack(spacing: 10){ VStack{ prefView() .padding(.bottom, 30) Text("Tap to start making friend") } ScrollView(.horizontal, content: { HStack(spacing: 10) { ForEach(userDataList) { user in NavigationLink(destination: ChatView(chatMember: self.chatmember, user: user)){ SearchUser() } } } .padding(.leading, 10) }) .frame(width: 300, height: 400)

How can I use Navigation in alert using SwiftUI

亡梦爱人 提交于 2020-02-12 01:33:08
问题 I'm working on a Bluetooth Application.It has onboarding and dashboard.On the Onboarding there is pairing and instructions on how to use the module, and the dashboard controls the peripheral device.So I need to unpair using an alert and navigate it to a different page called Onboarding .How can I navigate to a different view using an alert. Code Block import SwiftUI import BLE struct Dashboard: View { @EnvironmentObject var BLE: BLE @State private var showUnpairAlert: Bool = false @State

Swift UI detail remove

孤人 提交于 2020-01-24 14:03:30
问题 I have a SwiftUI list which presents a detail view/pushes to the navigation when a cell is tapped: import SwiftUI struct DevicesInRangeList: View { @ObservedObject var central = Central() var body: some View { NavigationView { List(central.peripheralsInRange) { peripheral in NavigationLink(destination: DeviceView(peripheral: peripheral).onAppear { self.central.connect(peripheral: peripheral) }.onDisappear { self.central.disconnect(peripheral: peripheral) }) { DeviceRow(deviceID: peripheral

SwiftUI unable to navigate back and forth with navigationLink

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-16 10:32:12
问题 Notice in the gif that once I navigate and dismiss the new view, I am unable to navigate back! Is this a SwiftUI bug or a misuse of NavigationLinks? struct ContentView: View { var body: some View { return NavigationView { NavigationLink(destination: FakeView1()) { Text("Navigate") } } } } struct FakeView1: View { var body: some View { Text("Hey") } } 回答1: This seems swiftUI bug. I also faced the same issue so, I have used this workaround for it. struct ContentView: View { @State var

SwiftUI unable to navigate back and forth with navigationLink

时光总嘲笑我的痴心妄想 提交于 2020-01-16 10:31:50
问题 Notice in the gif that once I navigate and dismiss the new view, I am unable to navigate back! Is this a SwiftUI bug or a misuse of NavigationLinks? struct ContentView: View { var body: some View { return NavigationView { NavigationLink(destination: FakeView1()) { Text("Navigate") } } } } struct FakeView1: View { var body: some View { Text("Hey") } } 回答1: This seems swiftUI bug. I also faced the same issue so, I have used this workaround for it. struct ContentView: View { @State var

SwiftUI unable to navigate back and forth with navigationLink

坚强是说给别人听的谎言 提交于 2020-01-16 10:31:37
问题 Notice in the gif that once I navigate and dismiss the new view, I am unable to navigate back! Is this a SwiftUI bug or a misuse of NavigationLinks? struct ContentView: View { var body: some View { return NavigationView { NavigationLink(destination: FakeView1()) { Text("Navigate") } } } } struct FakeView1: View { var body: some View { Text("Hey") } } 回答1: This seems swiftUI bug. I also faced the same issue so, I have used this workaround for it. struct ContentView: View { @State var