toolheim/mobile-app/lib/widgets/warband_drawer_widget.dart

76 lines
2.2 KiB
Dart
Raw Normal View History

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';
import 'package:toolheim/data/warband_roaster.dart';
class WarbandDrawerWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
GitHubAdapter github = Provider.of<GitHubAdapter>(context);
if (github.lastSync == null) {
// Add search button
2019-07-10 22:28:51 +02:00
return Column(children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 50),
child: RaisedButton(
onPressed: github.search,
child: const Text('Search for warbands')),
)
]);
2019-07-10 14:16:13 +02:00
}
WarbandRoaster activeRoaster = github.activeRoaster;
List<WarbandRoaster> roasters = github.roasters;
List<Widget> tiles = new List();
// Show some stats for the own warband
tiles.add(UserAccountsDrawerHeader(
//otherAccountsPictures: <Widget>[
// IconButton(
// icon: Icon(Icons.refresh),
// color: Colors.white,
// highlightColor: Colors.brown,
// tooltip: 'Refresh warbands',
// onPressed: github.update,
// ),
// IconButton(
// icon: Icon(Icons.search),
// color: Colors.white,
// tooltip: 'Read warbands',
// onPressed: github.search,
// )
//],
accountName: Text(activeRoaster.name),
accountEmail: Text(activeRoaster.race),
));
// TODO: Order Players on CP or rating
roasters.forEach((roaster) {
// We mark inactive warbands with a gray acent
var textColor = Colors.black;
if (!roaster.active) {
textColor = Colors.black45;
}
tiles.add(ListTile(
onTap: () {
github.changeActiveRoaster(roaster.playerName);
Navigator.of(context).pop();
},
title: Text(roaster.name + ' (' + roaster.playerName + ')',
style: TextStyle(color: textColor)),
subtitle: Text(roaster.currentVersion.message),
isThreeLine: true,
trailing:
Chip(label: Text(roaster.campaignPoints.toString() + ' CP'))));
});
tiles.add(Divider());
return Column(children: tiles);
}
}