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 {
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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,7 +207,8 @@ class _FlowInfoPageState extends State<FlowInfoPage> {
|
||||||
|
|
||||||
var data = snapshot.data!;
|
var data = snapshot.data!;
|
||||||
|
|
||||||
return ListView(
|
return Expanded(
|
||||||
|
child: ListView(
|
||||||
children: data
|
children: data
|
||||||
.map((x) => ListTile(
|
.map((x) => ListTile(
|
||||||
title: Text(x.id),
|
title: Text(x.id),
|
||||||
|
@ -217,7 +216,8 @@ class _FlowInfoPageState extends State<FlowInfoPage> {
|
||||||
Navigator.of(context).push(MaterialPageRoute(
|
Navigator.of(context).push(MaterialPageRoute(
|
||||||
builder: (context) => ActiveFlowPage(x),
|
builder: (context) => ActiveFlowPage(x),
|
||||||
))))
|
))))
|
||||||
.toList());
|
.toList()),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
|
|
@ -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!),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
|
|
@ -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),
|
||||||
|
|
||||||
|
if (transaction.origin != null)
|
||||||
IconText(Icons.store, transaction.origin!, color: Colors.blue),
|
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)
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue