2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-04-28 05:26:47 +00:00

migrate showFormDialog to OneContext

This commit is contained in:
Oliver Walters 2021-02-15 20:54:15 +11:00
parent 14161c5d42
commit 80247f84c1
11 changed files with 30 additions and 31 deletions

View File

@ -85,6 +85,16 @@ bool isInDebugMode() {
}
Future<void> _uploadErrorReport(dynamic error, dynamic stackTrace) async {
// Errors thrown in development mode are unlikely to be interesting. You can
// check if you are running in dev mode using an assertion and omit sending
// the report.
if (isInDebugMode()) {
print('In dev mode. Not sending report to Sentry.io.');
return;
}
final server_info = getServerInfo();
final app_info = await getAppInfo();
final device_info = await getDeviceInfo();
@ -109,15 +119,6 @@ Future<void> sentryReportError(dynamic error, dynamic stackTrace) async {
print('Intercepted error: $error');
print(stackTrace);
// Errors thrown in development mode are unlikely to be interesting. You can
// check if you are running in dev mode using an assertion and omit sending
// the report.
if (isInDebugMode()) {
print('In dev mode. Not sending report to Sentry.io.');
return;
}
await OneContext().showDialog(
builder: (context) => AlertDialog(
title: ListTile(

@ -1 +1 @@
Subproject commit 0a196087238e13ddba282ce36c56b87fe1ad6fe5
Subproject commit 81a41ca5d698b540af9fd00300d3159ba943a13d

View File

@ -53,7 +53,6 @@ class _InvenTreeLoginSettingsState extends State<InvenTreeLoginSettingsWidget> {
}
showFormDialog(
context,
I18N.of(context).profileAdd,
key: _addProfileKey,
actions: <Widget> [

View File

@ -119,7 +119,6 @@ class _InvenTreeSettingsState extends State<InvenTreeSettingsWidget> {
_controller.clear();
showFormDialog(
context,
"Upload Bug Report",
key: _bugKey,
callback: () {

View File

@ -77,7 +77,6 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
var _description;
showFormDialog(
context,
I18N.of(context).editCategory,
key: _editCategoryKey,
callback: () {

View File

@ -55,7 +55,7 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
var _description;
var _website;
showFormDialog(context, I18N.of(context).edit,
showFormDialog(I18N.of(context).edit,
key: _editCompanyKey,
actions: <Widget>[
FlatButton(

View File

@ -3,7 +3,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:one_context/one_context.dart';
Future<void> confirmationDialog(BuildContext context, String title, String text, {String acceptText, String rejectText, Function onAccept, Function onReject}) async {
@ -57,6 +57,7 @@ void showMessage(BuildContext context, String message) {
));
}
Future<void> showInfoDialog(BuildContext context, String title, String description, {IconData icon = FontAwesomeIcons.info, String info, Function onDismissed}) async {
if (info == null || info.isEmpty) {
@ -160,42 +161,42 @@ void hideProgressDialog(BuildContext context) {
Navigator.pop(context);
}
void showFormDialog(BuildContext context, String title, {GlobalKey<FormState> key, List<Widget> fields, List<Widget> actions, Function callback}) {
void showFormDialog(String title, {GlobalKey<FormState> key, List<Widget> fields, List<Widget> actions, Function callback}) {
BuildContext dialogContext;
// Undefined actions = OK + Cancel
if (actions == null) {
actions = <Widget>[
FlatButton(
child: Text(I18N.of(context).cancel),
child: Text(I18N.of(OneContext().context).cancel),
onPressed: () {
// Close the form
Navigator.pop(context);
Navigator.of(OneContext().context).pop();
}
),
FlatButton(
child: Text(I18N.of(context).save),
child: Text(I18N.of(OneContext().context).save),
onPressed: () {
if (key.currentState.validate()) {
key.currentState.save();
// Close the dialog
Navigator.pop(context);
Navigator.pop(OneContext().context);
// Callback
if (callback != null) {
callback();
}
}
}
)
];
}
showDialog(
context: context,
OneContext().showDialog(
builder: (BuildContext context) {
dialogContext = context;
return AlertDialog(
title: Text(title),
actions: actions,

View File

@ -75,7 +75,7 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
var _name;
var _description;
showFormDialog(context, I18N.of(context).editLocation,
showFormDialog(I18N.of(context).editLocation,
key: _editLocationKey,
callback: () {
_editLocation({

View File

@ -108,7 +108,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
var _keywords;
var _link;
showFormDialog(context, I18N.of(context).editPart,
showFormDialog(I18N.of(context).editPart,
key: _editPartKey,
callback: () {
_savePart({

View File

@ -119,7 +119,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
_quantityController.clear();
_notesController.clear();
showFormDialog(context, I18N.of(context).addStock,
showFormDialog( I18N.of(context).addStock,
key: _addStockKey,
actions: <Widget>[
FlatButton(
@ -173,7 +173,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
_quantityController.clear();
_notesController.clear();
showFormDialog(context, I18N.of(context).removeStock,
showFormDialog(I18N.of(context).removeStock,
key: _removeStockKey,
actions: <Widget>[
FlatButton(
@ -219,7 +219,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
_quantityController.text = item.quantityString;
_notesController.clear();
showFormDialog(context, I18N.of(context).countStock,
showFormDialog(I18N.of(context).countStock,
key: _countStockKey,
actions: <Widget> [
FlatButton(
@ -273,7 +273,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
_quantityController.text = "${item.quantityString}";
showFormDialog(context, I18N.of(context).transferStock,
showFormDialog(I18N.of(context).transferStock,
key: _moveStockKey,
actions: <Widget>[
FlatButton(

View File

@ -72,7 +72,7 @@ class _StockItemTestResultDisplayState extends RefreshableState<StockItemTestRes
String _notes;
File _attachment;
showFormDialog(context, "Add Test Data",
showFormDialog("Add Test Data",
key: _addResultKey,
callback: () {
uploadTestResult(_name, _result, _value, _notes, _attachment);