Skip to content

Commit

Permalink
Merge pull request #54 from moneymanagerex/ipad
Browse files Browse the repository at this point in the history
Refine Txn edit to better use available space
  • Loading branch information
guanlisheng authored Sep 27, 2024
2 parents 09a67f8 + 73cf641 commit ce3bbfe
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
4 changes: 4 additions & 0 deletions MMEX/Views/Transactions/TransactionAddView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,14 @@ struct TransactionAddView: View {
isPresentingTransactionAddView = false
onSave(&newTxn)
}
.disabled(!isTransactionValid())
}
}
}
}
func isTransactionValid() -> Bool {
return newTxn.payeeId > 0 && newTxn.categId > 0
}
}

#Preview {
Expand Down
5 changes: 5 additions & 0 deletions MMEX/Views/Transactions/TransactionAddView2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ struct TransactionAddView2: View {
selectedTab = 0
newTxn = TransactionData()
}
.disabled(!isTransactionValid())
}
}
}
Expand All @@ -57,6 +58,10 @@ struct TransactionAddView2: View {
}
}

func isTransactionValid() -> Bool {
return newTxn.payeeId > 0 && newTxn.categId > 0
}

func addTransaction(txn: inout TransactionData) {
let repository = dataManager.getTransactionRepository()
if repository.insert(&txn) {
Expand Down
10 changes: 5 additions & 5 deletions MMEX/Views/Transactions/TransactionEditView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ struct TransactionEditView: View {
}
}
.pickerStyle(SegmentedPickerStyle()) // Use a segmented style for the picker
.padding(.horizontal)

Spacer()

Expand All @@ -45,11 +44,12 @@ struct TransactionEditView: View {
Text(account.data.name).tag(account.data.id)
}
}
.frame(maxWidth: .infinity) // Allow picker to use available space
}
.padding(.horizontal)
.padding(.horizontal, 0)

// 2. Unified Numeric Input for the Amount with automatic keyboard focus
TextField("¥0", text: $amountString)
TextField("0", text: $amountString)
.keyboardType(.decimalPad) // Show numeric keyboard with decimal support
.font(.system(size: 48, weight: .bold)) // Large, bold text for amount input
.multilineTextAlignment(.center) // Center the text for better UX
Expand Down Expand Up @@ -101,7 +101,7 @@ struct TransactionEditView: View {
}
}
}
.padding(.horizontal)
.padding(.horizontal, 0)

// 5. Horizontal stack for Payee and Category pickers
HStack {
Expand Down Expand Up @@ -132,7 +132,7 @@ struct TransactionEditView: View {
}
.pickerStyle(MenuPickerStyle()) // Show a menu for the category picker
}
.padding(.horizontal)
.padding(.horizontal, 0)

Spacer() // Push the contents to the top
}
Expand Down

0 comments on commit ce3bbfe

Please sign in to comment.