Add keygen & change database
@ -25,6 +25,12 @@ apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
|
||||
|
||||
def keystoreProperties = new Properties()
|
||||
def keystorePropertiesFile = rootProject.file('key.properties')
|
||||
if (keystorePropertiesFile.exists()) {
|
||||
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion flutter.compileSdkVersion
|
||||
|
||||
@ -50,13 +56,19 @@ android {
|
||||
versionName flutterVersionName
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
// TODO: Add your own signing config for the release build.
|
||||
// Signing with the debug keys for now, so `flutter run --release` works.
|
||||
signingConfig signingConfigs.debug
|
||||
}
|
||||
}
|
||||
signingConfigs {
|
||||
release {
|
||||
keyAlias keystoreProperties['keyAlias']
|
||||
keyPassword keystoreProperties['keyPassword']
|
||||
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
|
||||
storePassword keystoreProperties['storePassword']
|
||||
}
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
flutter {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.example.wordle">
|
||||
<application
|
||||
android:label="wordle"
|
||||
android:label="Wordle"
|
||||
android:name="${applicationName}"
|
||||
android:icon="@mipmap/ic_launcher">
|
||||
<activity
|
||||
|
||||
BIN
android/app/src/main/res/mipmap-hdpi/ic_launcher.png
Normal file → Executable file
|
Before Width: | Height: | Size: 544 B After Width: | Height: | Size: 2.3 KiB |
BIN
android/app/src/main/res/mipmap-mdpi/ic_launcher.png
Normal file → Executable file
|
Before Width: | Height: | Size: 442 B After Width: | Height: | Size: 2.1 KiB |
BIN
android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Normal file → Executable file
|
Before Width: | Height: | Size: 721 B After Width: | Height: | Size: 2.5 KiB |
BIN
android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Normal file → Executable file
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 4.4 KiB |
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* @Author : Linloir
|
||||
* @Date : 2022-03-05 20:56:05
|
||||
* @LastEditTime : 2022-03-07 09:35:24
|
||||
* @LastEditTime : 2022-03-07 12:03:43
|
||||
* @Description : The display widget of the wordle game
|
||||
*/
|
||||
|
||||
@ -212,6 +212,9 @@ class _WordleDisplayWidgetState extends State<WordleDisplayWidget> with TickerPr
|
||||
c++;
|
||||
});
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if(noti.type == InputType.backSpace) {
|
||||
if(c > 0 && !onAnimation) {
|
||||
|
||||
@ -1,12 +1,10 @@
|
||||
/*
|
||||
* @Author : Linloir
|
||||
* @Date : 2022-03-05 21:50:33
|
||||
* @LastEditTime : 2022-03-05 23:15:18
|
||||
* @LastEditTime : 2022-03-07 10:26:04
|
||||
* @Description : Event bus class
|
||||
*/
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
typedef EventCallBack = void Function(dynamic args);
|
||||
|
||||
final EventBus mainBus = EventBus();
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* @Author : Linloir
|
||||
* @Date : 2022-03-06 15:03:57
|
||||
* @LastEditTime : 2022-03-07 08:34:56
|
||||
* @LastEditTime : 2022-03-07 11:16:16
|
||||
* @Description : Word generator
|
||||
*/
|
||||
|
||||
@ -15,13 +15,13 @@ abstract class Words {
|
||||
static String _cache = "";
|
||||
//static Map<String, String> explainations = {};
|
||||
|
||||
static Future<void> importWordsDatabase({int length = 5}) async {
|
||||
static Future<bool> importWordsDatabase({int length = 5}) async {
|
||||
//explainations.clear();
|
||||
if(length != _length || dataBase.isEmpty){
|
||||
_length = length;
|
||||
dataBase.clear();
|
||||
_cache = "";
|
||||
var data = await rootBundle.loadString('popular.txt');
|
||||
var data = await rootBundle.loadString('assets/popular.txt');
|
||||
// LineSplitter.split(data).forEach((line) {
|
||||
// int seperatePos = line.indexOf(',');
|
||||
// if(seperatePos != length + 2) {
|
||||
@ -38,14 +38,20 @@ abstract class Words {
|
||||
}
|
||||
_cache = line + "s";
|
||||
});
|
||||
print('Imported ${dataBase.length}');
|
||||
}
|
||||
if(dataBase.isEmpty) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static Future<String> generateWord() async{
|
||||
static Future<String?> generateWord() async{
|
||||
int bound = dataBase.length;
|
||||
if(bound == 0) {
|
||||
await Words.importWordsDatabase();
|
||||
var import = await Words.importWordsDatabase();
|
||||
if(!import) {
|
||||
return null;
|
||||
}
|
||||
bound = dataBase.length;
|
||||
}
|
||||
var rng = Random();
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* @Author : Linloir
|
||||
* @Date : 2022-03-05 20:41:41
|
||||
* @LastEditTime : 2022-03-07 09:30:56
|
||||
* @LastEditTime : 2022-03-07 11:05:14
|
||||
* @Description : Offline page
|
||||
*/
|
||||
|
||||
@ -40,8 +40,8 @@ class _OfflinePageState extends State<OfflinePage> with TickerProviderStateMixin
|
||||
actions: [AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 750),
|
||||
reverseDuration: const Duration(milliseconds: 750),
|
||||
switchInCurve: Curves.bounceInOut,
|
||||
switchOutCurve: Curves.bounceInOut,
|
||||
switchInCurve: Curves.bounceOut,
|
||||
switchOutCurve: Curves.bounceIn,
|
||||
transitionBuilder: (child, animation) {
|
||||
var rotateAnimation = Tween<double>(begin: 0, end: 2 * pi).animate(animation);
|
||||
var opacAnimation = Tween<double>(begin: 0, end: 1).animate(animation);
|
||||
|
||||
54
lib/show_dialogs.dart
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* @Author : Linloir
|
||||
* @Date : 2022-03-07 10:28:38
|
||||
* @LastEditTime : 2022-03-07 10:59:46
|
||||
* @Description : Show import failed dialog
|
||||
*/
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
Future<bool?> showFailedDialog({required context}) {
|
||||
return showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Error Occurred'),
|
||||
content: const Text('Something went wrong when importing dictionary, nothing is imported.'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text('Retry'),
|
||||
onPressed: () => Navigator.of(context).pop(true),
|
||||
),
|
||||
TextButton(
|
||||
child: const Text('Ignore'),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Future<bool?> showLoadingDialog({required context}) {
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return UnconstrainedBox(
|
||||
child: SizedBox(
|
||||
width: 280,
|
||||
child: AlertDialog(
|
||||
contentPadding: const EdgeInsets.all(50.0),
|
||||
content: Align(
|
||||
alignment: Alignment.center,
|
||||
child: CircularProgressIndicator(
|
||||
color: Theme.of(context).brightness == Brightness.dark ? Colors.white : Colors.grey[850],
|
||||
strokeWidth: 6.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
barrierDismissible: false,
|
||||
);
|
||||
}
|
||||
@ -1,11 +1,12 @@
|
||||
/*
|
||||
* @Author : Linloir
|
||||
* @Date : 2022-03-05 21:40:51
|
||||
* @LastEditTime : 2022-03-07 08:10:08
|
||||
* @LastEditTime : 2022-03-07 11:15:55
|
||||
* @Description : Validation Provider class
|
||||
*/
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'show_dialogs.dart';
|
||||
import './event_bus.dart';
|
||||
import './generator.dart';
|
||||
|
||||
@ -39,8 +40,22 @@ class _ValidationProviderState extends State<ValidationProvider> {
|
||||
}
|
||||
|
||||
void _newGame() async{
|
||||
answer = await Words.generateWord();
|
||||
print('Generated answer $answer');
|
||||
showLoadingDialog(context: context);
|
||||
var generated = await Words.generateWord();
|
||||
Navigator.of(context).pop();
|
||||
while(generated == null) {
|
||||
var retry = await showFailedDialog(context: context);
|
||||
if(retry == null) {
|
||||
Navigator.of(context).popUntil(ModalRoute.withName('/'));
|
||||
break;
|
||||
}
|
||||
else {
|
||||
showLoadingDialog(context: context);
|
||||
generated = await Words.generateWord();
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
}
|
||||
answer = generated ?? "";
|
||||
answer = answer.toUpperCase();
|
||||
letterMap = {};
|
||||
answer.split('').forEach((c) {
|
||||
@ -95,7 +110,6 @@ class _ValidationProviderState extends State<ValidationProvider> {
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
_newGame();
|
||||
mainBus.onBus(event: "NewGame", onEvent: _onNewGame);
|
||||
mainBus.onBus(event: "Result", onEvent: _onGameEnd);
|
||||
}
|
||||
|
||||
44
pubspec.lock
@ -5,56 +5,56 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: async
|
||||
url: "https://pub.flutter-io.cn"
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.8.2"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: boolean_selector
|
||||
url: "https://pub.flutter-io.cn"
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
characters:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: characters
|
||||
url: "https://pub.flutter-io.cn"
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
charcode:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: charcode
|
||||
url: "https://pub.flutter-io.cn"
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.1"
|
||||
clock:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: clock
|
||||
url: "https://pub.flutter-io.cn"
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
collection:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: collection
|
||||
url: "https://pub.flutter-io.cn"
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.15.0"
|
||||
cupertino_icons:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: cupertino_icons
|
||||
url: "https://pub.flutter-io.cn"
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.4"
|
||||
fake_async:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: fake_async
|
||||
url: "https://pub.flutter-io.cn"
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
flutter:
|
||||
@ -66,7 +66,7 @@ packages:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: flutter_lints
|
||||
url: "https://pub.flutter-io.cn"
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.4"
|
||||
flutter_test:
|
||||
@ -78,35 +78,35 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: lints
|
||||
url: "https://pub.flutter-io.cn"
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: matcher
|
||||
url: "https://pub.flutter-io.cn"
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.12.11"
|
||||
material_color_utilities:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: material_color_utilities
|
||||
url: "https://pub.flutter-io.cn"
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.1.3"
|
||||
meta:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: meta
|
||||
url: "https://pub.flutter-io.cn"
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.7.0"
|
||||
path:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path
|
||||
url: "https://pub.flutter-io.cn"
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.8.0"
|
||||
sky_engine:
|
||||
@ -118,56 +118,56 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: source_span
|
||||
url: "https://pub.flutter-io.cn"
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.8.1"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stack_trace
|
||||
url: "https://pub.flutter-io.cn"
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.10.0"
|
||||
stream_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stream_channel
|
||||
url: "https://pub.flutter-io.cn"
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
string_scanner:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: string_scanner
|
||||
url: "https://pub.flutter-io.cn"
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
term_glyph:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: term_glyph
|
||||
url: "https://pub.flutter-io.cn"
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
test_api:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
url: "https://pub.flutter-io.cn"
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.4.8"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: typed_data
|
||||
url: "https://pub.flutter-io.cn"
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vector_math
|
||||
url: "https://pub.flutter-io.cn"
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
sdks:
|
||||
|
||||
@ -64,7 +64,7 @@ flutter:
|
||||
assets:
|
||||
- assets/unixWords.txt
|
||||
- assets/ospd.txt
|
||||
- popular.txt
|
||||
- assets/popular.txt
|
||||
|
||||
# An image asset can refer to one or more resolution-specific "variants", see
|
||||
# https://flutter.dev/assets-and-images/#resolution-aware.
|
||||
|
||||