Skip to content

Commit

Permalink
Support for multiplication operation in score entering dialog.
Browse files Browse the repository at this point in the history
Updated minimum SDK version to support audio input in future.
  • Loading branch information
zmej-serow committed May 27, 2020
1 parent 0fca9b8 commit 29206e8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Weekend project: a score counter (leaderboard) for games like Scrabble, written

- easy to use, native interface;

- you can ask program to multiply numbers for you, i.e. `3*18` will result in `54`.

- ability to add or remove players during the game;

- intrigues players till the end: final score isn't displayed until you explicitly want it.
Expand All @@ -29,3 +31,6 @@ Weekend project: a score counter (leaderboard) for games like Scrabble, written

### 1.0.0:
- persistent players and scores.

### 1.1.0:
- added math to input parsing.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.proprepress.eleven"
minSdkVersion 16
minSdkVersion 21
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down
8 changes: 6 additions & 2 deletions lib/tabs/game_tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ class ScoresState extends State<Scores> {
}
}

int parseInput(input) {
return input.split("*").fold(1, (a, b) => a * (int.tryParse(b) ?? 1));
}

Widget scoreDialog(BuildContext context, int score) {
String dialogText = score == null ? "Enter score" : "Edit score";
TextEditingController initialValue = score == null ? null : TextEditingController(text: score.toString());
Expand All @@ -115,9 +119,9 @@ class ScoresState extends State<Scores> {
controller: initialValue,
autofocus: true,
keyboardType: TextInputType.phone,
inputFormatters: [WhitelistingTextInputFormatter.digitsOnly],
inputFormatters: [WhitelistingTextInputFormatter(RegExp(r"\d|\*"))],
decoration: InputDecoration(),
onSubmitted: (s) => Navigator.of(context).pop(int.tryParse(s))
onSubmitted: (input) => Navigator.of(context).pop(parseInput(input))
),
actions: [
FlatButton(
Expand Down

0 comments on commit 29206e8

Please sign in to comment.