NetNewsWire/iOS/Settings/SettingsLocalAccountView.swift

62 lines
1.3 KiB
Swift
Raw Normal View History

2019-06-11 23:59:16 +02:00
//
// SettingsLocalAccountView.swift
// NetNewsWire-iOS
//
// Created by Maurice Parker on 6/11/19.
// Copyright © 2019 Ranchero Software. All rights reserved.
//
import SwiftUI
import Account
struct SettingsLocalAccountView : View {
@Environment(\.isPresented) private var isPresented
2019-06-12 15:33:14 +02:00
@State var name: String
2019-06-11 23:59:16 +02:00
var body: some View {
NavigationView {
Form {
2019-06-11 23:59:16 +02:00
Section(header:
2019-06-13 21:30:56 +02:00
SettingsAccountLabelView(accountImage: "accountLocal", accountLabel: Account.defaultLocalAccountName).padding()
2019-06-11 23:59:16 +02:00
) {
HStack {
2019-06-16 01:19:20 +02:00
Text("Name")
Divider()
TextField($name, placeholder: Text("(Optional)"))
2019-06-11 23:59:16 +02:00
}
}
Section {
HStack {
Spacer()
Button(action: { self.addAccount() }) {
Text("Add Account")
}
Spacer()
}
}
}
.navigationBarTitle(Text(""), displayMode: .inline)
2019-06-12 15:33:14 +02:00
.navigationBarItems(leading: Button(action: { self.dismiss() }) { Text("Cancel") } )
2019-06-11 23:59:16 +02:00
}
}
private func addAccount() {
2019-06-11 23:59:16 +02:00
let account = AccountManager.shared.createAccount(type: .onMyMac)
account.name = name
dismiss()
2019-06-11 23:59:16 +02:00
}
private func dismiss() {
isPresented?.value = false
}
2019-06-11 23:59:16 +02:00
}
#if DEBUG
struct SettingsLocalAccountView_Previews : PreviewProvider {
static var previews: some View {
SettingsLocalAccountView(name: "")
}
}
#endif