diff --git a/build/app/outputs/flutter-apk/app-arm64-v8a-release.apk b/build/app/outputs/flutter-apk/app-arm64-v8a-release.apk index 0dd293e..7cc6506 100644 Binary files a/build/app/outputs/flutter-apk/app-arm64-v8a-release.apk and b/build/app/outputs/flutter-apk/app-arm64-v8a-release.apk differ diff --git a/lib/features/tests/test_widgets/input_buttons_test.dart b/lib/features/tests/test_widgets/input_buttons_test.dart index 64fedbd..8a36985 100644 --- a/lib/features/tests/test_widgets/input_buttons_test.dart +++ b/lib/features/tests/test_widgets/input_buttons_test.dart @@ -2,7 +2,8 @@ import 'package:collection/collection.dart'; import 'package:flutter/material.dart'; import 'package:mnemo_cards/features/tests/test_manager.dart'; import 'package:mnemo_cards/features/tests/test_widgets/common_test_question_widget.dart'; -import 'package:mnemo_cards_common/mnemo_cards_common.dart'; +import 'package:mnemo_cards_common/mnemo_cards_common.dart' + hide NullableIterableHelper; import '../../../di/locator.dart'; import '../question_states/input_buttons_test_state.dart'; import 'test_button.dart'; @@ -82,7 +83,10 @@ class InputButtonsTestWidget extends StatelessWidget { } int splitIndex = 0; - if (model.template.length * 32 > constraints.maxWidth * 0.9) { + if (model.template.characters.where((c) => c == '_').length * 32 + + model.template.characters.where((c) => c != '_').length * + 18 > + constraints.maxWidth * 0.9) { splitIndex = model.template.indexOf( ' ', (model.template.length / 2).ceil(), @@ -104,34 +108,36 @@ class InputButtonsTestWidget extends StatelessWidget { splitIndex = 0; } + final stringRows = [ + if (splitIndex > 0) model.template.substring(0, splitIndex), + model.template.substring(splitIndex), + ]; int stateAnswerIndex = 0; - final letters = model.template - .split('') - .map( - (letter) => letter == '_' - ? _Letter( - text: state.answer.length > stateAnswerIndex - ? state.answer[stateAnswerIndex++] - : ' ', - borderColor: testColor, - ) - : _Letter.readOnly( - text: letter, - ), - ) - .toList(); + final letters = + stringRows.map((row) => row.split(RegExp('(?=_)|(?<=_)')).map( + (letter) => letter == '_' + ? _Letter( + text: state.answer.length > stateAnswerIndex + ? state.answer[stateAnswerIndex++] + : ' ', + borderColor: testColor, + ) + : _Letter.readOnly( + text: letter, + ), + )); final rows = [ if (splitIndex > 0) Padding( padding: const EdgeInsets.only(bottom: 8.0), child: Row( mainAxisAlignment: MainAxisAlignment.center, - children: letters.sublist(0, splitIndex), + children: letters.first.toList(), ), ), Row( mainAxisAlignment: MainAxisAlignment.center, - children: letters.sublist(splitIndex), + children: letters.last.toList(), ) ]; @@ -216,25 +222,32 @@ class _Letter extends StatelessWidget { final String text; final Color? borderColor; final Color? backgroundColor; - final double _width; + final double? _width; final double _padding; - final double _margin; + final double _innerPadding; + final double _innerMargin; _Letter({ this.text = '', this.borderColor, this.backgroundColor, }) : this._width = 32, - this._padding = 5, - this._margin = 2.0; + this._padding = 0, + this._innerPadding = 5, + this._innerMargin = 2.0; _Letter.readOnly({ this.text = '', }) : this.borderColor = null, this.backgroundColor = Colors.transparent, - this._width = text == ' ' ? 10 : 20, - this._padding = 0.0, - this._margin = 0.0; + this._width = text == ' ' + ? 10 + : text.length == 1 + ? 20 + : null, + this._padding = 5.0, + this._innerPadding = 0.0, + this._innerMargin = 0.0; @override Widget build(BuildContext context) { @@ -242,8 +255,9 @@ class _Letter extends StatelessWidget { width: _width, height: 45, alignment: Alignment.center, - margin: EdgeInsets.all(_margin), - padding: EdgeInsets.all(_padding), + margin: EdgeInsets.all(_innerMargin), + padding: EdgeInsets.all(_innerPadding) + .copyWith(right: _padding + _innerPadding), clipBehavior: Clip.antiAlias, decoration: BoxDecoration( color: backgroundColor ?? Theme.of(context).scaffoldBackgroundColor, @@ -254,7 +268,9 @@ class _Letter extends StatelessWidget { color: backgroundColor ?? Theme.of(context).scaffoldBackgroundColor, child: Text( text, - style: Theme.of(context).textTheme.titleLarge, + style: Theme.of(context).textTheme.titleLarge?.copyWith( + letterSpacing: 1.1, + ), textAlign: TextAlign.center, ), ), diff --git a/lib/main.dart b/lib/main.dart index 41fa42f..e7d1d18 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -37,8 +37,9 @@ final appRouter = AppRouter(ADMIN_BUILD); AndroidDeviceInfo? androidDeviceInfo; -Future _screenOff() async => - ADMIN_BUILD || await NoScreenshot.instance.screenshotOff(); +Future _screenOff() async => ADMIN_BUILD + ? await NoScreenshot.instance.screenshotOn() + : await NoScreenshot.instance.screenshotOff(); void main() async { WidgetsFlutterBinding.ensureInitialized(); @@ -83,17 +84,29 @@ void main() async { unawaited(initFirebase()); print('initing... ${stopwatch.elapsedMilliseconds}'); await Future.wait([ - locator.packCacheManager.init().then((_) => print('packCacheManager inited')), - locator.previewPackHolder.init().then((_) => print('previewPackHolder inited')), - locator.previewPackPoller.init().then((_) => print('previewPackPoller inited')), + locator.packCacheManager + .init() + .then((_) => print('packCacheManager inited')), + locator.previewPackHolder + .init() + .then((_) => print('previewPackHolder inited')), + locator.previewPackPoller + .init() + .then((_) => print('previewPackPoller inited')), locator.packManager.init().then((_) => print('packManager inited')), locator.userManager.init().then((_) => print('userManager inited')), - locator.favoriteCardsController.init().then((_) => print('favoriteCardsController inited')), - locator.previewPackPoller.init().then((_) => print('previewPackPoller inited')), - locator.deeplinkManager.init().then((_) => print('deeplinkManager inited')), + locator.favoriteCardsController + .init() + .then((_) => print('favoriteCardsController inited')), + locator.previewPackPoller + .init() + .then((_) => print('previewPackPoller inited')), + locator.deeplinkManager + .init() + .then((_) => print('deeplinkManager inited')), ]); await locator.packUpdater.init().then((_) => print('packUpdater inited')); - print('initing complete ${stopwatch.elapsedMilliseconds}'); + print('initing complete ${stopwatch.elapsedMilliseconds}'); if (!kIsWeb) unawaited(MobileAds.initialize()); print('mobile ads ${stopwatch.elapsedMilliseconds}'); print('runApp ${stopwatch.elapsedMilliseconds}'); @@ -117,7 +130,7 @@ Future _fillSp() async { } final soundSpeed = globalSharedPreferences.getDouble('sound_speed'); if (soundSpeed == null) { - await globalSharedPreferences.setDouble('sound_speed', 1.0); + await globalSharedPreferences.setDouble('sound_speed', 0.8); } final autoPlay = globalSharedPreferences.getBool('auto_play_sound_tests'); if (autoPlay == null) { diff --git a/lib/managers/audio_player.dart b/lib/managers/audio_player.dart index fe216df..a4754c1 100644 --- a/lib/managers/audio_player.dart +++ b/lib/managers/audio_player.dart @@ -23,7 +23,7 @@ class AudioPlayer { var speed = globalSharedPreferences.getDouble('sound_speed'); if (speed == null) { speed = 0.8; - globalSharedPreferences.setDouble('sound_speed', 0.8); + globalSharedPreferences.setDouble('sound_speed', speed); } await flutterTts.setSpeechRate(speed); flutterTts.speak(playText); diff --git a/lib/managers/repository/api.dart b/lib/managers/repository/api.dart index 54fcd53..8fbdd5a 100644 --- a/lib/managers/repository/api.dart +++ b/lib/managers/repository/api.dart @@ -7,9 +7,5 @@ mixin Api { !ADMIN_BUILD || (globalSharedPreferences.getBool('env') ?? true) //prod ? 'https://89.19.210.178:8080' //FirebaseRepository.appConfig.path - : androidDeviceInfo!.isPhysicalDevice - //device to localhost - ? 'https://192.168.31.158:8080' - : //emulator to localhost - 'https://10.0.2.2:8080'; + : 'https://192.168.31.158:8080'; }