2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-04-28 05:26:47 +00:00

Add FAB context menu for the StockItem view

- Uses flutter_speed_dial plugin
This commit is contained in:
Oliver Walters 2020-04-08 11:59:39 +10:00
parent 0cc2efe218
commit 5382ded50c
3 changed files with 51 additions and 4 deletions

View File

@ -11,6 +11,7 @@ import 'package:InvenTree/api.dart';
import 'package:InvenTree/widget/drawer.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
class StockDetailWidget extends StatefulWidget {
@ -152,6 +153,43 @@ class _StockItemDisplayState extends State<StockDetailWidget> {
return tiles;
}
/*
* Return a list of context-sensitive action buttons.
* Not all buttons will be avaialable for a given StockItem,
* depending on the properties of that StockItem
*/
List<SpeedDialChild> actionButtons() {
var buttons = List<SpeedDialChild>();
buttons.add(SpeedDialChild(
child: Icon(Icons.add_circle),
label: "Add Stock",
onTap: null,
)
);
buttons.add(SpeedDialChild(
child: Icon(Icons.remove_circle),
label: "Remove Stock",
onTap: null,
),
);
buttons.add(SpeedDialChild(
child: Icon(Icons.check_circle),
label: "Count Stock",
onTap: null,
));
buttons.add(SpeedDialChild(
child: Icon(Icons.location_on),
label: "Transfer Stock",
onTap: null,
));
return buttons;
}
@override
Widget build(BuildContext context) {
return Scaffold(
@ -159,10 +197,11 @@ class _StockItemDisplayState extends State<StockDetailWidget> {
title: Text("Stock Item"),
),
drawer: new InvenTreeDrawer(context),
floatingActionButton: FloatingActionButton(
child: FaIcon(FontAwesomeIcons.ellipsisH),
// TODO: Add pop-up icons
// REF: https://stackoverflow.com/questions/46480221/flutter-floating-action-button-with-speed-dial#46480722
floatingActionButton: SpeedDial(
visible: true,
animatedIcon: AnimatedIcons.menu_close,
heroTag: 'stock-item-fab',
children: actionButtons(),
),
body: Center(
child: ListView(

View File

@ -83,6 +83,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.7.4"
flutter_speed_dial:
dependency: "direct main"
description:
name: flutter_speed_dial
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.5"
flutter_svg:
dependency: transitive
description:

View File

@ -31,6 +31,7 @@ dependencies:
qr_utils: ^0.1.4 # Barcode / QR-code support
package_info: ^0.4.0+16 # App information introspection
font_awesome_flutter: ^8.8.1 # FontAwesome icon set
flutter_speed_dial: ^1.2.5 # FAB menu elements
dev_dependencies:
flutter_test: