refactor(mobile): build context extensions (#4923)

* refactor: move all extensions to separate package

* refactor(mobile): add BuildContext extension

* refactor(mobile): use theme getters from context

* refactor(mobile): use media query size from context

* refactor(mobile): use auto router methods from context

* refactor(mobile): use navigator methods from context

---------

Co-authored-by: shalong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
shenlong 2023-11-09 16:19:53 +00:00 committed by GitHub
parent a147dee4b6
commit bffc2cdf60
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
106 changed files with 660 additions and 628 deletions

View file

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:immich_mobile/extensions/build_context_extensions.dart';
import 'package:immich_mobile/shared/models/logger_message.model.dart';
import 'package:flutter/services.dart';
@ -10,7 +11,7 @@ class AppLogDetailPage extends HookConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
var isDarkMode = Theme.of(context).brightness == Brightness.dark;
var isDarkTheme = context.isDarkTheme;
buildStackMessage(String stackTrace) {
return Padding(
@ -28,7 +29,7 @@ class AppLogDetailPage extends HookConsumerWidget {
"STACK TRACES",
style: TextStyle(
fontSize: 12.0,
color: Theme.of(context).primaryColor,
color: context.primaryColor,
fontWeight: FontWeight.bold,
),
),
@ -45,14 +46,14 @@ class AppLogDetailPage extends HookConsumerWidget {
icon: Icon(
Icons.copy,
size: 16.0,
color: Theme.of(context).primaryColor,
color: context.primaryColor,
),
),
],
),
Container(
decoration: BoxDecoration(
color: isDarkMode ? Colors.grey[900] : Colors.grey[200],
color: isDarkTheme ? Colors.grey[900] : Colors.grey[200],
borderRadius: BorderRadius.circular(15.0),
),
child: Padding(
@ -88,7 +89,7 @@ class AppLogDetailPage extends HookConsumerWidget {
"MESSAGE",
style: TextStyle(
fontSize: 12.0,
color: Theme.of(context).primaryColor,
color: context.primaryColor,
fontWeight: FontWeight.bold,
),
),
@ -104,14 +105,14 @@ class AppLogDetailPage extends HookConsumerWidget {
icon: Icon(
Icons.copy,
size: 16.0,
color: Theme.of(context).primaryColor,
color: context.primaryColor,
),
),
],
),
Container(
decoration: BoxDecoration(
color: isDarkMode ? Colors.grey[900] : Colors.grey[200],
color: isDarkTheme ? Colors.grey[900] : Colors.grey[200],
borderRadius: BorderRadius.circular(15.0),
),
child: Padding(
@ -143,14 +144,14 @@ class AppLogDetailPage extends HookConsumerWidget {
"FROM",
style: TextStyle(
fontSize: 12.0,
color: Theme.of(context).primaryColor,
color: context.primaryColor,
fontWeight: FontWeight.bold,
),
),
),
Container(
decoration: BoxDecoration(
color: isDarkMode ? Colors.grey[900] : Colors.grey[200],
color: isDarkTheme ? Colors.grey[900] : Colors.grey[200],
borderRadius: BorderRadius.circular(15.0),
),
child: Padding(