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:
@ -13,9 +13,7 @@ import "package:inventree/widget/progress.dart";
|
||||
import "package:inventree/widget/snacks.dart";
|
||||
import "package:inventree/widget/refreshable_state.dart";
|
||||
|
||||
|
||||
class CategoryDisplayWidget extends StatefulWidget {
|
||||
|
||||
const CategoryDisplayWidget(this.category, {Key? key}) : super(key: key);
|
||||
|
||||
final InvenTreePartCategory? category;
|
||||
@ -24,9 +22,7 @@ class CategoryDisplayWidget extends StatefulWidget {
|
||||
_CategoryDisplayState createState() => _CategoryDisplayState();
|
||||
}
|
||||
|
||||
|
||||
class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
||||
|
||||
_CategoryDisplayState();
|
||||
|
||||
@override
|
||||
@ -40,12 +36,12 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
||||
if (InvenTreePartCategory().canEdit) {
|
||||
actions.add(
|
||||
IconButton(
|
||||
icon: Icon(TablerIcons.edit),
|
||||
icon: Icon(TablerIcons.edit),
|
||||
tooltip: L10().editCategory,
|
||||
onPressed: () {
|
||||
_editCategoryDialog(context);
|
||||
},
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -58,13 +54,13 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
||||
List<SpeedDialChild> actions = [];
|
||||
|
||||
if (InvenTreePart().canCreate) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.box),
|
||||
label: L10().partCreateDetail,
|
||||
onTap: _newPart,
|
||||
)
|
||||
);
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.box),
|
||||
label: L10().partCreateDetail,
|
||||
onTap: _newPart,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (InvenTreePartCategory().canCreate) {
|
||||
@ -74,8 +70,8 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
||||
label: L10().categoryCreateDetail,
|
||||
onTap: () {
|
||||
_newCategory(context);
|
||||
}
|
||||
)
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -91,12 +87,12 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
||||
}
|
||||
|
||||
_cat.editForm(
|
||||
context,
|
||||
L10().editCategory,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().categoryUpdated, success: true);
|
||||
}
|
||||
context,
|
||||
L10().editCategory,
|
||||
onSuccess: (data) async {
|
||||
refresh(context);
|
||||
showSnackIcon(L10().categoryUpdated, success: true);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@ -107,7 +103,6 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
||||
|
||||
@override
|
||||
Future<void> request(BuildContext context) async {
|
||||
|
||||
// Update the category
|
||||
if (widget.category != null) {
|
||||
final bool result = await widget.category?.reload() ?? false;
|
||||
@ -126,79 +121,69 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
||||
title: Text(
|
||||
L10().partCategoryTopLevel,
|
||||
style: TextStyle(fontStyle: FontStyle.italic),
|
||||
)
|
||||
)
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
|
||||
List<Widget> children = [
|
||||
ListTile(
|
||||
title: Text("${widget.category?.name}",
|
||||
style: TextStyle(fontWeight: FontWeight.bold)
|
||||
title: Text(
|
||||
"${widget.category?.name}",
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
subtitle: Text("${widget.category?.description}"),
|
||||
leading: widget.category!.customIcon != null ? Icon(widget.category!.customIcon) : Icon(TablerIcons.sitemap)
|
||||
leading: widget.category!.customIcon != null
|
||||
? Icon(widget.category!.customIcon)
|
||||
: Icon(TablerIcons.sitemap),
|
||||
),
|
||||
];
|
||||
|
||||
if (extra) {
|
||||
children.add(
|
||||
ListTile(
|
||||
title: Text(L10().parentCategory),
|
||||
subtitle: Text("${widget.category?.parentPathString}"),
|
||||
leading: Icon(
|
||||
TablerIcons.arrow_move_up,
|
||||
color: COLOR_ACTION,
|
||||
),
|
||||
onTap: () async {
|
||||
ListTile(
|
||||
title: Text(L10().parentCategory),
|
||||
subtitle: Text("${widget.category?.parentPathString}"),
|
||||
leading: Icon(TablerIcons.arrow_move_up, color: COLOR_ACTION),
|
||||
onTap: () async {
|
||||
int parentId = widget.category?.parentId ?? -1;
|
||||
|
||||
int parentId = widget.category?.parentId ?? -1;
|
||||
if (parentId < 0) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => CategoryDisplayWidget(null),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
showLoadingOverlay();
|
||||
var cat = await InvenTreePartCategory().get(parentId);
|
||||
hideLoadingOverlay();
|
||||
|
||||
if (parentId < 0) {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => CategoryDisplayWidget(null)));
|
||||
} else {
|
||||
|
||||
showLoadingOverlay();
|
||||
var cat = await InvenTreePartCategory().get(parentId);
|
||||
hideLoadingOverlay();
|
||||
|
||||
if (cat is InvenTreePartCategory) {
|
||||
cat.goToDetailPage(context);
|
||||
}
|
||||
if (cat is InvenTreePartCategory) {
|
||||
cat.goToDetailPage(context);
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Card(
|
||||
child: Column(
|
||||
children: children
|
||||
),
|
||||
);
|
||||
return Card(child: Column(children: children));
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
List<Widget> getTabIcons(BuildContext context) {
|
||||
|
||||
return [
|
||||
Tab(text: L10().details),
|
||||
Tab(text: L10().parts),
|
||||
];
|
||||
return [Tab(text: L10().details), Tab(text: L10().parts)];
|
||||
}
|
||||
|
||||
@override
|
||||
List<Widget> getTabs(BuildContext context) {
|
||||
return [
|
||||
Column(children: detailTiles()),
|
||||
Column(children: partsTiles()),
|
||||
];
|
||||
return [Column(children: detailTiles()), Column(children: partsTiles())];
|
||||
}
|
||||
|
||||
// Construct the "details" panel
|
||||
List<Widget> detailTiles() {
|
||||
|
||||
Map<String, String> filters = {};
|
||||
|
||||
int? parent = widget.category?.pk;
|
||||
@ -212,12 +197,9 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
||||
List<Widget> tiles = <Widget>[
|
||||
getCategoryDescriptionCard(),
|
||||
Expanded(
|
||||
child: PaginatedPartCategoryList(
|
||||
filters,
|
||||
title: L10().subcategories,
|
||||
),
|
||||
child: PaginatedPartCategoryList(filters, title: L10().subcategories),
|
||||
flex: 10,
|
||||
)
|
||||
),
|
||||
];
|
||||
|
||||
return tiles;
|
||||
@ -225,31 +207,21 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
||||
|
||||
// Construct the "parts" panel
|
||||
List<Widget> partsTiles() {
|
||||
|
||||
Map<String, String> filters = {
|
||||
"category": widget.category?.pk.toString() ?? "null",
|
||||
};
|
||||
|
||||
return [
|
||||
Expanded(
|
||||
child: PaginatedPartList(filters),
|
||||
flex: 10,
|
||||
)
|
||||
];
|
||||
return [Expanded(child: PaginatedPartList(filters), flex: 10)];
|
||||
}
|
||||
|
||||
Future<void> _newCategory(BuildContext context) async {
|
||||
|
||||
int pk = widget.category?.pk ?? -1;
|
||||
|
||||
InvenTreePartCategory().createForm(
|
||||
context,
|
||||
L10().categoryCreate,
|
||||
data: {
|
||||
"parent": (pk > 0) ? pk : null,
|
||||
},
|
||||
data: {"parent": (pk > 0) ? pk : null},
|
||||
onSuccess: (result) async {
|
||||
|
||||
Map<String, dynamic> data = result as Map<String, dynamic>;
|
||||
|
||||
if (data.containsKey("pk")) {
|
||||
@ -260,29 +232,25 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
||||
} else {
|
||||
refresh(context);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _newPart() async {
|
||||
|
||||
int pk = widget.category?.pk ?? -1;
|
||||
|
||||
InvenTreePart().createForm(
|
||||
context,
|
||||
L10().partCreate,
|
||||
data: {
|
||||
"category": (pk > 0) ? pk : null
|
||||
},
|
||||
data: {"category": (pk > 0) ? pk : null},
|
||||
onSuccess: (result) async {
|
||||
|
||||
Map<String, dynamic> data = result as Map<String, dynamic>;
|
||||
|
||||
if (data.containsKey("pk")) {
|
||||
var part = InvenTreePart.fromJson(data);
|
||||
part.goToDetailPage(context);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user