Add settings account header image view

This commit is contained in:
Rizwan Mohamed Ibrahim 2020-07-08 14:40:14 +05:30
parent 9a054a320c
commit 48f212abcd
No known key found for this signature in database
GPG Key ID: D5BEE468D448BCC5
4 changed files with 75 additions and 61 deletions

View File

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

View File

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

View File

@ -15,42 +15,31 @@ struct SettingsLocalAccountView: View {
var body: some View {
NavigationView {
List {
Section {
imageView
HStack {
TextField("Name", text: $name)
}
}
Section {
HStack {
Spacer()
Button(action: { self.addAccount() }) {
Text("Add Account")
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")
}
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

View File

@ -670,6 +670,7 @@
6581C74020CED60100F4AD34 /* netnewswire-subscribe-to-feed.js in Resources */ = {isa = PBXBuildFile; fileRef = 6581C73F20CED60100F4AD34 /* netnewswire-subscribe-to-feed.js */; };
6581C74220CED60100F4AD34 /* ToolbarItemIcon.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 6581C74120CED60100F4AD34 /* ToolbarItemIcon.pdf */; };
6591720E24B59C5100B638E8 /* SettingsFeedbinAccountModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6591720D24B59C5100B638E8 /* SettingsFeedbinAccountModel.swift */; };
6591723124B5C35400B638E8 /* AccountHeaderImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6591723024B5C35400B638E8 /* AccountHeaderImageView.swift */; };
6594CA3B24AF6F2A005C7D7C /* OPMLExporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8444C8F11FED81840051386C /* OPMLExporter.swift */; };
65ACE48424B4779B003AE06A /* SettingsAddAccountView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65ACE48324B4779B003AE06A /* SettingsAddAccountView.swift */; };
65ACE48624B477C9003AE06A /* SettingsAccountLabelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65ACE48524B477C9003AE06A /* SettingsAccountLabelView.swift */; };
@ -2085,6 +2086,7 @@
6581C74120CED60100F4AD34 /* ToolbarItemIcon.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = ToolbarItemIcon.pdf; sourceTree = "<group>"; };
6581C74320CED60100F4AD34 /* Subscribe_to_Feed.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Subscribe_to_Feed.entitlements; sourceTree = "<group>"; };
6591720D24B59C5100B638E8 /* SettingsFeedbinAccountModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsFeedbinAccountModel.swift; sourceTree = "<group>"; };
6591723024B5C35400B638E8 /* AccountHeaderImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountHeaderImageView.swift; sourceTree = "<group>"; };
65ACE48324B4779B003AE06A /* SettingsAddAccountView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsAddAccountView.swift; sourceTree = "<group>"; };
65ACE48524B477C9003AE06A /* SettingsAccountLabelView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsAccountLabelView.swift; sourceTree = "<group>"; };
65ACE48724B48020003AE06A /* SettingsLocalAccountView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsLocalAccountView.swift; sourceTree = "<group>"; };
@ -3145,6 +3147,7 @@
65ACE48724B48020003AE06A /* SettingsLocalAccountView.swift */,
65ACE48924B4C2D8003AE06A /* SettingsFeedbinAccountView.swift */,
6591720D24B59C5100B638E8 /* SettingsFeedbinAccountModel.swift */,
6591723024B5C35400B638E8 /* AccountHeaderImageView.swift */,
);
path = Accounts;
sourceTree = "<group>";
@ -4964,6 +4967,7 @@
51E4992F24A8676400B667CB /* ArticleArray.swift in Sources */,
5177471C24B387AC00EB0F74 /* ImageScrollView.swift in Sources */,
51E498F824A8085D00B667CB /* UnreadFeed.swift in Sources */,
6591723124B5C35400B638E8 /* AccountHeaderImageView.swift in Sources */,
FF64D0E724AF53EE0084080A /* RefreshProgressModel.swift in Sources */,
51E4996A24A8762D00B667CB /* ExtractedArticle.swift in Sources */,
51919FF124AB864A00541E64 /* TimelineModel.swift in Sources */,