refactor
This commit is contained in:
parent
c7f07c3d0a
commit
080afe70ee
5 changed files with 39 additions and 28 deletions
|
@ -312,7 +312,7 @@ class FlowInfo {
|
|||
class Item {
|
||||
late String id;
|
||||
late String name;
|
||||
late String category;
|
||||
late String? category;
|
||||
late Map<String, ItemVariant> variants;
|
||||
|
||||
Item(Map<String, dynamic> json) {
|
||||
|
@ -367,7 +367,7 @@ class Transaction {
|
|||
late ConsumeInfo? consumed;
|
||||
late bool expired;
|
||||
late String? note;
|
||||
late String? location;
|
||||
late Location? location;
|
||||
|
||||
Transaction(Map<String, dynamic> json) {
|
||||
uuid = json["uuid"];
|
||||
|
@ -379,7 +379,7 @@ class Transaction {
|
|||
expired = json["expired"];
|
||||
note = json["note"];
|
||||
consumed = json["consumed"] != null ? ConsumeInfo(json["consumed"]) : null;
|
||||
location = json["location"];
|
||||
location = json["location"] != null ? Location(json["location"]) : null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,15 @@ class _ExpandableListState extends State<ExpandableList> {
|
|||
children: widget.entries.map<ExpansionPanel>((ExpandableListItem item) {
|
||||
return ExpansionPanel(
|
||||
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,
|
||||
isExpanded: item.isExpanded,
|
||||
|
|
|
@ -91,8 +91,7 @@ class _FlowsPageState extends State<FlowsPage> {
|
|||
children: producedMapping[key]!.map((x) {
|
||||
return flowTile(context, x);
|
||||
}).toList());
|
||||
items.add(
|
||||
ExpandableListItem(body: flows, header: ListTile(title: Text(key))));
|
||||
items.add(ExpandableListItem(body: flows, header: Text(key)));
|
||||
}
|
||||
|
||||
return ExpandableList(items);
|
||||
|
@ -120,8 +119,7 @@ class _FlowsPageState extends State<FlowsPage> {
|
|||
children: dependsMapping[key]!.map((x) {
|
||||
return flowTile(context, x);
|
||||
}).toList());
|
||||
items.add(
|
||||
ExpandableListItem(body: flows, header: ListTile(title: Text(key))));
|
||||
items.add(ExpandableListItem(body: flows, header: Text(key)));
|
||||
}
|
||||
|
||||
return ExpandableList(items);
|
||||
|
@ -209,15 +207,17 @@ class _FlowInfoPageState extends State<FlowInfoPage> {
|
|||
|
||||
var data = snapshot.data!;
|
||||
|
||||
return ListView(
|
||||
children: data
|
||||
.map((x) => ListTile(
|
||||
title: Text(x.id),
|
||||
onTap: () =>
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (context) => ActiveFlowPage(x),
|
||||
))))
|
||||
.toList());
|
||||
return Expanded(
|
||||
child: ListView(
|
||||
children: data
|
||||
.map((x) => ListTile(
|
||||
title: Text(x.id),
|
||||
onTap: () =>
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (context) => ActiveFlowPage(x),
|
||||
))))
|
||||
.toList()),
|
||||
);
|
||||
},
|
||||
)
|
||||
],
|
||||
|
|
|
@ -50,7 +50,8 @@ class _ItemViewState extends State<ItemView> {
|
|||
widget.item.name,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
Text(widget.item.category),
|
||||
if (widget.item.category != null)
|
||||
Text(widget.item.category!),
|
||||
],
|
||||
)
|
||||
],
|
||||
|
|
|
@ -22,6 +22,7 @@ class TransactionPage extends StatelessWidget {
|
|||
semanticsLabel: "Transaction UUID",
|
||||
),
|
||||
|
||||
// todo : human names
|
||||
Text("${transaction.item} - ${transaction.variant}"),
|
||||
|
||||
Text("Added: ${tsFormat(transaction.timestamp)}"),
|
||||
|
@ -31,9 +32,11 @@ class TransactionPage extends StatelessWidget {
|
|||
IconText(Icons.money, transaction.price.format(),
|
||||
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!),
|
||||
|
||||
|
@ -134,16 +137,15 @@ class TransactionCard extends StatelessWidget {
|
|||
),
|
||||
],
|
||||
),
|
||||
if ((t.note ?? "").isNotEmpty) ...[
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
Text(t.note!)
|
||||
],
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
if ((t.note ?? "").isNotEmpty) ...[
|
||||
const SizedBox(height: 8),
|
||||
Text(t.note!),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
)
|
||||
],
|
||||
IconText(Icons.money,
|
||||
"${t.price.value.toStringAsFixed(2)} ${t.price.currency}",
|
||||
color: Colors.green),
|
||||
|
@ -155,7 +157,7 @@ class TransactionCard extends StatelessWidget {
|
|||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
IconText(Icons.location_city, t.location!)
|
||||
IconText(Icons.location_city, t.location!.name)
|
||||
]
|
||||
],
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue