meta information
This commit is contained in:
parent
ceae866d97
commit
b5a5f60618
5 changed files with 228 additions and 110 deletions
|
@ -375,6 +375,18 @@ class WarbandRoster {
|
||||||
return rating;
|
return rating;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int routLimit() {
|
||||||
|
var unitCount = heros.length;
|
||||||
|
henchmenGroups.forEach((group) => unitCount += group.number);
|
||||||
|
|
||||||
|
var routLimit = (unitCount / 4).round();
|
||||||
|
if (unitCount / 4 > routLimit) {
|
||||||
|
routLimit++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return routLimit;
|
||||||
|
}
|
||||||
|
|
||||||
static HashMap<String, String> _warbandNameAndRaceFromJson(
|
static HashMap<String, String> _warbandNameAndRaceFromJson(
|
||||||
String nameAndRace) {
|
String nameAndRace) {
|
||||||
HashMap<String, String> nr = new HashMap();
|
HashMap<String, String> nr = new HashMap();
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
import 'package:badges/badges.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:timeago_flutter/timeago_flutter.dart';
|
import 'package:timeago_flutter/timeago_flutter.dart';
|
||||||
|
|
||||||
import 'package:toolheim/data/github_adapter.dart';
|
import 'package:toolheim/data/github_adapter.dart';
|
||||||
import 'package:toolheim/widgets/stats_widget.dart';
|
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';
|
||||||
import 'package:toolheim/widgets/warband_drawer_widget.dart';
|
import 'package:toolheim/widgets/warband_drawer_widget.dart';
|
||||||
|
|
||||||
class WarbandRosterScreen extends StatelessWidget {
|
class WarbandRosterScreen extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
GitHubAdapter github = Provider.of<GitHubAdapter>(context);
|
if (github(context).activeRoster == null) {
|
||||||
|
|
||||||
if (github.activeRoster == null) {
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(title: const Text('Toolheim')),
|
appBar: AppBar(title: const Text('Toolheim')),
|
||||||
body: Builder(builder: (BuildContext context) {
|
body: Builder(builder: (BuildContext context) {
|
||||||
|
@ -40,11 +40,65 @@ class WarbandRosterScreen extends StatelessWidget {
|
||||||
child: SingleChildScrollView(child: WarbandDrawerWidget())));
|
child: SingleChildScrollView(child: WarbandDrawerWidget())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WarbandRoster roster = github(context).activeRoster;
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
drawer: warbandDrawer(context),
|
||||||
title: Text(github.activeRoster.name),
|
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()),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
drawer: Drawer(
|
),
|
||||||
|
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),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
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>[
|
child: Column(children: <Widget>[
|
||||||
Expanded(child: SingleChildScrollView(child: WarbandDrawerWidget())),
|
Expanded(child: SingleChildScrollView(child: WarbandDrawerWidget())),
|
||||||
Container(
|
Container(
|
||||||
|
@ -53,100 +107,23 @@ class WarbandRosterScreen extends StatelessWidget {
|
||||||
child: Align(
|
child: Align(
|
||||||
alignment: Alignment.bottomLeft,
|
alignment: Alignment.bottomLeft,
|
||||||
child: Timeago(
|
child: Timeago(
|
||||||
date: github.lastSync,
|
date: github(context).lastSync,
|
||||||
builder: (_, value) => Text(
|
builder: (_, value) => Text(
|
||||||
'Last sync: ' + value,
|
'Last sync: ' + value,
|
||||||
style: TextStyle(color: Colors.white),
|
style: TextStyle(color: Colors.white),
|
||||||
))))
|
))))
|
||||||
])),
|
]));
|
||||||
body: SingleChildScrollView(
|
}
|
||||||
child: Column(children: [
|
|
||||||
for (var hero in github.activeRoster.heros)
|
List<Widget> units(WarbandRoster roster) {
|
||||||
ListTile(
|
return [
|
||||||
title: Padding(
|
for (var hero in roster.heros) HeroListTileWidget(hero),
|
||||||
padding: const EdgeInsets.only(bottom: 5),
|
|
||||||
child: Row(children: <Widget>[
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(right: 5),
|
|
||||||
child: Text(hero.name,
|
|
||||||
style: TextStyle(
|
|
||||||
fontWeight: hero.rules.contains('Leader')
|
|
||||||
? FontWeight.bold
|
|
||||||
: FontWeight.normal)),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'(' + hero.type + ')',
|
|
||||||
style: TextStyle(fontSize: 10),
|
|
||||||
)
|
|
||||||
]),
|
|
||||||
),
|
|
||||||
leading: CircleAvatar(
|
|
||||||
child: Row(children: <Widget>[
|
|
||||||
Spacer(),
|
|
||||||
Text(hero.experience.toString(),
|
|
||||||
style: TextStyle(color: Colors.white)),
|
|
||||||
Text(
|
|
||||||
'xp',
|
|
||||||
style: TextStyle(fontSize: 8),
|
|
||||||
),
|
|
||||||
Spacer()
|
|
||||||
]),
|
|
||||||
backgroundColor: hero.hiredSword ? Colors.black : Colors.green,
|
|
||||||
foregroundColor:
|
|
||||||
hero.hiredSword ? Colors.grey : Colors.greenAccent,
|
|
||||||
),
|
|
||||||
subtitle: StatsWidget(hero.stats),
|
|
||||||
isThreeLine: true,
|
|
||||||
onTap: () {
|
|
||||||
//Navigator.pushNamed(context, '/unit', arguments: hero);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Divider(),
|
Divider(),
|
||||||
for (var henchmenGroup in github.activeRoster.henchmenGroups)
|
for (var henchmenGroup in roster.henchmenGroups)
|
||||||
ListTile(
|
HenchmengroupListTileWidget(henchmenGroup),
|
||||||
title: Padding(
|
|
||||||
padding: const EdgeInsets.only(bottom: 7),
|
|
||||||
child: Row(children: <Widget>[
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(right: 5),
|
|
||||||
child: Text(henchmenGroup.name),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'(' + henchmenGroup.type + ')',
|
|
||||||
style: TextStyle(fontSize: 10),
|
|
||||||
),
|
|
||||||
Spacer(),
|
|
||||||
Badge(
|
|
||||||
badgeColor: Colors.black12,
|
|
||||||
shape: BadgeShape.square,
|
|
||||||
borderRadius: 2,
|
|
||||||
badgeContent: Text(henchmenGroup.number.toString() + 'x',
|
|
||||||
style: TextStyle(color: Colors.white)),
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
),
|
|
||||||
leading: CircleAvatar(
|
|
||||||
child: Row(children: <Widget>[
|
|
||||||
Spacer(),
|
|
||||||
Text(henchmenGroup.experience.toString(),
|
|
||||||
style: TextStyle(color: Colors.white)),
|
|
||||||
Text(
|
|
||||||
'xp',
|
|
||||||
style: TextStyle(fontSize: 8),
|
|
||||||
),
|
|
||||||
Spacer()
|
|
||||||
]),
|
|
||||||
backgroundColor: Colors.orange,
|
|
||||||
foregroundColor: Colors.white,
|
|
||||||
),
|
|
||||||
subtitle: StatsWidget(henchmenGroup.stats),
|
|
||||||
isThreeLine: true,
|
|
||||||
onTap: () {
|
|
||||||
//Navigator.pushNamed(context, '/unit', arguments: hero);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Divider()
|
Divider()
|
||||||
])),
|
];
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GitHubAdapter github(context) => Provider.of<GitHubAdapter>(context);
|
||||||
}
|
}
|
||||||
|
|
56
mobile-app/lib/widgets/henchmengroup_list_tile_widget.dart
Normal file
56
mobile-app/lib/widgets/henchmengroup_list_tile_widget.dart
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
import 'package:badges/badges.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:toolheim/widgets/stats_widget.dart';
|
||||||
|
|
||||||
|
class HenchmengroupListTileWidget extends StatelessWidget {
|
||||||
|
final henchmenGroup;
|
||||||
|
|
||||||
|
HenchmengroupListTileWidget(this.henchmenGroup);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ListTile(
|
||||||
|
title: Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 7),
|
||||||
|
child: Row(children: <Widget>[
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 5),
|
||||||
|
child: Text(henchmenGroup.name),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'(' + henchmenGroup.type + ')',
|
||||||
|
style: TextStyle(fontSize: 10),
|
||||||
|
),
|
||||||
|
Spacer(),
|
||||||
|
Badge(
|
||||||
|
badgeColor: Colors.black12,
|
||||||
|
shape: BadgeShape.square,
|
||||||
|
borderRadius: 2,
|
||||||
|
badgeContent: Text(henchmenGroup.number.toString() + 'x',
|
||||||
|
style: TextStyle(color: Colors.white)),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
leading: CircleAvatar(
|
||||||
|
child: Row(children: <Widget>[
|
||||||
|
Spacer(),
|
||||||
|
Text(henchmenGroup.experience.toString(),
|
||||||
|
style: TextStyle(color: Colors.white)),
|
||||||
|
Text(
|
||||||
|
'xp',
|
||||||
|
style: TextStyle(fontSize: 8),
|
||||||
|
),
|
||||||
|
Spacer()
|
||||||
|
]),
|
||||||
|
backgroundColor: Colors.orange,
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
),
|
||||||
|
subtitle: StatsWidget(henchmenGroup.stats),
|
||||||
|
isThreeLine: true,
|
||||||
|
onTap: () {
|
||||||
|
//Navigator.pushNamed(context, '/unit', arguments: hero);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
50
mobile-app/lib/widgets/hero_list_tile_widget.dart
Normal file
50
mobile-app/lib/widgets/hero_list_tile_widget.dart
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:toolheim/widgets/stats_widget.dart';
|
||||||
|
|
||||||
|
class HeroListTileWidget extends StatelessWidget {
|
||||||
|
final hero;
|
||||||
|
|
||||||
|
HeroListTileWidget(this.hero);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ListTile(
|
||||||
|
title: Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 5),
|
||||||
|
child: Row(children: <Widget>[
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 5),
|
||||||
|
child: Text(hero.name,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: hero.rules.contains('Leader')
|
||||||
|
? FontWeight.bold
|
||||||
|
: FontWeight.normal)),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'(' + hero.type + ')',
|
||||||
|
style: TextStyle(fontSize: 10),
|
||||||
|
)
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
leading: CircleAvatar(
|
||||||
|
child: Row(children: <Widget>[
|
||||||
|
Spacer(),
|
||||||
|
Text(hero.experience.toString(),
|
||||||
|
style: TextStyle(color: Colors.white)),
|
||||||
|
Text(
|
||||||
|
'xp',
|
||||||
|
style: TextStyle(fontSize: 8),
|
||||||
|
),
|
||||||
|
Spacer()
|
||||||
|
]),
|
||||||
|
backgroundColor: hero.hiredSword ? Colors.black : Colors.green,
|
||||||
|
foregroundColor: hero.hiredSword ? Colors.grey : Colors.greenAccent,
|
||||||
|
),
|
||||||
|
subtitle: StatsWidget(hero.stats),
|
||||||
|
isThreeLine: true,
|
||||||
|
onTap: () {
|
||||||
|
//Navigator.pushNamed(context, '/unit', arguments: hero);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
23
mobile-app/lib/widgets/value_chip_widget.dart
Normal file
23
mobile-app/lib/widgets/value_chip_widget.dart
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class ValueChipWidget extends StatelessWidget {
|
||||||
|
final String name;
|
||||||
|
final String value;
|
||||||
|
|
||||||
|
ValueChipWidget(this.name, this.value);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Chip(
|
||||||
|
label: Row(children: <Widget>[
|
||||||
|
Text(name.toString() + ': '),
|
||||||
|
Text(
|
||||||
|
value.toString(),
|
||||||
|
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
||||||
|
)
|
||||||
|
])),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue