import 'package:badges/badges.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:timeago_flutter/timeago_flutter.dart'; import 'package:toolheim/data/github_adapter.dart'; import 'package:toolheim/widgets/stats_widget.dart'; import 'package:toolheim/widgets/warband_drawer_widget.dart'; class WarbandRosterScreen extends StatelessWidget { @override Widget build(BuildContext context) { GitHubAdapter github = Provider.of(context); if (github.activeRoster == null) { return Scaffold( appBar: AppBar(title: const Text('Toolheim')), body: Builder(builder: (BuildContext context) { return Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( 'assets/images/heads.png', width: 250, ), FlatButton( onPressed: () { Scaffold.of(context).openDrawer(); }, child: Text( 'Select a warband', style: TextStyle(color: Colors.blue), ), ), ]), ); }), drawer: Drawer( child: SingleChildScrollView(child: WarbandDrawerWidget()))); } return Scaffold( appBar: AppBar( title: Text(github.activeRoster.name), ), drawer: Drawer( child: Column(children: [ Expanded(child: SingleChildScrollView(child: WarbandDrawerWidget())), Container( color: Colors.brown, padding: EdgeInsets.all(10), child: Align( alignment: Alignment.bottomLeft, child: Timeago( date: github.lastSync, builder: (_, value) => Text( 'Last sync: ' + value, style: TextStyle(color: Colors.white), )))) ])), body: SingleChildScrollView( child: Column(children: [ for (var hero in github.activeRoster.heros) ListTile( title: Padding( padding: const EdgeInsets.only(bottom: 5), child: Row(children: [ 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: [ 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(), for (var henchmenGroup in github.activeRoster.henchmenGroups) ListTile( title: Padding( padding: const EdgeInsets.only(bottom: 7), child: Row(children: [ 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: [ 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() ])), ); } }