Skip to content

Commit

Permalink
Merge pull request #6 from chenasraf/develop
Browse files Browse the repository at this point in the history
Version 1.0.9
  • Loading branch information
chenasraf committed Dec 11, 2019
2 parents 01a4f89 + 67a421a commit 589ca3b
Show file tree
Hide file tree
Showing 19 changed files with 592 additions and 229 deletions.
2 changes: 1 addition & 1 deletion .flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"_info":"// This is a generated file; do not edit or check into version control.","dependencyGraph":[{"name":"cloud_firestore","dependencies":["firebase_core"]},{"name":"firebase_auth","dependencies":["firebase_core"]},{"name":"firebase_core","dependencies":[]},{"name":"google_sign_in","dependencies":[]},{"name":"package_info","dependencies":[]},{"name":"screen","dependencies":[]},{"name":"shared_preferences","dependencies":[]},{"name":"url_launcher","dependencies":[]}]}
{"_info":"// This is a generated file; do not edit or check into version control.","dependencyGraph":[{"name":"cloud_firestore","dependencies":["firebase_core"]},{"name":"firebase_auth","dependencies":["firebase_core"]},{"name":"firebase_core","dependencies":[]},{"name":"flutter_keyboard_visibility","dependencies":[]},{"name":"google_sign_in","dependencies":[]},{"name":"package_info","dependencies":[]},{"name":"screen","dependencies":[]},{"name":"shared_preferences","dependencies":[]},{"name":"url_launcher","dependencies":[]}]}
5 changes: 4 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
"name": "Flutter",
"type": "dart",
"request": "launch",
"program": "lib/main.dart"
"program": "lib/main.dart",
"env": {
"CHROME_EXECUTABLE": "brave",
}
}, {
"name": "Flutter (verbose)",
"type": "dart",
Expand Down
54 changes: 31 additions & 23 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build APK",
"type": "shell",
"command": "flutter build apk",
"problemMatcher": []
},
{
"label": "Push APK",
"type": "shell",
"command": "deploy.sh",
"problemMatcher": []
},
{
"label": "Build & Push APK",
"type": "shell",
"command": "deploy.sh -p",
"problemMatcher": []
}
]
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build APK",
"type": "shell",
"command": "./deploy.sh",
"problemMatcher": []
},
{
"label": "Push APK",
"type": "shell",
"command": "./deploy.sh",
"args": ["-p", "-b"],
"problemMatcher": []
},
{
"label": "Build & Push APK",
"type": "shell",
"command": "./deploy.sh",
"args": ["-p"],
"problemMatcher": []
},
{
"label": "Build, Push & Install APK",
"type": "shell",
"command": "./deploy.sh",
"args": ["-p", "-i"],
"problemMatcher": []
}]
}
8 changes: 5 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# CHANGELOG

## 1.0.8+1
* You should now be able to stay logged in for longer without having to choose your account again.
* Bugfixes
## 1.0.9
* Better auth renewal
* Better edit looks view
* Split move/spell creation
* Added spell create/edit screen

## 1.0.8
* Character creation wizard
Expand Down
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ android {

// VERSION
versionCode 30
versionName "1.0.8+1"
versionName "1.0.9"
}

