NetNewsWire/iOS/Settings/Account/SettingsLocalAccountView.swift

63 lines
1.2 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(\.presentationMode) var presentation
2019-06-12 15:33:14 +02:00
@State var name: String
2019-06-11 23:59:16 +02:00
var body: some View {
Form {
Section(header:
HStack {
Spacer()
2019-09-12 17:19:06 +02:00
SettingsAccountLabelView(accountImage: "accountLocal", accountLabel: Account.defaultLocalAccountName)
.padding()
.layoutPriority(1.0)
Spacer()
2019-06-11 23:59:16 +02:00
}
) {
HStack {
TextField("Name", text: $name)
}
}
Section {
HStack {
Spacer()
Button(action: { self.addAccount() }) {
Text("Add Account")
2019-06-11 23:59:16 +02:00
}
Spacer()
2019-06-11 23:59:16 +02:00
}
}
}
.navigationBarTitle(Text(""), displayMode: .inline)
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() {
presentation.wrappedValue.dismiss()
}
2019-06-11 23:59:16 +02:00
}
#if DEBUG
struct SettingsLocalAccountView_Previews : PreviewProvider {
static var previews: some View {
SettingsLocalAccountView(name: "")
2019-06-11 23:59:16 +02:00
}
}
#endif