This commit is contained in:
JMARyA 2024-09-23 20:19:30 +02:00
parent c7f07c3d0a
commit 080afe70ee
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
5 changed files with 39 additions and 28 deletions

View file

@ -312,7 +312,7 @@ class FlowInfo {
class Item { class Item {
late String id; late String id;
late String name; late String name;
late String category; late String? category;
late Map<String, ItemVariant> variants; late Map<String, ItemVariant> variants;
Item(Map<String, dynamic> json) { Item(Map<String, dynamic> json) {
@ -367,7 +367,7 @@ class Transaction {
late ConsumeInfo? consumed; late ConsumeInfo? consumed;
late bool expired; late bool expired;
late String? note; late String? note;
late String? location; late Location? location;
Transaction(Map<String, dynamic> json) { Transaction(Map<String, dynamic> json) {
uuid = json["uuid"]; uuid = json["uuid"];
@ -379,7 +379,7 @@ class Transaction {
expired = json["expired"]; expired = json["expired"];
note = json["note"]; note = json["note"];
consumed = json["consumed"] != null ? ConsumeInfo(json["consumed"]) : null; consumed = json["consumed"] != null ? ConsumeInfo(json["consumed"]) : null;
location = json["location"]; location = json["location"] != null ? Location(json["location"]) : null;
} }
} }

View file

@ -41,7 +41,15 @@ class _ExpandableListState extends State<ExpandableList> {
children: widget.entries.map<ExpansionPanel>((ExpandableListItem item) { children: widget.entries.map<ExpansionPanel>((ExpandableListItem item) {
return ExpansionPanel( return ExpansionPanel(
headerBuilder: (BuildContext context, bool isExpanded) { headerBuilder: (BuildContext context, bool isExpanded) {
return item.header; return ListTile(
title: item.header,
onTap: () {
setState(() {
widget.entries.firstWhere((x) => x == item).isExpanded =
!isExpanded;
});
},
);
}, },
body: item.body, body: item.body,
isExpanded: item.isExpanded, isExpanded: item.isExpanded,

View file

@ -91,8 +91,7 @@ class _FlowsPageState extends State<FlowsPage> {
children: producedMapping[key]!.map((x) { children: producedMapping[key]!.map((x) {
return flowTile(context, x); return flowTile(context, x);
}).toList()); }).toList());
items.add( items.add(ExpandableListItem(body: flows, header: Text(key)));
ExpandableListItem(body: flows, header: ListTile(title: Text(key))));
} }
return ExpandableList(items); return ExpandableList(items);
@ -120,8 +119,7 @@ class _FlowsPageState extends State<FlowsPage> {
children: dependsMapping[key]!.map((x) { children: dependsMapping[key]!.map((x) {
return flowTile(context, x); return flowTile(context, x);
}).toList()); }).toList());
items.add( items.add(ExpandableListItem(body: flows, header: Text(key)));
ExpandableListItem(body: flows, header: ListTile(title: Text(key))));
} }
return ExpandableList(items); return ExpandableList(items);
@ -209,15 +207,17 @@ class _FlowInfoPageState extends State<FlowInfoPage> {
var data = snapshot.data!; var data = snapshot.data!;
return ListView( return Expanded(
children: data child: ListView(
.map((x) => ListTile( children: data
title: Text(x.id), .map((x) => ListTile(
onTap: () => title: Text(x.id),
Navigator.of(context).push(MaterialPageRoute( onTap: () =>
builder: (context) => ActiveFlowPage(x), Navigator.of(context).push(MaterialPageRoute(
)))) builder: (context) => ActiveFlowPage(x),
.toList()); ))))
.toList()),
);
}, },
) )
], ],

View file

@ -50,7 +50,8 @@ class _ItemViewState extends State<ItemView> {
widget.item.name, widget.item.name,
style: const TextStyle(fontWeight: FontWeight.bold), style: const TextStyle(fontWeight: FontWeight.bold),
), ),
Text(widget.item.category), if (widget.item.category != null)
Text(widget.item.category!),
], ],
) )
], ],

View file

@ -22,6 +22,7 @@ class TransactionPage extends StatelessWidget {
semanticsLabel: "Transaction UUID", semanticsLabel: "Transaction UUID",
), ),
// todo : human names
Text("${transaction.item} - ${transaction.variant}"), Text("${transaction.item} - ${transaction.variant}"),
Text("Added: ${tsFormat(transaction.timestamp)}"), Text("Added: ${tsFormat(transaction.timestamp)}"),
@ -31,9 +32,11 @@ class TransactionPage extends StatelessWidget {
IconText(Icons.money, transaction.price.format(), IconText(Icons.money, transaction.price.format(),
color: Colors.green), color: Colors.green),
IconText(Icons.store, transaction.origin!, color: Colors.blue), if (transaction.origin != null)
IconText(Icons.store, transaction.origin!, color: Colors.blue),
IconText(Icons.location_city, transaction.location!), if (transaction.location != null)
IconText(Icons.location_city, transaction.location!.name),
if (transaction.note != null) Text(transaction.note!), if (transaction.note != null) Text(transaction.note!),
@ -134,16 +137,15 @@ class TransactionCard extends StatelessWidget {
), ),
], ],
), ),
if ((t.note ?? "").isNotEmpty) ...[
const SizedBox(
height: 4,
),
Text(t.note!)
],
const SizedBox( const SizedBox(
height: 10, height: 10,
), ),
if ((t.note ?? "").isNotEmpty) ...[
const SizedBox(height: 8),
Text(t.note!),
const SizedBox(
height: 10,
)
],
IconText(Icons.money, IconText(Icons.money,
"${t.price.value.toStringAsFixed(2)} ${t.price.currency}", "${t.price.value.toStringAsFixed(2)} ${t.price.currency}",
color: Colors.green), color: Colors.green),
@ -155,7 +157,7 @@ class TransactionCard extends StatelessWidget {
const SizedBox( const SizedBox(
height: 8, height: 8,
), ),
IconText(Icons.location_city, t.location!) IconText(Icons.location_city, t.location!.name)
] ]
], ],
), ),