mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Merge pull request #2230 from rizwankce/fix/settings-account-header-imageview
Settings account header imageview
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// 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(alignment: .center) {
|
||||
Spacer()
|
||||
Image(rsImage: image)
|
||||
.resizable()
|
||||
.scaledToFit()
|
||||
.frame(height: 48, alignment: .center)
|
||||
.foregroundColor(Color.primary)
|
||||
Spacer()
|
||||
}
|
||||
.padding(16)
|
||||
}
|
||||
}
|
||||
|
||||
struct AccountHeaderImageView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
Group {
|
||||
AccountHeaderImageView(image: AppAssets.image(for: .onMyMac)!)
|
||||
AccountHeaderImageView(image: AppAssets.image(for: .feedbin)!)
|
||||
AccountHeaderImageView(image: AppAssets.accountLocalPadImage)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,8 +17,8 @@ struct SettingsAccountLabelView: View {
|
||||
HStack {
|
||||
Image(rsImage: accountImage!)
|
||||
.resizable()
|
||||
.aspectRatio(1, contentMode: .fit)
|
||||
.frame(height: 32)
|
||||
.scaledToFit()
|
||||
.frame(width: 32, height: 32)
|
||||
Text(verbatim: accountLabel).font(.title)
|
||||
}
|
||||
.foregroundColor(.primary).padding(4.0)
|
||||
@@ -27,10 +27,23 @@ struct SettingsAccountLabelView: View {
|
||||
|
||||
struct SettingsAccountLabelView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
SettingsAccountLabelView(
|
||||
accountImage: AppAssets.image(for: .onMyMac),
|
||||
accountLabel: "On My Device"
|
||||
)
|
||||
.previewLayout(.fixed(width: 300, height: 44))
|
||||
List {
|
||||
SettingsAccountLabelView(
|
||||
accountImage: AppAssets.image(for: .onMyMac),
|
||||
accountLabel: "On My Device"
|
||||
)
|
||||
SettingsAccountLabelView(
|
||||
accountImage: AppAssets.image(for: .feedbin),
|
||||
accountLabel: "Feedbin"
|
||||
)
|
||||
SettingsAccountLabelView(
|
||||
accountImage: AppAssets.accountLocalPadImage,
|
||||
accountLabel: "On My iPad"
|
||||
)
|
||||
SettingsAccountLabelView(
|
||||
accountImage: AppAssets.accountLocalPhoneImage,
|
||||
accountLabel: "On My iPhone"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@ struct SettingsFeedbinAccountView: View {
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
List {
|
||||
Section {
|
||||
imageView
|
||||
Section(header: AccountHeaderImageView(image: AppAssets.image(for: .feedbin)!)) {
|
||||
TextField("Email", text: $settingsModel.email).textContentType(.emailAddress)
|
||||
SecureField("Password", text: $settingsModel.password)
|
||||
}
|
||||
@@ -42,13 +41,13 @@ struct SettingsFeedbinAccountView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
.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 +55,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()
|
||||
|
||||
@@ -16,8 +16,7 @@ struct SettingsLocalAccountView: View {
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
List {
|
||||
Section {
|
||||
imageView
|
||||
Section(header: AccountHeaderImageView(image: AppAssets.image(for: .onMyMac)!)) {
|
||||
HStack {
|
||||
TextField("Name", text: $name)
|
||||
}
|
||||
@@ -38,19 +37,6 @@ struct SettingsLocalAccountView: View {
|
||||
}
|
||||
}
|
||||
|
||||
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