1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2025-10-29 22:45:44 +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 path = join(databasesPath, "library.db");
var exists = await databaseExists(path); var exists = await databaseExists(path);
exists = false;
if (!exists) { if (!exists) {
print("Creating new copy from asset"); print("Creating new copy from asset");
@ -52,7 +53,7 @@ Future<Item> getItemWithId(String id) async {
} }
Future<Item> loadChildrenItems(Item item) async { Future<Item> loadChildrenItems(Item item) async {
print("getChildrenItems " + item.ItemType); print("getChildrenItems " + (item?.ItemType ?? ""));
if (item.ItemType.endsWith("Items")) { if (item.ItemType.endsWith("Items")) {
String itemType = String itemType =
item.ItemType.substring(0, item.ItemType.length - 1); item.ItemType.substring(0, item.ItemType.length - 1);

View file

@ -84,33 +84,29 @@ class _MyHomePageState extends State<MyHomePage> {
styleSheet: styleSheet, styleSheet: styleSheet,
onTapLink: (link) => Navigator.push( onTapLink: (link) => Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(builder: (context) => MyHomePage(id: link)),
builder: (context) => MyHomePage(id: link)
),
), ),
); );
} }
Widget buildMarkdownBody(BuildContext context) { Widget buildMarkdownBody(BuildContext context) {
return MarkdownBody( return MarkdownBody(
data: markdown, data: markdown,
styleSheet: styleSheet, styleSheet: styleSheet,
onTapLink: (link) => Navigator.push( onTapLink: (link) => Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(builder: (context) => MyHomePage(id: link)),
builder: (context) => MyHomePage(id: link)
),
), ),
); );
} }
Widget buildChildTile(BuildContext context, Item item) { Widget buildChildTile(BuildContext context, Item item) {
return ListTile( return ListTile(
title: Text(item.Name), title: Text(item.Name),
subtitle: Text(item.AliasText ?? ""), subtitle: Text(item.AliasText ?? ""),
onTap: () => Navigator.push( onTap: () => Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(builder: (context) => MyHomePage(id: item.Id)),
builder: (context) => MyHomePage(id: item.Id)
),
), ),
); );
} }
@ -119,12 +115,12 @@ class _MyHomePageState extends State<MyHomePage> {
return Stack( return Stack(
children: <Widget>[ children: <Widget>[
ListView.builder( ListView.builder(
itemCount: (item?.Children?.length ?? 0) + 1, itemCount: (item?.Children?.length ?? 0) + 1,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
return index == 0 ? return index == 0
buildMarkdownBody(context) ? buildMarkdownBody(context)
: buildChildTile(context, item.Children[index - 1]); : buildChildTile(context, item.Children[index - 1]);
}) })
], ],
); );
} }
@ -137,7 +133,8 @@ class _MyHomePageState extends State<MyHomePage> {
return Text("Search"); return Text("Search");
} }
BottomNavigationBarItem buildBottomNavigationBarItem(String title, String assetName) { BottomNavigationBarItem buildBottomNavigationBarItem(
String title, String assetName) {
return BottomNavigationBarItem( return BottomNavigationBarItem(
icon: SvgPicture.asset( icon: SvgPicture.asset(
assetName, assetName,
@ -156,8 +153,7 @@ class _MyHomePageState extends State<MyHomePage> {
} }
List buildBottomNavigationBarItems() { List buildBottomNavigationBarItems() {
return return <BottomNavigationBarItem>[
<BottomNavigationBarItem>[
buildBottomNavigationBarItem("Bibliothèque", "assets/spell-book.svg"), buildBottomNavigationBarItem("Bibliothèque", "assets/spell-book.svg"),
buildBottomNavigationBarItem("Favoris", "assets/stars-stack.svg"), buildBottomNavigationBarItem("Favoris", "assets/stars-stack.svg"),
buildBottomNavigationBarItem("Recherche", "assets/crystal-ball.svg"), buildBottomNavigationBarItem("Recherche", "assets/crystal-ball.svg"),
@ -169,7 +165,7 @@ class _MyHomePageState extends State<MyHomePage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Widget currentPage; Widget currentPage;
switch(indexPage) { switch (indexPage) {
case 0: case 0:
currentPage = buildLibraryPage(); currentPage = buildLibraryPage();
break; break;
@ -180,6 +176,7 @@ class _MyHomePageState extends State<MyHomePage> {
currentPage = buildSearchPage(); currentPage = buildSearchPage();
break; break;
} }
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text(widget.id), title: Text(widget.id),
@ -190,11 +187,60 @@ class _MyHomePageState extends State<MyHomePage> {
onTap: (int index) { onTap: (int index) {
setState(() { setState(() {
this.indexPage = index; this.indexPage = index;
} });
);
}, },
items: buildBottomNavigationBarItems(), 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");
},
),
],
),
),
],
),
),
); );
} }
} }