mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 13:36:50 +00:00
part category display is now refreshable
This commit is contained in:
parent
26c47b5fff
commit
9b14483273
@ -5,6 +5,7 @@ import 'package:InvenTree/preferences.dart';
|
|||||||
|
|
||||||
import 'package:InvenTree/widget/part_detail.dart';
|
import 'package:InvenTree/widget/part_detail.dart';
|
||||||
import 'package:InvenTree/widget/drawer.dart';
|
import 'package:InvenTree/widget/drawer.dart';
|
||||||
|
import 'package:InvenTree/widget/refreshable_state.dart';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
@ -26,11 +27,12 @@ class CategoryDisplayWidget extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class _CategoryDisplayState extends State<CategoryDisplayWidget> {
|
class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
||||||
|
|
||||||
_CategoryDisplayState(this.category) {
|
@override
|
||||||
_requestData();
|
String app_bar_title = "Part Category";
|
||||||
}
|
|
||||||
|
_CategoryDisplayState(this.category) {}
|
||||||
|
|
||||||
// The local InvenTreePartCategory object
|
// The local InvenTreePartCategory object
|
||||||
final InvenTreePartCategory category;
|
final InvenTreePartCategory category;
|
||||||
@ -39,19 +41,11 @@ class _CategoryDisplayState extends State<CategoryDisplayWidget> {
|
|||||||
|
|
||||||
List<InvenTreePart> _parts = List<InvenTreePart>();
|
List<InvenTreePart> _parts = List<InvenTreePart>();
|
||||||
|
|
||||||
String get _titleString {
|
|
||||||
|
|
||||||
if (category == null) {
|
|
||||||
return "Part Categories";
|
|
||||||
} else {
|
|
||||||
return "Part Category - ${category.name}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Request data from the server
|
* Request data from the server
|
||||||
*/
|
*/
|
||||||
void _requestData() {
|
@override
|
||||||
|
Future<void> request(BuildContext context) async {
|
||||||
|
|
||||||
int pk = category?.pk ?? -1;
|
int pk = category?.pk ?? -1;
|
||||||
|
|
||||||
@ -127,74 +121,68 @@ class _CategoryDisplayState extends State<CategoryDisplayWidget> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget getBody(BuildContext context) {
|
||||||
return Scaffold(
|
return ListView(
|
||||||
appBar: AppBar(
|
children: <Widget>[
|
||||||
title: Text(_titleString),
|
getCategoryDescriptionCard(),
|
||||||
),
|
ExpansionPanelList(
|
||||||
drawer: new InvenTreeDrawer(context),
|
expansionCallback: (int index, bool isExpanded) {
|
||||||
body: ListView(
|
setState(() {
|
||||||
children: <Widget>[
|
|
||||||
getCategoryDescriptionCard(),
|
|
||||||
ExpansionPanelList(
|
|
||||||
expansionCallback: (int index, bool isExpanded) {
|
|
||||||
setState(() {
|
|
||||||
|
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0:
|
case 0:
|
||||||
InvenTreePreferences().expandCategoryList = !isExpanded;
|
InvenTreePreferences().expandCategoryList = !isExpanded;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
InvenTreePreferences().expandPartList = !isExpanded;
|
InvenTreePreferences().expandPartList = !isExpanded;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
children: <ExpansionPanel> [
|
||||||
|
ExpansionPanel(
|
||||||
|
headerBuilder: (BuildContext context, bool isExpanded) {
|
||||||
|
return ListTile(
|
||||||
|
title: Text("Subcategories"),
|
||||||
|
leading: FaIcon(FontAwesomeIcons.stream),
|
||||||
|
trailing: Text("${_subcategories.length}"),
|
||||||
|
onTap: () {
|
||||||
|
setState(() {
|
||||||
|
InvenTreePreferences().expandCategoryList = !InvenTreePreferences().expandCategoryList;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onLongPress: () {
|
||||||
|
// TODO - Context menu for e.g. creating a new PartCategory
|
||||||
|
},
|
||||||
|
);
|
||||||
},
|
},
|
||||||
children: <ExpansionPanel> [
|
body: SubcategoryList(_subcategories),
|
||||||
ExpansionPanel(
|
isExpanded: InvenTreePreferences().expandCategoryList && _subcategories.length > 0,
|
||||||
headerBuilder: (BuildContext context, bool isExpanded) {
|
|
||||||
return ListTile(
|
|
||||||
title: Text("Subcategories"),
|
|
||||||
leading: FaIcon(FontAwesomeIcons.stream),
|
|
||||||
trailing: Text("${_subcategories.length}"),
|
|
||||||
onTap: () {
|
|
||||||
setState(() {
|
|
||||||
InvenTreePreferences().expandCategoryList = !InvenTreePreferences().expandCategoryList;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onLongPress: () {
|
|
||||||
// TODO - Context menu for e.g. creating a new PartCategory
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
body: SubcategoryList(_subcategories),
|
|
||||||
isExpanded: InvenTreePreferences().expandCategoryList && _subcategories.length > 0,
|
|
||||||
),
|
|
||||||
ExpansionPanel(
|
|
||||||
headerBuilder: (BuildContext context, bool isExpanded) {
|
|
||||||
return ListTile(
|
|
||||||
title: Text("Parts"),
|
|
||||||
leading: FaIcon(FontAwesomeIcons.shapes),
|
|
||||||
trailing: Text("${_parts.length}"),
|
|
||||||
onTap: () {
|
|
||||||
setState(() {
|
|
||||||
InvenTreePreferences().expandPartList = !InvenTreePreferences().expandPartList;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onLongPress: () {
|
|
||||||
// TODO - Context menu for e.g. creating a new Part
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
body: PartList(_parts),
|
|
||||||
isExpanded: InvenTreePreferences().expandPartList && _parts.length > 0,
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
]
|
ExpansionPanel(
|
||||||
)
|
headerBuilder: (BuildContext context, bool isExpanded) {
|
||||||
|
return ListTile(
|
||||||
|
title: Text("Parts"),
|
||||||
|
leading: FaIcon(FontAwesomeIcons.shapes),
|
||||||
|
trailing: Text("${_parts.length}"),
|
||||||
|
onTap: () {
|
||||||
|
setState(() {
|
||||||
|
InvenTreePreferences().expandPartList = !InvenTreePreferences().expandPartList;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onLongPress: () {
|
||||||
|
// TODO - Context menu for e.g. creating a new Part
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
body: PartList(_parts),
|
||||||
|
isExpanded: InvenTreePreferences().expandPartList && _parts.length > 0,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user