Add assets and make initial state pretty

This commit is contained in:
Aaron Fischer 2019-07-12 00:30:57 +02:00
parent 657ee00271
commit 51196f7c8c
7 changed files with 116 additions and 46 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

View file

@ -24,9 +24,16 @@ class GitHubAdapter extends ChangeNotifier {
UnmodifiableListView<WarbandRoaster> get roasters =>
UnmodifiableListView(_roasters);
WarbandRoaster get activeRoaster => _roasters.firstWhere((roaster) {
WarbandRoaster activeRoaster() {
if (_activePlayerName == null || _roasters.length == 0) {
return null;
}
return _roasters.firstWhere((roaster) {
return roaster.playerName == _activePlayerName;
});
}
void changeActiveRoaster(String playerName) {
_activePlayerName = playerName;

View file

@ -8,7 +8,19 @@ class SettingsScreen extends StatelessWidget {
Widget build(BuildContext context) {
GitHubAdapter github = Provider.of<GitHubAdapter>(context);
// TODO: Add this to local storage
//String _repository = 'Labernator/Mordheim';
//String _path = 'Mordheim-BorderTownBurning/Warband Rosters';
return Scaffold(
appBar: AppBar(title: Text('Settings')), body: Text(github.repository));
appBar: AppBar(title: Text('Settings')),
body: Column(children: <Widget>[
TextField(
decoration: InputDecoration(labelText: 'Repository'),
),
TextField(
decoration: InputDecoration(labelText: 'Path'),
)
]));
}
}

View file

@ -9,17 +9,36 @@ class WarbandRoasterScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
GitHubAdapter github = Provider.of<GitHubAdapter>(context);
WarbandRoaster roaster = github.activeRoaster();
if (github.lastSync == null) {
if (roaster == null) {
return Scaffold(
appBar: AppBar(title: const Text('Toolheim')),
body: Center(child: const Text('Please select a Warband.')),
body: Builder(builder: (BuildContext context) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
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())));
}
WarbandRoaster roaster = github.activeRoaster;
List<Widget> tiles = new List();
roaster.heros.forEach((hero) {

View file

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:badges/badges.dart';
import 'package:toolheim/data/github_adapter.dart';
import 'package:toolheim/data/warband_roaster.dart';
@ -8,40 +9,57 @@ class WarbandDrawerWidget extends StatelessWidget {
Widget build(BuildContext context) {
GitHubAdapter github = Provider.of<GitHubAdapter>(context);
if (github.lastSync == null) {
WarbandRoaster activeRoaster = github.activeRoaster();
if (activeRoaster == null) {
// Add search button
return Column(children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 50),
child: RaisedButton(
onPressed: github.search,
child: const Text('Search for warbands')),
)
]);
return Padding(
padding: const EdgeInsets.only(top: 100, left: 30, right: 30),
child: Column(children: <Widget>[
Text(
'There is no repository set up. Please open the settings and provide a valid GitHub repository.'),
FlatButton(
onPressed: () {
Navigator.popAndPushNamed(context, '/settings');
},
child: Text(
'Open Settings',
style: TextStyle(color: Colors.blue),
),
),
]),
);
}
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,
// )
//],
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,
),
IconButton(
icon: Icon(Icons.settings),
color: Colors.white,
highlightColor: Colors.brown,
onPressed: () {
Navigator.popAndPushNamed(context, '/settings');
},
),
],
accountName: Text(activeRoaster.name),
accountEmail: Text(activeRoaster.race),
));
@ -64,8 +82,14 @@ class WarbandDrawerWidget extends StatelessWidget {
style: TextStyle(color: textColor)),
subtitle: Text(roaster.currentVersion.message),
isThreeLine: true,
trailing:
Chip(label: Text(roaster.campaignPoints.toString() + ' CP'))));
trailing: Badge(
badgeColor: Colors.black12,
shape: BadgeShape.square,
borderRadius: 2,
badgeContent: Text(roaster.campaignPoints.toString() + ' CP',
style: TextStyle(color: Colors.white)),
),
));
});
tiles.add(Divider());

View file

@ -22,6 +22,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
badges:
dependency: "direct main"
description:
name: badges
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
boolean_selector:
dependency: transitive
description:
@ -459,3 +466,4 @@ packages:
version: "2.1.16"
sdks:
dart: ">=2.3.0-dev.0.1 <3.0.0"
flutter: ">=0.2.5 <2.0.0"

View file

@ -23,6 +23,7 @@ dependencies:
checked_yaml:
http:
provider:
badges:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
@ -47,9 +48,8 @@ flutter:
uses-material-design: true
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
assets:
- assets/images/
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.