Implemented Contextmenu to transfer money to selected transaction's other party

This commit is contained in:
dankito 2020-07-28 15:21:05 +02:00
parent 7b8a83d1fd
commit d76e4022ec
6 changed files with 186 additions and 0 deletions

View File

@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "transfer_money_2.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}

View File

@ -0,0 +1,119 @@
%PDF-1.7
1 0 obj
<< >>
endobj
2 0 obj
<< /Length 3 0 R >>
stream
/DeviceRGB CS
/DeviceRGB cs
q
1.000000 0.000000 -0.000000 1.000000 5.000000 26.000000 cm
0.000000 0.000000 0.000000 scn
0.000000 5.000000 m
0.000000 5.552285 0.447715 6.000000 1.000000 6.000000 c
10.000000 6.000000 l
10.552285 6.000000 11.000000 5.552285 11.000000 5.000000 c
11.000000 1.000000 l
11.000000 0.447715 10.552284 0.000000 10.000000 0.000000 c
1.000000 0.000000 l
0.447715 0.000000 0.000000 0.447715 0.000000 1.000000 c
0.000000 5.000000 l
h
f
n
Q
q
-1.000000 -0.000000 -0.000000 1.000000 29.000000 8.000000 cm
0.000000 0.000000 0.000000 scn
0.000000 5.000000 m
0.000000 5.552285 0.447715 6.000000 1.000000 6.000000 c
10.000000 6.000000 l
10.552285 6.000000 11.000000 5.552285 11.000000 5.000000 c
11.000000 1.000000 l
11.000000 0.447715 10.552284 0.000000 10.000000 0.000000 c
1.000000 0.000000 l
0.447715 0.000000 0.000000 0.447715 0.000000 1.000000 c
0.000000 5.000000 l
h
f
n
Q
q
-0.000000 -1.000000 1.000000 -0.000000 16.871948 40.000000 cm
0.000000 0.000000 0.000000 scn
9.267950 14.128052 m
10.037750 15.461385 11.962252 15.461386 12.732052 14.128053 c
18.794230 3.628055 l
19.564030 2.294721 18.601780 0.628054 17.062180 0.628054 c
4.937824 0.628054 l
3.398223 0.628054 2.435971 2.294721 3.205772 3.628054 c
9.267950 14.128052 l
h
f
n
Q
q
0.000000 -1.000000 -1.000000 -0.000000 17.128052 22.000000 cm
0.000000 0.000000 0.000000 scn
9.267950 14.128052 m
10.037750 15.461385 11.962252 15.461386 12.732052 14.128053 c
18.794230 3.628055 l
19.564030 2.294721 18.601780 0.628054 17.062180 0.628054 c
4.937824 0.628054 l
3.398223 0.628054 2.435971 2.294721 3.205772 3.628054 c
9.267950 14.128052 l
h
f
n
Q
endstream
endobj
3 0 obj
1620
endobj
4 0 obj
<< /Annots []
/Type /Page
/MediaBox [ 0.000000 0.000000 34.000000 40.000000 ]
/Resources 1 0 R
/Contents 2 0 R
/Parent 5 0 R
>>
endobj
5 0 obj
<< /Kids [ 4 0 R ]
/Count 1
/Type /Pages
>>
endobj
6 0 obj
<< /Type /Catalog
/Pages 5 0 R
>>
endobj
xref
0 7
0000000000 65535 f
0000000010 00000 n
0000000034 00000 n
0000001710 00000 n
0000001733 00000 n
0000001906 00000 n
0000001980 00000 n
trailer
<< /ID [ (some) (id) ]
/Root 6 0 R
/Size 7
>>
startxref
2039
%%EOF

View File

@ -33,8 +33,16 @@
"Error message from your bank %@" = "Error message from your bank:\n\n%@";
/* AccountTransactionsDialog */
"Transfer money to %@" = "Transfer money to %@";
/* New action sheet */
"Show transfer money dialog" = "Transfer money";
/* TransferMoneyDialog */
"Transfer Money Dialog Title" = "Überweisung";

View File

@ -33,8 +33,16 @@
"Error message from your bank %@" = "Fehlermeldung Ihrer Bank:\n\n%@";
/* AccountTransactionsDialog */
"Transfer money to %@" = "Neue Überweisung an %@";
/* New action sheet */
"Show transfer money dialog" = "Überweisung";
/* TransferMoneyDialog */
"Transfer Money Dialog Title" = "Überweisung";

View File

@ -16,11 +16,16 @@ struct AccountTransactionListItem: View {
private let transaction: AccountTransaction
private var transferMoneyData: TransferMoneyData
@Inject private var presenter: BankingPresenterSwift
init(_ transaction: AccountTransaction) {
self.transaction = transaction
self.transferMoneyData = TransferMoneyData.Companion().fromAccountTransaction(transaction: transaction)
}
@ -48,6 +53,17 @@ struct AccountTransactionListItem: View {
.styleAsDetail()
}
}
.contextMenu {
if transaction.otherPartyAccountId != nil && transaction.bankAccount.supportsTransferringMoney {
NavigationLink(destination: LazyView(TransferMoneyDialog(preselectedBankAccount: self.transaction.bankAccount, preselectedValues: self.transferMoneyData))) {
HStack {
Text("Transfer money to \(transaction.otherPartyName ?? "")")
Image("TransferMoney")
}
}
}
}
}

View File

@ -56,6 +56,26 @@ struct TransferMoneyDialog: View {
self.showAccounts = self.accountsSupportingTransferringMoney.count > 1
}
init(preselectedBankAccount: BankAccount, preselectedValues: TransferMoneyData) {
self.init()
self._selectedAccountIndex = State(initialValue: accountsSupportingTransferringMoney.firstIndex(where: { account in account == preselectedBankAccount }) ?? 0)
self._remitteeName = State(initialValue: preselectedValues.creditorName)
self._remitteeBic = State(initialValue: preselectedValues.creditorBic)
self._remitteeIban = State(initialValue: preselectedValues.creditorIban)
self._usage = State(initialValue: preselectedValues.usage)
if preselectedValues.amount.decimal != NSDecimalNumber.zero {
self._amount = State(initialValue: preselectedValues.amount.format(countDecimalPlaces: 2))
}
if preselectedBankAccount.supportsInstantPaymentMoneyTransfer {
self._instantPayment = State(initialValue: preselectedValues.instantPayment)
}
}
var body: some View {
Form {