diff --git a/lib/api.dart b/lib/api.dart index 984458b9..127152f0 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -8,13 +8,10 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:image/image.dart'; import 'package:InvenTree/widget/dialogs.dart'; -import 'package:path/path.dart' as path; import 'package:http/http.dart' as http; -import 'package:shared_preferences/shared_preferences.dart'; /** diff --git a/lib/inventree/stock.dart b/lib/inventree/stock.dart index 494b3aea..516672f4 100644 --- a/lib/inventree/stock.dart +++ b/lib/inventree/stock.dart @@ -1,13 +1,13 @@ -import 'dart:convert'; - import 'package:InvenTree/inventree/part.dart'; import 'package:flutter/cupertino.dart'; import 'package:http/http.dart' as http; import 'model.dart'; + import 'dart:async'; import 'dart:io'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:InvenTree/api.dart'; @@ -49,6 +49,51 @@ class InvenTreeStockItemTestResult extends InvenTreeModel { class InvenTreeStockItem extends InvenTreeModel { + // Stock status codes + static const int OK = 10; + static const int ATTENTION = 50; + static const int DAMAGED = 55; + static const int DESTROYED = 60; + static const int REJECTED = 65; + static const int LOST = 70; + + String statusLabel(BuildContext context) { + + switch (status) { + case OK: + return I18N.of(context).ok; + case ATTENTION: + return I18N.of(context).attention; + case DAMAGED: + return I18N.of(context).damaged; + case DESTROYED: + return I18N.of(context).destroyed; + case REJECTED: + return I18N.of(context).rejected; + case LOST: + return I18N.of(context).lost; + default: + return status.toString(); + } + } + + // Return color associated with stock status + Color get statusColor { + switch (status) { + case OK: + return Color(0xFF50aa51); + case ATTENTION: + return Color(0xFFfdc82a); + case DAMAGED: + case DESTROYED: + case REJECTED: + return Color(0xFFe35a57); + case LOST: + default: + return Color(0xFFAAAAAA); + } + } + @override String NAME = "StockItem"; @@ -168,6 +213,8 @@ class InvenTreeStockItem extends InvenTreeModel { String get uid => jsondata['uid'] ?? ''; + int get status => jsondata['status'] ?? -1; + int get partId => jsondata['part'] ?? -1; int get trackingItemCount => jsondata['tracking_items'] as int ?? 0; diff --git a/lib/l10n b/lib/l10n index 90f3bbf1..249e4964 160000 --- a/lib/l10n +++ b/lib/l10n @@ -1 +1 @@ -Subproject commit 90f3bbf1fae86efd0bb0686bef12452a09507669 +Subproject commit 249e4964a08b79e53df7e1ea18b051de0d307905 diff --git a/lib/widget/location_display.dart b/lib/widget/location_display.dart index ef75f408..5498793a 100644 --- a/lib/widget/location_display.dart +++ b/lib/widget/location_display.dart @@ -99,6 +99,7 @@ class _LocationDisplayState extends RefreshableState { child: ListTile( title: Text(I18N.of(context).stockLocations), subtitle: Text(I18N.of(context).stockTopLevel), + leading: FaIcon(FontAwesomeIcons.levelUpAlt), ) ); } else { @@ -112,6 +113,7 @@ class _LocationDisplayState extends RefreshableState { ListTile( title: Text("Parent Category"), subtitle: Text("${location.parentpathstring}"), + leading: FaIcon(FontAwesomeIcons.levelUpAlt), onTap: () { if (location.parentId < 0) { Navigator.push(context, MaterialPageRoute(builder: (context) => LocationDisplayWidget(null))); diff --git a/lib/widget/stock_detail.dart b/lib/widget/stock_detail.dart index 95d9fb9d..dc4beddd 100644 --- a/lib/widget/stock_detail.dart +++ b/lib/widget/stock_detail.dart @@ -303,7 +303,13 @@ class _StockItemDisplayState extends RefreshableState { title: Text("${item.partName}"), subtitle: Text("${item.partDescription}"), leading: InvenTreeAPI().getImage(item.partImage), - trailing: Text(item.serialOrQuantityDisplay()), + trailing: Text( + item.statusLabel(context), + style: TextStyle( + color: item.statusColor + ) + ), + //trailing: Text(item.serialOrQuantityDisplay()), ) ); }