NetNewsWire/Multiplatform/iOS/Settings/Accounts/SettingsLocalAccountView.swift

56 lines
1.2 KiB
Swift
Raw Normal View History

//
// SettingsLocalAccountView.swift
// Multiplatform iOS
//
// Created by Rizwan on 07/07/20.
// Copyright © 2020 Ranchero Software. All rights reserved.
//
import SwiftUI
import Account
struct SettingsLocalAccountView: View {
@Environment(\.presentationMode) var presentation
@State var name: String = ""
var body: some View {
NavigationView {
2020-07-08 12:39:49 +02:00
List {
Section(header: AccountHeaderImageView(image: AppAssets.image(for: .onMyMac)!)) {
HStack {
TextField("Name", text: $name)
}
2020-07-08 12:39:49 +02:00
}
Section {
HStack {
Spacer()
Button(action: { self.addAccount() }) {
Text("Add Account")
}
2020-07-08 12:39:49 +02:00
Spacer()
}
}
}
2020-07-08 12:39:49 +02:00
.listStyle(InsetGroupedListStyle())
.navigationBarTitle(Text(verbatim: Account.defaultLocalAccountName), displayMode: .inline)
.navigationBarItems(leading: Button(action: { self.dismiss() }) { Text("Cancel") } )
}
}
private func addAccount() {
let account = AccountManager.shared.createAccount(type: .onMyMac)
account.name = name
dismiss()
}
private func dismiss() {
presentation.wrappedValue.dismiss()
}
}
struct SettingsLocalAccountView_Previews: PreviewProvider {
static var previews: some View {
SettingsLocalAccountView()
}
}