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;
|
DateTime _lastSync;
|
||||||
|
|
||||||
List<WarbandRoaster> _roasters = [];
|
List<WarbandRoaster> _roasters = [];
|
||||||
String _activePlayerName = 'Aaron';
|
String _activePlayerName;
|
||||||
|
|
||||||
String get repository => _repository;
|
String get repository => _repository;
|
||||||
String get path => _path;
|
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();
|
_lastSync = DateTime.now();
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,33 +12,18 @@ class WarbandRoasterScreen extends StatelessWidget {
|
||||||
|
|
||||||
if (github.lastSync == null) {
|
if (github.lastSync == null) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(title: Text('Toolheim')),
|
appBar: AppBar(title: const Text('Toolheim')),
|
||||||
body: Center(
|
body: Center(child: const Text('Please select a Warband.')),
|
||||||
child: IconButton(
|
drawer: Drawer(
|
||||||
icon: Icon(Icons.search),
|
child: SingleChildScrollView(child: WarbandDrawerWidget())));
|
||||||
color: Colors.black,
|
|
||||||
tooltip: 'Search for warbands',
|
|
||||||
onPressed: github.search,
|
|
||||||
),
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WarbandRoaster roaster = github.activeRoaster;
|
WarbandRoaster roaster = github.activeRoaster;
|
||||||
|
|
||||||
return Scaffold(
|
List<Widget> tiles = new List();
|
||||||
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];
|
|
||||||
|
|
||||||
return ListTile(
|
roaster.heros.forEach((hero) {
|
||||||
|
tiles.add(new ListTile(
|
||||||
title: Text(hero.name),
|
title: Text(hero.name),
|
||||||
leading: CircleAvatar(
|
leading: CircleAvatar(
|
||||||
child: Text(hero.experience.toString()),
|
child: Text(hero.experience.toString()),
|
||||||
|
@ -46,23 +31,31 @@ class WarbandRoasterScreen extends StatelessWidget {
|
||||||
foregroundColor: Colors.greenAccent,
|
foregroundColor: Colors.greenAccent,
|
||||||
),
|
),
|
||||||
subtitle: Text(hero.type),
|
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),
|
title: Text(henchmenGroup.name),
|
||||||
trailing:
|
trailing: Chip(label: Text(henchmenGroup.number.toString() + 'x')),
|
||||||
Chip(label: Text(henchmenGroup.number.toString() + 'x')),
|
|
||||||
leading: CircleAvatar(
|
leading: CircleAvatar(
|
||||||
child: Text(henchmenGroup.experience.toString()),
|
child: Text(henchmenGroup.experience.toString()),
|
||||||
backgroundColor: Colors.orange,
|
backgroundColor: Colors.orange,
|
||||||
foregroundColor: Colors.white,
|
foregroundColor: Colors.white,
|
||||||
),
|
),
|
||||||
subtitle: Text(henchmenGroup.type),
|
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) {
|
if (github.lastSync == null) {
|
||||||
// Add search button
|
// 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;
|
WarbandRoaster activeRoaster = github.activeRoaster;
|
||||||
|
|
Loading…
Reference in a new issue