mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-11-27 06:46:52 +00:00
Add settings account header image view
This commit is contained in:
4 files changed
+74
-60
No files matched your search
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// AccountHeaderImageView.swift
|
||||
// Multiplatform iOS
|
||||
//
|
||||
// Created by Rizwan on 08/07/20.
|
||||
// Copyright © 2020 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import RSCore
|
||||
|
||||
struct AccountHeaderImageView: View {
|
||||
var image: RSImage
|
||||
|
||||
var body: some View {
|
||||
HStack {
|
||||
Spacer()
|
||||
Image(rsImage: image)
|
||||
.resizable()
|
||||
.aspectRatio(1, contentMode: .fit)
|
||||
.frame(height: 48, alignment: .center)
|
||||
.padding()
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct AccountHeaderImageView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
AccountHeaderImageView(image: AppAssets.image(for: .onMyMac)!)
|
||||
}
|
||||
}
|
||||
@@ -18,37 +18,39 @@ struct SettingsFeedbinAccountView: View {
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
List {
|
||||
Section {
|
||||
imageView
|
||||
TextField("Email", text: $settingsModel.email).textContentType(.emailAddress)
|
||||
SecureField("Password", text: $settingsModel.password)
|
||||
}
|
||||
Section(footer: errorFooter) {
|
||||
HStack {
|
||||
Spacer()
|
||||
Button(action: { settingsModel.addAccount() }) {
|
||||
if settingsModel.isUpdate {
|
||||
Text("Update Account")
|
||||
} else {
|
||||
Text("Add Account")
|
||||
VStack {
|
||||
AccountHeaderImageView(image: AppAssets.image(for: .feedbin)!)
|
||||
List {
|
||||
Section {
|
||||
TextField("Email", text: $settingsModel.email).textContentType(.emailAddress)
|
||||
SecureField("Password", text: $settingsModel.password)
|
||||
}
|
||||
Section(footer: errorFooter) {
|
||||
HStack {
|
||||
Spacer()
|
||||
Button(action: { settingsModel.addAccount() }) {
|
||||
if settingsModel.isUpdate {
|
||||
Text("Update Account")
|
||||
} else {
|
||||
Text("Add Account")
|
||||
}
|
||||
}
|
||||
.disabled(!settingsModel.isValid)
|
||||
Spacer()
|
||||
if settingsModel.busy {
|
||||
ProgressView()
|
||||
}
|
||||
}
|
||||
.disabled(!settingsModel.isValid)
|
||||
Spacer()
|
||||
if settingsModel.busy {
|
||||
ProgressView()
|
||||
}
|
||||
}
|
||||
}
|
||||
.listStyle(InsetGroupedListStyle())
|
||||
.disabled(settingsModel.busy)
|
||||
}
|
||||
.onReceive(settingsModel.$shouldDismiss, perform: { dismiss in
|
||||
if dismiss == true {
|
||||
presentationMode.wrappedValue.dismiss()
|
||||
}
|
||||
})
|
||||
.listStyle(InsetGroupedListStyle())
|
||||
.disabled(settingsModel.busy)
|
||||
.navigationBarTitle(Text(verbatim: "Feedbin"), displayMode: .inline)
|
||||
.navigationBarItems(leading:
|
||||
Button(action: { self.dismiss() }) { Text("Cancel") }
|
||||
@@ -56,19 +58,6 @@ struct SettingsFeedbinAccountView: View {
|
||||
}
|
||||
}
|
||||
|
||||
var imageView: some View {
|
||||
HStack {
|
||||
Spacer()
|
||||
Image(rsImage: AppAssets.image(for: .feedbin)!)
|
||||
.resizable()
|
||||
.aspectRatio(1, contentMode: .fit)
|
||||
.frame(height: 48, alignment: .center)
|
||||
.padding()
|
||||
Spacer()
|
||||
}
|
||||
.listRowBackground(Color.clear)
|
||||
}
|
||||
|
||||
var errorFooter: some View {
|
||||
HStack {
|
||||
Spacer()
|
||||
|
||||
@@ -15,42 +15,31 @@ struct SettingsLocalAccountView: View {
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
List {
|
||||
Section {
|
||||
imageView
|
||||
HStack {
|
||||
TextField("Name", text: $name)
|
||||
VStack(spacing: 0) {
|
||||
AccountHeaderImageView(image: AppAssets.image(for: .onMyMac)!)
|
||||
List {
|
||||
Section {
|
||||
HStack {
|
||||
TextField("Name", text: $name)
|
||||
}
|
||||
}
|
||||
}
|
||||
Section {
|
||||
HStack {
|
||||
Spacer()
|
||||
Button(action: { self.addAccount() }) {
|
||||
Text("Add Account")
|
||||
Section {
|
||||
HStack {
|
||||
Spacer()
|
||||
Button(action: { self.addAccount() }) {
|
||||
Text("Add Account")
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
.listStyle(InsetGroupedListStyle())
|
||||
}
|
||||
.listStyle(InsetGroupedListStyle())
|
||||
.navigationBarTitle(Text(verbatim: Account.defaultLocalAccountName), displayMode: .inline)
|
||||
.navigationBarItems(leading: Button(action: { self.dismiss() }) { Text("Cancel") } )
|
||||
}
|
||||
}
|
||||
|
||||
var imageView: some View {
|
||||
HStack {
|
||||
Spacer()
|
||||
Image(rsImage: AppAssets.image(for: .onMyMac)!)
|
||||
.resizable()
|
||||
.aspectRatio(1, contentMode: .fit)
|
||||
.frame(height: 48, alignment: .center)
|
||||
.padding()
|
||||
Spacer()
|
||||
}
|
||||
.listRowBackground(Color.clear)
|
||||
}
|
||||
|
||||
private func addAccount() {
|
||||
let account = AccountManager.shared.createAccount(type: .onMyMac)
|
||||
account.name = name
|
||||
|
||||
Reference in new issue
Block a user