2019-07-10 14:16:13 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
2019-08-11 22:36:56 +02:00
|
|
|
import 'package:timeago_flutter/timeago_flutter.dart';
|
2019-07-10 14:16:13 +02:00
|
|
|
|
|
|
|
import 'package:toolheim/data/github_adapter.dart';
|
2019-08-13 22:37:22 +02:00
|
|
|
import 'package:toolheim/data/warband_roster.dart';
|
|
|
|
import 'package:toolheim/widgets/henchmengroup_list_tile_widget.dart';
|
|
|
|
import 'package:toolheim/widgets/hero_list_tile_widget.dart';
|
|
|
|
import 'package:toolheim/widgets/value_chip_widget.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) {
|
2019-08-13 22:37:22 +02:00
|
|
|
if (github(context).activeRoster == 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-08-13 22:37:22 +02:00
|
|
|
WarbandRoster roster = github(context).activeRoster;
|
|
|
|
|
2019-07-10 22:28:51 +02:00
|
|
|
return Scaffold(
|
2019-08-13 22:37:22 +02:00
|
|
|
drawer: warbandDrawer(context),
|
|
|
|
appBar: AppBar(title: Text(roster.name)),
|
|
|
|
body: SingleChildScrollView(
|
|
|
|
child: Column(children: [
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(left: 10),
|
|
|
|
child: Row(
|
|
|
|
children: <Widget>[
|
|
|
|
ValueChipWidget('CP', roster.campaignPoints.toString()),
|
|
|
|
ValueChipWidget('Rating', roster.rating().toString()),
|
|
|
|
ValueChipWidget('Rout Limit', roster.routLimit().toString()),
|
|
|
|
],
|
2019-08-07 14:55:33 +02:00
|
|
|
),
|
2019-08-02 00:21:41 +02:00
|
|
|
),
|
2019-08-13 22:37:22 +02:00
|
|
|
Divider(),
|
|
|
|
...units(roster),
|
|
|
|
warbandMetaInformation(roster)
|
|
|
|
])));
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget warbandMetaInformation(WarbandRoster roster) {
|
|
|
|
return Padding(
|
|
|
|
padding: const EdgeInsets.only(left: 40, right: 40, top: 30),
|
|
|
|
child: Table(
|
|
|
|
columnWidths: {0: FixedColumnWidth(80)},
|
|
|
|
children: <TableRow>[
|
|
|
|
metaTableRow('Alignment', roster.alignment),
|
|
|
|
metaTableRow('Objective', roster.objective),
|
|
|
|
metaTableRow('Achivements', roster.achievments),
|
|
|
|
metaTableRow('Shards', roster.shards),
|
|
|
|
metaTableRow('GC', roster.gc),
|
|
|
|
metaTableRow('Equipment', roster.equipment),
|
|
|
|
],
|
|
|
|
),
|
2019-07-10 22:28:51 +02:00
|
|
|
);
|
2019-07-10 14:16:13 +02:00
|
|
|
}
|
2019-08-13 22:37:22 +02:00
|
|
|
|
|
|
|
TableRow metaTableRow(String name, dynamic value) {
|
|
|
|
return TableRow(children: [
|
|
|
|
Text(
|
|
|
|
name.toString().trim() + ':',
|
|
|
|
style: TextStyle(fontSize: 12),
|
|
|
|
textAlign: TextAlign.right,
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(left: 10, bottom: 10),
|
|
|
|
child: Text(
|
|
|
|
value.toString().trim(),
|
|
|
|
style: TextStyle(fontWeight: FontWeight.bold),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
Drawer warbandDrawer(BuildContext context) {
|
|
|
|
return Drawer(
|
|
|
|
child: Column(children: <Widget>[
|
|
|
|
Expanded(child: SingleChildScrollView(child: WarbandDrawerWidget())),
|
|
|
|
Container(
|
|
|
|
color: Colors.brown,
|
|
|
|
padding: EdgeInsets.all(10),
|
|
|
|
child: Align(
|
|
|
|
alignment: Alignment.bottomLeft,
|
|
|
|
child: Timeago(
|
|
|
|
date: github(context).lastSync,
|
|
|
|
builder: (_, value) => Text(
|
|
|
|
'Last sync: ' + value,
|
|
|
|
style: TextStyle(color: Colors.white),
|
|
|
|
))))
|
|
|
|
]));
|
|
|
|
}
|
|
|
|
|
|
|
|
List<Widget> units(WarbandRoster roster) {
|
|
|
|
return [
|
|
|
|
for (var hero in roster.heros) HeroListTileWidget(hero),
|
|
|
|
Divider(),
|
|
|
|
for (var henchmenGroup in roster.henchmenGroups)
|
|
|
|
HenchmengroupListTileWidget(henchmenGroup),
|
|
|
|
Divider()
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
GitHubAdapter github(context) => Provider.of<GitHubAdapter>(context);
|
2019-07-10 14:16:13 +02:00
|
|
|
}
|