More code cleanup
This commit is contained in:
parent
9ef1b30516
commit
657ee00271
3 changed files with 53 additions and 47 deletions
|
@ -14,7 +14,7 @@ class GitHubAdapter extends ChangeNotifier {
|
|||
DateTime _lastSync;
|
||||
|
||||
List<WarbandRoaster> _roasters = [];
|
||||
String _activePlayerName = 'Aaron';
|
||||
String _activePlayerName;
|
||||
|
||||
String get repository => _repository;
|
||||
String get path => _path;
|
||||
|
@ -155,6 +155,12 @@ class GitHubAdapter extends ChangeNotifier {
|
|||
}
|
||||
}
|
||||
|
||||
// Sort by CP
|
||||
_roasters.sort((a, b) => b.campaignPoints.compareTo(a.campaignPoints));
|
||||
|
||||
// Select first as active player if no active player is selected
|
||||
_activePlayerName = _roasters.first.playerName;
|
||||
|
||||
_lastSync = DateTime.now();
|
||||
notifyListeners();
|
||||
}
|
||||
|
|
|
@ -12,33 +12,18 @@ class WarbandRoasterScreen extends StatelessWidget {
|
|||
|
||||
if (github.lastSync == null) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text('Toolheim')),
|
||||
body: Center(
|
||||
child: IconButton(
|
||||
icon: Icon(Icons.search),
|
||||
color: Colors.black,
|
||||
tooltip: 'Search for warbands',
|
||||
onPressed: github.search,
|
||||
),
|
||||
));
|
||||
appBar: AppBar(title: const Text('Toolheim')),
|
||||
body: Center(child: const Text('Please select a Warband.')),
|
||||
drawer: Drawer(
|
||||
child: SingleChildScrollView(child: WarbandDrawerWidget())));
|
||||
}
|
||||
|
||||
WarbandRoaster roaster = github.activeRoaster;
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(roaster.name),
|
||||
),
|
||||
drawer:
|
||||
Drawer(child: SingleChildScrollView(child: WarbandDrawerWidget())),
|
||||
body: ListView.builder(
|
||||
itemCount: roaster.heros.length + roaster.henchmenGroups.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
// TODO: Sort by initiative
|
||||
if (index < roaster.heros.length) {
|
||||
var hero = roaster.heros[index];
|
||||
List<Widget> tiles = new List();
|
||||
|
||||
return ListTile(
|
||||
roaster.heros.forEach((hero) {
|
||||
tiles.add(new ListTile(
|
||||
title: Text(hero.name),
|
||||
leading: CircleAvatar(
|
||||
child: Text(hero.experience.toString()),
|
||||
|
@ -46,23 +31,31 @@ class WarbandRoasterScreen extends StatelessWidget {
|
|||
foregroundColor: Colors.greenAccent,
|
||||
),
|
||||
subtitle: Text(hero.type),
|
||||
);
|
||||
} else {
|
||||
var henchmenGroup =
|
||||
roaster.henchmenGroups[index - roaster.heros.length];
|
||||
));
|
||||
});
|
||||
|
||||
return ListTile(
|
||||
tiles.add(Divider());
|
||||
|
||||
roaster.henchmenGroups.forEach((henchmenGroup) {
|
||||
tiles.add(new ListTile(
|
||||
title: Text(henchmenGroup.name),
|
||||
trailing:
|
||||
Chip(label: Text(henchmenGroup.number.toString() + 'x')),
|
||||
trailing: Chip(label: Text(henchmenGroup.number.toString() + 'x')),
|
||||
leading: CircleAvatar(
|
||||
child: Text(henchmenGroup.experience.toString()),
|
||||
backgroundColor: Colors.orange,
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
subtitle: Text(henchmenGroup.type),
|
||||
));
|
||||
});
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(roaster.name),
|
||||
),
|
||||
drawer:
|
||||
Drawer(child: SingleChildScrollView(child: WarbandDrawerWidget())),
|
||||
body: SingleChildScrollView(child: Column(children: tiles)),
|
||||
);
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,14 @@ class WarbandDrawerWidget extends StatelessWidget {
|
|||
|
||||
if (github.lastSync == null) {
|
||||
// Add search button
|
||||
return Column(children: <Widget>[]);
|
||||
return Column(children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 50),
|
||||
child: RaisedButton(
|
||||
onPressed: github.search,
|
||||
child: const Text('Search for warbands')),
|
||||
)
|
||||
]);
|
||||
}
|
||||
|
||||
WarbandRoaster activeRoaster = github.activeRoaster;
|
||||
|
|
Loading…
Reference in a new issue