diff --git a/core/lib/presentation/utils/theme_utils.dart b/core/lib/presentation/utils/theme_utils.dart index 7aed719272..83058a04af 100644 --- a/core/lib/presentation/utils/theme_utils.dart +++ b/core/lib/presentation/utils/theme_utils.dart @@ -89,4 +89,20 @@ class ThemeUtils { systemNavigationBarIconBrightness: Brightness.dark, )); } + + static void setPreferredPortraitOrientations() { + SystemChrome.setPreferredOrientations([ + DeviceOrientation.portraitUp, + DeviceOrientation.portraitDown + ]); + } + + static void setPreferredFullOrientations() { + SystemChrome.setPreferredOrientations([ + DeviceOrientation.portraitUp, + DeviceOrientation.portraitDown, + DeviceOrientation.landscapeLeft, + DeviceOrientation.landscapeRight, + ]); + } } \ No newline at end of file diff --git a/lib/features/home/presentation/home_controller.dart b/lib/features/home/presentation/home_controller.dart index 149a6611c7..e3b3d7b788 100644 --- a/lib/features/home/presentation/home_controller.dart +++ b/lib/features/home/presentation/home_controller.dart @@ -1,3 +1,4 @@ +import 'package:core/presentation/utils/theme_utils.dart'; import 'package:core/utils/platform_info.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter_downloader/flutter_downloader.dart'; @@ -50,6 +51,8 @@ class HomeController extends ReloadableController { @override void onInit() { if (PlatformInfo.isMobile) { + ThemeUtils.setSystemDarkUIStyle(); + ThemeUtils.setPreferredFullOrientations(); _initFlutterDownloader(); _registerReceivingSharingIntent(); } diff --git a/lib/features/home/presentation/home_view.dart b/lib/features/home/presentation/home_view.dart index eca67e6eb4..40fbb31496 100644 --- a/lib/features/home/presentation/home_view.dart +++ b/lib/features/home/presentation/home_view.dart @@ -1,5 +1,4 @@ import 'package:core/presentation/extensions/color_extension.dart'; -import 'package:core/presentation/utils/theme_utils.dart'; import 'package:flutter/cupertino.dart'; import 'package:get/get.dart'; import 'package:tmail_ui_user/features/home/presentation/home_controller.dart'; @@ -9,8 +8,6 @@ class HomeView extends GetWidget { @override Widget build(BuildContext context) { - ThemeUtils.setSystemDarkUIStyle(); - return Container( color: AppColor.primaryLightColor, child: const SizedBox( diff --git a/lib/features/login/presentation/login_controller.dart b/lib/features/login/presentation/login_controller.dart index f5fc357b07..93ce51ae6c 100644 --- a/lib/features/login/presentation/login_controller.dart +++ b/lib/features/login/presentation/login_controller.dart @@ -2,6 +2,7 @@ import 'package:core/presentation/extensions/url_extension.dart'; import 'package:core/presentation/state/failure.dart'; import 'package:core/presentation/state/success.dart'; import 'package:core/presentation/utils/keyboard_utils.dart'; +import 'package:core/presentation/utils/theme_utils.dart'; import 'package:core/utils/app_logger.dart'; import 'package:core/utils/platform_info.dart'; import 'package:dartz/dartz.dart'; @@ -90,6 +91,15 @@ class LoginController extends ReloadableController { this._dnsLookupToGetJmapUrlInteractor, ); + @override + void onInit() { + if (PlatformInfo.isMobile) { + ThemeUtils.setSystemDarkUIStyle(); + ThemeUtils.setPreferredFullOrientations(); + } + super.onInit(); + } + @override void onReady() { super.onReady(); diff --git a/lib/features/login/presentation/login_view.dart b/lib/features/login/presentation/login_view.dart index 8fa4822e59..b69d94f17b 100644 --- a/lib/features/login/presentation/login_view.dart +++ b/lib/features/login/presentation/login_view.dart @@ -1,6 +1,5 @@ import 'package:core/presentation/extensions/color_extension.dart'; import 'package:core/presentation/state/success.dart'; -import 'package:core/presentation/utils/theme_utils.dart'; import 'package:core/presentation/views/text/type_ahead_form_field_builder.dart'; import 'package:flutter/material.dart'; import 'package:flutter_typeahead/flutter_typeahead.dart'; @@ -24,8 +23,6 @@ class LoginView extends BaseLoginView { @override Widget build(BuildContext context) { - ThemeUtils.setSystemDarkUIStyle(); - return PopScope( canPop: false, onPopInvoked: (didPop) => !didPop diff --git a/lib/features/mailbox/presentation/mailbox_controller.dart b/lib/features/mailbox/presentation/mailbox_controller.dart index 8452d40b04..27b32c4f5c 100644 --- a/lib/features/mailbox/presentation/mailbox_controller.dart +++ b/lib/features/mailbox/presentation/mailbox_controller.dart @@ -133,6 +133,9 @@ class MailboxController extends BaseMailboxController with MailboxActionHandlerM @override void onInit() { + if (PlatformInfo.isMobile) { + ThemeUtils.setStatusBarTransparentColor(); + } _registerObxStreamListener(); super.onInit(); } diff --git a/lib/features/mailbox/presentation/mailbox_view.dart b/lib/features/mailbox/presentation/mailbox_view.dart index 069ebf4107..c3efab4922 100644 --- a/lib/features/mailbox/presentation/mailbox_view.dart +++ b/lib/features/mailbox/presentation/mailbox_view.dart @@ -24,8 +24,6 @@ class MailboxView extends BaseMailboxView { @override Widget build(BuildContext context) { - ThemeUtils.setStatusBarTransparentColor(); - return SafeArea(bottom: false, left: false, right: false, top: controller.responsiveUtils.isMobile(context), child: ClipRRect( diff --git a/lib/features/mailto/presentation/mailto_url_view.dart b/lib/features/mailto/presentation/mailto_url_view.dart index 35bf853f05..1248d4ccf2 100644 --- a/lib/features/mailto/presentation/mailto_url_view.dart +++ b/lib/features/mailto/presentation/mailto_url_view.dart @@ -1,5 +1,4 @@ import 'package:core/presentation/extensions/color_extension.dart'; -import 'package:core/presentation/utils/theme_utils.dart'; import 'package:flutter/cupertino.dart'; import 'package:get/get.dart'; import 'package:tmail_ui_user/features/mailto/presentation/mailto_url_controller.dart'; @@ -9,8 +8,6 @@ class MailtoUrlView extends GetWidget { @override Widget build(BuildContext context) { - ThemeUtils.setSystemDarkUIStyle(); - return Container( color: AppColor.primaryLightColor, child: const SizedBox( diff --git a/lib/features/starting_page/presentation/twake_id/twake_id_controller.dart b/lib/features/starting_page/presentation/twake_id/twake_id_controller.dart index e112068037..838805be5d 100644 --- a/lib/features/starting_page/presentation/twake_id/twake_id_controller.dart +++ b/lib/features/starting_page/presentation/twake_id/twake_id_controller.dart @@ -1,4 +1,5 @@ +import 'package:core/presentation/utils/theme_utils.dart'; import 'package:get/get.dart'; import 'package:tmail_ui_user/features/login/presentation/login_form_type.dart'; import 'package:tmail_ui_user/features/login/presentation/model/login_arguments.dart'; @@ -7,6 +8,12 @@ import 'package:tmail_ui_user/main/routes/route_navigation.dart'; class TwakeIdController extends GetxController { + @override + void onInit() { + ThemeUtils.setPreferredPortraitOrientations(); + super.onInit(); + } + void handleUseCompanyServer() { popAndPush( AppRoutes.login, diff --git a/lib/features/starting_page/presentation/twake_id/twake_id_view.dart b/lib/features/starting_page/presentation/twake_id/twake_id_view.dart index 3c75cfcb2f..cd8fbdddc0 100644 --- a/lib/features/starting_page/presentation/twake_id/twake_id_view.dart +++ b/lib/features/starting_page/presentation/twake_id/twake_id_view.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:get/get.dart'; import 'package:linagora_design_flutter/linagora_design_flutter.dart'; import 'package:tmail_ui_user/features/starting_page/presentation/twake_id/twake_id_controller.dart'; @@ -11,11 +10,6 @@ class TwakeIdView extends GetWidget { @override Widget build(BuildContext context) { - SystemChrome.setPreferredOrientations([ - DeviceOrientation.portraitUp, - DeviceOrientation.portraitDown - ]); - return TwakeIdScreen( focusColor: Colors.transparent, hoverColor: Colors.transparent, diff --git a/lib/features/starting_page/presentation/twake_welcome/twake_welcome_controller.dart b/lib/features/starting_page/presentation/twake_welcome/twake_welcome_controller.dart index 7beff54c80..a5cc6b6f87 100644 --- a/lib/features/starting_page/presentation/twake_welcome/twake_welcome_controller.dart +++ b/lib/features/starting_page/presentation/twake_welcome/twake_welcome_controller.dart @@ -1,4 +1,5 @@ +import 'package:core/presentation/utils/theme_utils.dart'; import 'package:tmail_ui_user/features/base/base_controller.dart'; import 'package:tmail_ui_user/main/routes/app_routes.dart'; import 'package:tmail_ui_user/main/routes/route_navigation.dart'; @@ -6,10 +7,17 @@ import 'package:tmail_ui_user/main/utils/app_config.dart'; class TwakeWelcomeController extends BaseController { + @override + void onInit() { + ThemeUtils.setPreferredPortraitOrientations(); + super.onInit(); + } + Future _saveStateFirstTimeAppLaunch() async { await appStore.setItemBoolean(AppConfig.firstTimeAppLaunchKey, true); } + @override void navigateToTwakeIdPage() async { await _saveStateFirstTimeAppLaunch(); popAndPush(AppRoutes.twakeId); diff --git a/lib/features/starting_page/presentation/twake_welcome/twake_welcome_view.dart b/lib/features/starting_page/presentation/twake_welcome/twake_welcome_view.dart index 16104b52a1..dae83b4a9a 100644 --- a/lib/features/starting_page/presentation/twake_welcome/twake_welcome_view.dart +++ b/lib/features/starting_page/presentation/twake_welcome/twake_welcome_view.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:get/get.dart'; import 'package:linagora_design_flutter/linagora_design_flutter.dart'; @@ -12,11 +11,6 @@ class TwakeWelcomeView extends GetWidget { @override Widget build(BuildContext context) { - SystemChrome.setPreferredOrientations([ - DeviceOrientation.portraitUp, - DeviceOrientation.portraitDown - ]); - return TwakeWelcomeScreen( welcomeTo: AppLocalizations.of(context).welcomeTo, logo: Padding( diff --git a/lib/main.dart b/lib/main.dart index 65b44a00f8..0f0a8aa803 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -20,6 +20,7 @@ void main() async { initLogger(() async { WidgetsFlutterBinding.ensureInitialized(); ThemeUtils.setSystemLightUIStyle(); + ThemeUtils.setPreferredFullOrientations(); await Future.wait([ MainBindings().dependencies(),