diff --git a/iOS/Settings/Account/SettingsAddAccountView.swift b/iOS/Settings/Account/SettingsAddAccountView.swift index 05b0786e7..dd47e94d3 100644 --- a/iOS/Settings/Account/SettingsAddAccountView.swift +++ b/iOS/Settings/Account/SettingsAddAccountView.swift @@ -11,18 +11,32 @@ import Account struct SettingsAddAccountView : View { @Environment(\.presentationMode) var presentation - + @State private var accountAddAction: Int? = nil + var body: some View { Form { - NavigationLink(destination: SettingsLocalAccountView(name: "")) { + + NavigationLink(destination: SettingsLocalAccountView(name: ""), tag: 1, selection: $accountAddAction) { SettingsAccountLabelView(accountImage: "accountLocal", accountLabel: Account.defaultLocalAccountName) } - NavigationLink(destination: SettingsFeedbinAccountView(viewModel: SettingsFeedbinAccountView.ViewModel())) { + .modifier(VibrantSelectAction(action: { + self.accountAddAction = 1 + })) + + NavigationLink(destination: SettingsFeedbinAccountView(viewModel: SettingsFeedbinAccountView.ViewModel()), tag: 2, selection: $accountAddAction) { SettingsAccountLabelView(accountImage: "accountFeedbin", accountLabel: "Feedbin") } - NavigationLink(destination: SettingsReaderAPIAccountView(viewModel: SettingsReaderAPIAccountView.ViewModel(accountType: .freshRSS))) { + .modifier(VibrantSelectAction(action: { + self.accountAddAction = 2 + })) + + NavigationLink(destination: SettingsReaderAPIAccountView(viewModel: SettingsReaderAPIAccountView.ViewModel(accountType: .freshRSS)), tag: 3, selection: $accountAddAction) { SettingsAccountLabelView(accountImage: "accountFreshRSS", accountLabel: "Fresh RSS") } + .modifier(VibrantSelectAction(action: { + self.accountAddAction = 3 + })) + } .navigationBarTitle(Text("Add Account"), displayMode: .inline) } diff --git a/iOS/Settings/Account/SettingsDetailAccountView.swift b/iOS/Settings/Account/SettingsDetailAccountView.swift index c05849549..d1c027a89 100644 --- a/iOS/Settings/Account/SettingsDetailAccountView.swift +++ b/iOS/Settings/Account/SettingsDetailAccountView.swift @@ -29,14 +29,10 @@ struct SettingsDetailAccountView : View { } if viewModel.isCreditialsAvailable { Section { - HStack { - Spacer() - Button(action: { - self.accountType = self.viewModel.account.type - }) { - Text("Credentials") - } - Spacer() + Button(action: { + self.accountType = self.viewModel.account.type + }) { + Text("Credentials") } } .sheet(item: $accountType) { type in @@ -50,14 +46,10 @@ struct SettingsDetailAccountView : View { } if viewModel.isDeletable { Section { - HStack { - Spacer() - Button(action: { - self.isDeleteAlertPresented.toggle() - }) { - Text("Delete Account").foregroundColor(.red) - } - Spacer() + Button(action: { + self.isDeleteAlertPresented.toggle() + }) { + Text("Delete Account").foregroundColor(.red) } .alert(isPresented: $isDeleteAlertPresented) { Alert(title: Text("Are you sure you want to delete \"\(viewModel.nameForDisplay)\"?"), @@ -70,6 +62,7 @@ struct SettingsDetailAccountView : View { } } } + .buttonStyle(VibrantButtonStyle(alignment: .center)) .navigationBarTitle(Text(verbatim: viewModel.nameForDisplay), displayMode: .inline) } diff --git a/iOS/Settings/Account/SettingsFeedbinAccountView.swift b/iOS/Settings/Account/SettingsFeedbinAccountView.swift index cd862ae89..1dad3a572 100644 --- a/iOS/Settings/Account/SettingsFeedbinAccountView.swift +++ b/iOS/Settings/Account/SettingsFeedbinAccountView.swift @@ -38,18 +38,15 @@ struct SettingsFeedbinAccountView : View { Spacer() } ) { - HStack { - Spacer() - Button(action: { self.addAccount() }) { - if viewModel.isUpdate { - Text("Update Account") - } else { - Text("Add Account") - } + Button(action: { self.addAccount() }) { + if viewModel.isUpdate { + Text("Update Account") + } else { + Text("Add Account") } - .disabled(!viewModel.isValid) - Spacer() } + .buttonStyle(VibrantButtonStyle(alignment: .center)) + .disabled(!viewModel.isValid) } } // .disabled(busy) // Maybe someday we can do this, but right now it crashes on the iPad diff --git a/iOS/Settings/Account/SettingsLocalAccountView.swift b/iOS/Settings/Account/SettingsLocalAccountView.swift index a3c2dcdf6..d92cd6f9b 100644 --- a/iOS/Settings/Account/SettingsLocalAccountView.swift +++ b/iOS/Settings/Account/SettingsLocalAccountView.swift @@ -29,13 +29,10 @@ struct SettingsLocalAccountView : View { } } Section { - HStack { - Spacer() - Button(action: { self.addAccount() }) { - Text("Add Account") - } - Spacer() + Button(action: { self.addAccount() }) { + Text("Add Account") } + .buttonStyle(VibrantButtonStyle(alignment: .center)) } } .navigationBarTitle(Text(""), displayMode: .inline) diff --git a/iOS/Settings/Account/SettingsReaderAPIAccountView.swift b/iOS/Settings/Account/SettingsReaderAPIAccountView.swift index a20255d67..c091fbdc8 100644 --- a/iOS/Settings/Account/SettingsReaderAPIAccountView.swift +++ b/iOS/Settings/Account/SettingsReaderAPIAccountView.swift @@ -41,18 +41,15 @@ struct SettingsReaderAPIAccountView : View { Spacer() } ) { - HStack { - Spacer() - Button(action: { self.addAccount() }) { - if viewModel.isUpdate { - Text("Update Account") - } else { - Text("Add Account") - } + Button(action: { self.addAccount() }) { + if viewModel.isUpdate { + Text("Update Account") + } else { + Text("Add Account") } - .disabled(!viewModel.isValid) - Spacer() } + .buttonStyle(VibrantButtonStyle(alignment: .center)) + .disabled(!viewModel.isValid) } } // .disabled(busy) diff --git a/iOS/Settings/SettingsView.swift b/iOS/Settings/SettingsView.swift index aecf87e33..fd397b2e9 100644 --- a/iOS/Settings/SettingsView.swift +++ b/iOS/Settings/SettingsView.swift @@ -36,7 +36,7 @@ struct SettingsView : View { buildDatabaseSection() buildAboutSection() } - .buttonStyle(VibrantButtonStyle()) + .buttonStyle(VibrantButtonStyle(alignment: .leading)) .navigationBarTitle(Text("Settings"), displayMode: .inline) .navigationBarItems(leading: Button(action: { self.viewController?.dismiss(animated: true) }) { Text("Done") } ) } diff --git a/iOS/SwiftUI Extensions/VibrantButtonStyle.swift b/iOS/SwiftUI Extensions/VibrantButtonStyle.swift index b95ad7137..b327dacf0 100644 --- a/iOS/SwiftUI Extensions/VibrantButtonStyle.swift +++ b/iOS/SwiftUI Extensions/VibrantButtonStyle.swift @@ -9,11 +9,13 @@ import SwiftUI struct VibrantButtonStyle: ButtonStyle { + + let alignment: Alignment func makeBody(configuration: Configuration) -> some View { GeometryReader { geometry in configuration.label - .frame(width: geometry.size.width, height: geometry.size.height, alignment: .leading) + .frame(width: geometry.size.width, height: geometry.size.height, alignment: self.alignment) } .foregroundColor(configuration.isPressed ? Color(AppAssets.tableViewCellHighlightedTextColor) : .primary) .listRowBackground(configuration.isPressed ? Color(AppAssets.tableViewCellSelectionColor) : Color(.secondarySystemGroupedBackground))