mirror of
https://github.com/inventree/inventree-app.git
synced 2025-05-02 23:38:54 +00:00
Merge branch 'barcode-fixes'
This commit is contained in:
commit
aca7b79a96
123
lib/barcode.dart
123
lib/barcode.dart
@ -23,7 +23,7 @@ import 'dart:io';
|
|||||||
|
|
||||||
|
|
||||||
class BarcodeHandler {
|
class BarcodeHandler {
|
||||||
/**
|
/*
|
||||||
* Class which "handles" a barcode, by communicating with the InvenTree server,
|
* Class which "handles" a barcode, by communicating with the InvenTree server,
|
||||||
* and handling match / unknown / error cases.
|
* and handling match / unknown / error cases.
|
||||||
*
|
*
|
||||||
@ -36,7 +36,6 @@ class BarcodeHandler {
|
|||||||
BarcodeHandler();
|
BarcodeHandler();
|
||||||
|
|
||||||
QRViewController? _controller;
|
QRViewController? _controller;
|
||||||
BuildContext? _context;
|
|
||||||
|
|
||||||
void successTone() async {
|
void successTone() async {
|
||||||
|
|
||||||
@ -58,12 +57,12 @@ class BarcodeHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> onBarcodeMatched(Map<String, dynamic> data) async {
|
Future<void> onBarcodeMatched(BuildContext context, Map<String, dynamic> data) async {
|
||||||
// Called when the server "matches" a barcode
|
// Called when the server "matches" a barcode
|
||||||
// Override this function
|
// Override this function
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> onBarcodeUnknown(Map<String, dynamic> data) async {
|
Future<void> onBarcodeUnknown(BuildContext context, Map<String, dynamic> data) async {
|
||||||
// Called when the server does not know about a barcode
|
// Called when the server does not know about a barcode
|
||||||
// Override this function
|
// Override this function
|
||||||
|
|
||||||
@ -76,7 +75,7 @@ class BarcodeHandler {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> onBarcodeUnhandled(Map<String, dynamic> data) async {
|
Future<void> onBarcodeUnhandled(BuildContext context, Map<String, dynamic> data) async {
|
||||||
|
|
||||||
failureTone();
|
failureTone();
|
||||||
|
|
||||||
@ -86,8 +85,7 @@ class BarcodeHandler {
|
|||||||
_controller?.resumeCamera();
|
_controller?.resumeCamera();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> processBarcode(BuildContext? context, QRViewController? _controller, String barcode, {String url = "barcode/"}) async {
|
Future<void> processBarcode(BuildContext context, QRViewController? _controller, String barcode, {String url = "barcode/"}) async {
|
||||||
this._context = context;
|
|
||||||
this._controller = _controller;
|
this._controller = _controller;
|
||||||
|
|
||||||
print("Scanned barcode data: ${barcode}");
|
print("Scanned barcode data: ${barcode}");
|
||||||
@ -106,20 +104,20 @@ class BarcodeHandler {
|
|||||||
|
|
||||||
if (response.data.containsKey('error')) {
|
if (response.data.containsKey('error')) {
|
||||||
_controller?.resumeCamera();
|
_controller?.resumeCamera();
|
||||||
onBarcodeUnknown(response.data);
|
onBarcodeUnknown(context, response.data);
|
||||||
} else if (response.data.containsKey('success')) {
|
} else if (response.data.containsKey('success')) {
|
||||||
_controller?.resumeCamera();
|
_controller?.resumeCamera();
|
||||||
onBarcodeMatched(response.data);
|
onBarcodeMatched(context, response.data);
|
||||||
} else {
|
} else {
|
||||||
_controller?.resumeCamera();
|
_controller?.resumeCamera();
|
||||||
onBarcodeUnhandled(response.data);
|
onBarcodeUnhandled(context, response.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class BarcodeScanHandler extends BarcodeHandler {
|
class BarcodeScanHandler extends BarcodeHandler {
|
||||||
/**
|
/*
|
||||||
* Class for general barcode scanning.
|
* Class for general barcode scanning.
|
||||||
* Scan *any* barcode without context, and then redirect app to correct view
|
* Scan *any* barcode without context, and then redirect app to correct view
|
||||||
*/
|
*/
|
||||||
@ -128,7 +126,7 @@ class BarcodeScanHandler extends BarcodeHandler {
|
|||||||
String getOverlayText(BuildContext context) => L10().barcodeScanGeneral;
|
String getOverlayText(BuildContext context) => L10().barcodeScanGeneral;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> onBarcodeUnknown(Map<String, dynamic> data) async {
|
Future<void> onBarcodeUnknown(BuildContext context, Map<String, dynamic> data) async {
|
||||||
|
|
||||||
failureTone();
|
failureTone();
|
||||||
|
|
||||||
@ -140,13 +138,10 @@ class BarcodeScanHandler extends BarcodeHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> onBarcodeMatched(Map<String, dynamic> data) async {
|
Future<void> onBarcodeMatched(BuildContext context, Map<String, dynamic> data) async {
|
||||||
|
|
||||||
int pk = -1;
|
int pk = -1;
|
||||||
|
|
||||||
print("Handle barcode:");
|
|
||||||
print(data);
|
|
||||||
|
|
||||||
// A stocklocation has been passed?
|
// A stocklocation has been passed?
|
||||||
if (data.containsKey('stocklocation')) {
|
if (data.containsKey('stocklocation')) {
|
||||||
|
|
||||||
@ -158,13 +153,8 @@ class BarcodeScanHandler extends BarcodeHandler {
|
|||||||
|
|
||||||
InvenTreeStockLocation().get(pk).then((var loc) {
|
InvenTreeStockLocation().get(pk).then((var loc) {
|
||||||
if (loc is InvenTreeStockLocation) {
|
if (loc is InvenTreeStockLocation) {
|
||||||
|
Navigator.of(context).pop();
|
||||||
var _ctx = _context;
|
Navigator.push(context, MaterialPageRoute(builder: (context) => LocationDisplayWidget(loc)));
|
||||||
|
|
||||||
if (_ctx != null) {
|
|
||||||
Navigator.of(_ctx).pop();
|
|
||||||
Navigator.push(_ctx, MaterialPageRoute(builder: (context) => LocationDisplayWidget(loc)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -187,16 +177,12 @@ class BarcodeScanHandler extends BarcodeHandler {
|
|||||||
|
|
||||||
InvenTreeStockItem().get(pk).then((var item) {
|
InvenTreeStockItem().get(pk).then((var item) {
|
||||||
|
|
||||||
var _ctx = _context;
|
|
||||||
|
|
||||||
if (_ctx != null) {
|
|
||||||
// Dispose of the barcode scanner
|
// Dispose of the barcode scanner
|
||||||
Navigator.of(_ctx).pop();
|
Navigator.of(context).pop();
|
||||||
|
|
||||||
if (item is InvenTreeStockItem) {
|
if (item is InvenTreeStockItem) {
|
||||||
Navigator.push(_ctx, MaterialPageRoute(builder: (context) => StockDetailWidget(item)));
|
Navigator.push(context, MaterialPageRoute(builder: (context) => StockDetailWidget(item)));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@ -217,16 +203,12 @@ class BarcodeScanHandler extends BarcodeHandler {
|
|||||||
|
|
||||||
InvenTreePart().get(pk).then((var part) {
|
InvenTreePart().get(pk).then((var part) {
|
||||||
|
|
||||||
var _ctx = _context;
|
|
||||||
|
|
||||||
if (_ctx != null) {
|
|
||||||
// Dismiss the barcode scanner
|
// Dismiss the barcode scanner
|
||||||
Navigator.of(_ctx).pop();
|
Navigator.of(context).pop();
|
||||||
|
|
||||||
if (part is InvenTreePart) {
|
if (part is InvenTreePart) {
|
||||||
Navigator.push(_ctx, MaterialPageRoute(builder: (context) => PartDetailWidget(part)));
|
Navigator.push(context, MaterialPageRoute(builder: (context) => PartDetailWidget(part)));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@ -265,7 +247,7 @@ class BarcodeScanHandler extends BarcodeHandler {
|
|||||||
|
|
||||||
|
|
||||||
class StockItemBarcodeAssignmentHandler extends BarcodeHandler {
|
class StockItemBarcodeAssignmentHandler extends BarcodeHandler {
|
||||||
/**
|
/*
|
||||||
* Barcode handler for assigning a new barcode to a stock item
|
* Barcode handler for assigning a new barcode to a stock item
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -277,7 +259,7 @@ class StockItemBarcodeAssignmentHandler extends BarcodeHandler {
|
|||||||
String getOverlayText(BuildContext context) => L10().barcodeScanAssign;
|
String getOverlayText(BuildContext context) => L10().barcodeScanAssign;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> onBarcodeMatched(Map<String, dynamic> data) async {
|
Future<void> onBarcodeMatched(BuildContext context, Map<String, dynamic> data) async {
|
||||||
|
|
||||||
failureTone();
|
failureTone();
|
||||||
|
|
||||||
@ -290,7 +272,7 @@ class StockItemBarcodeAssignmentHandler extends BarcodeHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> onBarcodeUnknown(Map<String, dynamic> data) async {
|
Future<void> onBarcodeUnknown(BuildContext context, Map<String, dynamic> data) async {
|
||||||
// If the barcode is unknown, we *can* assign it to the stock item!
|
// If the barcode is unknown, we *can* assign it to the stock item!
|
||||||
|
|
||||||
if (!data.containsKey("hash")) {
|
if (!data.containsKey("hash")) {
|
||||||
@ -310,14 +292,7 @@ class StockItemBarcodeAssignmentHandler extends BarcodeHandler {
|
|||||||
|
|
||||||
failureTone();
|
failureTone();
|
||||||
|
|
||||||
// Close the barcode scanner
|
Navigator.of(context).pop();
|
||||||
_controller?.dispose();
|
|
||||||
|
|
||||||
var _ctx = (_context);
|
|
||||||
|
|
||||||
if (_ctx != null) {
|
|
||||||
Navigator.of(_ctx).pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
showSnackIcon(
|
showSnackIcon(
|
||||||
L10().barcodeAssigned,
|
L10().barcodeAssigned,
|
||||||
@ -339,12 +314,8 @@ class StockItemBarcodeAssignmentHandler extends BarcodeHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class StockItemScanIntoLocationHandler extends BarcodeHandler {
|
class StockItemScanIntoLocationHandler extends BarcodeHandler {
|
||||||
/**
|
/*
|
||||||
* Barcode handler for scanning a provided StockItem into a scanned StockLocation
|
* Barcode handler for scanning a provided StockItem into a scanned StockLocation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -356,11 +327,20 @@ class StockItemScanIntoLocationHandler extends BarcodeHandler {
|
|||||||
String getOverlayText(BuildContext context) => L10().barcodeScanLocation;
|
String getOverlayText(BuildContext context) => L10().barcodeScanLocation;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> onBarcodeMatched(Map<String, dynamic> data) async {
|
Future<void> onBarcodeMatched(BuildContext context, Map<String, dynamic> data) async {
|
||||||
// If the barcode points to a 'stocklocation', great!
|
// If the barcode points to a 'stocklocation', great!
|
||||||
if (data.containsKey('stocklocation')) {
|
if (data.containsKey('stocklocation')) {
|
||||||
// Extract location information
|
// Extract location information
|
||||||
int location = data['stocklocation']['pk'] as int;
|
int location = (data['stocklocation']['pk'] ?? -1) as int;
|
||||||
|
|
||||||
|
if (location == -1) {
|
||||||
|
showSnackIcon(
|
||||||
|
L10().invalidStockLocation,
|
||||||
|
success: false,
|
||||||
|
);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Transfer stock to specified location
|
// Transfer stock to specified location
|
||||||
final result = await item.transferStock(location);
|
final result = await item.transferStock(location);
|
||||||
@ -369,14 +349,7 @@ class StockItemScanIntoLocationHandler extends BarcodeHandler {
|
|||||||
|
|
||||||
successTone();
|
successTone();
|
||||||
|
|
||||||
// Close the scanner
|
Navigator.of(context).pop();
|
||||||
_controller?.dispose();
|
|
||||||
|
|
||||||
var _ctx = _context;
|
|
||||||
|
|
||||||
if (_ctx != null) {
|
|
||||||
Navigator.of(_ctx).pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
showSnackIcon(
|
showSnackIcon(
|
||||||
L10().barcodeScanIntoLocationSuccess,
|
L10().barcodeScanIntoLocationSuccess,
|
||||||
@ -405,7 +378,7 @@ class StockItemScanIntoLocationHandler extends BarcodeHandler {
|
|||||||
|
|
||||||
|
|
||||||
class StockLocationScanInItemsHandler extends BarcodeHandler {
|
class StockLocationScanInItemsHandler extends BarcodeHandler {
|
||||||
/**
|
/*
|
||||||
* Barcode handler for scanning stock item(s) into the specified StockLocation
|
* Barcode handler for scanning stock item(s) into the specified StockLocation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -417,7 +390,7 @@ class StockLocationScanInItemsHandler extends BarcodeHandler {
|
|||||||
String getOverlayText(BuildContext context) => L10().barcodeScanItem;
|
String getOverlayText(BuildContext context) => L10().barcodeScanItem;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> onBarcodeMatched(Map<String, dynamic> data) async {
|
Future<void> onBarcodeMatched(BuildContext context, Map<String, dynamic> data) async {
|
||||||
|
|
||||||
// Returned barcode must match a stock item
|
// Returned barcode must match a stock item
|
||||||
if (data.containsKey('stockitem')) {
|
if (data.containsKey('stockitem')) {
|
||||||
@ -489,33 +462,32 @@ class InvenTreeQRView extends StatefulWidget {
|
|||||||
|
|
||||||
class _QRViewState extends State<InvenTreeQRView> {
|
class _QRViewState extends State<InvenTreeQRView> {
|
||||||
|
|
||||||
|
final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
|
||||||
|
|
||||||
QRViewController? _controller;
|
QRViewController? _controller;
|
||||||
|
|
||||||
final BarcodeHandler _handler;
|
final BarcodeHandler _handler;
|
||||||
|
|
||||||
BuildContext? _context;
|
|
||||||
|
|
||||||
// In order to get hot reload to work we need to pause the camera if the platform
|
// In order to get hot reload to work we need to pause the camera if the platform
|
||||||
// is android, or resume the camera if the platform is iOS.
|
// is android, or resume the camera if the platform is iOS.
|
||||||
@override
|
@override
|
||||||
void reassemble() {
|
void reassemble() {
|
||||||
super.reassemble();
|
super.reassemble();
|
||||||
|
|
||||||
if (Platform.isAndroid) {
|
if (Platform.isAndroid) {
|
||||||
_controller?.pauseCamera();
|
_controller!.pauseCamera();
|
||||||
} else if (Platform.isIOS) {
|
|
||||||
_controller?.resumeCamera();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_controller!.resumeCamera();
|
||||||
}
|
}
|
||||||
|
|
||||||
_QRViewState(this._handler) : super();
|
_QRViewState(this._handler) : super();
|
||||||
|
|
||||||
final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
|
void _onViewCreated(BuildContext context, QRViewController controller) {
|
||||||
|
|
||||||
void _onViewCreated(QRViewController controller) {
|
|
||||||
_controller = controller;
|
_controller = controller;
|
||||||
controller.scannedDataStream.listen((barcode) {
|
controller.scannedDataStream.listen((barcode) {
|
||||||
_controller?.pauseCamera();
|
_controller?.pauseCamera();
|
||||||
_handler.processBarcode(_context, _controller, barcode.code);
|
_handler.processBarcode(context, _controller, barcode.code);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -528,9 +500,6 @@ class _QRViewState extends State<InvenTreeQRView> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
// Save the context for later on!
|
|
||||||
this._context = context;
|
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: Stack(
|
body: Stack(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
@ -539,7 +508,9 @@ class _QRViewState extends State<InvenTreeQRView> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: QRView(
|
child: QRView(
|
||||||
key: qrKey,
|
key: qrKey,
|
||||||
onQRViewCreated: _onViewCreated,
|
onQRViewCreated: (QRViewController controller) {
|
||||||
|
_onViewCreated(context, controller);
|
||||||
|
},
|
||||||
overlay: QrScannerOverlayShape(
|
overlay: QrScannerOverlayShape(
|
||||||
borderColor: Colors.red,
|
borderColor: Colors.red,
|
||||||
borderRadius: 10,
|
borderRadius: 10,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:device_info/device_info.dart';
|
import 'package:device_info_plus/device_info_plus.dart';
|
||||||
import 'package:package_info/package_info.dart';
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||||
|
|
||||||
import 'package:inventree/api.dart';
|
import 'package:inventree/api.dart';
|
||||||
|
@ -8,6 +8,7 @@ import 'package:inventree/widget/home.dart';
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:one_context/one_context.dart';
|
import 'package:one_context/one_context.dart';
|
||||||
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
|
|
||||||
import 'dsn.dart';
|
import 'dsn.dart';
|
||||||
|
|
||||||
@ -17,14 +18,23 @@ import 'package:sentry_flutter/sentry_flutter.dart';
|
|||||||
|
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
|
|
||||||
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
await runZonedGuarded<Future<void>>(() async {
|
await runZonedGuarded<Future<void>>(() async {
|
||||||
|
|
||||||
|
PackageInfo info = await PackageInfo.fromPlatform();
|
||||||
|
String pkg = info.packageName;
|
||||||
|
String version = info.version;
|
||||||
|
String build = info.buildNumber;
|
||||||
|
|
||||||
|
String release = "${pkg}@${version}:${build}";
|
||||||
|
|
||||||
await Sentry.init((options) {
|
await Sentry.init((options) {
|
||||||
options.dsn = SENTRY_DSN_KEY;
|
options.dsn = SENTRY_DSN_KEY;
|
||||||
|
options.release = release;
|
||||||
|
options.environment = isInDebugMode() ? "debug" : "release";
|
||||||
});
|
});
|
||||||
|
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
|
||||||
|
|
||||||
// Pass any flutter errors off to the Sentry reporting context!
|
// Pass any flutter errors off to the Sentry reporting context!
|
||||||
FlutterError.onError = (FlutterErrorDetails details) async {
|
FlutterError.onError = (FlutterErrorDetails details) async {
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:package_info/package_info.dart';
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
|
|
||||||
import 'package:inventree/l10.dart';
|
import 'package:inventree/l10.dart';
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ import 'package:url_launcher/url_launcher.dart';
|
|||||||
|
|
||||||
import 'login.dart';
|
import 'login.dart';
|
||||||
|
|
||||||
import 'package:package_info/package_info.dart';
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
|
|
||||||
class InvenTreeSettingsWidget extends StatefulWidget {
|
class InvenTreeSettingsWidget extends StatefulWidget {
|
||||||
// InvenTree settings view
|
// InvenTree settings view
|
||||||
|
@ -39,14 +39,6 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
|
|||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
void _saveCompany(Map<String, String> values) async {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
|
|
||||||
await company.update(values: values);
|
|
||||||
|
|
||||||
refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
void editCompanyDialog() {
|
void editCompanyDialog() {
|
||||||
|
|
||||||
// Values which can be edited
|
// Values which can be edited
|
||||||
@ -54,55 +46,7 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
|
|||||||
var _description;
|
var _description;
|
||||||
var _website;
|
var _website;
|
||||||
|
|
||||||
showFormDialog(L10().edit,
|
// TODO - API form
|
||||||
key: _editCompanyKey,
|
|
||||||
actions: <Widget>[
|
|
||||||
TextButton(
|
|
||||||
child: Text(L10().cancel),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
child: Text(L10().save),
|
|
||||||
onPressed: () {
|
|
||||||
if (_editCompanyKey.currentState!.validate()) {
|
|
||||||
_editCompanyKey.currentState!.save();
|
|
||||||
|
|
||||||
_saveCompany({
|
|
||||||
"name": _name,
|
|
||||||
"description": _description,
|
|
||||||
"website": _website,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
fields: <Widget>[
|
|
||||||
StringField(
|
|
||||||
label: L10().name,
|
|
||||||
initial: company.name,
|
|
||||||
onSaved: (value) {
|
|
||||||
_name = value;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
StringField(
|
|
||||||
label: L10().description,
|
|
||||||
initial: company.description,
|
|
||||||
onSaved: (value) {
|
|
||||||
_description = value;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
StringField(
|
|
||||||
label: L10().website,
|
|
||||||
initial: company.website,
|
|
||||||
allowEmpty: true,
|
|
||||||
onSaved: (value) {
|
|
||||||
_website = value;
|
|
||||||
},
|
|
||||||
)
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> _companyTiles() {
|
List<Widget> _companyTiles() {
|
||||||
|
@ -184,62 +184,47 @@ Future<void> showTimeoutError() async {
|
|||||||
await showServerError(L10().timeout, L10().noResponse);
|
await showServerError(L10().timeout, L10().noResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
void showFormDialog(String title, {String? acceptText, String? cancelText, GlobalKey<FormState>? key, List<Widget>? fields, List<Widget>? actions, Function? callback}) {
|
void showFormDialog(String title, {String? acceptText, String? cancelText, GlobalKey<FormState>? key, List<Widget>? fields, Function? callback}) {
|
||||||
|
|
||||||
BuildContext? dialogContext;
|
|
||||||
|
|
||||||
String _accept = acceptText ?? L10().save;
|
String _accept = acceptText ?? L10().save;
|
||||||
String _cancel = cancelText ?? L10().cancel;
|
String _cancel = cancelText ?? L10().cancel;
|
||||||
|
|
||||||
// Undefined actions = OK + Cancel
|
|
||||||
if (actions == null) {
|
|
||||||
actions = <Widget>[
|
|
||||||
TextButton(
|
|
||||||
child: Text(_cancel),
|
|
||||||
onPressed: () {
|
|
||||||
// Close the form
|
|
||||||
var _ctx = dialogContext;
|
|
||||||
if (_ctx != null) {
|
|
||||||
Navigator.pop(_ctx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
child: Text(_accept),
|
|
||||||
onPressed: () {
|
|
||||||
|
|
||||||
var _key = key;
|
|
||||||
|
|
||||||
if (_key != null && _key.currentState != null) {
|
|
||||||
if (_key.currentState!.validate()) {
|
|
||||||
_key.currentState!.save();
|
|
||||||
|
|
||||||
// Close the dialog
|
|
||||||
var _ctx = dialogContext;
|
|
||||||
|
|
||||||
if (_ctx != null) {
|
|
||||||
Navigator.pop(_ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Callback
|
|
||||||
if (callback != null) {
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Widget> _fields = fields ?? [];
|
List<Widget> _fields = fields ?? [];
|
||||||
|
|
||||||
OneContext().showDialog(
|
OneContext().showDialog(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
dialogContext = context;
|
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
title: Text(title),
|
title: Text(title),
|
||||||
actions: actions,
|
actions: <Widget>[
|
||||||
|
TextButton(
|
||||||
|
child: Text(_cancel),
|
||||||
|
onPressed: () {
|
||||||
|
// Close the form
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
child: Text(_accept),
|
||||||
|
onPressed: () {
|
||||||
|
|
||||||
|
var _key = key;
|
||||||
|
|
||||||
|
if (_key != null && _key.currentState != null) {
|
||||||
|
if (_key.currentState!.validate()) {
|
||||||
|
_key.currentState!.save();
|
||||||
|
|
||||||
|
Navigator.pop(context);
|
||||||
|
|
||||||
|
// Callback
|
||||||
|
if (callback != null) {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
],
|
||||||
content: Form(
|
content: Form(
|
||||||
key: key,
|
key: key,
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
|
61
pubspec.lock
61
pubspec.lock
@ -113,20 +113,48 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.3"
|
version: "1.0.3"
|
||||||
device_info:
|
device_info_plus:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: device_info
|
name: device_info_plus
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.2"
|
version: "2.1.0"
|
||||||
device_info_platform_interface:
|
device_info_plus_linux:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: device_info_platform_interface
|
name: device_info_plus_linux
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.1"
|
version: "2.1.0"
|
||||||
|
device_info_plus_macos:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: device_info_plus_macos
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.0"
|
||||||
|
device_info_plus_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: device_info_plus_platform_interface
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.0"
|
||||||
|
device_info_plus_web:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: device_info_plus_web
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.0"
|
||||||
|
device_info_plus_windows:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: device_info_plus_windows
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.0"
|
||||||
dropdown_search:
|
dropdown_search:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -322,27 +350,20 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0"
|
version: "1.1.0"
|
||||||
package_info:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: package_info
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "2.0.2"
|
|
||||||
package_info_plus:
|
package_info_plus:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: package_info_plus
|
name: package_info_plus
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.3"
|
version: "1.0.4"
|
||||||
package_info_plus_linux:
|
package_info_plus_linux:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: package_info_plus_linux
|
name: package_info_plus_linux
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.2"
|
version: "1.0.3"
|
||||||
package_info_plus_macos:
|
package_info_plus_macos:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -356,21 +377,21 @@ packages:
|
|||||||
name: package_info_plus_platform_interface
|
name: package_info_plus_platform_interface
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.1"
|
version: "1.0.2"
|
||||||
package_info_plus_web:
|
package_info_plus_web:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: package_info_plus_web
|
name: package_info_plus_web
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.2"
|
version: "1.0.3"
|
||||||
package_info_plus_windows:
|
package_info_plus_windows:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: package_info_plus_windows
|
name: package_info_plus_windows
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.2"
|
version: "1.0.3"
|
||||||
path:
|
path:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -454,7 +475,7 @@ packages:
|
|||||||
name: qr_code_scanner
|
name: qr_code_scanner
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.5.1"
|
version: "0.5.2"
|
||||||
quiver:
|
quiver:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -24,9 +24,9 @@ dependencies:
|
|||||||
cupertino_icons: ^1.0.3
|
cupertino_icons: ^1.0.3
|
||||||
http: ^0.13.0
|
http: ^0.13.0
|
||||||
cached_network_image: ^3.0.0 # Download and cache remote images
|
cached_network_image: ^3.0.0 # Download and cache remote images
|
||||||
qr_code_scanner: ^0.5.1 # Barcode scanning
|
qr_code_scanner: ^0.5.2 # Barcode scanning
|
||||||
package_info: ^2.0.0 # App information introspection
|
package_info_plus: ^1.0.4 # App information introspection
|
||||||
device_info: ^2.0.0 # Information about the device
|
device_info_plus: ^2.1.0 # Information about the device
|
||||||
font_awesome_flutter: ^9.1.0 # FontAwesome icon set
|
font_awesome_flutter: ^9.1.0 # FontAwesome icon set
|
||||||
flutter_speed_dial: ^3.0.5 # FAB menu elements
|
flutter_speed_dial: ^3.0.5 # FAB menu elements
|
||||||
sentry_flutter: 5.0.0 # Error reporting
|
sentry_flutter: 5.0.0 # Error reporting
|
||||||
|
Loading…
x
Reference in New Issue
Block a user