mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
refactor(mobile): refactor to use context helpers for consistency (#14235)
refactor to use context helpers for consistency Co-authored-by: dvbthien <dvbthien@gmail.com>
This commit is contained in:
parent
45ba0cc3ac
commit
e8da6604c9
28 changed files with 66 additions and 46 deletions
|
|
@ -4,6 +4,9 @@ extension ContextHelper on BuildContext {
|
|||
// Returns the current padding from MediaQuery
|
||||
EdgeInsets get padding => MediaQuery.paddingOf(this);
|
||||
|
||||
// Returns the current view insets from MediaQuery
|
||||
EdgeInsets get viewInsets => MediaQuery.viewInsetsOf(this);
|
||||
|
||||
// Returns the current width from MediaQuery
|
||||
double get width => MediaQuery.sizeOf(this).width;
|
||||
|
||||
|
|
@ -13,6 +16,15 @@ extension ContextHelper on BuildContext {
|
|||
// Returns true if the app is running on a mobile device (!tablets)
|
||||
bool get isMobile => width < 550;
|
||||
|
||||
// Returns the current device pixel ratio from MediaQuery
|
||||
double get devicePixelRatio => MediaQuery.devicePixelRatioOf(this);
|
||||
|
||||
// Returns the current orientation from MediaQuery
|
||||
Orientation get orientation => MediaQuery.orientationOf(this);
|
||||
|
||||
// Returns the current platform brightness from MediaQuery
|
||||
Brightness get platformBrightness => MediaQuery.platformBrightnessOf(this);
|
||||
|
||||
// Returns the current ThemeData
|
||||
ThemeData get themeData => Theme.of(this);
|
||||
|
||||
|
|
@ -31,6 +43,15 @@ extension ContextHelper on BuildContext {
|
|||
// Current ColorScheme used
|
||||
ColorScheme get colorScheme => themeData.colorScheme;
|
||||
|
||||
// Navigate by pushing or popping routes from the current context
|
||||
NavigatorState get navigator => Navigator.of(this);
|
||||
|
||||
// Showing material banners from the current context
|
||||
ScaffoldMessengerState get scaffoldMessenger => ScaffoldMessenger.of(this);
|
||||
|
||||
// Pop-out from the current context with optional result
|
||||
void pop<T>([T? result]) => Navigator.of(this).pop(result);
|
||||
|
||||
// Managing focus within the widget tree from the current context
|
||||
FocusScopeNode get focusScope => FocusScope.of(this);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue