2019-08-07 14:55:33 +02:00
|
|
|
import 'package:badges/badges.dart';
|
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-08-07 14:55:33 +02:00
|
|
|
import 'package:toolheim/widgets/stats_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) {
|
|
|
|
GitHubAdapter github = Provider.of<GitHubAdapter>(context);
|
|
|
|
|
2019-07-30 00:30:39 +02:00
|
|
|
if (github.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-07-10 22:28:51 +02:00
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
2019-07-30 00:30:39 +02:00
|
|
|
title: Text(github.activeRoster.name),
|
2019-07-10 22:28:51 +02:00
|
|
|
),
|
|
|
|
drawer:
|
|
|
|
Drawer(child: SingleChildScrollView(child: WarbandDrawerWidget())),
|
2019-08-02 00:21:41 +02:00
|
|
|
body: SingleChildScrollView(
|
|
|
|
child: Column(children: [
|
|
|
|
for (var hero in github.activeRoster.heros)
|
|
|
|
ListTile(
|
2019-08-07 14:55:33 +02:00
|
|
|
title: Padding(
|
|
|
|
padding: const EdgeInsets.only(bottom: 7),
|
|
|
|
child: Row(children: <Widget>[
|
|
|
|
Text(hero.name,
|
|
|
|
style: TextStyle(
|
|
|
|
fontWeight: hero.rules.contains('Leader')
|
|
|
|
? FontWeight.bold
|
|
|
|
: FontWeight.normal)),
|
|
|
|
Text(
|
|
|
|
'(' + hero.type + ')',
|
|
|
|
style: TextStyle(fontSize: 10),
|
|
|
|
)
|
|
|
|
]),
|
|
|
|
),
|
2019-08-02 00:21:41 +02:00
|
|
|
leading: CircleAvatar(
|
2019-08-07 14:55:33 +02:00
|
|
|
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,
|
2019-08-02 00:21:41 +02:00
|
|
|
),
|
2019-08-07 14:55:33 +02:00
|
|
|
subtitle: StatsWidget(hero.stats),
|
|
|
|
isThreeLine: true,
|
|
|
|
onTap: () {
|
|
|
|
//Navigator.pushNamed(context, '/unit', arguments: hero);
|
|
|
|
},
|
2019-08-02 00:21:41 +02:00
|
|
|
),
|
|
|
|
Divider(),
|
|
|
|
for (var henchmenGroup in github.activeRoster.henchmenGroups)
|
|
|
|
ListTile(
|
2019-08-07 14:55:33 +02:00
|
|
|
title: Padding(
|
|
|
|
padding: const EdgeInsets.only(bottom: 7),
|
|
|
|
child: Row(children: <Widget>[
|
|
|
|
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)),
|
|
|
|
),
|
|
|
|
]),
|
|
|
|
),
|
2019-08-02 00:21:41 +02:00
|
|
|
leading: CircleAvatar(
|
2019-08-07 14:55:33 +02:00
|
|
|
child: Row(children: <Widget>[
|
|
|
|
Spacer(),
|
|
|
|
Text(henchmenGroup.experience.toString(),
|
|
|
|
style: TextStyle(color: Colors.white)),
|
|
|
|
Text(
|
|
|
|
'xp',
|
|
|
|
style: TextStyle(fontSize: 8),
|
|
|
|
),
|
|
|
|
Spacer()
|
|
|
|
]),
|
2019-08-02 00:21:41 +02:00
|
|
|
backgroundColor: Colors.orange,
|
|
|
|
foregroundColor: Colors.white,
|
|
|
|
),
|
2019-08-07 14:55:33 +02:00
|
|
|
subtitle: StatsWidget(henchmenGroup.stats),
|
|
|
|
isThreeLine: true,
|
|
|
|
onTap: () {
|
|
|
|
//Navigator.pushNamed(context, '/unit', arguments: hero);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
Divider()
|
2019-08-02 00:21:41 +02:00
|
|
|
])),
|
2019-07-10 22:28:51 +02:00
|
|
|
);
|
2019-07-10 14:16:13 +02:00
|
|
|
}
|
|
|
|
}
|