mirror of
https://github.com/inventree/inventree-app.git
synced 2025-07-01 19:30:44 +00:00
Format Code and Add Format Checks to CI (#643)
* Remove unused lib/generated/i18n.dart * Use `fvm dart format .` * Add contributing guidelines * Enforce dart format * Add `dart format off` directive to generated files
This commit is contained in:
@ -1,4 +1,3 @@
|
||||
|
||||
import "package:flutter/material.dart";
|
||||
import "package:flutter_tabler_icons/flutter_tabler_icons.dart";
|
||||
|
||||
@ -14,13 +13,15 @@ import "package:inventree/widget/paginator.dart";
|
||||
import "package:inventree/widget/progress.dart";
|
||||
import "package:inventree/widget/refreshable_state.dart";
|
||||
|
||||
|
||||
/*
|
||||
* Widget for displaying a Bill of Materials for a specified Part instance
|
||||
*/
|
||||
class BillOfMaterialsWidget extends StatefulWidget {
|
||||
|
||||
const BillOfMaterialsWidget(this.part, {this.isParentComponent = true, Key? key}) : super(key: key);
|
||||
const BillOfMaterialsWidget(
|
||||
this.part, {
|
||||
this.isParentComponent = true,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
final InvenTreePart part;
|
||||
|
||||
@ -53,12 +54,11 @@ class _BillOfMaterialsState extends RefreshableState<BillOfMaterialsWidget> {
|
||||
showFilterOptions = !showFilterOptions;
|
||||
});
|
||||
},
|
||||
)
|
||||
),
|
||||
];
|
||||
|
||||
@override
|
||||
Widget getBody(BuildContext context) {
|
||||
|
||||
Map<String, String> filters = {};
|
||||
|
||||
if (widget.isParentComponent) {
|
||||
@ -72,7 +72,11 @@ class _BillOfMaterialsState extends RefreshableState<BillOfMaterialsWidget> {
|
||||
ListTile(
|
||||
leading: InvenTreeAPI().getThumbnail(widget.part.thumbnail),
|
||||
title: Text(widget.part.fullname),
|
||||
subtitle: Text(widget.isParentComponent ? L10().billOfMaterials : L10().usedInDetails),
|
||||
subtitle: Text(
|
||||
widget.isParentComponent
|
||||
? L10().billOfMaterials
|
||||
: L10().usedInDetails,
|
||||
),
|
||||
trailing: Text(L10().quantity),
|
||||
),
|
||||
Divider(thickness: 1.25),
|
||||
@ -87,13 +91,14 @@ class _BillOfMaterialsState extends RefreshableState<BillOfMaterialsWidget> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Create a paginated widget displaying a list of BomItem objects
|
||||
*/
|
||||
class PaginatedBomList extends PaginatedSearchWidget {
|
||||
|
||||
const PaginatedBomList(Map<String, String> filters, {this.isParentPart = true}) : super(filters: filters);
|
||||
const PaginatedBomList(
|
||||
Map<String, String> filters, {
|
||||
this.isParentPart = true,
|
||||
}) : super(filters: filters);
|
||||
|
||||
final bool isParentPart;
|
||||
|
||||
@ -104,9 +109,7 @@ class PaginatedBomList extends PaginatedSearchWidget {
|
||||
_PaginatedBomListState createState() => _PaginatedBomListState();
|
||||
}
|
||||
|
||||
|
||||
class _PaginatedBomListState extends PaginatedSearchState<PaginatedBomList> {
|
||||
|
||||
_PaginatedBomListState() : super();
|
||||
|
||||
@override
|
||||
@ -123,23 +126,31 @@ class _PaginatedBomListState extends PaginatedSearchState<PaginatedBomList> {
|
||||
"sub_part_assembly": {
|
||||
"label": L10().filterAssembly,
|
||||
"help_text": L10().filterAssemblyDetail,
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@override
|
||||
Future<InvenTreePageResponse?> requestPage(int limit, int offset, Map<String, String> params) async {
|
||||
|
||||
final page = await InvenTreeBomItem().listPaginated(limit, offset, filters: params);
|
||||
Future<InvenTreePageResponse?> requestPage(
|
||||
int limit,
|
||||
int offset,
|
||||
Map<String, String> params,
|
||||
) async {
|
||||
final page = await InvenTreeBomItem().listPaginated(
|
||||
limit,
|
||||
offset,
|
||||
filters: params,
|
||||
);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildItem(BuildContext context, InvenTreeModel model) {
|
||||
|
||||
InvenTreeBomItem bomItem = model as InvenTreeBomItem;
|
||||
|
||||
InvenTreePart? subPart = widget.isParentPart ? bomItem.subPart : bomItem.part;
|
||||
InvenTreePart? subPart = widget.isParentPart
|
||||
? bomItem.subPart
|
||||
: bomItem.part;
|
||||
|
||||
String title = subPart?.fullname ?? "error - no name";
|
||||
|
||||
@ -151,16 +162,17 @@ class _PaginatedBomListState extends PaginatedSearchState<PaginatedBomList> {
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
leading: InvenTreeAPI().getThumbnail(subPart?.thumbnail ?? ""),
|
||||
onTap: subPart == null ? null : () async {
|
||||
onTap: subPart == null
|
||||
? null
|
||||
: () async {
|
||||
showLoadingOverlay();
|
||||
var part = await InvenTreePart().get(subPart.pk);
|
||||
hideLoadingOverlay();
|
||||
|
||||
showLoadingOverlay();
|
||||
var part = await InvenTreePart().get(subPart.pk);
|
||||
hideLoadingOverlay();
|
||||
|
||||
if (part is InvenTreePart) {
|
||||
part.goToDetailPage(context);
|
||||
}
|
||||
},
|
||||
if (part is InvenTreePart) {
|
||||
part.goToDetailPage(context);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user