Automatically dismiss the add account view when an account is added
This commit is contained in:
parent
ccaeeb8e6d
commit
1718810701
@ -10,7 +10,7 @@ import SwiftUI
|
||||
import Account
|
||||
|
||||
struct SettingsAddAccountView : View {
|
||||
|
||||
@Environment(\.presentationMode) var presentation
|
||||
@State private var selectedAccountType: AccountType = nil
|
||||
|
||||
var body: some View {
|
||||
@ -32,10 +32,10 @@ struct SettingsAddAccountView : View {
|
||||
}
|
||||
.sheet(item: $selectedAccountType) { accountType in
|
||||
if accountType == .onMyMac {
|
||||
SettingsLocalAccountView(name: "")
|
||||
SettingsLocalAccountView(name: "", onDismiss: { self.presentation.wrappedValue.dismiss() })
|
||||
}
|
||||
if accountType == .feedbin {
|
||||
SettingsFeedbinAccountView(viewModel: SettingsFeedbinAccountView.ViewModel())
|
||||
SettingsFeedbinAccountView(viewModel: SettingsFeedbinAccountView.ViewModel(), onDismiss: { self.presentation.wrappedValue.dismiss() })
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ struct SettingsDetailAccountView : View {
|
||||
|
||||
var settingsFeedbinAccountView: SettingsFeedbinAccountView {
|
||||
let feedbinViewModel = SettingsFeedbinAccountView.ViewModel(account: viewModel.account)
|
||||
return SettingsFeedbinAccountView(viewModel: feedbinViewModel)
|
||||
return SettingsFeedbinAccountView(viewModel: feedbinViewModel, onDismiss: {})
|
||||
}
|
||||
|
||||
class ViewModel: ObservableObject {
|
||||
|
@ -17,6 +17,9 @@ struct SettingsFeedbinAccountView : View {
|
||||
@State var busy: Bool = false
|
||||
@State var error: String = ""
|
||||
|
||||
// This is a hack around the fact that onDismiss isn't being called by the sheet modifier.
|
||||
var onDismiss: () -> Void
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
Form {
|
||||
@ -116,6 +119,7 @@ struct SettingsFeedbinAccountView : View {
|
||||
|
||||
private func dismiss() {
|
||||
presentation.wrappedValue.dismiss()
|
||||
onDismiss()
|
||||
}
|
||||
|
||||
class ViewModel: ObservableObject {
|
||||
@ -160,7 +164,7 @@ struct SettingsFeedbinAccountView : View {
|
||||
#if DEBUG
|
||||
struct SettingsFeedbinAccountView_Previews : PreviewProvider {
|
||||
static var previews: some View {
|
||||
SettingsFeedbinAccountView(viewModel: SettingsFeedbinAccountView.ViewModel())
|
||||
SettingsFeedbinAccountView(viewModel: SettingsFeedbinAccountView.ViewModel(), onDismiss: {})
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -13,6 +13,9 @@ struct SettingsLocalAccountView : View {
|
||||
@Environment(\.presentationMode) var presentation
|
||||
@State var name: String
|
||||
|
||||
// This is a hack around the fact that onDismiss isn't being called by the sheet modifier.
|
||||
var onDismiss: () -> Void
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
Form {
|
||||
@ -50,6 +53,7 @@ struct SettingsLocalAccountView : View {
|
||||
|
||||
private func dismiss() {
|
||||
presentation.wrappedValue.dismiss()
|
||||
onDismiss()
|
||||
}
|
||||
|
||||
}
|
||||
@ -57,7 +61,7 @@ struct SettingsLocalAccountView : View {
|
||||
#if DEBUG
|
||||
struct SettingsLocalAccountView_Previews : PreviewProvider {
|
||||
static var previews: some View {
|
||||
SettingsLocalAccountView(name: "")
|
||||
SettingsLocalAccountView(name: "", onDismiss: {})
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user