Add vibrant styling to Account Views

This commit is contained in:
Maurice Parker 2019-09-16 11:35:09 -05:00
parent 7bda205af8
commit ac93dfbd91
7 changed files with 48 additions and 48 deletions

View File

@ -11,18 +11,32 @@ import Account
struct SettingsAddAccountView : View { struct SettingsAddAccountView : View {
@Environment(\.presentationMode) var presentation @Environment(\.presentationMode) var presentation
@State private var accountAddAction: Int? = nil
var body: some View { var body: some View {
Form { Form {
NavigationLink(destination: SettingsLocalAccountView(name: "")) {
NavigationLink(destination: SettingsLocalAccountView(name: ""), tag: 1, selection: $accountAddAction) {
SettingsAccountLabelView(accountImage: "accountLocal", accountLabel: Account.defaultLocalAccountName) 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") 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") SettingsAccountLabelView(accountImage: "accountFreshRSS", accountLabel: "Fresh RSS")
} }
.modifier(VibrantSelectAction(action: {
self.accountAddAction = 3
}))
} }
.navigationBarTitle(Text("Add Account"), displayMode: .inline) .navigationBarTitle(Text("Add Account"), displayMode: .inline)
} }

View File

@ -29,14 +29,10 @@ struct SettingsDetailAccountView : View {
} }
if viewModel.isCreditialsAvailable { if viewModel.isCreditialsAvailable {
Section { Section {
HStack { Button(action: {
Spacer() self.accountType = self.viewModel.account.type
Button(action: { }) {
self.accountType = self.viewModel.account.type Text("Credentials")
}) {
Text("Credentials")
}
Spacer()
} }
} }
.sheet(item: $accountType) { type in .sheet(item: $accountType) { type in
@ -50,14 +46,10 @@ struct SettingsDetailAccountView : View {
} }
if viewModel.isDeletable { if viewModel.isDeletable {
Section { Section {
HStack { Button(action: {
Spacer() self.isDeleteAlertPresented.toggle()
Button(action: { }) {
self.isDeleteAlertPresented.toggle() Text("Delete Account").foregroundColor(.red)
}) {
Text("Delete Account").foregroundColor(.red)
}
Spacer()
} }
.alert(isPresented: $isDeleteAlertPresented) { .alert(isPresented: $isDeleteAlertPresented) {
Alert(title: Text("Are you sure you want to delete \"\(viewModel.nameForDisplay)\"?"), 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) .navigationBarTitle(Text(verbatim: viewModel.nameForDisplay), displayMode: .inline)
} }

View File

@ -38,18 +38,15 @@ struct SettingsFeedbinAccountView : View {
Spacer() Spacer()
} }
) { ) {
HStack { Button(action: { self.addAccount() }) {
Spacer() if viewModel.isUpdate {
Button(action: { self.addAccount() }) { Text("Update Account")
if viewModel.isUpdate { } else {
Text("Update Account") Text("Add 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 // .disabled(busy) // Maybe someday we can do this, but right now it crashes on the iPad

View File

@ -29,13 +29,10 @@ struct SettingsLocalAccountView : View {
} }
} }
Section { Section {
HStack { Button(action: { self.addAccount() }) {
Spacer() Text("Add Account")
Button(action: { self.addAccount() }) {
Text("Add Account")
}
Spacer()
} }
.buttonStyle(VibrantButtonStyle(alignment: .center))
} }
} }
.navigationBarTitle(Text(""), displayMode: .inline) .navigationBarTitle(Text(""), displayMode: .inline)

View File

@ -41,18 +41,15 @@ struct SettingsReaderAPIAccountView : View {
Spacer() Spacer()
} }
) { ) {
HStack { Button(action: { self.addAccount() }) {
Spacer() if viewModel.isUpdate {
Button(action: { self.addAccount() }) { Text("Update Account")
if viewModel.isUpdate { } else {
Text("Update Account") Text("Add Account")
} else {
Text("Add Account")
}
} }
.disabled(!viewModel.isValid)
Spacer()
} }
.buttonStyle(VibrantButtonStyle(alignment: .center))
.disabled(!viewModel.isValid)
} }
} }
// .disabled(busy) // .disabled(busy)

View File

@ -36,7 +36,7 @@ struct SettingsView : View {
buildDatabaseSection() buildDatabaseSection()
buildAboutSection() buildAboutSection()
} }
.buttonStyle(VibrantButtonStyle()) .buttonStyle(VibrantButtonStyle(alignment: .leading))
.navigationBarTitle(Text("Settings"), displayMode: .inline) .navigationBarTitle(Text("Settings"), displayMode: .inline)
.navigationBarItems(leading: Button(action: { self.viewController?.dismiss(animated: true) }) { Text("Done") } ) .navigationBarItems(leading: Button(action: { self.viewController?.dismiss(animated: true) }) { Text("Done") } )
} }

View File

@ -10,10 +10,12 @@ import SwiftUI
struct VibrantButtonStyle: ButtonStyle { struct VibrantButtonStyle: ButtonStyle {
let alignment: Alignment
func makeBody(configuration: Configuration) -> some View { func makeBody(configuration: Configuration) -> some View {
GeometryReader { geometry in GeometryReader { geometry in
configuration.label 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) .foregroundColor(configuration.isPressed ? Color(AppAssets.tableViewCellHighlightedTextColor) : .primary)
.listRowBackground(configuration.isPressed ? Color(AppAssets.tableViewCellSelectionColor) : Color(.secondarySystemGroupedBackground)) .listRowBackground(configuration.isPressed ? Color(AppAssets.tableViewCellSelectionColor) : Color(.secondarySystemGroupedBackground))