swiftui

Why pop to root does not work in this sample code SwiftUI?

我的未来我决定 提交于 2021-01-13 09:45:42
问题 For the purpose of this question, I have provided minimum sample code to re-create the bug. Just copy/paste it to run. import SwiftUI final class Popper: ObservableObject { @Published var shouldProceed: String? = nil var id: String init(id: String) { self.id = id } } struct ContentView: View { @StateObject var popper = Popper(id: "ROOT") var body: some View { NavigationView { VStack(spacing: 40) { Text("You are now in ROOT").font(.largeTitle) Text("Tap Here to goto V1").onTapGesture { popper

Why pop to root does not work in this sample code SwiftUI?

三世轮回 提交于 2021-01-13 09:44:31
问题 For the purpose of this question, I have provided minimum sample code to re-create the bug. Just copy/paste it to run. import SwiftUI final class Popper: ObservableObject { @Published var shouldProceed: String? = nil var id: String init(id: String) { self.id = id } } struct ContentView: View { @StateObject var popper = Popper(id: "ROOT") var body: some View { NavigationView { VStack(spacing: 40) { Text("You are now in ROOT").font(.largeTitle) Text("Tap Here to goto V1").onTapGesture { popper

Errors after changing NSNumber to Int/Double

让人想犯罪 __ 提交于 2021-01-07 06:59:26
问题 I have this class to get data from Firestore: struct Spty: Identifiable{ var id: String var spty: String var r: NSNumber var g: NSNumber var b: NSNumber } class SptyViewModel: NSObject, ObservableObject{ @Published var specialities = [Spty]() @Published var search = "" func fetchData(){ let db = Firestore.firestore() db.collection("specialities").addSnapshotListener { (querySnapshot, error) in guard let documents = querySnapshot else {return } self.specialities = documents.documents

Errors after changing NSNumber to Int/Double

无人久伴 提交于 2021-01-07 06:58:28
问题 I have this class to get data from Firestore: struct Spty: Identifiable{ var id: String var spty: String var r: NSNumber var g: NSNumber var b: NSNumber } class SptyViewModel: NSObject, ObservableObject{ @Published var specialities = [Spty]() @Published var search = "" func fetchData(){ let db = Firestore.firestore() db.collection("specialities").addSnapshotListener { (querySnapshot, error) in guard let documents = querySnapshot else {return } self.specialities = documents.documents

SwiftUI and AppKit: Use close dialog to ask if the app is allowed to quit

时间秒杀一切 提交于 2021-01-07 05:09:32
问题 I am using Big Sur and SwiftUI with the SwiftUI lifecycle. I want to implement an alert, where the user gets asked, if the application can be quit or not. How is this possible with SwiftUI? It should look like this: 回答1: It's possible by using this code (this code opens the Alert only in the key window): import SwiftUI import AppKit class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject { @Published var willTerminate = false func applicationShouldTerminate(_ sender:

SwiftUI and AppKit: Use close dialog to ask if the app is allowed to quit

半城伤御伤魂 提交于 2021-01-07 05:06:38
问题 I am using Big Sur and SwiftUI with the SwiftUI lifecycle. I want to implement an alert, where the user gets asked, if the application can be quit or not. How is this possible with SwiftUI? It should look like this: 回答1: It's possible by using this code (this code opens the Alert only in the key window): import SwiftUI import AppKit class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject { @Published var willTerminate = false func applicationShouldTerminate(_ sender:

SwiftUI and AppKit: Use close dialog to ask if the app is allowed to quit

大兔子大兔子 提交于 2021-01-07 05:05:12
问题 I am using Big Sur and SwiftUI with the SwiftUI lifecycle. I want to implement an alert, where the user gets asked, if the application can be quit or not. How is this possible with SwiftUI? It should look like this: 回答1: It's possible by using this code (this code opens the Alert only in the key window): import SwiftUI import AppKit class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject { @Published var willTerminate = false func applicationShouldTerminate(_ sender:

SwiftUI Position Google and Facebook login buttons

此生再无相见时 提交于 2021-01-07 04:13:23
问题 I am using Firebase Auth and I have two buttons. One for Google and one for Facebook. I'm trying to set the height and width via .frame() but they are not responding properly. Moreover, the Google sign in button wont appear in the middle but on the right of the screen. I tried to put them inside a VStack but still the same thing. VStack(alignment: .center) { FacebookLoginButtonView() .frame(width: 100, height: 28) // duhet 28 fiks .border(Color.red) GoogleLoginButtonView() .frame(width: 100,

SwiftUI: detecting the NavigationView back button press

孤街醉人 提交于 2021-01-07 03:01:48
问题 In SwiftUI I couldn't find a way to detect when the user taps on the default back button of the navigation view when I am inside DetailView1 in this code: struct RootView: View { @State private var showDetails: Bool = false var body: some View { NavigationView { VStack { NavigationLink(destination: DetailView1(), isActive: $showDetails) { Text("show DetailView1") } } .navigationBarTitle("RootView") } } } struct DetailView1: View { @State private var showDetails: Bool = false var body: some

SwiftUI swizzling disabled by default, phone auth not working

安稳与你 提交于 2021-01-07 02:40:54
问题 I am building a screen with phone number login. I checked over and over again and the project is newly created, however, I am getting this log: 7.2.0 - [Firebase/Auth][I-AUT000015] The UIApplicationDelegate must handle remote notification for phone number authentication to work. If app delegate swizzling is disabled, remote notifications received by UIApplicationDelegate need to be forwarded to FIRAuth's canHandleNotificaton: method. I did read in the documentation about swizzling and I don't