mirror of
https://github.com/inventree/inventree-app.git
synced 2025-07-23 05:36:28 +00:00
Format code
This commit is contained in:
lib
api.dartapi_form.dartapp_colors.dart
tasks.pybarcode
barcode.dartcamera_controller.dartcontroller.darthandler.dartpurchase_order.dartsales_order.dartstock.darttones.dartwedge_controller.dart
dsn.darthelpers.dartinventree
bom.dartcompany.dartmodel.dartnotification.dartorders.dartpart.dartproject_code.dartpurchase_order.dartsales_order.dartsentry.dartstatus_codes.dartstock.dart
l10.dartlabels.dartmain.dartpreferences.dartsettings
about.dartapp_settings.dartbarcode_settings.darthome_settings.dartlogin.dartpart_settings.dartpurchase_order_settings.dartrelease.dartsales_order_settings.dartselect_server.dartsettings.dart
user_profile.dartwidget
attachment_widget.dartback.dart
company
company_detail.dartcompany_list.dartmanufacturer_part_detail.dartsupplier_part_detail.dartsupplier_part_list.dart
dialogs.dartdrawer.dartfields.darthome.dartnotes_widget.dartnotifications.dartorder
extra_line_detail.dartpo_extra_line_list.dartpo_line_detail.dartpo_line_list.dartpurchase_order_detail.dartpurchase_order_list.dartsales_order_detail.dartsales_order_list.dartso_extra_line_list.dartso_line_detail.dartso_line_list.dartso_shipment_list.dart
paginator.dartpart
bom_list.dartcategory_display.dartcategory_list.dartpart_detail.dartpart_image_widget.dartpart_list.dartpart_parameter_widget.dartpart_pricing.dartpart_suppliers.dart
progress.dartrefreshable_state.dartsearch.dartsnacks.dartspinner.dartstock
test
@@ -10,12 +10,10 @@ import "package:inventree/widget/back.dart";
|
||||
import "package:inventree/widget/drawer.dart";
|
||||
import "package:inventree/widget/search.dart";
|
||||
|
||||
|
||||
/*
|
||||
* Simple mixin class which defines simple methods for defining widget properties
|
||||
*/
|
||||
mixin BaseWidgetProperties {
|
||||
|
||||
/*
|
||||
* Return a list of appBar actions
|
||||
* By default, no appBar actions are available
|
||||
@@ -23,7 +21,9 @@ mixin BaseWidgetProperties {
|
||||
List<Widget> appBarActions(BuildContext context) => [];
|
||||
|
||||
// Return a title for the appBar (placeholder)
|
||||
String getAppBarTitle() { return "--- app bar ---"; }
|
||||
String getAppBarTitle() {
|
||||
return "--- app bar ---";
|
||||
}
|
||||
|
||||
// Function to construct a drawer (override if needed)
|
||||
Widget getDrawer(BuildContext context) {
|
||||
@@ -38,7 +38,6 @@ mixin BaseWidgetProperties {
|
||||
|
||||
// Function to construct a body
|
||||
Widget getBody(BuildContext context) {
|
||||
|
||||
// Default implementation is to return a ListView
|
||||
// Override getTiles to replace the internal context
|
||||
return ListView(
|
||||
@@ -51,7 +50,6 @@ mixin BaseWidgetProperties {
|
||||
* Construct the top AppBar for this view
|
||||
*/
|
||||
AppBar? buildAppBar(BuildContext context, GlobalKey<ScaffoldState> key) {
|
||||
|
||||
List<Widget> tabs = getTabIcons(context);
|
||||
|
||||
return AppBar(
|
||||
@@ -70,8 +68,8 @@ mixin BaseWidgetProperties {
|
||||
* - Button to access global search
|
||||
* - Button to access barcode scan
|
||||
*/
|
||||
BottomAppBar? buildBottomAppBar(BuildContext context, GlobalKey<ScaffoldState> key) {
|
||||
|
||||
BottomAppBar? buildBottomAppBar(
|
||||
BuildContext context, GlobalKey<ScaffoldState> key) {
|
||||
const double iconSize = 40;
|
||||
|
||||
List<Widget> icons = [
|
||||
@@ -89,12 +87,8 @@ mixin BaseWidgetProperties {
|
||||
iconSize: iconSize,
|
||||
onPressed: () {
|
||||
if (InvenTreeAPI().checkConnection()) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SearchWidget(true)
|
||||
)
|
||||
);
|
||||
Navigator.push(context,
|
||||
MaterialPageRoute(builder: (context) => SearchWidget(true)));
|
||||
}
|
||||
},
|
||||
),
|
||||
@@ -125,9 +119,7 @@ mixin BaseWidgetProperties {
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: icons,
|
||||
)
|
||||
)
|
||||
);
|
||||
)));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -146,7 +138,6 @@ mixin BaseWidgetProperties {
|
||||
* Build out action buttons for a given widget
|
||||
*/
|
||||
Widget? buildSpeedDial(BuildContext context) {
|
||||
|
||||
final actions = actionButtons(context);
|
||||
final barcodeActions = barcodeButtons(context);
|
||||
|
||||
@@ -157,29 +148,25 @@ mixin BaseWidgetProperties {
|
||||
List<Widget> children = [];
|
||||
|
||||
if (barcodeActions.isNotEmpty) {
|
||||
children.add(
|
||||
SpeedDial(
|
||||
icon: Icons.qr_code_scanner,
|
||||
activeIcon: Icons.close,
|
||||
children: barcodeActions,
|
||||
spacing: 14,
|
||||
childPadding: const EdgeInsets.all(5),
|
||||
spaceBetweenChildren: 15,
|
||||
)
|
||||
);
|
||||
children.add(SpeedDial(
|
||||
icon: Icons.qr_code_scanner,
|
||||
activeIcon: Icons.close,
|
||||
children: barcodeActions,
|
||||
spacing: 14,
|
||||
childPadding: const EdgeInsets.all(5),
|
||||
spaceBetweenChildren: 15,
|
||||
));
|
||||
}
|
||||
|
||||
if (actions.isNotEmpty) {
|
||||
children.add(
|
||||
SpeedDial(
|
||||
icon: Icons.more_horiz,
|
||||
activeIcon: Icons.close,
|
||||
children: actions,
|
||||
spacing: 14,
|
||||
childPadding: const EdgeInsets.all(5),
|
||||
spaceBetweenChildren: 15,
|
||||
)
|
||||
);
|
||||
children.add(SpeedDial(
|
||||
icon: Icons.more_horiz,
|
||||
activeIcon: Icons.close,
|
||||
children: actions,
|
||||
spacing: 14,
|
||||
childPadding: const EdgeInsets.all(5),
|
||||
spaceBetweenChildren: 15,
|
||||
));
|
||||
}
|
||||
|
||||
return Wrap(
|
||||
@@ -191,18 +178,16 @@ mixin BaseWidgetProperties {
|
||||
|
||||
// Return list of "tabs" for this widget
|
||||
List<Widget> getTabIcons(BuildContext context) => [];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Abstract base class which provides generic "refresh" functionality.
|
||||
*
|
||||
* - Drag down and release to 'refresh' the widget
|
||||
* - Define some method which runs to 'refresh' the widget state
|
||||
*/
|
||||
abstract class RefreshableState<T extends StatefulWidget> extends State<T> with BaseWidgetProperties {
|
||||
|
||||
abstract class RefreshableState<T extends StatefulWidget> extends State<T>
|
||||
with BaseWidgetProperties {
|
||||
final scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
final refreshKey = GlobalKey<RefreshIndicatorState>();
|
||||
|
||||
@@ -235,7 +220,6 @@ abstract class RefreshableState<T extends StatefulWidget> extends State<T> with
|
||||
|
||||
// Refresh the widget - handler for custom request() method
|
||||
Future<void> refresh(BuildContext context) async {
|
||||
|
||||
// Escape if the widget is no longer loaded
|
||||
if (!mounted) {
|
||||
return;
|
||||
@@ -259,13 +243,14 @@ abstract class RefreshableState<T extends StatefulWidget> extends State<T> with
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
// Save the context for future use
|
||||
_context = context;
|
||||
|
||||
List<Widget> tabs = getTabIcons(context);
|
||||
|
||||
Widget body = tabs.isEmpty ? getBody(context) : TabBarView(children: getTabs(context));
|
||||
Widget body = tabs.isEmpty
|
||||
? getBody(context)
|
||||
: TabBarView(children: getTabs(context));
|
||||
|
||||
Scaffold view = Scaffold(
|
||||
key: scaffoldKey,
|
||||
@@ -274,27 +259,25 @@ abstract class RefreshableState<T extends StatefulWidget> extends State<T> with
|
||||
floatingActionButton: buildSpeedDial(context),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.miniEndDocked,
|
||||
body: RefreshIndicator(
|
||||
key: refreshKey,
|
||||
notificationPredicate: (ScrollNotification notification) {
|
||||
return true;
|
||||
},
|
||||
|
||||
onRefresh: () async {
|
||||
refresh(context);
|
||||
},
|
||||
child: body
|
||||
),
|
||||
key: refreshKey,
|
||||
notificationPredicate: (ScrollNotification notification) {
|
||||
return true;
|
||||
},
|
||||
onRefresh: () async {
|
||||
refresh(context);
|
||||
},
|
||||
child: body),
|
||||
bottomNavigationBar: buildBottomAppBar(context, scaffoldKey),
|
||||
);
|
||||
|
||||
// Default implementation is *not* tabbed
|
||||
if (tabs.isNotEmpty) {
|
||||
return DefaultTabController(
|
||||
length: tabs.length,
|
||||
child: view,
|
||||
length: tabs.length,
|
||||
child: view,
|
||||
);
|
||||
} else {
|
||||
return view;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user