diff --git a/src/ui/flutter_app/lib/l10n/resources.dart b/src/ui/flutter_app/lib/l10n/resources.dart index c5f0bcdd..d021a442 100644 --- a/src/ui/flutter_app/lib/l10n/resources.dart +++ b/src/ui/flutter_app/lib/l10n/resources.dart @@ -19,10 +19,10 @@ import 'dart:io'; import 'package:flutter/material.dart'; -import 'package:sanmill/generated/l10n.dart'; -import 'package:sanmill/screens/list_item_divider.dart'; import 'package:sanmill/shared/common/config.dart'; import 'package:sanmill/shared/common/constants.dart'; +import 'package:sanmill/generated/l10n.dart'; +import 'package:sanmill/shared/list_item_divider.dart'; import 'package:sanmill/shared/theme/app_theme.dart'; Map languageCodeToStrings = { @@ -520,9 +520,7 @@ class Resources { } Future setLanguage( - BuildContext context, - Function(String?)? callback, -) async { + BuildContext context, Function(String?)? callback) async { final languageColumn = Column( mainAxisSize: MainAxisSize.min, children: [ @@ -572,7 +570,7 @@ Bidirectionality getBidirectionality(BuildContext context) { currentLocale.languageCode == "he" || currentLocale.languageCode == "ps" || currentLocale.languageCode == "ur") { - debugPrint("bidirectionality: RTL"); + print("bidirectionality: RTL"); return Bidirectionality.rightToLeft; } else { return Bidirectionality.leftToRight; @@ -593,5 +591,5 @@ void setSpecialCountryAndRegion(BuildContext context) { break; } - debugPrint("Set Special Country and Region to $specialCountryAndRegion."); + print("Set Special Country and Region to $specialCountryAndRegion."); } diff --git a/src/ui/flutter_app/lib/main.dart b/src/ui/flutter_app/lib/main.dart index 9a1b9e52..d480f51b 100644 --- a/src/ui/flutter_app/lib/main.dart +++ b/src/ui/flutter_app/lib/main.dart @@ -16,7 +16,6 @@ along with this program. If not, see . */ -import 'dart:async'; import 'dart:io'; import 'dart:ui'; @@ -34,8 +33,6 @@ import 'package:sanmill/services/audios.dart'; import 'package:sanmill/shared/common/constants.dart'; import 'package:sanmill/shared/theme/app_theme.dart'; -import 'services/audios.dart'; - Future main() async { final catcher = Catcher( rootWidget: BetterFeedback( diff --git a/src/ui/flutter_app/lib/mill/game.dart b/src/ui/flutter_app/lib/mill/game.dart index eb28357d..18b91007 100644 --- a/src/ui/flutter_app/lib/mill/game.dart +++ b/src/ui/flutter_app/lib/mill/game.dart @@ -17,12 +17,11 @@ */ import 'package:flutter/foundation.dart'; -import 'package:sanmill/engine/engine.dart'; +import 'package:sanmill/mill/position.dart'; +import 'package:sanmill/mill/types.dart'; +import 'package:sanmill/services/engine/engine.dart'; import 'package:sanmill/shared/common/config.dart'; -import 'position.dart'; -import 'types.dart'; - enum PlayerType { human, AI } Map isAi = {PieceColor.white: false, PieceColor.black: true}; diff --git a/src/ui/flutter_app/lib/mill/mills.dart b/src/ui/flutter_app/lib/mill/mills.dart index 19cbee5e..03f7940c 100644 --- a/src/ui/flutter_app/lib/mill/mills.dart +++ b/src/ui/flutter_app/lib/mill/mills.dart @@ -16,8 +16,8 @@ along with this program. If not, see . */ -import 'position.dart'; -import 'rule.dart'; +import 'package:sanmill/mill/position.dart'; +import 'package:sanmill/mill/rule.dart'; class Mills { const Mills._(); diff --git a/src/ui/flutter_app/lib/mill/position.dart b/src/ui/flutter_app/lib/mill/position.dart index 8cd06f69..a219e540 100644 --- a/src/ui/flutter_app/lib/mill/position.dart +++ b/src/ui/flutter_app/lib/mill/position.dart @@ -17,16 +17,14 @@ */ import 'package:flutter/foundation.dart'; -import 'package:sanmill/engine/engine.dart'; import 'package:sanmill/mill/game.dart'; +import 'package:sanmill/mill/mills.dart'; import 'package:sanmill/mill/recorder.dart'; import 'package:sanmill/mill/rule.dart'; import 'package:sanmill/mill/types.dart'; +import 'package:sanmill/mill/zobrist.dart'; import 'package:sanmill/services/audios.dart'; - -import 'mills.dart'; -import 'types.dart'; -import 'zobrist.dart'; +import 'package:sanmill/services/engine/engine.dart'; List posKeyHistory = []; diff --git a/src/ui/flutter_app/lib/mill/recorder.dart b/src/ui/flutter_app/lib/mill/recorder.dart index 42940b0f..a7cd1472 100644 --- a/src/ui/flutter_app/lib/mill/recorder.dart +++ b/src/ui/flutter_app/lib/mill/recorder.dart @@ -17,11 +17,10 @@ */ import 'package:flutter/foundation.dart'; +import 'package:sanmill/mill/position.dart'; +import 'package:sanmill/mill/types.dart'; import 'package:sanmill/shared/common/config.dart'; -import 'position.dart'; -import 'types.dart'; - // TODO class GameRecorder { int cur = -1; diff --git a/src/ui/flutter_app/lib/screens/about_page.dart b/src/ui/flutter_app/lib/screens/about_page.dart index 8b2ad500..e003c0bb 100644 --- a/src/ui/flutter_app/lib/screens/about_page.dart +++ b/src/ui/flutter_app/lib/screens/about_page.dart @@ -24,15 +24,14 @@ import 'package:flutter/material.dart'; import 'package:package_info_plus/package_info_plus.dart'; import 'package:sanmill/generated/flutter_version.dart'; import 'package:sanmill/generated/l10n.dart'; -import 'package:sanmill/screens/settings/settings_list_tile.dart'; +import 'package:sanmill/screens/license_page.dart'; +import 'package:sanmill/screens/oss_license_page.dart'; import 'package:sanmill/shared/common/constants.dart'; +import 'package:sanmill/shared/list_item_divider.dart'; +import 'package:sanmill/shared/settings/settings_list_tile.dart'; import 'package:sanmill/shared/theme/app_theme.dart'; import 'package:url_launcher/url_launcher.dart'; -import 'license_page.dart'; -import 'list_item_divider.dart'; -import 'oss_license_page.dart'; - class AboutPage extends StatelessWidget { final String tag = "[about] "; diff --git a/src/ui/flutter_app/lib/screens/board.dart b/src/ui/flutter_app/lib/screens/game_page/board.dart similarity index 93% rename from src/ui/flutter_app/lib/screens/board.dart rename to src/ui/flutter_app/lib/screens/game_page/board.dart index b01ab97c..e544adbc 100644 --- a/src/ui/flutter_app/lib/screens/board.dart +++ b/src/ui/flutter_app/lib/screens/game_page/board.dart @@ -16,15 +16,7 @@ along with this program. If not, see . */ -import 'package:flutter/material.dart'; -import 'package:sanmill/generated/l10n.dart'; -import 'package:sanmill/l10n/resources.dart'; -import 'package:sanmill/mill/game.dart'; -import 'package:sanmill/mill/types.dart'; -import 'package:sanmill/shared/common/config.dart'; -import 'package:sanmill/shared/painters/board_painter.dart'; -import 'package:sanmill/shared/painters/pieces_painter.dart'; -import 'package:sanmill/shared/theme/app_theme.dart'; +part of 'package:sanmill/screens/game_page/game_page.dart'; typedef BoardTapCallback = dynamic Function(int index); diff --git a/src/ui/flutter_app/lib/screens/game_page/game_page.dart b/src/ui/flutter_app/lib/screens/game_page/game_page.dart index 5c187224..d599a1b9 100644 --- a/src/ui/flutter_app/lib/screens/game_page/game_page.dart +++ b/src/ui/flutter_app/lib/screens/game_page/game_page.dart @@ -16,15 +16,13 @@ along with this program. If not, see . */ -import 'dart:async'; - //import 'dart:typed_data'; +import 'dart:async'; + import 'package:fluentui_system_icons/fluentui_system_icons.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:sanmill/engine/engine.dart'; -import 'package:sanmill/engine/native_engine.dart'; import 'package:sanmill/generated/l10n.dart'; import 'package:sanmill/l10n/resources.dart'; import 'package:sanmill/main.dart'; @@ -32,9 +30,10 @@ import 'package:sanmill/mill/game.dart'; import 'package:sanmill/mill/position.dart'; import 'package:sanmill/mill/rule.dart'; import 'package:sanmill/mill/types.dart'; -import 'package:sanmill/screens/board.dart'; import 'package:sanmill/screens/game_settings_page.dart'; import 'package:sanmill/services/audios.dart'; +import 'package:sanmill/services/engine/engine.dart'; +import 'package:sanmill/services/engine/native_engine.dart'; import 'package:sanmill/shared/common/config.dart'; import 'package:sanmill/shared/common/constants.dart'; import 'package:sanmill/shared/dialog.dart'; @@ -45,6 +44,10 @@ import 'package:sanmill/shared/theme/app_theme.dart'; import 'package:stack_trace/stack_trace.dart'; part 'package:sanmill/screens/game_page/game_page_tool_bar.dart'; +part 'package:sanmill/screens/game_page/board.dart'; +part 'package:sanmill/shared/painters/board_painter.dart'; +part 'package:sanmill/shared/painters/pieces_painter.dart'; +part 'package:sanmill/shared/painters/painter_base.dart'; double boardWidth = 0.0; diff --git a/src/ui/flutter_app/lib/screens/game_settings_page.dart b/src/ui/flutter_app/lib/screens/game_settings_page.dart index b78aaa09..43a8fa2d 100644 --- a/src/ui/flutter_app/lib/screens/game_settings_page.dart +++ b/src/ui/flutter_app/lib/screens/game_settings_page.dart @@ -21,16 +21,15 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:sanmill/generated/l10n.dart'; -import 'package:sanmill/screens/settings/settings_card.dart'; -import 'package:sanmill/screens/settings/settings_list_tile.dart'; -import 'package:sanmill/screens/settings/settings_switch_list_tile.dart'; +import 'package:sanmill/screens/env_page.dart'; import 'package:sanmill/shared/common/config.dart'; import 'package:sanmill/shared/common/settings.dart'; +import 'package:sanmill/shared/dialog.dart'; +import 'package:sanmill/shared/settings/settings_card.dart'; +import 'package:sanmill/shared/settings/settings_list_tile.dart'; +import 'package:sanmill/shared/settings/settings_switch_list_tile.dart'; import 'package:sanmill/shared/theme/app_theme.dart'; -import '../shared/dialog.dart'; -import 'env_page.dart'; - class Developer { const Developer._(); static bool developerModeEnabled = false; diff --git a/src/ui/flutter_app/lib/screens/home_drawer.dart b/src/ui/flutter_app/lib/screens/home_drawer.dart index 4c38bc3b..b6c3af0e 100644 --- a/src/ui/flutter_app/lib/screens/home_drawer.dart +++ b/src/ui/flutter_app/lib/screens/home_drawer.dart @@ -16,16 +16,7 @@ along with this program. If not, see . */ -import 'dart:async'; - -import 'package:animated_text_kit/animated_text_kit.dart'; -import 'package:flutter/material.dart'; -import 'package:sanmill/generated/l10n.dart'; -import 'package:sanmill/l10n/resources.dart'; -import 'package:sanmill/screens/game_settings_page.dart'; -import 'package:sanmill/shared/common/config.dart'; -import 'package:sanmill/shared/common/constants.dart'; -import 'package:sanmill/shared/theme/app_theme.dart'; +part of 'package:sanmill/screens/navigation_home_screen.dart'; enum DrawerIndex { humanVsAi, diff --git a/src/ui/flutter_app/lib/screens/navigation_home_screen.dart b/src/ui/flutter_app/lib/screens/navigation_home_screen.dart index 7b0477a7..473e3a55 100644 --- a/src/ui/flutter_app/lib/screens/navigation_home_screen.dart +++ b/src/ui/flutter_app/lib/screens/navigation_home_screen.dart @@ -19,19 +19,20 @@ import 'dart:io'; import 'dart:typed_data'; +import 'package:animated_text_kit/animated_text_kit.dart'; import 'package:feedback/feedback.dart'; +import 'package:fluentui_system_icons/fluentui_system_icons.dart'; import 'package:flutter/material.dart'; import 'package:flutter_email_sender/flutter_email_sender.dart'; import 'package:package_info_plus/package_info_plus.dart'; import 'package:path_provider/path_provider.dart'; -import 'package:sanmill/engine/engine.dart'; +import 'package:sanmill/generated/l10n.dart'; +import 'package:sanmill/l10n/resources.dart'; import 'package:sanmill/mill/game.dart'; import 'package:sanmill/screens/about_page.dart'; -import 'package:sanmill/screens/drawer_user_controller.dart'; import 'package:sanmill/screens/game_page/game_page.dart'; import 'package:sanmill/screens/game_settings_page.dart'; import 'package:sanmill/screens/help_screen.dart'; -import 'package:sanmill/screens/home_drawer.dart'; import 'package:sanmill/screens/personalization_settings_page.dart'; import 'package:sanmill/screens/rule_settings_page.dart'; import 'package:sanmill/services/engine/engine.dart'; @@ -39,6 +40,9 @@ import 'package:sanmill/shared/common/config.dart'; import 'package:sanmill/shared/common/constants.dart'; import 'package:sanmill/shared/theme/app_theme.dart'; +part 'package:sanmill/screens/home_drawer.dart'; +part 'package:sanmill/shared/drawer_controller.dart'; + class NavigationHomeScreen extends StatefulWidget { @override _NavigationHomeScreenState createState() => _NavigationHomeScreenState(); @@ -59,7 +63,7 @@ class _NavigationHomeScreenState extends State { Widget build(BuildContext context) { return Material( color: AppTheme.navigationHomeScreenBackgroundColor, - child: DrawerUserController( + child: DrawerController( screenIndex: drawerIndex, drawerWidth: MediaQuery.of(context).size.width * 0.75, onDrawerCall: changeIndex, diff --git a/src/ui/flutter_app/lib/screens/personalization_settings_page.dart b/src/ui/flutter_app/lib/screens/personalization_settings_page.dart index 330df6ec..c94e7415 100644 --- a/src/ui/flutter_app/lib/screens/personalization_settings_page.dart +++ b/src/ui/flutter_app/lib/screens/personalization_settings_page.dart @@ -20,11 +20,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_colorpicker/flutter_colorpicker.dart'; import 'package:sanmill/generated/l10n.dart'; import 'package:sanmill/l10n/resources.dart'; -import 'package:sanmill/screens/settings/settings_card.dart'; -import 'package:sanmill/screens/settings/settings_list_tile.dart'; -import 'package:sanmill/screens/settings/settings_switch_list_tile.dart'; import 'package:sanmill/shared/common/config.dart'; import 'package:sanmill/shared/common/constants.dart'; +import 'package:sanmill/shared/settings/settings_card.dart'; +import 'package:sanmill/shared/settings/settings_list_tile.dart'; +import 'package:sanmill/shared/settings/settings_switch_list_tile.dart'; import 'package:sanmill/shared/theme/app_theme.dart'; class PersonalizationSettingsPage extends StatefulWidget { diff --git a/src/ui/flutter_app/lib/screens/rule_settings_page.dart b/src/ui/flutter_app/lib/screens/rule_settings_page.dart index ec2589c2..acd11b2f 100644 --- a/src/ui/flutter_app/lib/screens/rule_settings_page.dart +++ b/src/ui/flutter_app/lib/screens/rule_settings_page.dart @@ -20,14 +20,13 @@ import 'package:flutter/material.dart'; import 'package:sanmill/generated/l10n.dart'; import 'package:sanmill/l10n/resources.dart'; import 'package:sanmill/mill/rule.dart'; -import 'package:sanmill/screens/settings/settings_card.dart'; -import 'package:sanmill/screens/settings/settings_list_tile.dart'; -import 'package:sanmill/screens/settings/settings_switch_list_tile.dart'; import 'package:sanmill/shared/common/config.dart'; +import 'package:sanmill/shared/settings/settings_card.dart'; +import 'package:sanmill/shared/settings/settings_list_tile.dart'; +import 'package:sanmill/shared/settings/settings_switch_list_tile.dart'; +import 'package:sanmill/shared/snack_bar.dart'; import 'package:sanmill/shared/theme/app_theme.dart'; -import '../shared/snack_bar.dart'; - class RuleSettingsPage extends StatefulWidget { @override _RuleSettingsPageState createState() => _RuleSettingsPageState(); diff --git a/src/ui/flutter_app/lib/engine/engine.dart b/src/ui/flutter_app/lib/services/engine/engine.dart similarity index 100% rename from src/ui/flutter_app/lib/engine/engine.dart rename to src/ui/flutter_app/lib/services/engine/engine.dart diff --git a/src/ui/flutter_app/lib/engine/native_engine.dart b/src/ui/flutter_app/lib/services/engine/native_engine.dart similarity index 95% rename from src/ui/flutter_app/lib/engine/native_engine.dart rename to src/ui/flutter_app/lib/services/engine/native_engine.dart index dec820c6..4a02e349 100644 --- a/src/ui/flutter_app/lib/engine/native_engine.dart +++ b/src/ui/flutter_app/lib/services/engine/native_engine.dart @@ -22,10 +22,9 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:sanmill/mill/position.dart'; import 'package:sanmill/mill/types.dart'; +import 'package:sanmill/services/engine/engine.dart'; import 'package:sanmill/shared/common/config.dart'; -import 'engine.dart'; - class NativeEngine extends Engine { static const platform = MethodChannel('com.calcitem.sanmill/engine'); bool isActive = false; @@ -55,8 +54,13 @@ class NativeEngine extends Engine { return platform.invokeMethod('isReady'); } - Future isThinking() async { - return platform.invokeMethod('isThinking') as Future; + FutureOr isThinking() async { + final _isThinking = await platform.invokeMethod('isThinking'); + if (_isThinking is bool) { + return _isThinking; + } else { + throw 'Invalid platform response. Expected a value of type bool'; + } } @override diff --git a/src/ui/flutter_app/lib/screens/drawer_user_controller.dart b/src/ui/flutter_app/lib/shared/drawer_controller.dart similarity index 94% rename from src/ui/flutter_app/lib/screens/drawer_user_controller.dart rename to src/ui/flutter_app/lib/shared/drawer_controller.dart index d19f387e..94a14dfe 100644 --- a/src/ui/flutter_app/lib/screens/drawer_user_controller.dart +++ b/src/ui/flutter_app/lib/shared/drawer_controller.dart @@ -16,16 +16,10 @@ along with this program. If not, see . */ -import 'package:fluentui_system_icons/fluentui_system_icons.dart'; -import 'package:flutter/material.dart'; -import 'package:sanmill/generated/l10n.dart'; -import 'package:sanmill/l10n/resources.dart'; -import 'package:sanmill/screens/home_drawer.dart'; -import 'package:sanmill/shared/common/config.dart'; -import 'package:sanmill/shared/theme/app_theme.dart'; +part of 'package:sanmill/screens/navigation_home_screen.dart'; -class DrawerUserController extends StatefulWidget { - const DrawerUserController({ +class DrawerController extends StatefulWidget { + const DrawerController({ Key? key, this.drawerWidth = AppTheme.drawerWidth, required this.onDrawerCall, @@ -45,10 +39,10 @@ class DrawerUserController extends StatefulWidget { final DrawerIndex screenIndex; @override - _DrawerUserControllerState createState() => _DrawerUserControllerState(); + _DrawerControllerState createState() => _DrawerControllerState(); } -class _DrawerUserControllerState extends State +class _DrawerControllerState extends State with TickerProviderStateMixin { late final ScrollController scrollController; late final AnimationController iconAnimationController; diff --git a/src/ui/flutter_app/lib/screens/list_item_divider.dart b/src/ui/flutter_app/lib/shared/list_item_divider.dart similarity index 100% rename from src/ui/flutter_app/lib/screens/list_item_divider.dart rename to src/ui/flutter_app/lib/shared/list_item_divider.dart diff --git a/src/ui/flutter_app/lib/shared/painters/board_painter.dart b/src/ui/flutter_app/lib/shared/painters/board_painter.dart index a5951f5e..fa3cbb5a 100644 --- a/src/ui/flutter_app/lib/shared/painters/board_painter.dart +++ b/src/ui/flutter_app/lib/shared/painters/board_painter.dart @@ -16,14 +16,7 @@ along with this program. If not, see . */ -import 'package:flutter/material.dart'; -import 'package:sanmill/mill/game.dart'; -import 'package:sanmill/mill/types.dart'; -import 'package:sanmill/screens/game_page/game_page.dart'; -import 'package:sanmill/shared/common/config.dart'; -import 'package:sanmill/shared/theme/app_theme.dart'; - -import 'painter_base.dart'; +part of 'package:sanmill/screens/game_page/game_page.dart'; class BoardPainter extends PiecesBasePainter { BoardPainter({required double width}) : super(width: width); diff --git a/src/ui/flutter_app/lib/shared/painters/painter_base.dart b/src/ui/flutter_app/lib/shared/painters/painter_base.dart index c661c4db..b8c62b3e 100644 --- a/src/ui/flutter_app/lib/shared/painters/painter_base.dart +++ b/src/ui/flutter_app/lib/shared/painters/painter_base.dart @@ -16,8 +16,7 @@ along with this program. If not, see . */ -import 'package:flutter/material.dart'; -import 'package:sanmill/shared/theme/app_theme.dart'; +part of 'package:sanmill/screens/game_page/game_page.dart'; abstract class PiecesBasePainter extends CustomPainter { final double width; diff --git a/src/ui/flutter_app/lib/shared/painters/pieces_painter.dart b/src/ui/flutter_app/lib/shared/painters/pieces_painter.dart index 63542751..1ae305bd 100644 --- a/src/ui/flutter_app/lib/shared/painters/pieces_painter.dart +++ b/src/ui/flutter_app/lib/shared/painters/pieces_painter.dart @@ -16,13 +16,7 @@ along with this program. If not, see . */ -import 'package:flutter/material.dart'; -import 'package:sanmill/mill/position.dart'; -import 'package:sanmill/mill/types.dart'; -import 'package:sanmill/shared/common/config.dart'; -import 'package:sanmill/shared/theme/app_theme.dart'; - -import 'painter_base.dart'; +part of 'package:sanmill/screens/game_page/game_page.dart'; class PiecePaintParam { final String piece; diff --git a/src/ui/flutter_app/lib/screens/settings/settings_card.dart b/src/ui/flutter_app/lib/shared/settings/settings_card.dart similarity index 96% rename from src/ui/flutter_app/lib/screens/settings/settings_card.dart rename to src/ui/flutter_app/lib/shared/settings/settings_card.dart index 0debe7a1..5b16e8f0 100644 --- a/src/ui/flutter_app/lib/screens/settings/settings_card.dart +++ b/src/ui/flutter_app/lib/shared/settings/settings_card.dart @@ -17,7 +17,7 @@ */ import 'package:flutter/material.dart'; -import 'package:sanmill/screens/list_item_divider.dart'; +import 'package:sanmill/shared/list_item_divider.dart'; import 'package:sanmill/shared/theme/app_theme.dart'; class SettingsCard extends StatelessWidget { diff --git a/src/ui/flutter_app/lib/screens/settings/settings_list_tile.dart b/src/ui/flutter_app/lib/shared/settings/settings_list_tile.dart similarity index 100% rename from src/ui/flutter_app/lib/screens/settings/settings_list_tile.dart rename to src/ui/flutter_app/lib/shared/settings/settings_list_tile.dart diff --git a/src/ui/flutter_app/lib/screens/settings/settings_switch_list_tile.dart b/src/ui/flutter_app/lib/shared/settings/settings_switch_list_tile.dart similarity index 100% rename from src/ui/flutter_app/lib/screens/settings/settings_switch_list_tile.dart rename to src/ui/flutter_app/lib/shared/settings/settings_switch_list_tile.dart