2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-13 18:55:34 +00:00
Oliver Walters
2021-02-09 21:38:50 +11:00
parent 90072904a0
commit 33bb6148de
11 changed files with 162 additions and 167 deletions

View File

@ -3,6 +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:flutter_gen/gen_l10n/app_localizations.dart';
Future<void> confirmationDialog(BuildContext context, String title, String text, {String acceptText, String rejectText, Function onAccept, Function onReject}) async {
@ -92,37 +93,55 @@ Future<void> showErrorDialog(BuildContext context, String title, String descript
showDialog(
context: context,
child: SimpleDialog(
title: ListTile(
title: Text(error),
leading: FaIcon(icon),
),
children: <Widget>[
ListTile(
title: Text(title),
subtitle: Text(description)
)
]
)
).then((value) {
if (onDismissed != null) {
onDismissed();
}
});
builder: (dialogContext) {
return SimpleDialog(
title: ListTile(
title: Text(error),
leading: FaIcon(icon),
),
children: <Widget>[
ListTile(
title: Text(title),
subtitle: Text(description)
)
]
);
}).then((value) {
if (onDismissed != null) {
onDismissed();
}
});
}
void showTimeoutDialog(BuildContext context) {
/*
Show a server timeout dialog
*/
Future<void> showServerError(BuildContext context, String title, String description) async {
showErrorDialog(
if (title == null || title.isEmpty) {
title = I18N.of(context).serverError;
}
await showErrorDialog(
context,
I18N.of(context).timeout,
I18N.of(context).noResponse
title,
description,
error: I18N.of(context).serverError,
icon: FontAwesomeIcons.server
);
}
Future<void> showStatusCodeError(BuildContext context, int status, {int expected = 200}) async {
await showServerError(
context,
"Invalid Response Code",
"Server responded with status code ${status}"
);
}
Future<void> showTimeoutError(BuildContext context) async {
await showServerError(context, I18N.of(context).timeout, I18N.of(context).noResponse);
}
void showProgressDialog(BuildContext context, String title, String description) {
showDialog(