mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-10-30 06:56:10 +00:00
Events
This commit is contained in:
parent
025077bee7
commit
60d83137be
7 changed files with 421 additions and 308 deletions
|
|
@ -1,40 +0,0 @@
|
||||||
import 'package:aidedejeu_flutter/models/items.dart';
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
class RangeFilter extends StatefulWidget {
|
|
||||||
Filter filter;
|
|
||||||
|
|
||||||
RangeFilter({@required this.filter});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<StatefulWidget> createState() {
|
|
||||||
// TODO: implement createState
|
|
||||||
return _RangeFilter(filter: filter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _RangeFilter extends State<RangeFilter> {
|
|
||||||
Filter filter;
|
|
||||||
RangeValues rangeValues;
|
|
||||||
_RangeFilter({@required this.filter}) {
|
|
||||||
rangeValues = RangeValues(0, filter.values.length.toDouble() - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
|
|
||||||
return RangeSlider(
|
|
||||||
min: 0,
|
|
||||||
max: filter.values.length.toDouble() - 1,
|
|
||||||
divisions: filter.values.length,
|
|
||||||
labels: RangeLabels(
|
|
||||||
'${filter.values[rangeValues.start.round()]}', '${filter.values[rangeValues.end.round()]}'),
|
|
||||||
values: rangeValues ?? RangeValues(0, filter.values.length.toDouble() - 1),
|
|
||||||
onChanged: (RangeValues values) {
|
|
||||||
setState(() {
|
|
||||||
rangeValues = values;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,10 +1,5 @@
|
||||||
import 'package:aidedejeu_flutter/database.dart';
|
import 'package:aidedejeu_flutter/widgets/homepage.dart';
|
||||||
import 'package:aidedejeu_flutter/filterWidgets.dart';
|
|
||||||
import 'package:aidedejeu_flutter/models/items.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:flutter_markdown/flutter_markdown.dart';
|
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
|
||||||
|
|
||||||
void main() => runApp(MyApp());
|
void main() => runApp(MyApp());
|
||||||
|
|
||||||
|
|
@ -21,263 +16,3 @@ class MyApp extends StatelessWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyHomePage extends StatefulWidget {
|
|
||||||
MyHomePage({Key key, @required this.id}) : super(key: key);
|
|
||||||
|
|
||||||
final String id;
|
|
||||||
|
|
||||||
@override
|
|
||||||
_MyHomePageState createState() => _MyHomePageState(id: this.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
class _MyHomePageState extends State<MyHomePage> {
|
|
||||||
_MyHomePageState({@required this.id});
|
|
||||||
|
|
||||||
final String id;
|
|
||||||
|
|
||||||
void setItem(Item item) {
|
|
||||||
setState(() {
|
|
||||||
this.item = item;
|
|
||||||
this.markdown =
|
|
||||||
item.Markdown.replaceAllMapped(RegExp(r'<!--.*?-->'), (match) {
|
|
||||||
return '';
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
String markdown = "";
|
|
||||||
Item item = null;
|
|
||||||
MarkdownStyleSheet styleSheet;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
|
|
||||||
ThemeData theme = ThemeData(
|
|
||||||
brightness: Brightness.light,
|
|
||||||
primaryColor: Colors.lightBlue[800],
|
|
||||||
accentColor: Colors.cyan[600],
|
|
||||||
fontFamily: 'LinuxLibertine',
|
|
||||||
textTheme: TextTheme(
|
|
||||||
headline: TextStyle(fontSize: 28.0, fontWeight: FontWeight.bold),
|
|
||||||
title: TextStyle(fontSize: 22.0, fontStyle: FontStyle.italic),
|
|
||||||
body1: TextStyle(fontSize: 16.0, fontFamily: 'Hind'),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
styleSheet = MarkdownStyleSheet.fromTheme(theme).copyWith(
|
|
||||||
tableColumnWidth: IntrinsicColumnWidth(),
|
|
||||||
tableCellsPadding: EdgeInsets.all(0.2));
|
|
||||||
|
|
||||||
loadItem().then((item) => setItem(item));
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<Item> loadItem() async {
|
|
||||||
var item = await getItemWithId(this.id);
|
|
||||||
var items = await loadChildrenItems(item);
|
|
||||||
//setItem(item);
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget buildMarkdown(BuildContext context) {
|
|
||||||
return Markdown(
|
|
||||||
data: markdown,
|
|
||||||
styleSheet: styleSheet,
|
|
||||||
onTapLink: (link) => Navigator.push(
|
|
||||||
context,
|
|
||||||
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)),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
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)),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget buildLibraryPage() {
|
|
||||||
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]);
|
|
||||||
})
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget buildBookmarksPage() {
|
|
||||||
return Text("Bookmarks");
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget buildSearchPage() {
|
|
||||||
return Text("Search");
|
|
||||||
}
|
|
||||||
|
|
||||||
BottomNavigationBarItem buildBottomNavigationBarItem(
|
|
||||||
String title, String assetName) {
|
|
||||||
return BottomNavigationBarItem(
|
|
||||||
icon: SvgPicture.asset(
|
|
||||||
assetName,
|
|
||||||
height: 30.0,
|
|
||||||
width: 30.0,
|
|
||||||
allowDrawingOutsideViewBox: true,
|
|
||||||
),
|
|
||||||
title: Text(title),
|
|
||||||
activeIcon: SvgPicture.asset(
|
|
||||||
assetName,
|
|
||||||
height: 40.0,
|
|
||||||
width: 40.0,
|
|
||||||
allowDrawingOutsideViewBox: true,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
List buildBottomNavigationBarItems() {
|
|
||||||
return <BottomNavigationBarItem>[
|
|
||||||
buildBottomNavigationBarItem("Bibliothèque", "assets/spell-book.svg"),
|
|
||||||
buildBottomNavigationBarItem("Favoris", "assets/stars-stack.svg"),
|
|
||||||
buildBottomNavigationBarItem("Recherche", "assets/crystal-ball.svg"),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Widget> buildFilterChipList(List<String> choices) {
|
|
||||||
return choices
|
|
||||||
.map((choice) => Padding(
|
|
||||||
padding: const EdgeInsets.all(4.0),
|
|
||||||
child: FilterChip(
|
|
||||||
label: Text(choice),
|
|
||||||
backgroundColor: Colors.transparent,
|
|
||||||
shape: StadiumBorder(side: BorderSide()),
|
|
||||||
onSelected: (bool value) {
|
|
||||||
print("selected");
|
|
||||||
},
|
|
||||||
)))
|
|
||||||
.toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget buildChoiceFilter(Filter filter) {
|
|
||||||
return Wrap(children: buildFilterChipList(filter.values));
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget buildRangeFilter(Filter filter) {
|
|
||||||
/*return RangeSlider(
|
|
||||||
min: 0,
|
|
||||||
max: 1.0 * filter.values.length,
|
|
||||||
divisions: filter.values.length,
|
|
||||||
labels: RangeLabels(
|
|
||||||
'début ${filter.values.first}', 'fin ${filter.values.last}'),
|
|
||||||
values: RangeValues(0, 1.0 * filter.values.length),
|
|
||||||
onChanged: (RangeValues value) {});*/
|
|
||||||
return RangeFilter(filter: filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget buildFilter(Filter filter) {
|
|
||||||
return Column(children: <Widget>[
|
|
||||||
Divider(
|
|
||||||
color: Colors.blueGrey,
|
|
||||||
height: 10.0,
|
|
||||||
),
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.centerLeft,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: Text(filter.name),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
child: filter.type == FilterType.Choices
|
|
||||||
? buildChoiceFilter(filter)
|
|
||||||
: buildRangeFilter(filter))
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Widget> buildFilterList() {
|
|
||||||
return (item as FilteredItems)
|
|
||||||
.toFilterList()
|
|
||||||
.map((filter) => buildFilter(filter))
|
|
||||||
.toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
int indexPage = 0;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
Widget currentPage;
|
|
||||||
switch (indexPage) {
|
|
||||||
case 0:
|
|
||||||
currentPage = buildLibraryPage();
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
currentPage = buildBookmarksPage();
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
currentPage = buildSearchPage();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Scaffold(
|
|
||||||
//appBar: AppBar(
|
|
||||||
// title: Text(widget.id),
|
|
||||||
//),
|
|
||||||
body: currentPage,
|
|
||||||
bottomNavigationBar: BottomNavigationBar(
|
|
||||||
currentIndex: indexPage,
|
|
||||||
onTap: (int index) {
|
|
||||||
setState(() {
|
|
||||||
this.indexPage = index;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
items: buildBottomNavigationBarItems(),
|
|
||||||
),
|
|
||||||
endDrawer: item is FilteredItems
|
|
||||||
? Drawer(
|
|
||||||
child: ListView(
|
|
||||||
// Important: Remove any padding from the ListView.
|
|
||||||
padding: EdgeInsets.zero,
|
|
||||||
children: buildFilterList()),
|
|
||||||
)
|
|
||||||
: null,
|
|
||||||
appBar: AppBar(
|
|
||||||
title: Text(widget.id),
|
|
||||||
actions: item is FilteredItems
|
|
||||||
? [
|
|
||||||
Builder(
|
|
||||||
builder: (context) => IconButton(
|
|
||||||
icon: SvgPicture.asset(
|
|
||||||
"assets/funnel.svg",
|
|
||||||
height: 30.0,
|
|
||||||
width: 30.0,
|
|
||||||
allowDrawingOutsideViewBox: true,
|
|
||||||
), //Icon(Icons.filter),
|
|
||||||
onPressed: () => Scaffold.of(context).openEndDrawer(),
|
|
||||||
tooltip:
|
|
||||||
MaterialLocalizations.of(context).openAppDrawerTooltip,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
: null,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class Item {
|
class Item {
|
||||||
String Id;
|
String Id;
|
||||||
String RootId;
|
String RootId;
|
||||||
|
|
@ -127,7 +129,12 @@ class Filter {
|
||||||
String name;
|
String name;
|
||||||
FilterType type;
|
FilterType type;
|
||||||
List<String> values;
|
List<String> values;
|
||||||
Filter({this.name, this.type, this.values});
|
Set<String> selectedValues = Set<String>();
|
||||||
|
RangeValues rangeValues;
|
||||||
|
|
||||||
|
Filter({this.name, this.type, this.values}) {
|
||||||
|
rangeValues = RangeValues(0, values.length.toDouble() - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MonsterItems extends FilteredItems {
|
class MonsterItems extends FilteredItems {
|
||||||
|
|
|
||||||
115
aidedejeu_flutter/lib/widgets/filterWidgets.dart
Normal file
115
aidedejeu_flutter/lib/widgets/filterWidgets.dart
Normal file
|
|
@ -0,0 +1,115 @@
|
||||||
|
import 'package:aidedejeu_flutter/models/items.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class RangeFilter extends StatefulWidget {
|
||||||
|
final List<String> values;
|
||||||
|
final RangeValues rangeValues;
|
||||||
|
final ValueChanged<RangeValues> updateRangeValues;
|
||||||
|
|
||||||
|
RangeFilter(
|
||||||
|
{@required this.values, this.rangeValues, this.updateRangeValues});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<StatefulWidget> createState() {
|
||||||
|
return _RangeFilterState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _RangeFilterState extends State<RangeFilter> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return RangeSlider(
|
||||||
|
min: 0,
|
||||||
|
max: widget.values.length.toDouble() - 1,
|
||||||
|
divisions: widget.values.length,
|
||||||
|
labels: RangeLabels(
|
||||||
|
'${widget.values[widget.rangeValues.start.round()]}',
|
||||||
|
'${widget.values[widget.rangeValues.end.round()]}'),
|
||||||
|
values: widget.rangeValues,
|
||||||
|
onChanged: (RangeValues values) {
|
||||||
|
setState(() {
|
||||||
|
widget.updateRangeValues(values);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ChipListFilter extends StatefulWidget {
|
||||||
|
final List<String> choices;
|
||||||
|
final Set<String> selectedChoices;
|
||||||
|
final ValueChanged<Set<String>> updateSelectedChoices;
|
||||||
|
|
||||||
|
ChipListFilter({this.choices, this.selectedChoices, this.updateSelectedChoices});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<StatefulWidget> createState() {
|
||||||
|
return _ChipListFilterState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ChipListFilterState extends State<ChipListFilter> {
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Wrap(
|
||||||
|
children: widget.choices
|
||||||
|
.map((choice) => Padding(
|
||||||
|
padding: const EdgeInsets.all(4.0),
|
||||||
|
child: FilterChip(
|
||||||
|
label: Text(choice),
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
shape: StadiumBorder(side: BorderSide()),
|
||||||
|
selected: widget.selectedChoices.contains(choice),
|
||||||
|
onSelected: (bool value) {
|
||||||
|
print("selected");
|
||||||
|
var selectedChoices = widget.selectedChoices.toSet();
|
||||||
|
setState(() {
|
||||||
|
if (value) {
|
||||||
|
selectedChoices.add(choice);
|
||||||
|
} else {
|
||||||
|
selectedChoices.remove(choice);
|
||||||
|
}
|
||||||
|
widget.updateSelectedChoices(selectedChoices);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
)))
|
||||||
|
.toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ChipFilter extends StatefulWidget {
|
||||||
|
final String label;
|
||||||
|
|
||||||
|
ChipFilter({this.label});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<StatefulWidget> createState() {
|
||||||
|
return _ChipFilterState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ChipFilterState extends State<ChipFilter> {
|
||||||
|
bool selected = true;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
// TODO: implement build
|
||||||
|
return FilterChip(
|
||||||
|
label: Text(widget.label),
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
shape: StadiumBorder(side: BorderSide()),
|
||||||
|
selected: selected,
|
||||||
|
onSelected: (bool value) {
|
||||||
|
print("selected");
|
||||||
|
setState(() {
|
||||||
|
this.selected = value;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
259
aidedejeu_flutter/lib/widgets/homepage.dart
Normal file
259
aidedejeu_flutter/lib/widgets/homepage.dart
Normal file
|
|
@ -0,0 +1,259 @@
|
||||||
|
import 'package:aidedejeu_flutter/database.dart';
|
||||||
|
import 'package:aidedejeu_flutter/widgets/filterWidgets.dart';
|
||||||
|
import 'package:aidedejeu_flutter/models/items.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:flutter_markdown/flutter_markdown.dart';
|
||||||
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
|
||||||
|
class MyHomePage extends StatefulWidget {
|
||||||
|
MyHomePage({Key key, @required this.id}) : super(key: key);
|
||||||
|
|
||||||
|
final String id;
|
||||||
|
|
||||||
|
@override
|
||||||
|
_MyHomePageState createState() => _MyHomePageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MyHomePageState extends State<MyHomePage> {
|
||||||
|
void setItem(Item item) {
|
||||||
|
setState(() {
|
||||||
|
this.item = item;
|
||||||
|
if (item is FilteredItems) {
|
||||||
|
this.filters = (item as FilteredItems).toFilterList();
|
||||||
|
} else {
|
||||||
|
this.filters = null;
|
||||||
|
}
|
||||||
|
this.markdown =
|
||||||
|
item.Markdown.replaceAllMapped(RegExp(r'<!--.*?-->'), (match) {
|
||||||
|
return '';
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
String markdown = "";
|
||||||
|
Item item = null;
|
||||||
|
MarkdownStyleSheet styleSheet;
|
||||||
|
List<Filter> filters = null;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
|
||||||
|
ThemeData theme = ThemeData(
|
||||||
|
brightness: Brightness.light,
|
||||||
|
primaryColor: Colors.lightBlue[800],
|
||||||
|
accentColor: Colors.cyan[600],
|
||||||
|
fontFamily: 'LinuxLibertine',
|
||||||
|
textTheme: TextTheme(
|
||||||
|
headline: TextStyle(fontSize: 28.0, fontWeight: FontWeight.bold),
|
||||||
|
title: TextStyle(fontSize: 22.0, fontStyle: FontStyle.italic),
|
||||||
|
body1: TextStyle(fontSize: 16.0, fontFamily: 'Hind'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
styleSheet = MarkdownStyleSheet.fromTheme(theme).copyWith(
|
||||||
|
tableColumnWidth: IntrinsicColumnWidth(),
|
||||||
|
tableCellsPadding: EdgeInsets.all(0.2));
|
||||||
|
|
||||||
|
_loadItem().then((item) => setItem(item));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Item> _loadItem() async {
|
||||||
|
var item = await getItemWithId(this.widget.id);
|
||||||
|
var items = await loadChildrenItems(item);
|
||||||
|
//setItem(item);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildMarkdown(BuildContext context) {
|
||||||
|
return Markdown(
|
||||||
|
data: markdown,
|
||||||
|
styleSheet: styleSheet,
|
||||||
|
onTapLink: (link) => Navigator.push(
|
||||||
|
context,
|
||||||
|
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)),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
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)),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildLibraryPage() {
|
||||||
|
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]);
|
||||||
|
})
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildBookmarksPage() {
|
||||||
|
return Text("Bookmarks");
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildSearchPage() {
|
||||||
|
return Text("Search");
|
||||||
|
}
|
||||||
|
|
||||||
|
BottomNavigationBarItem _buildBottomNavigationBarItem(
|
||||||
|
String title, String assetName) {
|
||||||
|
return BottomNavigationBarItem(
|
||||||
|
icon: SvgPicture.asset(
|
||||||
|
assetName,
|
||||||
|
height: 30.0,
|
||||||
|
width: 30.0,
|
||||||
|
allowDrawingOutsideViewBox: true,
|
||||||
|
),
|
||||||
|
title: Text(title),
|
||||||
|
activeIcon: SvgPicture.asset(
|
||||||
|
assetName,
|
||||||
|
height: 40.0,
|
||||||
|
width: 40.0,
|
||||||
|
allowDrawingOutsideViewBox: true,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
List _buildBottomNavigationBarItems() {
|
||||||
|
return <BottomNavigationBarItem>[
|
||||||
|
_buildBottomNavigationBarItem("Bibliothèque", "assets/spell-book.svg"),
|
||||||
|
_buildBottomNavigationBarItem("Favoris", "assets/stars-stack.svg"),
|
||||||
|
_buildBottomNavigationBarItem("Recherche", "assets/crystal-ball.svg"),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildChoiceFilter(Filter filter) {
|
||||||
|
return ChipListFilter(
|
||||||
|
choices: filter.values,
|
||||||
|
selectedChoices: filter.selectedValues,
|
||||||
|
updateSelectedChoices: (Set<String> choices) {
|
||||||
|
setState(() {
|
||||||
|
filter.selectedValues = choices;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildRangeFilter(Filter filter) {
|
||||||
|
return RangeFilter(
|
||||||
|
values: filter.values,
|
||||||
|
rangeValues: filter.rangeValues,
|
||||||
|
updateRangeValues: (RangeValues values) {
|
||||||
|
setState(() {
|
||||||
|
filter.rangeValues = values;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildFilter(Filter filter) {
|
||||||
|
return Column(children: <Widget>[
|
||||||
|
Divider(
|
||||||
|
color: Colors.blueGrey,
|
||||||
|
height: 10.0,
|
||||||
|
),
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.centerLeft,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Text(filter.name),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
child: filter.type == FilterType.Choices
|
||||||
|
? _buildChoiceFilter(filter)
|
||||||
|
: _buildRangeFilter(filter))
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Widget> _buildFilterList() {
|
||||||
|
return filters.map((filter) => _buildFilter(filter)).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
int indexPage = 0;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
Widget currentPage;
|
||||||
|
switch (indexPage) {
|
||||||
|
case 0:
|
||||||
|
currentPage = _buildLibraryPage();
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
currentPage = _buildBookmarksPage();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
currentPage = _buildSearchPage();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
//appBar: AppBar(
|
||||||
|
// title: Text(widget.id),
|
||||||
|
//),
|
||||||
|
body: currentPage,
|
||||||
|
bottomNavigationBar: BottomNavigationBar(
|
||||||
|
currentIndex: indexPage,
|
||||||
|
onTap: (int index) {
|
||||||
|
setState(() {
|
||||||
|
this.indexPage = index;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
items: _buildBottomNavigationBarItems(),
|
||||||
|
),
|
||||||
|
endDrawer: filters != null
|
||||||
|
? Drawer(
|
||||||
|
child: ListView(
|
||||||
|
// Important: Remove any padding from the ListView.
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
children: _buildFilterList()),
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text(widget.id),
|
||||||
|
actions: filters != null
|
||||||
|
? [
|
||||||
|
Builder(
|
||||||
|
builder: (context) => IconButton(
|
||||||
|
icon: SvgPicture.asset(
|
||||||
|
"assets/funnel.svg",
|
||||||
|
height: 30.0,
|
||||||
|
width: 30.0,
|
||||||
|
allowDrawingOutsideViewBox: true,
|
||||||
|
), //Icon(Icons.filter),
|
||||||
|
onPressed: () => Scaffold.of(context).openEndDrawer(),
|
||||||
|
tooltip:
|
||||||
|
MaterialLocalizations.of(context).openAppDrawerTooltip,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -22,6 +22,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.0"
|
version: "2.4.0"
|
||||||
|
bloc:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: bloc
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "3.0.0"
|
||||||
boolean_selector:
|
boolean_selector:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
@ -69,6 +76,13 @@ packages:
|
||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
flutter_bloc:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: flutter_bloc
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "3.2.0"
|
||||||
flutter_markdown:
|
flutter_markdown:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|
@ -116,6 +130,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.8"
|
version: "1.1.8"
|
||||||
|
nested:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: nested
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.0.4"
|
||||||
path:
|
path:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|
@ -151,6 +172,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.0"
|
version: "2.4.0"
|
||||||
|
provider:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: provider
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "4.0.4"
|
||||||
quiver:
|
quiver:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
@ -158,6 +186,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.5"
|
version: "2.0.5"
|
||||||
|
rxdart:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: rxdart
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.23.1"
|
||||||
sky_engine:
|
sky_engine:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
|
|
@ -242,4 +277,4 @@ packages:
|
||||||
version: "3.5.0"
|
version: "3.5.0"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=2.6.0 <3.0.0"
|
dart: ">=2.6.0 <3.0.0"
|
||||||
flutter: ">=1.10.7 <2.0.0"
|
flutter: ">=1.12.1 <2.0.0"
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,8 @@ dependencies:
|
||||||
sqflite:
|
sqflite:
|
||||||
path:
|
path:
|
||||||
flutter_svg:
|
flutter_svg:
|
||||||
|
bloc:
|
||||||
|
flutter_bloc:
|
||||||
# The following adds the Cupertino Icons font to your application.
|
# The following adds the Cupertino Icons font to your application.
|
||||||
# Use with the CupertinoIcons class for iOS style icons.
|
# Use with the CupertinoIcons class for iOS style icons.
|
||||||
cupertino_icons: ^0.1.2
|
cupertino_icons: ^0.1.2
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue