mirror of
https://github.com/inventree/inventree-app.git
synced 2026-07-10 06:41:02 +00:00
349a8e0ef5
* Updated dashboard - Display "outstanding" badges - Display "overdue" badges - Pull-to-refresh * Remove dead code * Refactor app colors * Add "pending shipments" icon * Remove custom spinner * Refactor error dialog * Updated redirect after login * Refactor login/account pages - Better UX and confirmation messages * Refactor API error messages * Improve token management - Secure storage - Handle session expiry - Per-profile HTTPS certificate checks * Improved error messages
42 lines
1.3 KiB
Dart
42 lines
1.3 KiB
Dart
import "package:adaptive_theme/adaptive_theme.dart";
|
|
import "package:flutter/material.dart";
|
|
import "package:inventree/helpers.dart";
|
|
import "package:one_context/one_context.dart";
|
|
|
|
bool isDarkMode() {
|
|
if (!hasContext()) {
|
|
return false;
|
|
}
|
|
|
|
BuildContext? context = OneContext().context;
|
|
|
|
if (context == null) {
|
|
return false;
|
|
}
|
|
|
|
return AdaptiveTheme.of(context).brightness == Brightness.dark;
|
|
}
|
|
|
|
// Resolve the app's current ColorScheme, falling back to a sensible default
|
|
// if no BuildContext is available yet (e.g. very early app startup).
|
|
ColorScheme get _colorScheme {
|
|
final BuildContext? context = OneContext().context;
|
|
|
|
if (context == null) {
|
|
return const ColorScheme.light();
|
|
}
|
|
|
|
return Theme.of(context).colorScheme;
|
|
}
|
|
|
|
// Semantic colors, derived from the current theme's ColorScheme.
|
|
// Material 3 has no dedicated "success"/"warning" roles, so those map onto
|
|
// the nearest available accent (tertiary / secondary respectively).
|
|
Color get COLOR_ACTION => Colors.blue;
|
|
Color get COLOR_WARNING => Colors.orange;
|
|
Color get COLOR_DANGER => _colorScheme.error;
|
|
Color get COLOR_SUCCESS => Colors.lightGreen;
|
|
Color get COLOR_PROGRESS => Colors.lightBlue;
|
|
Color get COLOR_GRAY_LIGHT => _colorScheme.onSurfaceVariant;
|
|
Color get COLOR_TEXT => _colorScheme.onSurface;
|