mirror of
https://github.com/inventree/inventree-app.git
synced 2025-05-08 02:08:55 +00:00
Add beginnings of "page" widget view
This commit is contained in:
parent
e92a05a306
commit
c2e398463f
lib/widget
@ -33,6 +33,8 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
|
||||
InvenTreePart part;
|
||||
|
||||
int _tabIndex = 0;
|
||||
|
||||
@override
|
||||
Future<void> request(BuildContext context) async {
|
||||
await part.reload(context);
|
||||
@ -162,12 +164,56 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
|
||||
}
|
||||
|
||||
void _onTabSelectionChanged(int index) {
|
||||
setState(() {
|
||||
_tabIndex = index;
|
||||
});
|
||||
}
|
||||
|
||||
Widget getSelectedWidget(int index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return Center(
|
||||
child: ListView(
|
||||
children: partTiles(),
|
||||
),
|
||||
);
|
||||
case 1:
|
||||
return Center(
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
ListTile(
|
||||
title: Text("Stock"),
|
||||
subtitle: Text("Stock info goes here!"),
|
||||
)
|
||||
],
|
||||
)
|
||||
);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget getBody(BuildContext context) {
|
||||
return Center(
|
||||
child: ListView(
|
||||
children: partTiles(),
|
||||
),
|
||||
Widget getBottomNavBar(BuildContext context) {
|
||||
return BottomNavigationBar(
|
||||
currentIndex: _tabIndex,
|
||||
onTap: _onTabSelectionChanged,
|
||||
items: const <BottomNavigationBarItem> [
|
||||
BottomNavigationBarItem(
|
||||
icon: FaIcon(FontAwesomeIcons.infoCircle),
|
||||
title: Text("Details"),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: FaIcon(FontAwesomeIcons.boxes),
|
||||
title: Text("Stock"),
|
||||
),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget getBody(BuildContext context) {
|
||||
return getSelectedWidget(_tabIndex);
|
||||
}
|
||||
}
|
@ -46,7 +46,13 @@ abstract class RefreshableState<T extends StatefulWidget> extends State<T> {
|
||||
}
|
||||
|
||||
// Function to construct a body (MUST BE PROVIDED)
|
||||
Widget getBody(BuildContext context);
|
||||
Widget getBody(BuildContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Widget getBottomNavBar(BuildContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -60,7 +66,8 @@ abstract class RefreshableState<T extends StatefulWidget> extends State<T> {
|
||||
body: RefreshIndicator(
|
||||
onRefresh: refresh,
|
||||
child: getBody(context)
|
||||
)
|
||||
),
|
||||
bottomNavigationBar: getBottomNavBar(context),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user