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/api.dart';
|
||||||
import 'package:cdb_ui/pages/transaction.dart';
|
import 'package:cdb_ui/pages/transaction.dart';
|
||||||
import 'package:flutter/material.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';
|
import 'package:qr_bar_code_scanner_dialog/qr_bar_code_scanner_dialog.dart';
|
||||||
|
|
||||||
class LocationsPage extends StatefulWidget {
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// todo : add locations tree view
|
|
||||||
|
|
||||||
if (locations == null) {
|
if (locations == null) {
|
||||||
return const Scaffold(
|
return const Scaffold(
|
||||||
body: CircularProgressIndicator(),
|
body: CircularProgressIndicator(),
|
||||||
|
@ -39,7 +59,12 @@ class _LocationsPageState extends State<LocationsPage> {
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: const Text("Locations"),
|
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(
|
floatingActionButton: FloatingActionButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
// scan location code
|
// scan location code
|
||||||
|
|
64
pubspec.lock
64
pubspec.lock
|
@ -1,14 +1,6 @@
|
||||||
# Generated by pub
|
# Generated by pub
|
||||||
# See https://dart.dev/tools/pub/glossary#lockfile
|
# See https://dart.dev/tools/pub/glossary#lockfile
|
||||||
packages:
|
packages:
|
||||||
animated_tree_view:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: animated_tree_view
|
|
||||||
sha256: ed982be7fa2cf51b62bb76e95b6a0f423cde12f1da8745a1da938e82a7baacf2
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.3.0"
|
|
||||||
async:
|
async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -49,14 +41,6 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.18.0"
|
version: "1.18.0"
|
||||||
crypto:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: crypto
|
|
||||||
sha256: ec30d999af904f33454ba22ed9a86162b35e52b44ac4807d1d93c288041d7d27
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "3.0.5"
|
|
||||||
cupertino_icons:
|
cupertino_icons:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -65,14 +49,6 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.8"
|
version: "1.0.8"
|
||||||
diffutil_dart:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: diffutil_dart
|
|
||||||
sha256: "5e74883aedf87f3b703cb85e815bdc1ed9208b33501556e4a8a5572af9845c81"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "4.0.1"
|
|
||||||
equatable:
|
equatable:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -105,14 +81,6 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "7.0.0"
|
version: "7.0.0"
|
||||||
fixnum:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: fixnum
|
|
||||||
sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.1.0"
|
|
||||||
fl_chart:
|
fl_chart:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -134,6 +102,14 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.3"
|
version: "2.0.3"
|
||||||
|
flutter_simple_treeview:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: flutter_simple_treeview
|
||||||
|
sha256: ad4978d2668dd078d3a09966832da111bef9102dd636e572c50c80133b7ff4d9
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.0.2"
|
||||||
flutter_test:
|
flutter_test:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description: flutter
|
description: flutter
|
||||||
|
@ -304,14 +280,6 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.1"
|
version: "1.0.1"
|
||||||
scroll_to_index:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: scroll_to_index
|
|
||||||
sha256: b707546e7500d9f070d63e5acf74fd437ec7eeeb68d3412ef7b0afada0b4f176
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "3.0.1"
|
|
||||||
shared_preferences:
|
shared_preferences:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -381,14 +349,6 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.10.0"
|
version: "1.10.0"
|
||||||
sprintf:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: sprintf
|
|
||||||
sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "7.0.0"
|
|
||||||
stack_trace:
|
stack_trace:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -437,14 +397,6 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.2"
|
version: "1.3.2"
|
||||||
uuid:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: uuid
|
|
||||||
sha256: f33d6bb662f0e4f79dcd7ada2e6170f3b3a2530c28fc41f49a411ddedd576a77
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "4.5.0"
|
|
||||||
vector_math:
|
vector_math:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -30,7 +30,7 @@ environment:
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
animated_tree_view: ^2.3.0
|
flutter_simple_treeview: ^3.0.2
|
||||||
qr_bar_code: ^1.3.0
|
qr_bar_code: ^1.3.0
|
||||||
qr_bar_code_scanner_dialog: ^0.0.5
|
qr_bar_code_scanner_dialog: ^0.0.5
|
||||||
intl: ^0.18.0
|
intl: ^0.18.0
|
||||||
|
|
Loading…
Reference in a new issue