location tree view
This commit is contained in:
parent
5687efae4f
commit
1131e74691
3 changed files with 37 additions and 60 deletions
|
@ -1,6 +1,7 @@
|
|||
import 'package:cdb_ui/api.dart';
|
||||
import 'package:cdb_ui/pages/transaction.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_simple_treeview/flutter_simple_treeview.dart';
|
||||
import 'package:qr_bar_code_scanner_dialog/qr_bar_code_scanner_dialog.dart';
|
||||
|
||||
class LocationsPage extends StatefulWidget {
|
||||
|
@ -25,10 +26,29 @@ class _LocationsPageState extends State<LocationsPage> {
|
|||
);
|
||||
}
|
||||
|
||||
TreeNode buildTree(BuildContext context, String locID) {
|
||||
return TreeNode(
|
||||
key: ValueKey(locID),
|
||||
content: ListTile(
|
||||
title: Text(locations![locID]!.name),
|
||||
onTap: () {
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (context) => LocationView(locations![locID]!),
|
||||
));
|
||||
},
|
||||
),
|
||||
children: locations!.keys.where((key2) {
|
||||
if (locations![key2]!.parent != null) {
|
||||
return locations![key2]!.parent! == locations![locID]!.id;
|
||||
}
|
||||
return false;
|
||||
}).map((key2) {
|
||||
return buildTree(context, key2);
|
||||
}).toList());
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// todo : add locations tree view
|
||||
|
||||
if (locations == null) {
|
||||
return const Scaffold(
|
||||
body: CircularProgressIndicator(),
|
||||
|
@ -39,7 +59,12 @@ class _LocationsPageState extends State<LocationsPage> {
|
|||
appBar: AppBar(
|
||||
title: const Text("Locations"),
|
||||
),
|
||||
body: null,
|
||||
body: TreeView(
|
||||
nodes: locations!.keys
|
||||
.where((key) => locations![key]!.parent == null)
|
||||
.map((key) {
|
||||
return buildTree(context, key);
|
||||
}).toList()),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () {
|
||||
// scan location code
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue