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:
parent
14161c5d42
commit
80247f84c1
@ -85,6 +85,16 @@ bool isInDebugMode() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _uploadErrorReport(dynamic error, dynamic stackTrace) async {
|
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 server_info = getServerInfo();
|
||||||
final app_info = await getAppInfo();
|
final app_info = await getAppInfo();
|
||||||
final device_info = await getDeviceInfo();
|
final device_info = await getDeviceInfo();
|
||||||
@ -109,15 +119,6 @@ Future<void> sentryReportError(dynamic error, dynamic stackTrace) async {
|
|||||||
print('Intercepted error: $error');
|
print('Intercepted error: $error');
|
||||||
print(stackTrace);
|
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(
|
await OneContext().showDialog(
|
||||||
builder: (context) => AlertDialog(
|
builder: (context) => AlertDialog(
|
||||||
title: ListTile(
|
title: ListTile(
|
||||||
|
2
lib/l10n
2
lib/l10n
@ -1 +1 @@
|
|||||||
Subproject commit 0a196087238e13ddba282ce36c56b87fe1ad6fe5
|
Subproject commit 81a41ca5d698b540af9fd00300d3159ba943a13d
|
@ -53,7 +53,6 @@ class _InvenTreeLoginSettingsState extends State<InvenTreeLoginSettingsWidget> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
showFormDialog(
|
showFormDialog(
|
||||||
context,
|
|
||||||
I18N.of(context).profileAdd,
|
I18N.of(context).profileAdd,
|
||||||
key: _addProfileKey,
|
key: _addProfileKey,
|
||||||
actions: <Widget> [
|
actions: <Widget> [
|
||||||
|
@ -119,7 +119,6 @@ class _InvenTreeSettingsState extends State<InvenTreeSettingsWidget> {
|
|||||||
_controller.clear();
|
_controller.clear();
|
||||||
|
|
||||||
showFormDialog(
|
showFormDialog(
|
||||||
context,
|
|
||||||
"Upload Bug Report",
|
"Upload Bug Report",
|
||||||
key: _bugKey,
|
key: _bugKey,
|
||||||
callback: () {
|
callback: () {
|
||||||
|
@ -77,7 +77,6 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
|||||||
var _description;
|
var _description;
|
||||||
|
|
||||||
showFormDialog(
|
showFormDialog(
|
||||||
context,
|
|
||||||
I18N.of(context).editCategory,
|
I18N.of(context).editCategory,
|
||||||
key: _editCategoryKey,
|
key: _editCategoryKey,
|
||||||
callback: () {
|
callback: () {
|
||||||
|
@ -55,7 +55,7 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
|
|||||||
var _description;
|
var _description;
|
||||||
var _website;
|
var _website;
|
||||||
|
|
||||||
showFormDialog(context, I18N.of(context).edit,
|
showFormDialog(I18N.of(context).edit,
|
||||||
key: _editCompanyKey,
|
key: _editCompanyKey,
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
FlatButton(
|
FlatButton(
|
||||||
|
@ -3,7 +3,7 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.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 {
|
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 {
|
Future<void> showInfoDialog(BuildContext context, String title, String description, {IconData icon = FontAwesomeIcons.info, String info, Function onDismissed}) async {
|
||||||
|
|
||||||
if (info == null || info.isEmpty) {
|
if (info == null || info.isEmpty) {
|
||||||
@ -160,42 +161,42 @@ void hideProgressDialog(BuildContext context) {
|
|||||||
Navigator.pop(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
|
// Undefined actions = OK + Cancel
|
||||||
if (actions == null) {
|
if (actions == null) {
|
||||||
actions = <Widget>[
|
actions = <Widget>[
|
||||||
FlatButton(
|
FlatButton(
|
||||||
child: Text(I18N.of(context).cancel),
|
child: Text(I18N.of(OneContext().context).cancel),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
// Close the form
|
// Close the form
|
||||||
Navigator.pop(context);
|
Navigator.of(OneContext().context).pop();
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
FlatButton(
|
FlatButton(
|
||||||
child: Text(I18N.of(context).save),
|
child: Text(I18N.of(OneContext().context).save),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (key.currentState.validate()) {
|
if (key.currentState.validate()) {
|
||||||
key.currentState.save();
|
key.currentState.save();
|
||||||
|
|
||||||
// Close the dialog
|
// Close the dialog
|
||||||
Navigator.pop(context);
|
Navigator.pop(OneContext().context);
|
||||||
|
|
||||||
// Callback
|
// Callback
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
showDialog(
|
OneContext().showDialog(
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
|
dialogContext = context;
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
title: Text(title),
|
title: Text(title),
|
||||||
actions: actions,
|
actions: actions,
|
||||||
|
@ -75,7 +75,7 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
|||||||
var _name;
|
var _name;
|
||||||
var _description;
|
var _description;
|
||||||
|
|
||||||
showFormDialog(context, I18N.of(context).editLocation,
|
showFormDialog(I18N.of(context).editLocation,
|
||||||
key: _editLocationKey,
|
key: _editLocationKey,
|
||||||
callback: () {
|
callback: () {
|
||||||
_editLocation({
|
_editLocation({
|
||||||
|
@ -108,7 +108,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
|||||||
var _keywords;
|
var _keywords;
|
||||||
var _link;
|
var _link;
|
||||||
|
|
||||||
showFormDialog(context, I18N.of(context).editPart,
|
showFormDialog(I18N.of(context).editPart,
|
||||||
key: _editPartKey,
|
key: _editPartKey,
|
||||||
callback: () {
|
callback: () {
|
||||||
_savePart({
|
_savePart({
|
||||||
|
@ -119,7 +119,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
|||||||
_quantityController.clear();
|
_quantityController.clear();
|
||||||
_notesController.clear();
|
_notesController.clear();
|
||||||
|
|
||||||
showFormDialog(context, I18N.of(context).addStock,
|
showFormDialog( I18N.of(context).addStock,
|
||||||
key: _addStockKey,
|
key: _addStockKey,
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
FlatButton(
|
FlatButton(
|
||||||
@ -173,7 +173,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
|||||||
_quantityController.clear();
|
_quantityController.clear();
|
||||||
_notesController.clear();
|
_notesController.clear();
|
||||||
|
|
||||||
showFormDialog(context, I18N.of(context).removeStock,
|
showFormDialog(I18N.of(context).removeStock,
|
||||||
key: _removeStockKey,
|
key: _removeStockKey,
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
FlatButton(
|
FlatButton(
|
||||||
@ -219,7 +219,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
|||||||
_quantityController.text = item.quantityString;
|
_quantityController.text = item.quantityString;
|
||||||
_notesController.clear();
|
_notesController.clear();
|
||||||
|
|
||||||
showFormDialog(context, I18N.of(context).countStock,
|
showFormDialog(I18N.of(context).countStock,
|
||||||
key: _countStockKey,
|
key: _countStockKey,
|
||||||
actions: <Widget> [
|
actions: <Widget> [
|
||||||
FlatButton(
|
FlatButton(
|
||||||
@ -273,7 +273,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
|||||||
|
|
||||||
_quantityController.text = "${item.quantityString}";
|
_quantityController.text = "${item.quantityString}";
|
||||||
|
|
||||||
showFormDialog(context, I18N.of(context).transferStock,
|
showFormDialog(I18N.of(context).transferStock,
|
||||||
key: _moveStockKey,
|
key: _moveStockKey,
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
FlatButton(
|
FlatButton(
|
||||||
|
@ -72,7 +72,7 @@ class _StockItemTestResultDisplayState extends RefreshableState<StockItemTestRes
|
|||||||
String _notes;
|
String _notes;
|
||||||
File _attachment;
|
File _attachment;
|
||||||
|
|
||||||
showFormDialog(context, "Add Test Data",
|
showFormDialog("Add Test Data",
|
||||||
key: _addResultKey,
|
key: _addResultKey,
|
||||||
callback: () {
|
callback: () {
|
||||||
uploadTestResult(_name, _result, _value, _notes, _attachment);
|
uploadTestResult(_name, _result, _value, _notes, _attachment);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user