Add drawer
This commit is contained in:
parent
46f738775a
commit
35276cf974
2 changed files with 82 additions and 17 deletions
|
@ -67,8 +67,8 @@ class HenchmenGroup extends Unit {
|
|||
var matches = re.allMatches(header).toList().first;
|
||||
|
||||
h['name'] = matches.group(1);
|
||||
h['type'] = matches.group(2);
|
||||
h['number'] = matches.group(3);
|
||||
h['number'] = matches.group(2);
|
||||
h['type'] = matches.group(3);
|
||||
h['experience'] = matches.group(4);
|
||||
|
||||
return h;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import 'dart:collection';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/material.dart' as prefix0;
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:toolheim/WarbandRoaster.dart';
|
||||
import 'package:yaml/yaml.dart';
|
||||
|
@ -28,8 +29,7 @@ class RoasterWidget extends StatefulWidget {
|
|||
class _RoasterWidgetState extends State<RoasterWidget> {
|
||||
Future<WarbandRoaster> roaster;
|
||||
|
||||
static Future<WarbandRoaster> fetchWarband() async {
|
||||
final String urlPath = 'https://raw.githubusercontent.com/Labernator/Mordheim/master/Mordheim-BorderTownBurning/Warband%20Rosters/Aaron/aaron.mordheim.yml';
|
||||
static Future<WarbandRoaster> fetchWarband(urlPath) async {
|
||||
http.Response response = await http.get(urlPath);
|
||||
YamlMap yamlObject = loadYaml(response.body);
|
||||
return WarbandRoaster.fromJson(yamlObject);
|
||||
|
@ -37,7 +37,49 @@ class _RoasterWidgetState extends State<RoasterWidget> {
|
|||
|
||||
void initState() {
|
||||
super.initState();
|
||||
roaster = fetchWarband();
|
||||
roaster = fetchWarband(players()['Aaron']);
|
||||
}
|
||||
|
||||
HashMap players() {
|
||||
HashMap players = new HashMap();
|
||||
players['Aaron'] = 'https://raw.githubusercontent.com/Labernator/Mordheim/master/Mordheim-BorderTownBurning/Warband%20Rosters/Aaron/aaron.mordheim.yml';
|
||||
players['Kai'] = 'https://raw.githubusercontent.com/Labernator/Mordheim/master/Mordheim-BorderTownBurning/Warband%20Rosters/kai/kai.mordheim_post5.yml';
|
||||
players['Fabian'] = 'https://raw.githubusercontent.com/Labernator/Mordheim/master/Mordheim-BorderTownBurning/Warband%20Rosters/Fabian/fabian.mordheim.yml';
|
||||
players['Marius'] = 'https://raw.githubusercontent.com/Labernator/Mordheim/master/Mordheim-BorderTownBurning/Warband%20Rosters/Marius/Marius_Post_5.mordheim.yml';
|
||||
players['Stefan'] = 'https://raw.githubusercontent.com/Labernator/Mordheim/master/Mordheim-BorderTownBurning/Warband%20Rosters/Stefan/Pit%20Fighter.yml';
|
||||
|
||||
return players;
|
||||
}
|
||||
|
||||
List<Widget> playerList() {
|
||||
List<Widget> tiles = new List();
|
||||
|
||||
// Show some stats for the own warband
|
||||
tiles.add(UserAccountsDrawerHeader(
|
||||
accountName: Text('The Revolting Dwarfs'),
|
||||
accountEmail: Text('Dwarf Rangers'),
|
||||
currentAccountPicture: CircleAvatar(
|
||||
child: Text('Aa'),
|
||||
),
|
||||
));
|
||||
|
||||
// TODO: Order Players on CP or rating
|
||||
|
||||
players().forEach((player, url) {
|
||||
tiles.add(ListTile(
|
||||
title: Text(player.toString()),
|
||||
leading: CircleAvatar(
|
||||
child: Text('WB'),
|
||||
),
|
||||
trailing: Chip(
|
||||
label: Text('326 XP')
|
||||
)
|
||||
));
|
||||
});
|
||||
|
||||
tiles.add(Divider());
|
||||
|
||||
return tiles;
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -56,9 +98,16 @@ class _RoasterWidgetState extends State<RoasterWidget> {
|
|||
appBar: AppBar(
|
||||
title: Text(roaster.name),
|
||||
),
|
||||
drawer: Drawer(
|
||||
child: Column(
|
||||
children: this.playerList()
|
||||
),
|
||||
),
|
||||
body: ListView.builder(
|
||||
itemCount: roaster.heros.length,
|
||||
itemCount: roaster.heros.length + roaster.henchmenGroups.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
// TODO: Sort by initiative
|
||||
if (index < roaster.heros.length) {
|
||||
var hero = roaster.heros[index];
|
||||
|
||||
return ListTile(
|
||||
|
@ -70,6 +119,22 @@ class _RoasterWidgetState extends State<RoasterWidget> {
|
|||
),
|
||||
subtitle: Text(hero.type),
|
||||
);
|
||||
} else {
|
||||
var henchmenGroup = roaster.henchmenGroups[index-roaster.heros.length];
|
||||
|
||||
return ListTile(
|
||||
title: Text(henchmenGroup.name),
|
||||
trailing: Chip(
|
||||
label: Text(henchmenGroup.number.toString() + 'x')
|
||||
),
|
||||
leading: CircleAvatar(
|
||||
child: Text(henchmenGroup.experience.toString()),
|
||||
backgroundColor: Colors.orange,
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
subtitle: Text(henchmenGroup.type),
|
||||
);
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue