This commit is contained in:
JMARyA 2024-09-23 10:31:40 +02:00
parent aa816f8893
commit df69e56d95
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
3 changed files with 40 additions and 13 deletions

View file

@ -2,6 +2,8 @@ import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:shared_preferences/shared_preferences.dart';
// todo : api errors
class API {
late SharedPreferences pref;
static final API _instance = API._internal();

View file

@ -4,10 +4,24 @@ import 'package:flutter/material.dart';
class FlowsPage extends StatelessWidget {
const FlowsPage({super.key});
Widget listAllFlowInfos(
BuildContext context, Map<String, API.FlowInfo> infos) {
return ListView(
children: infos.values.map((x) {
return ListTile(
title: Text(x.name),
onTap: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => FlowPage(x),
));
},
);
}).toList());
}
@override
Widget build(BuildContext context) {
// todo : flows by item produced
// todo : list all flow kinds
// todo : flows (info) by item produced
// todo : list currently active
// todo : flows by item needed (show only avail)
return Scaffold(
@ -21,17 +35,7 @@ class FlowsPage extends StatelessWidget {
var data = snap.data!;
return ListView(
children: data.values.map((x) {
return ListTile(
title: Text(x.name),
onTap: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => FlowPage(x),
));
},
);
}).toList());
return listAllFlowInfos(context, data);
}));
}
}

View file

@ -1,6 +1,8 @@
import 'package:cdb_ui/api.dart';
import 'package:cdb_ui/pages/itemview.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});
@ -25,6 +27,25 @@ class ItemsPage extends StatelessWidget {
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),
),
);
}
}