mirror of
https://github.com/inventree/inventree-app.git
synced 2025-06-12 02:05:29 +00:00
API refactoring:
- Error if the server version is *older* than the min required version - Display dialog boxes for different server errors
This commit is contained in:
@ -2,6 +2,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';
|
||||
|
||||
void showMessage(BuildContext context, String message) {
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
@ -9,7 +10,12 @@ void showMessage(BuildContext context, String message) {
|
||||
));
|
||||
}
|
||||
|
||||
Future<void> showInfoDialog(BuildContext context, String title, String description, {IconData icon = FontAwesomeIcons.info, String info = "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) {
|
||||
info = I18N.of(context).info;
|
||||
}
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
child: SimpleDialog(
|
||||
@ -31,7 +37,12 @@ Future<void> showInfoDialog(BuildContext context, String title, String descripti
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> showErrorDialog(BuildContext context, String title, String description, {IconData icon = FontAwesomeIcons.exclamationCircle, String error = "Error", Function onDismissed}) async {
|
||||
Future<void> showErrorDialog(BuildContext context, String title, String description, {IconData icon = FontAwesomeIcons.exclamationCircle, String error, Function onDismissed}) async {
|
||||
|
||||
if (error == null || error.isEmpty) {
|
||||
error = I18N.of(context).error;
|
||||
}
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
child: SimpleDialog(
|
||||
|
@ -25,7 +25,6 @@ class InvenTreeHomePage extends StatefulWidget {
|
||||
class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
|
||||
|
||||
_InvenTreeHomePageState() : super() {
|
||||
_checkServerConnection();
|
||||
}
|
||||
|
||||
String _serverAddress = "";
|
||||
@ -63,7 +62,7 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
|
||||
/*
|
||||
* Test the server connection
|
||||
*/
|
||||
void _checkServerConnection() async {
|
||||
void _checkServerConnection(BuildContext context) async {
|
||||
|
||||
var prefs = await SharedPreferences.getInstance();
|
||||
|
||||
@ -76,7 +75,7 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
|
||||
_serverIcon = new FaIcon(FontAwesomeIcons.spinner);
|
||||
_serverStatusColor = Color.fromARGB(255, 50, 50, 250);
|
||||
|
||||
InvenTreeAPI().connect().then((bool result) {
|
||||
InvenTreeAPI().connect(context).then((bool result) {
|
||||
|
||||
if (result) {
|
||||
onConnectSuccess("");
|
||||
@ -322,7 +321,7 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
|
||||
leading: _serverIcon,
|
||||
onTap: () {
|
||||
if (!_serverConnection) {
|
||||
_checkServerConnection();
|
||||
_checkServerConnection(context);
|
||||
}
|
||||
},
|
||||
),
|
||||
|
Reference in New Issue
Block a user