2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-12 02:05:29 +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

@ -268,7 +268,7 @@ class PartList extends StatelessWidget {
return ListTile(
title: Text("${part.name}"),
subtitle: Text("${part.description}"),
trailing: Text("${part.inStock}"),
trailing: Text("${part.inStockString}"),
leading: InvenTreeAPI().getImage(
part.thumbnail,
width: 40,

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(

View File

@ -27,6 +27,8 @@ class InvenTreeHomePage extends StatefulWidget {
class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
final GlobalKey<_InvenTreeHomePageState> _homeKey = GlobalKey<_InvenTreeHomePageState>();
_InvenTreeHomePageState() : super() {
// Initially load the profile and attempt server connection
@ -115,7 +117,7 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
if (!InvenTreeAPI().isConnected() && !InvenTreeAPI().isConnecting()) {
// Attempt server connection
InvenTreeAPI().connectToServer(_context).then((result) {
InvenTreeAPI().connectToServer(_homeKey.currentContext).then((result) {
setState(() {});
});
}
@ -198,6 +200,7 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return Scaffold(
key: _homeKey,
appBar: AppBar(
title: Text(I18N.of(context).appTitle),
actions: <Widget>[

View File

@ -217,7 +217,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
ListTile(
title: Text(I18N.of(context).stock),
leading: FaIcon(FontAwesomeIcons.boxes),
trailing: Text("${part.inStock}"),
trailing: Text("${part.inStockString}"),
onTap: () {
_showStock(context);
},