2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-04-28 05:26:47 +00:00
inventree-app/lib/widget/stock_item_history.dart
Oliver a8f87e2f5a
UX Overhaul (#300)
* 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
2023-04-08 23:59:11 +10:00

75 lines
1.7 KiB
Dart

import "package:flutter/material.dart";
import "package:inventree/widget/refreshable_state.dart";
import "package:inventree/l10.dart";
import "package:inventree/inventree/stock.dart";
import "package:inventree/inventree/model.dart";
class StockItemHistoryWidget extends StatefulWidget {
const StockItemHistoryWidget(this.item, {Key? key}) : super(key: key);
final InvenTreeStockItem item;
@override
_StockItemHistoryDisplayState createState() => _StockItemHistoryDisplayState(item);
}
class _StockItemHistoryDisplayState extends RefreshableState<StockItemHistoryWidget> {
_StockItemHistoryDisplayState(this.item);
final InvenTreeStockItem item;
@override
String getAppBarTitle() => L10().stockItemHistory;
List<InvenTreeStockItemHistory> history = [];
@override
Future<void> request(BuildContext refresh) async {
history.clear();
InvenTreeStockItemHistory().list(filters: {"item": "${item.pk}"}).then((List<InvenTreeModel> results) {
for (var result in results) {
if (result is InvenTreeStockItemHistory) {
history.add(result);
}
}
// Refresh
setState(() {
});
});
}
@override
Widget getBody(BuildContext context) {
return ListView(
children: ListTile.divideTiles(
context: context,
tiles: historyList(),
).toList()
);
}
List<Widget> historyList() {
List<Widget> tiles = [];
for (var entry in history) {
tiles.add(
ListTile(
leading: Text(entry.dateString),
trailing: entry.quantityString.isNotEmpty ? Text(entry.quantityString) : null,
title: Text(entry.label),
subtitle: entry.notes.isNotEmpty ? Text(entry.notes) : null,
)
);
}
return tiles;
}
}