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 {
@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)
}

View File

@ -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)
}

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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") } )
}

View File

@ -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))