add adaptive_scaffold

This commit is contained in:
shenlong-tanwen
2024-05-24 09:42:02 +05:30
parent fb6253d2d1
commit 1631df70e9
295 changed files with 2540 additions and 44480 deletions
@@ -0,0 +1,4 @@
import 'package:flutter/material.dart';
/// Global ScaffoldMessengerKey to show snackbars
final GlobalKey<ScaffoldMessengerState> kScafMessengerKey = GlobalKey();
@@ -0,0 +1,11 @@
import 'package:flutter/material.dart';
@immutable
class SizeConstants {
const SizeConstants._();
static const s = 8.0;
static const m = 16.0;
static const l = 32.0;
static const xl = 64.0;
}
@@ -0,0 +1,30 @@
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
extension BuildContextHelper on BuildContext {
/// Get the current [ThemeData] used
ThemeData get theme => Theme.of(this);
/// Get the default [TextStyle]
TextStyle get defaultTextStyle => DefaultTextStyle.of(this).style;
/// Get the [Size] of [MediaQuery]
Size get mediaQuerySize => MediaQuery.sizeOf(this);
/// Get the [EdgeInsets] of [MediaQuery]
EdgeInsets get viewInsets => MediaQuery.viewInsetsOf(this);
/// True if the current device is a Tablet
bool get isTablet => (mediaQuerySize.width >= 600);
/// True if the current app theme is dark
bool get isDarkTheme => theme.brightness == Brightness.dark;
/// Navigate using the root router
// ignore: avoid-dynamic
Future<dynamic> navigateRoot(
PageRouteInfo route, {
OnNavigationFailure? onFailure,
}) =>
router.root.navigate(route, onFailure: onFailure);
}
@@ -0,0 +1,12 @@
import 'package:flutter/material.dart';
extension MaterialStateHelpers on Iterable<WidgetState> {
bool get isDisabled => contains(WidgetState.disabled);
bool get isDragged => contains(WidgetState.dragged);
bool get isError => contains(WidgetState.error);
bool get isFocused => contains(WidgetState.focused);
bool get isHovered => contains(WidgetState.hovered);
bool get isPressed => contains(WidgetState.pressed);
bool get isScrolledUnder => contains(WidgetState.scrolledUnder);
bool get isSelected => contains(WidgetState.selected);
}
@@ -2,13 +2,7 @@ import 'package:flutter/foundation.dart';
import 'package:logging/logging.dart';
mixin LogContext {
late final String ctx = logContext;
/// Context name of the log message
/// Override this to provide a custom name
String get logContext => runtimeType.toString();
@protected
@nonVirtual
Logger get log => Logger.detached(ctx);
Logger get log => Logger.detached(runtimeType.toString());
}
+13
View File
@@ -0,0 +1,13 @@
import 'package:flutter/material.dart';
import 'package:immich_mobile/utils/constants/globals.dart';
class SnackbarManager {
const SnackbarManager();
static ScaffoldMessengerState? get _s => kScafMessengerKey.currentState;
static void showError(String errorMsg) {
_s?.clearSnackBars();
_s?.showSnackBar(SnackBar(content: Text(errorMsg)));
}
}