Add assets and make initial state pretty
This commit is contained in:
parent
657ee00271
commit
51196f7c8c
7 changed files with 116 additions and 46 deletions
BIN
mobile-app/assets/images/heads.png
Normal file
BIN
mobile-app/assets/images/heads.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 49 KiB |
|
@ -24,9 +24,16 @@ class GitHubAdapter extends ChangeNotifier {
|
||||||
|
|
||||||
UnmodifiableListView<WarbandRoaster> get roasters =>
|
UnmodifiableListView<WarbandRoaster> get roasters =>
|
||||||
UnmodifiableListView(_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;
|
return roaster.playerName == _activePlayerName;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void changeActiveRoaster(String playerName) {
|
void changeActiveRoaster(String playerName) {
|
||||||
_activePlayerName = playerName;
|
_activePlayerName = playerName;
|
||||||
|
|
|
@ -8,7 +8,19 @@ class SettingsScreen extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
GitHubAdapter github = Provider.of<GitHubAdapter>(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(
|
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'),
|
||||||
|
)
|
||||||
|
]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,17 +9,36 @@ class WarbandRoasterScreen extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
GitHubAdapter github = Provider.of<GitHubAdapter>(context);
|
GitHubAdapter github = Provider.of<GitHubAdapter>(context);
|
||||||
|
WarbandRoaster roaster = github.activeRoaster();
|
||||||
|
|
||||||
if (github.lastSync == null) {
|
if (roaster == null) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(title: const Text('Toolheim')),
|
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(
|
drawer: Drawer(
|
||||||
child: SingleChildScrollView(child: WarbandDrawerWidget())));
|
child: SingleChildScrollView(child: WarbandDrawerWidget())));
|
||||||
}
|
}
|
||||||
|
|
||||||
WarbandRoaster roaster = github.activeRoaster;
|
|
||||||
|
|
||||||
List<Widget> tiles = new List();
|
List<Widget> tiles = new List();
|
||||||
|
|
||||||
roaster.heros.forEach((hero) {
|
roaster.heros.forEach((hero) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:badges/badges.dart';
|
||||||
import 'package:toolheim/data/github_adapter.dart';
|
import 'package:toolheim/data/github_adapter.dart';
|
||||||
import 'package:toolheim/data/warband_roaster.dart';
|
import 'package:toolheim/data/warband_roaster.dart';
|
||||||
|
|
||||||
|
@ -8,40 +9,57 @@ class WarbandDrawerWidget extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
GitHubAdapter github = Provider.of<GitHubAdapter>(context);
|
GitHubAdapter github = Provider.of<GitHubAdapter>(context);
|
||||||
|
|
||||||
if (github.lastSync == null) {
|
WarbandRoaster activeRoaster = github.activeRoaster();
|
||||||
|
|
||||||
|
if (activeRoaster == null) {
|
||||||
// Add search button
|
// Add search button
|
||||||
return Column(children: <Widget>[
|
return Padding(
|
||||||
Padding(
|
padding: const EdgeInsets.only(top: 100, left: 30, right: 30),
|
||||||
padding: const EdgeInsets.only(top: 50),
|
child: Column(children: <Widget>[
|
||||||
child: RaisedButton(
|
Text(
|
||||||
onPressed: github.search,
|
'There is no repository set up. Please open the settings and provide a valid GitHub repository.'),
|
||||||
child: const Text('Search for warbands')),
|
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<WarbandRoaster> roasters = github.roasters;
|
||||||
|
|
||||||
List<Widget> tiles = new List();
|
List<Widget> tiles = new List();
|
||||||
|
|
||||||
// Show some stats for the own warband
|
// Show some stats for the own warband
|
||||||
tiles.add(UserAccountsDrawerHeader(
|
tiles.add(UserAccountsDrawerHeader(
|
||||||
//otherAccountsPictures: <Widget>[
|
otherAccountsPictures: <Widget>[
|
||||||
// IconButton(
|
IconButton(
|
||||||
// icon: Icon(Icons.refresh),
|
icon: Icon(Icons.refresh),
|
||||||
// color: Colors.white,
|
color: Colors.white,
|
||||||
// highlightColor: Colors.brown,
|
highlightColor: Colors.brown,
|
||||||
// tooltip: 'Refresh warbands',
|
tooltip: 'Refresh warbands',
|
||||||
// onPressed: github.update,
|
onPressed: github.update,
|
||||||
// ),
|
),
|
||||||
// IconButton(
|
IconButton(
|
||||||
// icon: Icon(Icons.search),
|
icon: Icon(Icons.search),
|
||||||
// color: Colors.white,
|
color: Colors.white,
|
||||||
// tooltip: 'Read warbands',
|
tooltip: 'Read warbands',
|
||||||
// onPressed: github.search,
|
onPressed: github.search,
|
||||||
// )
|
),
|
||||||
//],
|
IconButton(
|
||||||
|
icon: Icon(Icons.settings),
|
||||||
|
color: Colors.white,
|
||||||
|
highlightColor: Colors.brown,
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.popAndPushNamed(context, '/settings');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
accountName: Text(activeRoaster.name),
|
accountName: Text(activeRoaster.name),
|
||||||
accountEmail: Text(activeRoaster.race),
|
accountEmail: Text(activeRoaster.race),
|
||||||
));
|
));
|
||||||
|
@ -64,8 +82,14 @@ class WarbandDrawerWidget extends StatelessWidget {
|
||||||
style: TextStyle(color: textColor)),
|
style: TextStyle(color: textColor)),
|
||||||
subtitle: Text(roaster.currentVersion.message),
|
subtitle: Text(roaster.currentVersion.message),
|
||||||
isThreeLine: true,
|
isThreeLine: true,
|
||||||
trailing:
|
trailing: Badge(
|
||||||
Chip(label: Text(roaster.campaignPoints.toString() + ' CP'))));
|
badgeColor: Colors.black12,
|
||||||
|
shape: BadgeShape.square,
|
||||||
|
borderRadius: 2,
|
||||||
|
badgeContent: Text(roaster.campaignPoints.toString() + ' CP',
|
||||||
|
style: TextStyle(color: Colors.white)),
|
||||||
|
),
|
||||||
|
));
|
||||||
});
|
});
|
||||||
|
|
||||||
tiles.add(Divider());
|
tiles.add(Divider());
|
||||||
|
|
|
@ -22,6 +22,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.0"
|
version: "2.1.0"
|
||||||
|
badges:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: badges
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.1.0"
|
||||||
boolean_selector:
|
boolean_selector:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -459,3 +466,4 @@ packages:
|
||||||
version: "2.1.16"
|
version: "2.1.16"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=2.3.0-dev.0.1 <3.0.0"
|
dart: ">=2.3.0-dev.0.1 <3.0.0"
|
||||||
|
flutter: ">=0.2.5 <2.0.0"
|
||||||
|
|
|
@ -23,6 +23,7 @@ dependencies:
|
||||||
checked_yaml:
|
checked_yaml:
|
||||||
http:
|
http:
|
||||||
provider:
|
provider:
|
||||||
|
badges:
|
||||||
|
|
||||||
# The following adds the Cupertino Icons font to your application.
|
# The following adds the Cupertino Icons font to your application.
|
||||||
# Use with the CupertinoIcons class for iOS style icons.
|
# Use with the CupertinoIcons class for iOS style icons.
|
||||||
|
@ -47,9 +48,8 @@ flutter:
|
||||||
uses-material-design: true
|
uses-material-design: true
|
||||||
|
|
||||||
# To add assets to your application, add an assets section, like this:
|
# To add assets to your application, add an assets section, like this:
|
||||||
# assets:
|
assets:
|
||||||
# - images/a_dot_burr.jpeg
|
- assets/images/
|
||||||
# - images/a_dot_ham.jpeg
|
|
||||||
|
|
||||||
# An image asset can refer to one or more resolution-specific "variants", see
|
# An image asset can refer to one or more resolution-specific "variants", see
|
||||||
# https://flutter.dev/assets-and-images/#resolution-aware.
|
# https://flutter.dev/assets-and-images/#resolution-aware.
|
||||||
|
|
Loading…
Reference in a new issue