From 97e37f304bb9e66f982b589f8c43a1a2f32f071e Mon Sep 17 00:00:00 2001 From: Dhruvan Bhalara <53393418+dhruvanbhalara@users.noreply.github.com> Date: Thu, 10 Aug 2023 17:55:07 +0530 Subject: [PATCH] refactor: migrate MediaQuery properties to InheritedModel (#1115) Co-authored-by: Ushie --- lib/ui/views/app_selector/app_selector_view.dart | 2 +- lib/ui/views/contributors/contributors_view.dart | 2 +- lib/ui/views/navigation/navigation_viewmodel.dart | 2 +- lib/ui/views/patches_selector/patches_selector_view.dart | 2 +- lib/ui/widgets/appSelectorView/app_skeleton_loader.dart | 2 +- .../widgets/installerView/gradient_progress_indicator.dart | 2 +- lib/ui/widgets/patchesSelectorView/patch_options_fields.dart | 5 +++-- 7 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/ui/views/app_selector/app_selector_view.dart b/lib/ui/views/app_selector/app_selector_view.dart index 6368df61..2a3ce795 100644 --- a/lib/ui/views/app_selector/app_selector_view.dart +++ b/lib/ui/views/app_selector/app_selector_view.dart @@ -94,7 +94,7 @@ class _AppSelectorViewState extends State { padding: const EdgeInsets.symmetric(horizontal: 12.0) .copyWith( bottom: - MediaQuery.of(context).viewPadding.bottom + 8.0, + MediaQuery.viewPaddingOf(context).bottom + 8.0, ), child: Column( children: [ diff --git a/lib/ui/views/contributors/contributors_view.dart b/lib/ui/views/contributors/contributors_view.dart index 26cdb12b..a409c17e 100644 --- a/lib/ui/views/contributors/contributors_view.dart +++ b/lib/ui/views/contributors/contributors_view.dart @@ -57,7 +57,7 @@ class ContributorsView extends StatelessWidget { title: 'contributorsView.managerContributors', contributors: model.managerContributors, ), - SizedBox(height: MediaQuery.of(context).viewPadding.bottom), + SizedBox(height: MediaQuery.viewPaddingOf(context).bottom), ], ), ), diff --git a/lib/ui/views/navigation/navigation_viewmodel.dart b/lib/ui/views/navigation/navigation_viewmodel.dart index 51b3497c..99110cc1 100644 --- a/lib/ui/views/navigation/navigation_viewmodel.dart +++ b/lib/ui/views/navigation/navigation_viewmodel.dart @@ -33,7 +33,7 @@ class NavigationViewModel extends IndexTrackingViewModel { if (prefs.getBool('useDarkTheme') == null) { final bool isDark = - MediaQuery.of(context).platformBrightness != Brightness.light; + MediaQuery.platformBrightnessOf(context) != Brightness.light; await prefs.setBool('useDarkTheme', isDark); await DynamicTheme.of(context)!.setTheme(isDark ? 1 : 0); } diff --git a/lib/ui/views/patches_selector/patches_selector_view.dart b/lib/ui/views/patches_selector/patches_selector_view.dart index f5f4a7bd..3067263a 100644 --- a/lib/ui/views/patches_selector/patches_selector_view.dart +++ b/lib/ui/views/patches_selector/patches_selector_view.dart @@ -139,7 +139,7 @@ class _PatchesSelectorViewState extends State { : Padding( padding: const EdgeInsets.symmetric(horizontal: 12.0).copyWith( - bottom: MediaQuery.of(context).viewPadding.bottom + 8.0, + bottom: MediaQuery.viewPaddingOf(context).bottom + 8.0, ), child: Column( children: [ diff --git a/lib/ui/widgets/appSelectorView/app_skeleton_loader.dart b/lib/ui/widgets/appSelectorView/app_skeleton_loader.dart index 51c51b72..0cb80428 100644 --- a/lib/ui/widgets/appSelectorView/app_skeleton_loader.dart +++ b/lib/ui/widgets/appSelectorView/app_skeleton_loader.dart @@ -7,7 +7,7 @@ class AppSkeletonLoader extends StatelessWidget { @override Widget build(BuildContext context) { - final screenWidth = MediaQuery.of(context).size.width; + final screenWidth = MediaQuery.sizeOf(context).width; return ListView.builder( shrinkWrap: true, itemCount: 7, diff --git a/lib/ui/widgets/installerView/gradient_progress_indicator.dart b/lib/ui/widgets/installerView/gradient_progress_indicator.dart index 3936810b..d4032184 100644 --- a/lib/ui/widgets/installerView/gradient_progress_indicator.dart +++ b/lib/ui/widgets/installerView/gradient_progress_indicator.dart @@ -25,7 +25,7 @@ class _GradientProgressIndicatorState extends State { ), ), height: 5, - width: MediaQuery.of(context).size.width * widget.progress!, + width: MediaQuery.sizeOf(context).width * widget.progress!, ), ); } diff --git a/lib/ui/widgets/patchesSelectorView/patch_options_fields.dart b/lib/ui/widgets/patchesSelectorView/patch_options_fields.dart index 3f40e4a5..45a13843 100644 --- a/lib/ui/widgets/patchesSelectorView/patch_options_fields.dart +++ b/lib/ui/widgets/patchesSelectorView/patch_options_fields.dart @@ -8,8 +8,9 @@ class OptionsTextField extends StatelessWidget { @override Widget build(BuildContext context) { - final sHeight = MediaQuery.of(context).size.height; - final sWidth = MediaQuery.of(context).size.width; + final size = MediaQuery.sizeOf(context); + final sHeight = size.height; + final sWidth = size.width; return Container( margin: const EdgeInsets.only(top: 12, bottom: 6), padding: EdgeInsets.zero,