1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2025-10-29 06:26:02 +00:00

Début filtres

This commit is contained in:
Yan Maniez 2020-02-22 02:43:08 +01:00
parent 033f7ec94a
commit c25cc83ec2
2 changed files with 69 additions and 22 deletions

View file

@ -18,6 +18,7 @@ Future<Database> getDatabaseInstance() async {
var path = join(databasesPath, "library.db");
var exists = await databaseExists(path);
exists = false;
if (!exists) {
print("Creating new copy from asset");
@ -52,7 +53,7 @@ Future<Item> getItemWithId(String id) async {
}
Future<Item> loadChildrenItems(Item item) async {
print("getChildrenItems " + item.ItemType);
print("getChildrenItems " + (item?.ItemType ?? ""));
if (item.ItemType.endsWith("Items")) {
String itemType =
item.ItemType.substring(0, item.ItemType.length - 1);

View file

@ -84,33 +84,29 @@ class _MyHomePageState extends State<MyHomePage> {
styleSheet: styleSheet,
onTapLink: (link) => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => MyHomePage(id: link)
),
MaterialPageRoute(builder: (context) => MyHomePage(id: link)),
),
);
}
Widget buildMarkdownBody(BuildContext context) {
return MarkdownBody(
data: markdown,
styleSheet: styleSheet,
onTapLink: (link) => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => MyHomePage(id: link)
),
MaterialPageRoute(builder: (context) => MyHomePage(id: link)),
),
);
}
Widget buildChildTile(BuildContext context, Item item) {
return ListTile(
title: Text(item.Name),
subtitle: Text(item.AliasText ?? ""),
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => MyHomePage(id: item.Id)
),
MaterialPageRoute(builder: (context) => MyHomePage(id: item.Id)),
),
);
}
@ -119,12 +115,12 @@ class _MyHomePageState extends State<MyHomePage> {
return Stack(
children: <Widget>[
ListView.builder(
itemCount: (item?.Children?.length ?? 0) + 1,
itemBuilder: (BuildContext context, int index) {
return index == 0 ?
buildMarkdownBody(context)
: buildChildTile(context, item.Children[index - 1]);
})
itemCount: (item?.Children?.length ?? 0) + 1,
itemBuilder: (BuildContext context, int index) {
return index == 0
? buildMarkdownBody(context)
: buildChildTile(context, item.Children[index - 1]);
})
],
);
}
@ -137,7 +133,8 @@ class _MyHomePageState extends State<MyHomePage> {
return Text("Search");
}
BottomNavigationBarItem buildBottomNavigationBarItem(String title, String assetName) {
BottomNavigationBarItem buildBottomNavigationBarItem(
String title, String assetName) {
return BottomNavigationBarItem(
icon: SvgPicture.asset(
assetName,
@ -156,8 +153,7 @@ class _MyHomePageState extends State<MyHomePage> {
}
List buildBottomNavigationBarItems() {
return
<BottomNavigationBarItem>[
return <BottomNavigationBarItem>[
buildBottomNavigationBarItem("Bibliothèque", "assets/spell-book.svg"),
buildBottomNavigationBarItem("Favoris", "assets/stars-stack.svg"),
buildBottomNavigationBarItem("Recherche", "assets/crystal-ball.svg"),
@ -169,7 +165,7 @@ class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
Widget currentPage;
switch(indexPage) {
switch (indexPage) {
case 0:
currentPage = buildLibraryPage();
break;
@ -180,6 +176,7 @@ class _MyHomePageState extends State<MyHomePage> {
currentPage = buildSearchPage();
break;
}
return Scaffold(
appBar: AppBar(
title: Text(widget.id),
@ -190,11 +187,60 @@ class _MyHomePageState extends State<MyHomePage> {
onTap: (int index) {
setState(() {
this.indexPage = index;
}
);
});
},
items: buildBottomNavigationBarItems(),
),
endDrawer: Drawer(
child: ListView(
// Important: Remove any padding from the ListView.
padding: EdgeInsets.zero,
children: <Widget>[
DrawerHeader(
child: Text('Drawer Header'),
decoration: BoxDecoration(
color: Colors.blue,
),
),
ListTile(
title: Text('Item 1'),
onTap: () {
// Update the state of the app.
// ...
},
),
ListTile(
title: Text('Item 2'),
onTap: () {
// Update the state of the app.
// ...
},
),
Container(
child: Wrap(
children: <Widget>[
FilterChip(
label: Text("truc"),
backgroundColor: Colors.transparent,
shape: StadiumBorder(side: BorderSide()),
onSelected: (bool value) {
print("selected");
},
),
FilterChip(
label: Text("truc"),
backgroundColor: Colors.transparent,
shape: StadiumBorder(side: BorderSide()),
onSelected: (bool value) {
print("selected");
},
),
],
),
),
],
),
),
);
}
}