// flavorDimensions "version"
Expand Down
5 changes: 4 additions & 1 deletion lib/redux/stores/prefs_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ class PrefsStore {
if (!store.credentials.isEmpty) {
FirebaseUser user =
await auth.getFirebaseUser(store.credentials.googleCredentials);
if (user == null) await auth.signInWithGoogle();
if (user == null) {
var creds = await auth.signInWithGoogle();
await auth.getFirebaseUser(creds);
}
}
return store;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart' show rootBundle;

capitalize(String string, [String sep = ' ']) {
String capitalize(String string, [String sep = ' ']) {
return string.splitMapJoin(RegExp(sep),
onMatch: (s) =>
s.input[s.start].toUpperCase() +
Expand Down
40 changes: 21 additions & 19 deletions lib/views/battle_view/spell_card.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import 'package:dungeon_paper/components/card_bottom_controls.dart';
import 'package:dungeon_paper/components/confirmation_dialog.dart';
import 'package:dungeon_paper/components/dialogs.dart';
import 'package:dungeon_paper/components/tags/tag_list.dart';
import 'package:dungeon_paper/db/spells.dart';
import 'package:dungeon_paper/views/move_screen/add_spell_screen.dart';
import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';

Expand Down Expand Up @@ -78,26 +80,26 @@ class SpellCardState extends State<SpellCard> {
},
)
],
// onEdit: () => Navigator.push(
// context,
// MaterialPageRoute(
// fullscreenDialog: true,
// builder: (ctx) => EditMoveScreen(
// index: widget.index,
// move: widget.spell,
// mode: DialogMode.Edit,
// ),
// ),
// ),
onEdit: () => Navigator.push(
context,
MaterialPageRoute(
fullscreenDialog: true,
builder: (ctx) => AddSpellScreen(
index: widget.index,
spell: widget.spell,
mode: DialogMode.Edit,
),
),
),
onDelete: () async => await showDialog(
context: context,
builder: (ctx) => ConfirmationDialog(
title: Text('Delete Spell?'),
okButtonText: Text('Delete Spell'),
),
)
? deleteSpell(widget.spell)
: null,
context: context,
builder: (ctx) => ConfirmationDialog(
title: Text('Delete Spell?'),
okButtonText: Text('Delete Spell'),
),
)
? deleteSpell(widget.spell)
: null,
)
: widget.mode == SpellCardMode.Addable
? Padding(
Expand Down
169 changes: 135 additions & 34 deletions lib/views/edit_character/edit_looks.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import '../../components/categorized_list.dart';
import 'package:dungeon_paper/utils.dart';
import 'package:flutter_typeahead/flutter_typeahead.dart';
import '../../components/title_subtitle_row.dart';
import '../../db/character.dart';
import '../../db/character_utils.dart';
Expand Down Expand Up @@ -43,49 +44,118 @@ class ChangeLooksDialog extends StatefulWidget {

class _ChangeLooksDialogState extends State<ChangeLooksDialog> {
List<String> selected;
List<TextEditingController> _controllers;
List<List<String>> looksOptions;

@override
void initState() {
selected = widget.character.looks.isEmpty
? List.generate(widget.character.mainClass.looks.length, (i) => null)
: List.generate(
widget.character.mainClass.looks.length,
(i) => widget.character.looks.length >= i
? widget.character.looks[i]
: null);
looksOptions = widget.character.mainClass.looks;
selected = List.generate(
widget.character.looks.isNotEmpty
? widget.character.looks.length
: looksOptions.length,
(i) => widget.character.looks.isNotEmpty &&
widget.character.looks.length >= i
? widget.character.looks[i]
: null);
_controllers = List.generate(
widget.character.looks.isNotEmpty
? widget.character.looks.length
: looksOptions.length,
(i) => TextEditingController(
text: selected[i] ?? '',
)..addListener(() {
setState(() {
selected[i] = _controllers[i].text;
});
}),
);
super.initState();
}

@override
Widget build(BuildContext context) {
List<List<String>> looksMap = widget.character.mainClass.looks;
Widget child = CategorizedList<int>.builder(
itemCount: (key, i) => looksMap[key].length,
categories: looksMap.asMap().keys,
itemBuilder: (context, looksCat, lookIdxInCat) => Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: TitleSubtitleCard(
color: Theme.of(context).canvasColor.withOpacity(
selected.length > looksCat &&
selected[looksCat] != null &&
selected[looksCat] != looksMap[looksCat][lookIdxInCat]
? 0.7
: 1.0),
title: Text(looksMap[looksCat][lookIdxInCat]),
trailing: selected.length > looksCat &&
selected[looksCat] == looksMap[looksCat][lookIdxInCat]
? Icon(Icons.check)
: null,
onTap: () => setState(() {
if (selected[looksCat] == looksMap[looksCat][lookIdxInCat])
selected[looksCat] = '';
else
selected[looksCat] = looksMap[looksCat][lookIdxInCat];
}),
Widget child = SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
for (var i = 0; i < selected.length; i++)
Card(
child: Padding(
padding:
const EdgeInsets.symmetric(vertical: 8, horizontal: 8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text('Enter a small feature of your appearance.'),
IconButton(
icon: Icon(Icons.delete),
onPressed: () {
_removeRow(i);
}),
],
),
TypeAheadField(
textFieldConfiguration: TextFieldConfiguration(
decoration: InputDecoration(
hintText: looksOptions[i % looksOptions.length]
.take(3)
.join(', ') +
'...',
),
controller: _controllers[i],
textCapitalization: TextCapitalization.words,
),
suggestionsCallback: (term) async => term.isNotEmpty
? (looksOptions.length > i
? looksOptions[i]
: looksOptions
.reduce((all, cur) => [...all, ...cur]))
.where(
(val) => val.toLowerCase().contains(
term.trim().toLowerCase(),
),
)
.map(capitalize)
.toList()
: [],
itemBuilder: (context, val) {
return ListTile(title: Text(val));
},
noItemsFoundBuilder: (context) =>
Container(width: 0, height: 0),
onSuggestionSelected: (val) => _setValue(i, val),
),
],
),
),
),
Center(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Container(
width: 50,
height: 50,
child: FloatingActionButton(
backgroundColor: Theme.of(context).canvasColor,
child: Icon(Icons.add),
onPressed: _addRow,
),
),
),
)
],
),
),
titleBuilder: (context, key, i) => Text('Choose one:'),
);

if (widget.builder != null) {
return widget.builder(
context: context,
Expand All @@ -103,14 +173,45 @@ class _ChangeLooksDialogState extends State<ChangeLooksDialog> {
widget.onSave(widget.character, [CharacterKeys.looks]);
}

void _setValue(int i, String val) {
setState(() {
selected[i] = val;
_controllers[i].text = val;
});
print(selected);
}

void _addRow() {
setState(() {
num i = selected.length;
selected.add('');
_controllers.add(
TextEditingController(text: '')
..addListener(() {
setState(() {
selected[i] = _controllers[i].text;
});
}),
);
});
}

void _removeRow(num i) {
setState(() {
selected.removeAt(i);
_controllers.removeAt(i);
});
}

bool _isValid() {
return true;
// return selected.length == widget.character.mainClass.looks.length &&
// selected.every((s) => s != null && s.isNotEmpty);
}

void _save() {
List<String> filtered = selected.where((s) => s != null && s.isNotEmpty).toList();
List<String> filtered =
selected.where((s) => s != null && s.isNotEmpty).toList();
changeLooks(filtered);
}
}
Expand Down
Loading

0 comments on commit 589ca3b

Please sign in to comment.