-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #169 from moneymanagerex/view-1-account
refine Account Views
- Loading branch information
Showing
13 changed files
with
678 additions
and
513 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -537,6 +537,9 @@ | |
} | ||
} | ||
} | ||
}, | ||
"Error" : { | ||
|
||
}, | ||
"expenses" : { | ||
"localizations" : { | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// | ||
// AccountCreateView.swift | ||
// MMEX | ||
// | ||
// Created by Lisheng Guan on 2024/9/9. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct AccountCreateView: View { | ||
@EnvironmentObject var env: EnvironmentManager | ||
@State var vm: RepositoryViewModel | ||
@State var data: AccountData | ||
@Binding var newData: AccountData? | ||
@Binding var isPresented: Bool | ||
|
||
@State private var alertIsPresented = false | ||
@State private var alertMessage: String? | ||
|
||
var body: some View { | ||
NavigationStack { | ||
Form { | ||
AccountEditForm( | ||
vm: vm, | ||
data: $data, | ||
edit: true | ||
) | ||
} | ||
.textSelection(.enabled) | ||
.toolbar { | ||
ToolbarItem(placement: .cancellationAction) { | ||
Button("Dismiss") { | ||
isPresented = false | ||
} | ||
} | ||
ToolbarItem(placement: .confirmationAction) { | ||
Button("Add") { | ||
if let createError = vm.createAccount(&data) { | ||
alertMessage = createError | ||
alertIsPresented = true | ||
} else { | ||
newData = data | ||
isPresented = false | ||
} | ||
} | ||
} | ||
} | ||
.alert(isPresented: $alertIsPresented) { | ||
Alert( | ||
title: Text("Error"), | ||
message: Text(alertMessage!), | ||
dismissButton: .default(Text("OK")) | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
/* | ||
#Preview { | ||
AccountCreateView( | ||
allCurrencyName: .constant(CurrencyData.sampleDataName), | ||
newAccount: .constant(AccountData()), | ||
isPresentingAddView: .constant(true) | ||
) { newAccount in | ||
// Handle saving in preview | ||
log.info("New account: \(newAccount.name)") | ||
} | ||
} | ||
*/ |
Oops, something went wrong.