2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-07-03 04:10:50 +00:00

UX Overhaul ()

* Add "global actions" to title bar

* Implement actions

* Add "speed dial" action buttons

* tweak global action icons

* Refactor actions for "stock item" display

* Refactor "part" detail

* part category

* SupplierPart

* More updates

* Add BottomAppBar

* Add a global bottom app bar

* Move "edit" buttons back to the app bar

* tweaks

* Updates to drawer navigation menu

* home screen improvements

* text tweaks

* Fix appBarTitle for notifications widget

* Update "tabs" for category display

* Fix for attachment widget

* Update tabs for purchaseorder view

* Update part display

* Cleanup

* Add "BOM" tab to part detail widget

* Paginated list search cleanup

* Update release notes

* Update old function

* linting

* linting

* Tweaks to bottomappbar

- Increase icon size slightly
- Adjust "actions" icon
This commit is contained in:
Oliver
2023-04-08 23:59:11 +10:00
committed by GitHub
parent 74176cdda8
commit a8f87e2f5a
38 changed files with 979 additions and 1159 deletions

@ -1,4 +1,5 @@
import "package:flutter/material.dart";
import "package:flutter_speed_dial/flutter_speed_dial.dart";
import "package:font_awesome_flutter/font_awesome_flutter.dart";
@ -40,35 +41,96 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
bool showFilterOptions = false;
@override
String getAppBarTitle(BuildContext context) { return L10().stockLocation; }
String getAppBarTitle() {
return L10().stockLocation;
}
@override
List<Widget> getAppBarActions(BuildContext context) {
List<Widget> appBarActions(BuildContext context) {
List<Widget> actions = [];
if (location != null) {
// Add "locate" button
if (api.supportsMixin("locate")) {
actions.add(
// Add "locate" button
if (location != null && api.supportsMixin("locate")) {
actions.add(
IconButton(
icon: FaIcon(FontAwesomeIcons.magnifyingGlassLocation),
tooltip: L10().locateLocation,
onPressed: () async {
_locateStockLocation(context);
},
icon: Icon(Icons.travel_explore),
tooltip: L10().locateLocation,
onPressed: () async {
api.locateItemOrLocation(context, location: location!.pk);
}
)
);
}
// Add "edit" button
if (location != null && api.checkPermission("stock_location", "change")) {
actions.add(
IconButton(
icon: Icon(Icons.edit_square),
tooltip: L10().editLocation,
onPressed: () {
_editLocationDialog(context);
}
)
);
}
return actions;
}
@override
List<SpeedDialChild> barcodeButtons(BuildContext context) {
List<SpeedDialChild> actions = [];
if (location != null) {
// Scan items into this location
if (api.checkPermission("stock", "change")) {
actions.add(
SpeedDialChild(
child: FaIcon(FontAwesomeIcons.qrcode),
label: L10().barcodeScanItem,
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) =>
InvenTreeQRView(
StockLocationScanInItemsHandler(location!)))
).then((value) {
refresh(context);
});
}
)
);
}
// Add "edit" button
// Scan this location into another one
if (api.checkPermission("stock_location", "change")) {
actions.add(
IconButton(
icon: FaIcon(FontAwesomeIcons.penToSquare),
tooltip: L10().edit,
onPressed: () { _editLocationDialog(context); },
SpeedDialChild(
child: FaIcon(FontAwesomeIcons.qrcode),
label: L10().transferStockLocation,
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) =>
InvenTreeQRView(
ScanParentLocationHandler(location!)))
).then((value) {
refresh(context);
});
}
)
);
}
// Assign or un-assign barcodes
if (api.supportModernBarcodes) {
actions.add(
customBarcodeAction(
context, this,
location!.customBarcode, "stocklocation",
location!.pk
)
);
}
@ -77,23 +139,43 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
return actions;
}
/*
* Request identification of this location
*/
Future<void> _locateStockLocation(BuildContext context) async {
@override
List<SpeedDialChild> actionButtons(BuildContext context) {
List<SpeedDialChild> actions = [];
final _loc = location;
if (_loc != null) {
api.locateItemOrLocation(context, location: _loc.pk);
// Create new location
if (api.checkPermission("stock_location", "add")) {
actions.add(
SpeedDialChild(
child: FaIcon(FontAwesomeIcons.sitemap),
label: L10().locationCreate,
onTap: () async {
_newLocation(context);
}
)
);
}
// Create new item
if (location != null && api.checkPermission("stock", "add")) {
actions.add(
SpeedDialChild(
child: FaIcon(FontAwesomeIcons.boxesStacked),
label: L10().stockItemCreate,
onTap: () async {
_newStockItem(context);
}
)
);
}
return actions;
}
/*
* Launch a dialog form to edit this stock location
*/
void _editLocationDialog(BuildContext context) {
final _loc = location;
if (_loc == null) {
@ -101,12 +183,12 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
}
_loc.editForm(
context,
L10().editLocation,
onSuccess: (data) async {
refresh(context);
showSnackIcon(L10().locationUpdated, success: true);
}
context,
L10().editLocation,
onSuccess: (data) async {
refresh(context);
showSnackIcon(L10().locationUpdated, success: true);
}
);
}
@ -117,7 +199,6 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
@override
Future<void> request(BuildContext context) async {
// Reload location information
if (location != null) {
final bool result = await location!.reload();
@ -133,35 +214,32 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
}
Future<void> _newLocation(BuildContext context) async {
int pk = location?.pk ?? -1;
InvenTreeStockLocation().createForm(
context,
L10().locationCreate,
data: {
"parent": (pk > 0) ? pk : null,
},
onSuccess: (result) async {
context,
L10().locationCreate,
data: {
"parent": (pk > 0) ? pk : null,
},
onSuccess: (result) async {
Map<String, dynamic> data = result as Map<String, dynamic>;
Map<String, dynamic> data = result as Map<String, dynamic>;
if (data.containsKey("pk")) {
var loc = InvenTreeStockLocation.fromJson(data);
if (data.containsKey("pk")) {
var loc = InvenTreeStockLocation.fromJson(data);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => LocationDisplayWidget(loc)
)
);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => LocationDisplayWidget(loc)
)
);
}
}
}
);
}
Future<void> _newStockItem(BuildContext context) async {
int pk = location?.pk ?? -1;
if (location != null && pk <= 0) {
@ -169,48 +247,46 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
}
InvenTreeStockItem().createForm(
context,
L10().stockItemCreate,
data: {
"location": location != null ? pk : null,
},
onSuccess: (result) async {
context,
L10().stockItemCreate,
data: {
"location": location != null ? pk : null,
},
onSuccess: (result) async {
Map<String, dynamic> data = result as Map<String, dynamic>;
Map<String, dynamic> data = result as Map<String, dynamic>;
if (data.containsKey("pk")) {
var item = InvenTreeStockItem.fromJson(data);
if (data.containsKey("pk")) {
var item = InvenTreeStockItem.fromJson(data);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => StockDetailWidget(item)
)
);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => StockDetailWidget(item)
)
);
}
}
}
);
}
Widget locationDescriptionCard({bool includeActions = true}) {
if (location == null) {
return Card(
child: ListTile(
title: Text(
L10().stockTopLevel,
style: TextStyle(fontStyle: FontStyle.italic)
),
leading: FaIcon(FontAwesomeIcons.boxesStacked),
)
child: ListTile(
title: Text(
L10().stockTopLevel,
style: TextStyle(fontStyle: FontStyle.italic)
),
leading: FaIcon(FontAwesomeIcons.boxesStacked),
)
);
} else {
List<Widget> children = [
ListTile(
title: Text("${location!.name}"),
subtitle: Text("${location!.description}"),
leading: location!.customIcon ?? FaIcon(FontAwesomeIcons.boxesStacked),
leading: location!.customIcon ??
FaIcon(FontAwesomeIcons.boxesStacked),
),
];
@ -221,19 +297,19 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
subtitle: Text("${location!.parentPathString}"),
leading: FaIcon(FontAwesomeIcons.turnUp, color: COLOR_CLICK),
onTap: () async {
int parentId = location?.parentId ?? -1;
if (parentId < 0) {
Navigator.push(context, MaterialPageRoute(builder: (context) => LocationDisplayWidget(null)));
Navigator.push(context, MaterialPageRoute(
builder: (context) => LocationDisplayWidget(null)));
} else {
showLoadingOverlay(context);
var loc = await InvenTreeStockLocation().get(parentId);
hideLoadingOverlay();
if (loc is InvenTreeStockLocation) {
Navigator.push(context, MaterialPageRoute(builder: (context) => LocationDisplayWidget(loc)));
Navigator.push(context, MaterialPageRoute(
builder: (context) => LocationDisplayWidget(loc)));
}
}
},
@ -242,63 +318,27 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
}
return Card(
child: Column(
children: children,
)
child: Column(
children: children,
)
);
}
}
@override
Widget getBottomNavBar(BuildContext context) {
return BottomNavigationBar(
currentIndex: tabIndex,
onTap: onTabSelectionChanged,
items: <BottomNavigationBarItem> [
BottomNavigationBarItem(
icon: FaIcon(FontAwesomeIcons.sitemap),
label: L10().details,
),
BottomNavigationBarItem(
icon: FaIcon(FontAwesomeIcons.boxesStacked),
label: L10().stock,
),
BottomNavigationBarItem(
icon: FaIcon(FontAwesomeIcons.wrench),
label: L10().actions,
)
]
);
}
int stockItemCount = 0;
Widget getSelectedWidget(int index) {
switch (index) {
case 0:
return Column(
children: detailTiles(),
);
case 1:
return Column(
children: stockTiles(),
);
case 2:
return ListView(
children: ListTile.divideTiles(
context: context,
tiles: actionTiles()
).toList()
);
default:
return ListView();
}
List<Widget> getTabIcons(BuildContext context) {
return [
Tab(text: L10().details),
Tab(text: L10().stockItems),
];
}
@override
Widget getBody(BuildContext context) {
return getSelectedWidget(tabIndex);
List<Widget> getTabs(BuildContext context) {
return [
Column(children: detailTiles()),
Column(children: stockTiles()),
];
}
// Construct the "details" panel
@ -306,18 +346,18 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
List<Widget> tiles = [
locationDescriptionCard(),
ListTile(
title: Text(
L10().sublocations,
style: TextStyle(fontWeight: FontWeight.bold),
),
trailing: GestureDetector(
child: FaIcon(FontAwesomeIcons.filter),
onTap: () async {
setState(() {
showFilterOptions = !showFilterOptions;
});
},
)
title: Text(
L10().sublocations,
style: TextStyle(fontWeight: FontWeight.bold),
),
trailing: GestureDetector(
child: FaIcon(FontAwesomeIcons.filter),
onTap: () async {
setState(() {
showFilterOptions = !showFilterOptions;
});
},
)
),
Expanded(
child: PaginatedStockLocationList(
@ -335,13 +375,11 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
// Construct the "stock" panel
List<Widget> stockTiles() {
Map<String, String> filters = {
"location": location?.pk.toString() ?? "null",
};
return [
locationDescriptionCard(includeActions: false),
ListTile(
title: Text(
L10().stock,
@ -365,115 +403,4 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
)
];
}
List<Widget> actionTiles() {
List<Widget> tiles = [];
tiles.add(locationDescriptionCard(includeActions: false));
if (api.checkPermission("stock", "add")) {
tiles.add(
ListTile(
title: Text(L10().locationCreate),
subtitle: Text(L10().locationCreateDetail),
leading: FaIcon(FontAwesomeIcons.sitemap, color: COLOR_CLICK),
trailing: FaIcon(FontAwesomeIcons.circlePlus, color: COLOR_CLICK),
onTap: () async {
_newLocation(context);
},
)
);
tiles.add(
ListTile(
title: Text(L10().stockItemCreate),
subtitle: Text(L10().stockItemCreateDetail),
leading: FaIcon(FontAwesomeIcons.boxesStacked, color: COLOR_CLICK),
trailing: FaIcon(FontAwesomeIcons.circlePlus, color: COLOR_CLICK),
onTap: () async {
_newStockItem(context);
},
)
);
}
if (location != null) {
// Scan stock item into location
if (api.checkPermission("stock", "change")) {
tiles.add(
ListTile(
title: Text(L10().barcodeScanItem),
subtitle: Text(L10().barcodeScanInItems),
leading: FaIcon(FontAwesomeIcons.rightLeft, color: COLOR_CLICK),
trailing: Icon(Icons.qr_code, color: COLOR_CLICK),
onTap: () {
var _loc = location;
if (_loc != null) {
Navigator.push(
context,
MaterialPageRoute(builder: (context) =>
InvenTreeQRView(
StockLocationScanInItemsHandler(_loc)))
).then((value) {
refresh(context);
});
}
},
)
);
// Scan this location into another one
if (api.checkPermission("stock_location", "change")) {
tiles.add(
ListTile(
title: Text(L10().transferStockLocation),
subtitle: Text(L10().transferStockLocationDetail),
leading: FaIcon(FontAwesomeIcons.rightToBracket, color: COLOR_CLICK),
trailing: Icon(Icons.qr_code, color: COLOR_CLICK),
onTap: () {
var _loc = location;
if (_loc != null) {
Navigator.push(
context,
MaterialPageRoute(builder: (context) =>
InvenTreeQRView(
ScanParentLocationHandler(_loc)))
).then((value) {
refresh(context);
});
}
}
)
);
}
if (api.supportModernBarcodes) {
tiles.add(
customBarcodeActionTile(context, this, location!.customBarcode, "stocklocation", location!.pk)
);
}
}
}
if (tiles.length <= 1) {
tiles.add(
ListTile(
title: Text(
L10().actionsNone,
style: TextStyle(
fontStyle: FontStyle.italic
),
)
)
);
}
return tiles;
}
}