2019-07-10 14:16:13 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
import 'package:toolheim/data/github_adapter.dart';
|
2019-07-16 23:37:18 +02:00
|
|
|
import 'package:toolheim/data/warband_roster.dart';
|
2019-07-10 14:16:13 +02:00
|
|
|
import 'package:toolheim/widgets/warband_drawer_widget.dart';
|
|
|
|
|
2019-07-16 23:37:18 +02:00
|
|
|
class WarbandRosterScreen extends StatelessWidget {
|
2019-07-10 14:16:13 +02:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
GitHubAdapter github = Provider.of<GitHubAdapter>(context);
|
2019-07-16 23:37:18 +02:00
|
|
|
WarbandRoster roster = github.activeRoster();
|
2019-07-10 14:16:13 +02:00
|
|
|
|
2019-07-16 23:37:18 +02:00
|
|
|
if (roster == null) {
|
2019-07-10 14:16:13 +02:00
|
|
|
return Scaffold(
|
2019-07-10 22:28:51 +02:00
|
|
|
appBar: AppBar(title: const Text('Toolheim')),
|
2019-07-12 00:30:57 +02:00
|
|
|
body: Builder(builder: (BuildContext context) {
|
|
|
|
return Center(
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: <Widget>[
|
|
|
|
Image.asset(
|
|
|
|
'assets/images/heads.png',
|
|
|
|
width: 250,
|
|
|
|
),
|
|
|
|
FlatButton(
|
|
|
|
onPressed: () {
|
|
|
|
Scaffold.of(context).openDrawer();
|
|
|
|
},
|
|
|
|
child: Text(
|
|
|
|
'Select a warband',
|
|
|
|
style: TextStyle(color: Colors.blue),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
]),
|
|
|
|
);
|
|
|
|
}),
|
2019-07-10 22:28:51 +02:00
|
|
|
drawer: Drawer(
|
|
|
|
child: SingleChildScrollView(child: WarbandDrawerWidget())));
|
2019-07-10 14:16:13 +02:00
|
|
|
}
|
|
|
|
|
2019-07-10 22:28:51 +02:00
|
|
|
List<Widget> tiles = new List();
|
|
|
|
|
2019-07-16 23:37:18 +02:00
|
|
|
roster.heros.forEach((hero) {
|
2019-07-10 22:28:51 +02:00
|
|
|
tiles.add(new ListTile(
|
|
|
|
title: Text(hero.name),
|
|
|
|
leading: CircleAvatar(
|
|
|
|
child: Text(hero.experience.toString()),
|
|
|
|
backgroundColor: Colors.green,
|
|
|
|
foregroundColor: Colors.greenAccent,
|
2019-07-10 14:16:13 +02:00
|
|
|
),
|
2019-07-10 22:28:51 +02:00
|
|
|
subtitle: Text(hero.type),
|
|
|
|
));
|
|
|
|
});
|
2019-07-10 14:16:13 +02:00
|
|
|
|
2019-07-10 22:28:51 +02:00
|
|
|
tiles.add(Divider());
|
2019-07-10 14:16:13 +02:00
|
|
|
|
2019-07-16 23:37:18 +02:00
|
|
|
roster.henchmenGroups.forEach((henchmenGroup) {
|
2019-07-10 22:28:51 +02:00
|
|
|
tiles.add(new 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),
|
|
|
|
));
|
|
|
|
});
|
|
|
|
|
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
2019-07-16 23:37:18 +02:00
|
|
|
title: Text(roster.name),
|
2019-07-10 22:28:51 +02:00
|
|
|
),
|
|
|
|
drawer:
|
|
|
|
Drawer(child: SingleChildScrollView(child: WarbandDrawerWidget())),
|
|
|
|
body: SingleChildScrollView(child: Column(children: tiles)),
|
|
|
|
);
|
2019-07-10 14:16:13 +02:00
|
|
|
}
|
|
|
|
}
|