diff --git a/android/app/build.gradle b/android/app/build.gradle index 9c1dbee..29d8a3d 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -41,7 +41,8 @@ android { } defaultConfig { - applicationId "de.hydrar.red.cdb" + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId "com.example.cdb_ui" // You can update the following values to match your application needs. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. minSdkVersion flutter.minSdkVersion diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index b1ca99c..cf5af51 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,7 +1,6 @@ - prefetch() async { - // todo : prefetch - // fetch items - var resp = jsonDecode(await getRequest("$instance/items")); - var lst = resp["items"] as List; - items = lst.map((x) => Item(x)).toList(); - - // fetch locations - var locResp = jsonDecode(await getRequest("$instance/locations")) - as Map; - locations = locResp.map((key, value) => MapEntry(key, Location(value))); - - // fetch flowInfos - var flowResp = - jsonDecode(await getRequest("$instance/flows")) as Map; - - flowInfos = flowResp.map((key, value) => MapEntry(key, FlowInfo(value))); - } - - Future init(Function refresh) async { + Future init() async { pref = await SharedPreferences.getInstance(); - instance = pref!.getString("instance") ?? ""; - refresh(); + instance = pref.getString("instance") ?? ""; } bool isInit() { - if (pref == null) { - return false; - } - - return pref!.containsKey("token") && pref!.containsKey("instance"); - } - - bool isPrefetched() { - return items != null && locations != null && flowInfos != null; + return pref.containsKey("token") && pref.containsKey("instance"); } void save(String instance, String token) { - pref!.setString("instance", instance); - pref!.setString("token", token); + pref.setString("instance", instance); + pref.setString("token", token); this.instance = instance; } @@ -69,7 +41,7 @@ class API { var resp = await http.get(Uri.parse(url), headers: { 'Access-Control-Allow-Origin': '*', 'Content-Type': 'application/json; charset=UTF-8', - 'Token': pref!.getString("token")! + 'Token': pref.getString("token")! }); return utf8.decode(resp.bodyBytes); @@ -80,7 +52,7 @@ class API { headers: { 'Access-Control-Allow-Origin': '*', 'Content-Type': 'application/json; charset=UTF-8', - 'Token': pref!.getString("token")! + 'Token': pref.getString("token")! }, body: jsonEncode(data)); @@ -88,7 +60,14 @@ class API { } // /items - List getItems() { + Future> getItems() async { + if (items != null) { + return items!; + } + + var resp = jsonDecode(await getRequest("$instance/items")); + var lst = resp["items"] as List; + items = lst.map((x) => Item(x)).toList(); return items!; } @@ -111,12 +90,23 @@ class API { return ret; } - Map getLocations() { + Future> getLocations() async { + if (locations != null) { + return locations!; + } + + var resp = jsonDecode(await getRequest("$instance/locations")) + as Map; + locations = resp.map((key, value) => MapEntry(key, Location(value))); return locations!; } - Item getItem(String item) { - return items!.firstWhere((x) => x.id == item); + Future getItem(String item) async { + if (items != null) { + return items!.firstWhere((x) => x.id == item); + } + + return Item(jsonDecode(await getRequest("$instance/item/$item"))); } Future getTransaction(String id) async { @@ -172,7 +162,7 @@ class API { } // /supply - Future supplyItem(String item, String variant, double price, + Future supplyItem(String item, String variant, String price, String? origin, String? location, String? note) async { if (origin!.isEmpty) { origin = null; @@ -201,19 +191,13 @@ class API { // /demand Future consumeItem( - String transaction, String destination, double price) async { + String transaction, String destination, String price) async { await postRequest("$instance/demand", {"uuid": transaction, "destination": destination, "price": price}); } // /item///stat - Future getStat(String item, String variant, - {bool full = false}) async { - if (full) { - return FullItemVariantStat(jsonDecode( - await getRequest("$instance/item/$item/$variant/stat?full=true"))); - } - + Future getStat(String item, String variant) async { return ItemVariantStat( jsonDecode(await getRequest("$instance/item/$item/$variant/stat"))); } @@ -223,7 +207,7 @@ class API { } // /item///price_history? - Future> getPriceHistory(String item, String variant, + Future> getPriceHistory(String item, String variant, {String? origin}) async { var url = "$instance/item/$item/$variant/price_history"; @@ -233,10 +217,10 @@ class API { var resp = jsonDecode(await getRequest(url)) as List; - return resp.map((x) => x as double).toList(); + return resp.map((x) => Price(x)).toList(); } - Future getLatestPrice(String item, String variant, + Future getLatestPrice(String item, String variant, {String? origin}) async { var url = "$instance/item/$item/$variant/price_latest"; @@ -246,19 +230,31 @@ class API { var resp = jsonDecode(await getRequest(url)) as Map; - return resp as double; + return Price(resp); } // Flows // /flows - Map getFlows() { + Future> getFlows() async { + if (flowInfos != null) { + return flowInfos!; + } + + var resp = + jsonDecode(await getRequest("$instance/flows")) as Map; + + flowInfos = resp.map((key, value) => MapEntry(key, FlowInfo(value))); return flowInfos!; } // /flow//info - FlowInfo getFlowInfo(String id) { - return flowInfos![id]!; + Future getFlowInfo(String id) async { + if (flowInfos != null) { + return flowInfos![id]!; + } + + return FlowInfo(jsonDecode(await getRequest("$instance/flow/$id/info"))); } Future getFlow(String id) async { @@ -281,18 +277,12 @@ class API { } // /flow//end - Future>?> endFlow(String id, - {List? produced}) async { + Future?> endFlow(String id, {List? produced}) async { var resp = jsonDecode(await postRequest("$instance/flow/$id/end", {"produced": produced?.map((x) => x.json()).toList()})); if (produced != null) { - var produced = resp["produced"] as Map; - return produced.map( - (key, value) { - return MapEntry(key, (value as List).cast()); - }, - ); + return (resp["produced"] as List).cast(); } return null; @@ -324,8 +314,13 @@ class API { "$instance/transaction/$id/move", {"to": newLocation})); } - Location getLocation(String id) { - return locations![id]!; + Future getLocation(String id) async { + if (locations != null) { + return locations![id]!; + } + + var resp = jsonDecode(await getRequest("$instance/location/$id")); + return Location(resp); } Future addNoteToFlow(String flowID, String content) async { @@ -361,14 +356,12 @@ class FlowInfo { class Item { late String id; - late String? image; late String name; late String? category; late Map variants; Item(Map json) { id = json["uuid"]; - image = json["image"]; name = json["name"]; category = json["category"]; variants = {}; @@ -385,7 +378,6 @@ class ItemVariant { late String name; int? min; int? expiry; - List? barcodes; ItemVariant(Map json) { item = json["item"]; @@ -393,9 +385,26 @@ class ItemVariant { name = json["name"]; min = json["min"]; expiry = json["expiry"]; - barcodes = json["barcodes"] != null - ? (json["barcodes"] as List).cast() - : null; + } +} + +class Price { + late double value; + late String currency; + + Price(Map json) { + value = json["value"]; + currency = json["currency"]; + } + + Price.fromString(String value) { + var priceSplit = value.split(" "); + this.value = double.parse(priceSplit[0]); + currency = priceSplit[1]; + } + + String format() { + return "${value.toStringAsFixed(2)} $currency"; } } @@ -403,7 +412,7 @@ class Transaction { late String uuid; late String item; late String variant; - late double price; + late Price price; String? origin; late int timestamp; ConsumeInfo? consumed; @@ -415,7 +424,7 @@ class Transaction { uuid = json["uuid"]; item = json["item"]; variant = json["variant"]; - price = json["price"]; + price = Price(json["price"]); origin = json["origin"]; timestamp = json["timestamp"]; expired = json["expired"]; @@ -424,11 +433,12 @@ class Transaction { location = json["location"] != null ? Location(json["location"]) : null; } - Transaction.inMemory(String itemID, String variantID, this.price, + Transaction.inMemory(String itemID, String variantID, String price, String? origin, Location? location, String? note) { uuid = ""; item = itemID; variant = variantID; + this.price = Price.fromString(price); origin = origin; timestamp = 0; consumed = null; @@ -440,12 +450,12 @@ class Transaction { class ConsumeInfo { late String destination; - late double price; + late Price price; late int timestamp; ConsumeInfo(Map json) { destination = json["destination"]; - price = json["price"]; + price = Price(json["price"]); timestamp = json["timestamp"]; } } @@ -553,14 +563,14 @@ class FlowNote { } class GlobalItemStat { - late int itemCount; - late int totalTransactions; - late double totalPrice; + late int item_count; + late int total_transactions; + late double total_price; GlobalItemStat(Map json) { - itemCount = json["item_count"]; - totalTransactions = json["total_transactions"]; - totalPrice = json["total_price"]; + item_count = json["item_count"]; + total_transactions = json["total_transactions"]; + total_price = json["total_price"]; } } @@ -568,28 +578,3 @@ class GlobalItemStat { var split = iv.split("::"); return (split[0], split[1]); } - -class FullItemVariantStat { - late int amount; - late double totalPrice; - late double expiryRate; - late Map origins; - - FullItemVariantStat(Map json) { - amount = json["amount"]; - totalPrice = json["total_price"]; - expiryRate = json["expiry_rate"]; - origins = (json["origins"] as Map) - .map((key, value) => MapEntry(key, OriginStat(value))); - } -} - -class OriginStat { - late double averagePrice; - late int inventory; - - OriginStat(Map json) { - averagePrice = json["average_price"]; - inventory = json["inventory"]; - } -} diff --git a/lib/main.dart b/lib/main.dart index 815427e..6df00dd 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -7,53 +7,24 @@ import 'package:cdb_ui/pages/stats.dart'; import 'package:flutter/material.dart'; Future main() async { + await API().init(); runApp(const MyApp()); } -class MyApp extends StatefulWidget { +class MyApp extends StatelessWidget { const MyApp({super.key}); - @override - State createState() => _MyAppState(); -} - -class _MyAppState extends State { - bool init = false; - - refresh() { - setState(() {}); - } - - @override - void initState() { - super.initState(); - () async { - await API().init(refresh); - if (API().isInit()) { - await API().prefetch(); - setState(() { - init = true; - }); - } - }(); - } - @override Widget build(BuildContext context) { return MaterialApp( - title: 'CDB', - theme: ThemeData( - colorScheme: ColorScheme.fromSeed( - seedColor: Colors.deepPurple, brightness: Brightness.dark), - useMaterial3: true, - ), - home: API().isInit() - ? (API().isPrefetched() - ? const MyHomePage() - : const Scaffold( - body: Center(child: CircularProgressIndicator()), - )) - : const SetupPage()); + title: 'CDB', + theme: ThemeData( + colorScheme: ColorScheme.fromSeed( + seedColor: Colors.deepPurple, brightness: Brightness.dark), + useMaterial3: true, + ), + home: API().isInit() ? const MyHomePage() : const SetupPage(), + ); } } diff --git a/lib/pages/consume.dart b/lib/pages/consume.dart index d3f03e2..9888126 100644 --- a/lib/pages/consume.dart +++ b/lib/pages/consume.dart @@ -27,8 +27,8 @@ class _ConsumePageState extends State { _formKey.currentState!.save(); API() - .consumeItem(widget.transaction.uuid, _selectedDestination, - double.parse(_price)) + .consumeItem( + widget.transaction.uuid, _selectedDestination, "$_price €") .then((_) { ScaffoldMessenger.of(context).showSnackBar( const SnackBar(content: Text('Item consumed successfully!')), diff --git a/lib/pages/flow/active_flow_page.dart b/lib/pages/flow/active_flow_page.dart index d43b74e..d1f963e 100644 --- a/lib/pages/flow/active_flow_page.dart +++ b/lib/pages/flow/active_flow_page.dart @@ -56,7 +56,7 @@ class _ActiveFlowPageState extends State { ), ); - if (confirm ?? false) { + if (confirm) { await API .API() .endFlow(widget.flow.id) @@ -67,22 +67,23 @@ class _ActiveFlowPageState extends State { if (widget.info.next != null) IconButton( onPressed: () { - var newInfo = API.API().getFlowInfo(widget.info.next!); - Navigator.of(context).push(MaterialPageRoute( - builder: (context) { - return CreateFlowPage( - newInfo, - () {}, - previousFlow: widget.flow, - ); - }, - )); + API.API().getFlowInfo(widget.info.next!).then((newInfo) { + Navigator.of(context).push(MaterialPageRoute( + builder: (context) { + return CreateFlowPage( + newInfo, + () {}, + previousFlow: widget.flow, + ); + }, + )); + }); }, icon: const Icon(Icons.arrow_forward)), ], ), body: Padding( - padding: const EdgeInsets.symmetric(horizontal: 18.0), + padding: EdgeInsets.symmetric(horizontal: 18.0), child: Column( children: [ Row( diff --git a/lib/pages/flow/create_flow_page.dart b/lib/pages/flow/create_flow_page.dart index 35d5fb2..2d66a66 100644 --- a/lib/pages/flow/create_flow_page.dart +++ b/lib/pages/flow/create_flow_page.dart @@ -25,10 +25,11 @@ class _CreateFlowPageState extends State { input: depends.map((x) => x.uuid).toList()) .then((x) { API.API().getFlow(x).then((flow) { - var info = API.API().getFlowInfo(flow.kind); - Navigator.of(context).pushReplacement(MaterialPageRoute( - builder: (context) => ActiveFlowPage(flow, info), - )); + API.API().getFlowInfo(flow.kind).then((info) { + Navigator.of(context).pushReplacement(MaterialPageRoute( + builder: (context) => ActiveFlowPage(flow, info), + )); + }); }); }); return; @@ -64,42 +65,26 @@ class _CreateFlowPageState extends State { }); } - List buildInputSelection(BuildContext context) { - if (widget.info.depends.isEmpty) { - return []; - } - - return [ - Column( - children: widget.info.depends.map((x) { - var (item, variant) = API.itemVariant(x); - return ElevatedButton( - onPressed: () { - selectDependItems(context, x); - }, - child: - Text("Add ${API.API().getItem(item).variants[variant]!.name}")); - }).toList()), - const Divider(), - ]; + Widget buildInputSelection(BuildContext context) { + return Column( + children: widget.info.depends.map((x) { + return ElevatedButton( + onPressed: () { + selectDependItems(context, x); + }, + child: Text("Add $x")); + }).toList()); } Widget flowContinuation() { return Row( - mainAxisAlignment: MainAxisAlignment.center, children: [ Card( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Text(API.API().getFlowInfo(widget.previousFlow!.kind).name), - ), + child: Text(widget.previousFlow!.kind), ), - const Card(child: Icon(Icons.arrow_right)), + const Text(" -> "), Card( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Text(widget.info.name), - ), + child: Text(widget.info.name), ) ], ); @@ -108,17 +93,15 @@ class _CreateFlowPageState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - title: Text(widget.previousFlow != null - ? "Continue to ${widget.previousFlow!.kind}" - : "Create new ${widget.info.name} Flow")), + appBar: AppBar(title: Text("Create new ${widget.info.name} Flow")), body: Column( children: [ if (widget.previousFlow != null) ...[ flowContinuation(), const Divider() ], - ...buildInputSelection(context), + buildInputSelection(context), + const Divider(), Card( child: Column( children: depends diff --git a/lib/pages/flow/end_flow_page.dart b/lib/pages/flow/end_flow_page.dart index 32f233d..212aaef 100644 --- a/lib/pages/flow/end_flow_page.dart +++ b/lib/pages/flow/end_flow_page.dart @@ -1,3 +1,5 @@ +import 'dart:js_interop_unsafe'; + import 'package:cdb_ui/api.dart' as API; import 'package:cdb_ui/api.dart'; import 'package:cdb_ui/pages/supply.dart'; @@ -21,7 +23,13 @@ class _EndFlowWithProduceState extends State { @override void initState() { super.initState(); - locations = API.API().getLocations(); + API.API().getLocations().then( + (value) { + setState(() { + locations = value; + }); + }, + ); } refresh() { @@ -38,24 +46,25 @@ class _EndFlowWithProduceState extends State { List ret = []; for (var i in widget.info.produces!) { - var (itemID, variant) = API.itemVariant(i); - var item = API.API().getItem(itemID); ret.add(ElevatedButton( onPressed: () { - Navigator.of(context).push(MaterialPageRoute( - builder: (context) { - return SupplyPage( - item, - refresh, - onlyVariants: [variant], - forcePrice: "0.00", - forceOrigin: "flow::${widget.flow.kind}::${widget.flow.id}", - onCreate: addProduced, - ); - }, - )); + var (itemID, variant) = API.itemVariant(i); + API.API().getItem(itemID).then((item) { + Navigator.of(context).push(MaterialPageRoute( + builder: (context) { + return SupplyPage( + item, + refresh, + onlyVariants: [variant], + forcePrice: "0.00", + forceOrigin: "flow::${widget.flow.kind}::${widget.flow.id}", + onCreate: addProduced, + ); + }, + )); + }); }, - child: Text("Produced ${item.variants[variant]!.name}"))); + child: Text("Produced $i"))); } return ret; diff --git a/lib/pages/flow/flow_info_page.dart b/lib/pages/flow/flow_info_page.dart index 7ba14e7..aea4b78 100644 --- a/lib/pages/flow/flow_info_page.dart +++ b/lib/pages/flow/flow_info_page.dart @@ -24,17 +24,13 @@ class _FlowInfoPageState extends State { body: Column( children: [ // todo : ui improve - if (widget.info.next != null) - Text("Next: ${API.API().getFlowInfo(widget.info.next!).name}"), + if (widget.info.next != null) Text("Next: ${widget.info.next}"), if (widget.info.depends.isNotEmpty) Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ const Text("Flow can use: "), - ...widget.info.depends.map((x) { - var (item, variant) = API.itemVariant(x); - return Text(API.API().getItem(item).variants[variant]!.name); - }).toList(), + ...widget.info.depends.map((x) => Text(x)).toList(), ], ), if (widget.info.produces?.isNotEmpty ?? false) @@ -42,10 +38,7 @@ class _FlowInfoPageState extends State { mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ const Text("Flow can produce: "), - ...widget.info.produces!.map((x) { - var (item, variant) = API.itemVariant(x); - return Text(API.API().getItem(item).variants[variant]!.name); - }).toList(), + ...widget.info.produces!.map((x) => Text(x)).toList(), ], ), const Divider(), diff --git a/lib/pages/flow/flows_page.dart b/lib/pages/flow/flows_page.dart index f172bea..8bcac95 100644 --- a/lib/pages/flow/flows_page.dart +++ b/lib/pages/flow/flows_page.dart @@ -2,8 +2,9 @@ import 'package:cdb_ui/api.dart' as API; import 'package:cdb_ui/pages/expandable_list.dart'; import 'package:cdb_ui/pages/flow/active_flow_page.dart'; import 'package:cdb_ui/pages/flow/flow_info_page.dart'; -import 'package:cdb_ui/pages/supply.dart'; +import 'package:cdb_ui/pages/transaction.dart'; import 'package:flutter/material.dart'; +import 'package:qr_bar_code_scanner_dialog/qr_bar_code_scanner_dialog.dart'; class FlowsPage extends StatefulWidget { const FlowsPage({super.key}); @@ -19,7 +20,13 @@ class _FlowsPageState extends State { @override void initState() { super.initState(); - flowInfos = API.API().getFlows(); + API.API().getFlows().then( + (value) { + setState(() { + flowInfos = value; + }); + }, + ); } Widget flowTile(BuildContext context, API.FlowInfo x) { @@ -87,8 +94,7 @@ class _FlowsPageState extends State { children: producedMapping[key]!.map((x) { return flowTile(context, x); }).toList()); - items.add(ExpandableListItem( - body: flows, header: Text(API.API().getItem(key).name))); + items.add(ExpandableListItem(body: flows, header: Text(key))); } return ExpandableList(items); @@ -116,8 +122,7 @@ class _FlowsPageState extends State { children: dependsMapping[key]!.map((x) { return flowTile(context, x); }).toList()); - items.add(ExpandableListItem( - body: flows, header: Text(API.API().getItem(key).name))); + items.add(ExpandableListItem(body: flows, header: Text(key))); } return ExpandableList(items); @@ -155,18 +160,25 @@ class _FlowsPageState extends State { _ => const Text("..."), }, floatingActionButton: FloatingActionButton( - onPressed: () async { + onPressed: () { // scan flow code - var code = await scanQRCode(context, title: "Scan Flow Code"); + QrBarCodeScannerDialog().getScannedQrBarCode( + context: context, + onCode: (code) { + // library is retarded + code = code!.replaceFirst("Code scanned = ", ""); - API.API().getFlow(code!).then((flow) { - var info = API.API().getFlowInfo(flow.kind); - Navigator.of(context).push(MaterialPageRoute( - builder: (context) { - return ActiveFlowPage(flow, info); - }, - )); - }); + API.API().getFlow(code).then((flow) { + API.API().getFlowInfo(flow.kind).then((info) { + Navigator.of(context).push(MaterialPageRoute( + builder: (context) { + return ActiveFlowPage(flow, info); + }, + )); + }); + }); + }, + ); }, child: const Icon(Icons.qr_code), ), diff --git a/lib/pages/items.dart b/lib/pages/items.dart index b4daa87..fa5db2f 100644 --- a/lib/pages/items.dart +++ b/lib/pages/items.dart @@ -1,61 +1,48 @@ import 'package:cdb_ui/api.dart'; import 'package:cdb_ui/pages/itemview.dart'; -import 'package:cdb_ui/pages/supply.dart'; import 'package:cdb_ui/pages/transaction.dart'; import 'package:flutter/material.dart'; +import 'package:qr_bar_code_scanner_dialog/qr_bar_code_scanner_dialog.dart'; class ItemsPage extends StatelessWidget { const ItemsPage({super.key}); - _scanBarcodeSupply(BuildContext context) async { - var code = - int.parse(await scanQRCode(context, title: "Scan Barcode") ?? "0"); - - var items = API().getItems(); - for (var item in items) { - for (var variant in item.variants.keys) { - for (var barcode in item.variants[variant]!.barcodes ?? []) { - if (code == barcode) { - Navigator.of(context).push(MaterialPageRoute( - builder: (context) => SupplyPage( - item, - () {}, - onlyVariants: [variant], - ))); - } - } - } - } - } - @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text("Items"), - // todo : add barcode scan - actions: [ - ElevatedButton( - onPressed: () { - _scanBarcodeSupply(context); - }, - child: const Icon(Icons.add_box)) - ], ), - body: ListView( - children: API().getItems().map((x) { - return ItemTile(x); - }).toList()), - floatingActionButton: FloatingActionButton( - onPressed: () async { - // scan transaction code - var code = await scanQRCode(context, title: "Scan Transaction Code"); + body: FutureBuilder( + future: API().getItems(), + builder: (context, snapshot) { + if (!snapshot.hasData) { + return const CircularProgressIndicator(); + } - API().getTransaction(code!).then((t) { - Navigator.of(context).push(MaterialPageRoute( - builder: (context) => TransactionPage(t), - )); - }); + var items = snapshot.data!; + + return ListView( + children: items.map((x) { + return ItemTile(x); + }).toList()); + }), + floatingActionButton: FloatingActionButton( + onPressed: () { + // scan transaction code + QrBarCodeScannerDialog().getScannedQrBarCode( + context: context, + onCode: (code) { + // library is retarded + code = code!.replaceFirst("Code scanned = ", ""); + + API().getTransaction(code).then((t) { + Navigator.of(context).push(MaterialPageRoute( + builder: (context) => TransactionPage(t), + )); + }); + }, + ); }, child: const Icon(Icons.qr_code), ), diff --git a/lib/pages/itemview.dart b/lib/pages/itemview.dart index 8ea7415..ab9e418 100644 --- a/lib/pages/itemview.dart +++ b/lib/pages/itemview.dart @@ -2,6 +2,7 @@ import 'package:cdb_ui/api.dart'; import 'package:cdb_ui/pages/stats.dart'; import 'package:cdb_ui/pages/transaction.dart'; import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; import 'supply.dart'; // todo : show est. time remaining until inventory gets empty (based on demand) @@ -32,7 +33,7 @@ class _ItemViewState extends State { builder: (context) => ItemStatPage(widget.item), )); }, - icon: const Icon(Icons.bar_chart)) + icon: Icon(Icons.bar_chart)) ], ), body: Column(children: [ @@ -43,15 +44,12 @@ class _ItemViewState extends State { Row( mainAxisAlignment: MainAxisAlignment.start, children: [ - Align( + const Align( alignment: Alignment.centerLeft, - child: widget.item.image != null - ? Image.network( - "${API().instance}/${widget.item.image}", - height: 100, - width: 100, - ) - : null, + child: Placeholder( + fallbackWidth: 100, + fallbackHeight: 100, + ), ), const SizedBox( width: 16.0, diff --git a/lib/pages/locations.dart b/lib/pages/locations.dart index 5e62a79..7d00bd9 100644 --- a/lib/pages/locations.dart +++ b/lib/pages/locations.dart @@ -1,8 +1,8 @@ import 'package:cdb_ui/api.dart'; -import 'package:cdb_ui/pages/supply.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 { const LocationsPage({super.key}); @@ -17,7 +17,13 @@ class _LocationsPageState extends State { @override void initState() { super.initState(); - locations = API().getLocations(); + API().getLocations().then( + (value) { + setState(() { + locations = value; + }); + }, + ); } TreeNode buildTree(BuildContext context, String locID) { @@ -63,20 +69,25 @@ class _LocationsPageState extends State { return buildTree(context, key); }).toList()), floatingActionButton: FloatingActionButton( - onPressed: () async { + onPressed: () { // scan location code - var code = await scanQRCode(context, title: "Scan Location Code"); + QrBarCodeScannerDialog().getScannedQrBarCode( + context: context, + onCode: (code) { + // library is retarded + code = code!.replaceFirst("Code scanned = ", ""); + if (!locations!.containsKey(code)) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text('The location $code does not exist.')), + ); + return; + } - if (!locations!.containsKey(code)) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar(content: Text('The location $code does not exist.')), - ); - return; - } - - Navigator.of(context).push(MaterialPageRoute( - builder: (context) => LocationView(locations![code]!), - )); + Navigator.of(context).push(MaterialPageRoute( + builder: (context) => LocationView(locations![code]!), + )); + }, + ); }, child: const Icon(Icons.qr_code), ), @@ -107,7 +118,7 @@ class _LocationViewState extends State { title: Text(widget.location.name), ), body: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10.0), + padding: EdgeInsets.symmetric(horizontal: 10.0), child: Column( children: [ Card( diff --git a/lib/pages/setup.dart b/lib/pages/setup.dart index 667861d..620413d 100644 --- a/lib/pages/setup.dart +++ b/lib/pages/setup.dart @@ -31,8 +31,6 @@ class _SetupPageState extends State { const SnackBar(content: Text('Setup Complete!')), ); - await API().prefetch(); - // Navigate or close the setup screen Navigator.pushReplacement( context, diff --git a/lib/pages/stats.dart b/lib/pages/stats.dart index 80ecceb..b612280 100644 --- a/lib/pages/stats.dart +++ b/lib/pages/stats.dart @@ -1,5 +1,4 @@ import 'package:cdb_ui/api.dart'; -import 'package:cdb_ui/pages/expandable_list.dart'; import 'package:cdb_ui/pages/transaction.dart'; import 'package:flutter/material.dart'; @@ -24,9 +23,6 @@ class StatsPage extends StatelessWidget { // global origin / destinations return Scaffold( - appBar: AppBar( - title: const Text("Home"), - ), body: FutureBuilder( future: _fetchData(), builder: (context, snapshot) { @@ -49,36 +45,26 @@ class StatsPage extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ IconText(Icons.data_object, - "Items: ${globalStat.itemCount}"), + "Items: ${globalStat.item_count}"), IconText(Icons.list_alt, - "Inventory: ${globalStat.totalTransactions}"), + "Inventory: ${globalStat.total_transactions}"), IconText(Icons.money, - "Price: ${globalStat.totalPrice.toStringAsFixed(2)} €") + "Price: ${globalStat.total_price.toStringAsFixed(2)} €") ], ), )), if (min.isNotEmpty) - const ListTile( - title: Text( - "Items under Minimum", - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), - )), + const ListTile(title: Text("Items under Minimum")), ...min.map((item) { - var (itemID, variant) = itemVariant(item.itemVariant); - var name = API().getItem(itemID).variants[variant]!.name; - return ListTile( - title: Text("$name under minimum. Needs ${item.need} more."), + title: Text( + "Item ${item.itemVariant} under minimum. Needs ${item.need} more."), ); }).toList(), if (expired.isNotEmpty) - const ListTile( - title: Text( - "Expired Items", - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), - )), + const ListTile(title: Text("Expired Items")), // Mapping expired list to widgets ...expired.map((item) { @@ -99,48 +85,16 @@ class ItemStatPage extends StatelessWidget { const ItemStatPage(this.item, {super.key}); + // todo : expiry ratio // todo : avg time of transaction active - ExpandableListItem buildVariantStat(String variant) { - return ExpandableListItem( - body: FutureBuilder( - future: API().getStat(item.id, variant, full: true), - builder: (context, snapshot) { - if (!snapshot.hasData) { - return const CircularProgressIndicator(); - } - - var data = snapshot.data! as FullItemVariantStat; - - return Column( - children: [ - Text("Amount: ${data.amount}"), - Text("Total Cost: ${data.totalPrice}"), - Text("Expiry Rate: ${data.expiryRate}"), - ...data.origins.keys.map((key) { - var originStat = data.origins[key]!; - return Column(children: [ - Text("Inventory: ${originStat.inventory}"), - Text( - "Average Price: ${originStat.averagePrice.toStringAsFixed(2)} €"), - ]); - }).toList() - ], - ); - }, - ), - header: Text(item.variants[variant]!.name)); - } - @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("Statistics of ${item.name}"), ), - body: Column(children: [ - ExpandableList(item.variants.keys.map(buildVariantStat).toList()) - ]), + body: null, ); } } diff --git a/lib/pages/supply.dart b/lib/pages/supply.dart index 792b766..342a352 100644 --- a/lib/pages/supply.dart +++ b/lib/pages/supply.dart @@ -1,21 +1,6 @@ import 'package:cdb_ui/api.dart'; import 'package:flutter/material.dart'; -import 'package:simple_barcode_scanner/enum.dart'; -import 'package:simple_barcode_scanner/simple_barcode_scanner.dart'; - -Future scanQRCode(BuildContext context, - {String title = "Scan QR Code"}) async { - var res = await Navigator.push( - context, - MaterialPageRoute( - builder: (context) => SimpleBarcodeScannerPage( - scanType: ScanType.qr, - appBarTitle: title, - ), - )); - - return res; -} +import 'package:qr_bar_code_scanner_dialog/qr_bar_code_scanner_dialog.dart'; class SupplyPage extends StatefulWidget { final Item item; @@ -68,7 +53,7 @@ class _SupplyPageState extends State { var t = SupplyForm( itemID: widget.item.id, variant: variant, - price: double.parse(_priceController.text), + price: "${_priceController.text} €", origin: _selectedOrigin, location: _selectedLocation, note: _noteController.text); @@ -81,13 +66,8 @@ class _SupplyPageState extends State { } API() - .supplyItem( - widget.item.id, - variant, - double.parse(_priceController.text), - _selectedOrigin, - _selectedLocation, - _noteController.text) + .supplyItem(widget.item.id, variant, "${_priceController.text} €", + _selectedOrigin, _selectedLocation, _noteController.text) .then((_) { ScaffoldMessenger.of(context).showSnackBar( const SnackBar(content: Text('Item added successfully!')), @@ -146,7 +126,7 @@ class _SupplyPageState extends State { const SizedBox(height: 16), // Origin Field with Dropdown and Text Input - if (widget.forceOrigin == null) ...[ + if (widget.forceOrigin == null) AutocompletedTextField( options: origins, getValue: () => _selectedOrigin, @@ -158,7 +138,7 @@ class _SupplyPageState extends State { ? await API() .getLatestPrice(widget.item.id, variant, origin: selection) - .then((x) => x.toStringAsFixed(2)) + .then((x) => x.value.toStringAsFixed(2)) : _priceController.text; setState(() { _priceController.text = price; @@ -166,11 +146,11 @@ class _SupplyPageState extends State { }); }, label: "Origin"), - const SizedBox(height: 16), - ], + + const SizedBox(height: 16), // Price Field - if (widget.forcePrice == null) ...[ + if (widget.forcePrice == null) TextFormField( decoration: const InputDecoration(labelText: 'Price'), keyboardType: TextInputType.number, @@ -185,8 +165,8 @@ class _SupplyPageState extends State { return null; }, ), - const SizedBox(height: 16), - ], + + const SizedBox(height: 16), // Location Dropdown Row( @@ -217,13 +197,15 @@ class _SupplyPageState extends State { width: 12, ), IconButton( - onPressed: () async { - var code = await scanQRCode(context); - setState(() { - if (API().getLocations().keys.contains(code)) { - _selectedLocation = code!; - } - }); + onPressed: () { + QrBarCodeScannerDialog().getScannedQrBarCode( + context: context, + onCode: (code) { + setState(() { + _selectedLocation = code!; + }); + }, + ); }, icon: const Icon(Icons.qr_code), ), @@ -253,7 +235,7 @@ class _SupplyPageState extends State { } Future> _fetchData() async { - var locations = API().getLocations(); + var locations = await API().getLocations(); var origins = await API().getUniqueField(widget.item.id, variant, "origin"); origins.insert(0, ""); locations[""] = Location.zero(); @@ -311,7 +293,7 @@ class AutocompletedTextField extends StatelessWidget { class SupplyForm { final String itemID; final String variant; - final double price; + final String price; final String? origin; final String? location; final String note; diff --git a/lib/pages/transaction.dart b/lib/pages/transaction.dart index 79e674d..a7d2d62 100644 --- a/lib/pages/transaction.dart +++ b/lib/pages/transaction.dart @@ -1,9 +1,9 @@ import 'package:cdb_ui/api.dart'; import 'package:cdb_ui/pages/consume.dart'; -import 'package:cdb_ui/pages/supply.dart'; import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import 'package:qr_bar_code/qr/qr.dart'; +import 'package:qr_bar_code_scanner_dialog/qr_bar_code_scanner_dialog.dart'; class TransactionPage extends StatefulWidget { final Transaction transaction; @@ -40,73 +40,84 @@ class _TransactionPageState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text(API().getItem(transaction.item).name), + title: Text(widget.transaction.item), actions: [ IconButton( onPressed: () { - var locations = API().getLocations(); - List locationList = locations.keys.toList(); - String? selectedLocationID; - - showDialog( - context: context, - builder: (BuildContext context) { - return AlertDialog( - title: const Text('Move Transaction'), - content: Row( - mainAxisSize: MainAxisSize.min, - children: [ - DropdownButton( - value: selectedLocationID, - onChanged: (value) { - selectedLocationID = value!; - API() - .moveTransaction(widget.transaction.uuid, - selectedLocationID!) - .then((x) { - Navigator.of(context).pop(); - }); - - setState(() {}); - }, - items: locationList - .map>((locationID) { - return DropdownMenuItem( - value: locationID, - child: Text(locations[locationID]!.name), - ); - }).toList(), - ), - IconButton( - onPressed: () async { - var locations = API().getLocations(); - var code = await scanQRCode(context, - title: "Scan Location Code"); - if (!locations.containsKey(code)) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - 'The location $code does not exist.')), - ); - return; - } + API().getLocations().then((locations) { + List locationList = locations.keys.toList(); + String? selectedLocationID; + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Move Transaction'), + content: Row( + mainAxisSize: MainAxisSize.min, + children: [ + DropdownButton( + value: selectedLocationID, + onChanged: (value) { + selectedLocationID = value!; API() .moveTransaction(widget.transaction.uuid, selectedLocationID!) - .then( - (x) { - Navigator.of(context).pop(); - }, - ); + .then((x) { + Navigator.of(context).pop(); + }); + setState(() {}); }, - icon: const Icon(Icons.qr_code)) - ], - ), - ); - }, - ); + items: locationList + .map>((locationID) { + return DropdownMenuItem( + value: locationID, + child: Text(locations[locationID]!.name), + ); + }).toList(), + ), + IconButton( + onPressed: () { + API().getLocations().then((locations) { + QrBarCodeScannerDialog() + .getScannedQrBarCode( + context: context, + onCode: (code) { + // library is retarded + code = code!.replaceFirst( + "Code scanned = ", ""); + if (!locations + .containsKey(code)) { + ScaffoldMessenger.of(context) + .showSnackBar( + SnackBar( + content: Text( + 'The location $code does not exist.')), + ); + return; + } + + API() + .moveTransaction( + widget.transaction.uuid, + selectedLocationID!) + .then( + (x) { + Navigator.of(context).pop(); + }, + ); + }); + }); + setState(() {}); + }, + icon: const Icon(Icons.qr_code)) + ], + ), + ); + }, + ); + }); }, icon: const Icon(Icons.move_up)) ], @@ -132,15 +143,12 @@ class _TransactionPageState extends State { children: [ // todo : human names Text( - API().getItem(transaction.item).name, + "${transaction.item}", style: const TextStyle( fontWeight: FontWeight.bold, fontSize: 28), ), Text( - API() - .getItem(transaction.item) - .variants[transaction.variant]! - .name, + "${transaction.variant}", style: const TextStyle( fontWeight: FontWeight.bold, fontSize: 20, @@ -161,7 +169,7 @@ class _TransactionPageState extends State { if (transaction.expired) const Text("Transaction is Expired!"), - IconText(Icons.money, transaction.price.toStringAsFixed(2), + IconText(Icons.money, transaction.price.format(), color: Colors.green), if (transaction.origin != null) @@ -177,8 +185,7 @@ class _TransactionPageState extends State { Text("Consumed on: ${tsFormat(transaction.consumed!.timestamp)}"), IconText(Icons.store, transaction.consumed!.destination, color: Colors.blue), - IconText( - Icons.money, transaction.consumed!.price.toStringAsFixed(2), + IconText(Icons.money, transaction.consumed!.price.format(), color: Colors.green), ] @@ -255,14 +262,14 @@ class TransactionCard extends StatelessWidget { Row( children: [ Text( - API().getItem(t.item).name, + t.item, style: const TextStyle(fontSize: 16), ), const SizedBox( - width: 8, + width: 4, ), Text( - API().getItem(t.item).variants[t.variant]!.name, + t.variant, style: TextStyle(fontSize: 14, color: Colors.grey[400]), ), ], @@ -283,7 +290,8 @@ class TransactionCard extends StatelessWidget { const SizedBox( height: 10, ), - IconText(Icons.money, "${t.price.toStringAsFixed(2)} €", + IconText(Icons.money, + "${t.price.value.toStringAsFixed(2)} ${t.price.currency}", color: Colors.green), if (t.origin != null) ...[ const SizedBox(height: 8), @@ -324,7 +332,6 @@ class IconText extends StatelessWidget { Text( text, style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold), - overflow: TextOverflow.fade, ), ], ); @@ -351,28 +358,29 @@ class TransactionSelectPage extends StatelessWidget { selectionList.add(s); } + if (selectionList.isEmpty) { + Navigator.of(context).pop(); + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('No Transactions to select')), + ); + } + return Scaffold( appBar: AppBar( title: const Text("Select a Transaction"), ), body: ListView( - children: selectionList.isEmpty - ? [ - const ListTile( - title: Center(child: Text("No Transactions available")), - ) - ] - : selectionList - .map((x) => TransactionCard( - x, - () {}, - onLongPress: (x) {}, - onTap: (t) { - onSelect(t); - Navigator.of(context).pop(); - }, - )) - .toList()), + children: selectionList + .map((x) => TransactionCard( + x, + () {}, + onLongPress: (x) {}, + onTap: (t) { + onSelect(t); + Navigator.of(context).pop(); + }, + )) + .toList()), ); } } diff --git a/pubspec.lock b/pubspec.lock index 92bae6e..8ec77fd 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -94,14 +94,6 @@ packages: description: flutter source: sdk version: "0.0.0" - flutter_barcode_scanner: - dependency: transitive - description: - name: flutter_barcode_scanner - sha256: a4ba37daf9933f451a5e812c753ddd045d6354e4a3280342d895b07fecaab3fa - url: "https://pub.dev" - source: hosted - version: "2.0.0" flutter_lints: dependency: "direct dev" description: @@ -110,14 +102,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.3" - flutter_plugin_android_lifecycle: - dependency: transitive - description: - name: flutter_plugin_android_lifecycle - sha256: "9ee02950848f61c4129af3d6ec84a1cfc0e47931abc746b03e7a3bc3e8ff6eda" - url: "https://pub.dev" - source: hosted - version: "2.0.22" flutter_simple_treeview: dependency: "direct main" description: @@ -140,10 +124,10 @@ packages: dependency: "direct main" description: name: http - sha256: b9c29a161230ee03d3ccf545097fccd9b87a5264228c5d348202e0f0c28f9010 + sha256: "761a297c042deedc1ffbb156d6e2af13886bb305c2a343a4d972504cd67dd938" url: "https://pub.dev" source: hosted - version: "1.2.2" + version: "1.2.1" http_parser: dependency: transitive description: @@ -160,22 +144,30 @@ packages: url: "https://pub.dev" source: hosted version: "0.18.1" + js: + dependency: transitive + description: + name: js + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + url: "https://pub.dev" + source: hosted + version: "0.6.7" leak_tracker: dependency: transitive description: name: leak_tracker - sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" + sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" url: "https://pub.dev" source: hosted - version: "10.0.5" + version: "10.0.4" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" + sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" url: "https://pub.dev" source: hosted - version: "3.0.5" + version: "3.0.3" leak_tracker_testing: dependency: transitive description: @@ -204,18 +196,18 @@ packages: dependency: transitive description: name: material_color_utilities - sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" url: "https://pub.dev" source: hosted - version: "0.11.1" + version: "0.8.0" meta: dependency: transitive description: name: meta - sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "1.12.0" path: dependency: transitive description: @@ -248,54 +240,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.3.0" - permission_handler: - dependency: transitive - description: - name: permission_handler - sha256: "18bf33f7fefbd812f37e72091a15575e72d5318854877e0e4035a24ac1113ecb" - url: "https://pub.dev" - source: hosted - version: "11.3.1" - permission_handler_android: - dependency: transitive - description: - name: permission_handler_android - sha256: "76e4ab092c1b240d31177bb64d2b0bea43f43d0e23541ec866151b9f7b2490fa" - url: "https://pub.dev" - source: hosted - version: "12.0.12" - permission_handler_apple: - dependency: transitive - description: - name: permission_handler_apple - sha256: e6f6d73b12438ef13e648c4ae56bd106ec60d17e90a59c4545db6781229082a0 - url: "https://pub.dev" - source: hosted - version: "9.4.5" - permission_handler_html: - dependency: transitive - description: - name: permission_handler_html - sha256: af26edbbb1f2674af65a8f4b56e1a6f526156bc273d0e65dd8075fab51c78851 - url: "https://pub.dev" - source: hosted - version: "0.1.3+2" - permission_handler_platform_interface: - dependency: transitive - description: - name: permission_handler_platform_interface - sha256: e9c8eadee926c4532d0305dff94b85bf961f16759c3af791486613152af4b4f9 - url: "https://pub.dev" - source: hosted - version: "4.2.3" - permission_handler_windows: - dependency: transitive - description: - name: permission_handler_windows - sha256: "1a790728016f79a41216d88672dbc5df30e686e811ad4e698bfc51f76ad91f1e" - url: "https://pub.dev" - source: hosted - version: "0.2.1" platform: dependency: transitive description: @@ -320,6 +264,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.0" + qr_bar_code_scanner_dialog: + dependency: "direct main" + description: + name: qr_bar_code_scanner_dialog + sha256: dcb937816d4e562141530265bd1ca39fe00f57000fd79e26c163c957d443e9e4 + url: "https://pub.dev" + source: hosted + version: "0.0.5" + qr_code_scanner: + dependency: transitive + description: + name: qr_code_scanner + sha256: f23b68d893505a424f0bd2e324ebea71ed88465d572d26bb8d2e78a4749591fd + url: "https://pub.dev" + source: hosted + version: "1.0.1" shared_preferences: dependency: "direct main" description: @@ -376,14 +336,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.4.1" - simple_barcode_scanner: - dependency: "direct main" - description: - name: simple_barcode_scanner - sha256: "52b30082ebd6fab1e6314cb9bfc1aca5372890616dcb89d0e254edf7b7ef4951" - url: "https://pub.dev" - source: hosted - version: "0.1.2" sky_engine: dependency: transitive description: flutter @@ -433,10 +385,10 @@ packages: dependency: transitive description: name: test_api - sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" + sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" url: "https://pub.dev" source: hosted - version: "0.7.2" + version: "0.7.0" typed_data: dependency: transitive description: @@ -457,26 +409,18 @@ packages: dependency: transitive description: name: vm_service - sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" + sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" url: "https://pub.dev" source: hosted - version: "14.2.5" + version: "14.2.1" web: dependency: transitive description: name: web - sha256: cd3543bd5798f6ad290ea73d210f423502e71900302dde696f8bff84bf89a1cb + sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27" url: "https://pub.dev" source: hosted - version: "1.1.0" - webview_windows: - dependency: transitive - description: - name: webview_windows - sha256: "47fcad5875a45db29dbb5c9e6709bf5c88dcc429049872701343f91ed7255730" - url: "https://pub.dev" - source: hosted - version: "0.4.0" + version: "0.5.1" xdg_directories: dependency: transitive description: @@ -486,5 +430,5 @@ packages: source: hosted version: "1.0.4" sdks: - dart: ">=3.5.3 <4.0.0" + dart: ">=3.4.0 <4.0.0" flutter: ">=3.22.0" diff --git a/pubspec.yaml b/pubspec.yaml index 461ce7e..c19fe54 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: cdb_ui -description: Economic Database. +description: A new Flutter project. # The following line prevents the package from being accidentally published to # pub.dev using `flutter pub publish`. This is preferred for private packages. publish_to: 'none' # Remove this line if you wish to publish to pub.dev @@ -32,7 +32,7 @@ dependencies: sdk: flutter flutter_simple_treeview: ^3.0.2 qr_bar_code: ^1.3.0 - simple_barcode_scanner: ^0.1.2 + qr_bar_code_scanner_dialog: ^0.0.5 intl: ^0.18.0 shared_preferences: ^2.1.0 fl_chart: ^0.69.0 diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 966ec1a..e8bdf58 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -6,15 +6,9 @@ #include "generated_plugin_registrant.h" -#include #include -#include void RegisterPlugins(flutter::PluginRegistry* registry) { - PermissionHandlerWindowsPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin")); QrBarCodePluginCApiRegisterWithRegistrar( registry->GetRegistrarForPlugin("QrBarCodePluginCApi")); - WebviewWindowsPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("WebviewWindowsPlugin")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 038df8f..6108823 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -3,9 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST - permission_handler_windows qr_bar_code - webview_windows ) list(APPEND FLUTTER_FFI_PLUGIN_LIST