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
|
import Account
|
||||||
|
|
||||||
struct SettingsAddAccountView : View {
|
struct SettingsAddAccountView : View {
|
||||||
|
@Environment(\.presentationMode) var presentation
|
||||||
@State private var selectedAccountType: AccountType = nil
|
@State private var selectedAccountType: AccountType = nil
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
@ -32,10 +32,10 @@ struct SettingsAddAccountView : View {
|
|||||||
}
|
}
|
||||||
.sheet(item: $selectedAccountType) { accountType in
|
.sheet(item: $selectedAccountType) { accountType in
|
||||||
if accountType == .onMyMac {
|
if accountType == .onMyMac {
|
||||||
SettingsLocalAccountView(name: "")
|
SettingsLocalAccountView(name: "", onDismiss: { self.presentation.wrappedValue.dismiss() })
|
||||||
}
|
}
|
||||||
if accountType == .feedbin {
|
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 {
|
var settingsFeedbinAccountView: SettingsFeedbinAccountView {
|
||||||
let feedbinViewModel = SettingsFeedbinAccountView.ViewModel(account: viewModel.account)
|
let feedbinViewModel = SettingsFeedbinAccountView.ViewModel(account: viewModel.account)
|
||||||
return SettingsFeedbinAccountView(viewModel: feedbinViewModel)
|
return SettingsFeedbinAccountView(viewModel: feedbinViewModel, onDismiss: {})
|
||||||
}
|
}
|
||||||
|
|
||||||
class ViewModel: ObservableObject {
|
class ViewModel: ObservableObject {
|
||||||
|
@ -17,6 +17,9 @@ struct SettingsFeedbinAccountView : View {
|
|||||||
@State var busy: Bool = false
|
@State var busy: Bool = false
|
||||||
@State var error: String = ""
|
@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 {
|
var body: some View {
|
||||||
NavigationView {
|
NavigationView {
|
||||||
Form {
|
Form {
|
||||||
@ -116,6 +119,7 @@ struct SettingsFeedbinAccountView : View {
|
|||||||
|
|
||||||
private func dismiss() {
|
private func dismiss() {
|
||||||
presentation.wrappedValue.dismiss()
|
presentation.wrappedValue.dismiss()
|
||||||
|
onDismiss()
|
||||||
}
|
}
|
||||||
|
|
||||||
class ViewModel: ObservableObject {
|
class ViewModel: ObservableObject {
|
||||||
@ -160,7 +164,7 @@ struct SettingsFeedbinAccountView : View {
|
|||||||
#if DEBUG
|
#if DEBUG
|
||||||
struct SettingsFeedbinAccountView_Previews : PreviewProvider {
|
struct SettingsFeedbinAccountView_Previews : PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
SettingsFeedbinAccountView(viewModel: SettingsFeedbinAccountView.ViewModel())
|
SettingsFeedbinAccountView(viewModel: SettingsFeedbinAccountView.ViewModel(), onDismiss: {})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -13,6 +13,9 @@ struct SettingsLocalAccountView : View {
|
|||||||
@Environment(\.presentationMode) var presentation
|
@Environment(\.presentationMode) var presentation
|
||||||
@State var name: String
|
@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 {
|
var body: some View {
|
||||||
NavigationView {
|
NavigationView {
|
||||||
Form {
|
Form {
|
||||||
@ -50,6 +53,7 @@ struct SettingsLocalAccountView : View {
|
|||||||
|
|
||||||
private func dismiss() {
|
private func dismiss() {
|
||||||
presentation.wrappedValue.dismiss()
|
presentation.wrappedValue.dismiss()
|
||||||
|
onDismiss()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -57,7 +61,7 @@ struct SettingsLocalAccountView : View {
|
|||||||
#if DEBUG
|
#if DEBUG
|
||||||
struct SettingsLocalAccountView_Previews : PreviewProvider {
|
struct SettingsLocalAccountView_Previews : PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
SettingsLocalAccountView(name: "")
|
SettingsLocalAccountView(name: "", onDismiss: {})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user