69 lines
2.3 KiB
Dart
69 lines
2.3 KiB
Dart
|
import 'package:flutter/material.dart';
|
||
|
import 'package:provider/provider.dart';
|
||
|
|
||
|
import 'package:toolheim/data/github_adapter.dart';
|
||
|
import 'package:toolheim/data/warband_roaster.dart';
|
||
|
import 'package:toolheim/widgets/warband_drawer_widget.dart';
|
||
|
|
||
|
class WarbandRoasterScreen extends StatelessWidget {
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
GitHubAdapter github = Provider.of<GitHubAdapter>(context);
|
||
|
|
||
|
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,
|
||
|
),
|
||
|
));
|
||
|
}
|
||
|
|
||
|
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];
|
||
|
|
||
|
return ListTile(
|
||
|
title: Text(hero.name),
|
||
|
leading: CircleAvatar(
|
||
|
child: Text(hero.experience.toString()),
|
||
|
backgroundColor: Colors.green,
|
||
|
foregroundColor: Colors.greenAccent,
|
||
|
),
|
||
|
subtitle: Text(hero.type),
|
||
|
);
|
||
|
} else {
|
||
|
var henchmenGroup =
|
||
|
roaster.henchmenGroups[index - roaster.heros.length];
|
||
|
|
||
|
return ListTile(
|
||
|
title: Text(henchmenGroup.name),
|
||
|
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),
|
||
|
);
|
||
|
}
|
||
|
}));
|
||
|
}
|
||
|
}
|