@@ 1,6 1,7 @@
package main
import (
+ "bytes"
"fmt"
"image"
"io"
@@ 334,6 335,30 @@ func (u *UI) layoutAccountTreeNode(gtx C, at *AccountTreeNode) D {
return d.DetailInset().Layout(gtx, theme.Account(u.Theme.Th, balance).Layout)
}
+func toTxBytes(tx ledger.Transaction) []byte {
+ var b bytes.Buffer
+ b.WriteString("\n\n")
+ b.WriteString(tx.Date.Format("2006-01-02"))
+ b.WriteString(" ")
+ b.WriteString(tx.Payee)
+ b.WriteString("\n")
+ for i, change := range tx.AccountChanges {
+ if i < len(tx.Comments) {
+ b.WriteString("\t; ")
+ b.WriteString(tx.Comments[i])
+ b.WriteString("\n")
+ }
+ b.WriteString("\t")
+ b.WriteString(change.Name)
+ b.WriteString(" ")
+ b.WriteString(change.Balance.StringFixedBank())
+ b.WriteString(" ; ")
+ b.WriteString(change.Comment)
+ b.WriteString("\n")
+ }
+ return b.Bytes()
+}
+
func (u *UI) layoutTransactions(gtx C) D {
u.TxList.Axis = layout.Vertical
list := material.List(u.Theme.Th, &u.TxList)
@@ 344,6 369,8 @@ func (u *UI) layoutTransactions(gtx C) D {
case appwidget.SuggestionRequestEvent[string]:
suggestions := fuzzy.FindFold(e.Text, maps.Keys(u.AccountRegistry.elements))
u.TxEditor.SetAccountSuggestions(suggestions)
+ case appwidget.TransactionSubmittedEvent:
+ log.Println(string(toTxBytes(e.Value)))
}
}
return layout.UniformInset(4).Layout(gtx, apptheme.TxForm(u.Theme, &u.TxEditor).Layout)