Skip to content

Commit

Permalink
TF-2421 Update preferred orientations for each screen
Browse files Browse the repository at this point in the history
Signed-off-by: dab246 <[email protected]>
  • Loading branch information
dab246 committed Jan 9, 2024
1 parent 105b997 commit 27d83d6
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 23 deletions.
16 changes: 16 additions & 0 deletions core/lib/presentation/utils/theme_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]);
}
}
3 changes: 3 additions & 0 deletions lib/features/home/presentation/home_controller.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -50,6 +51,8 @@ class HomeController extends ReloadableController {
@override
void onInit() {
if (PlatformInfo.isMobile) {
ThemeUtils.setSystemDarkUIStyle();
ThemeUtils.setPreferredFullOrientations();
_initFlutterDownloader();
_registerReceivingSharingIntent();
}
Expand Down
3 changes: 0 additions & 3 deletions lib/features/home/presentation/home_view.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -9,8 +8,6 @@ class HomeView extends GetWidget<HomeController> {

@override
Widget build(BuildContext context) {
ThemeUtils.setSystemDarkUIStyle();

return Container(
color: AppColor.primaryLightColor,
child: const SizedBox(
Expand Down
10 changes: 10 additions & 0 deletions lib/features/login/presentation/login_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();
Expand Down
3 changes: 0 additions & 3 deletions lib/features/login/presentation/login_view.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -24,8 +23,6 @@ class LoginView extends BaseLoginView {

@override
Widget build(BuildContext context) {
ThemeUtils.setSystemDarkUIStyle();

return PopScope(
canPop: false,
onPopInvoked: (didPop) => !didPop
Expand Down
3 changes: 3 additions & 0 deletions lib/features/mailbox/presentation/mailbox_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ class MailboxController extends BaseMailboxController with MailboxActionHandlerM

@override
void onInit() {
if (PlatformInfo.isMobile) {
ThemeUtils.setStatusBarTransparentColor();
}
_registerObxStreamListener();
super.onInit();
}
Expand Down
2 changes: 0 additions & 2 deletions lib/features/mailbox/presentation/mailbox_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 0 additions & 3 deletions lib/features/mailto/presentation/mailto_url_view.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -9,8 +8,6 @@ class MailtoUrlView extends GetWidget<MailtoUrlController> {

@override
Widget build(BuildContext context) {
ThemeUtils.setSystemDarkUIStyle();

return Container(
color: AppColor.primaryLightColor,
child: const SizedBox(
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -11,11 +10,6 @@ class TwakeIdView extends GetWidget<TwakeIdController> {

@override
Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown
]);

return TwakeIdScreen(
focusColor: Colors.transparent,
hoverColor: Colors.transparent,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@

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';
import 'package:tmail_ui_user/main/utils/app_config.dart';

class TwakeWelcomeController extends BaseController {

@override
void onInit() {
ThemeUtils.setPreferredPortraitOrientations();
super.onInit();
}

Future<void> _saveStateFirstTimeAppLaunch() async {
await appStore.setItemBoolean(AppConfig.firstTimeAppLaunchKey, true);
}

@override
void navigateToTwakeIdPage() async {
await _saveStateFirstTimeAppLaunch();
popAndPush(AppRoutes.twakeId);
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -12,11 +11,6 @@ class TwakeWelcomeView extends GetWidget<TwakeWelcomeController> {

@override
Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown
]);

return TwakeWelcomeScreen(
welcomeTo: AppLocalizations.of(context).welcomeTo,
logo: Padding(
Expand Down
1 change: 1 addition & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ void main() async {
initLogger(() async {
WidgetsFlutterBinding.ensureInitialized();
ThemeUtils.setSystemLightUIStyle();
ThemeUtils.setPreferredFullOrientations();

await Future.wait([
MainBindings().dependencies(),
Expand Down

0 comments on commit 27d83d6

Please sign in to comment.