fix: Broken dynamic color palette
This commit is contained in:
parent
05f55b7aad
commit
ea17a28519
12 changed files with 111 additions and 215 deletions
131
lib/main.dart
131
lib/main.dart
|
|
@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'package:adaptive_theme/adaptive_theme.dart';
|
||||
import 'package:dynamic_color/dynamic_color.dart';
|
||||
import 'package:flutter_app_lock/flutter_app_lock.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||
|
|
@ -99,69 +100,71 @@ class _FluffyChatAppState extends State<FluffyChatApp> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AdaptiveTheme(
|
||||
light: FluffyThemes.light,
|
||||
dark: FluffyThemes.dark,
|
||||
initial: AdaptiveThemeMode.system,
|
||||
builder: (theme, darkTheme) => LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
const maxColumns = 3;
|
||||
var newColumns =
|
||||
(constraints.maxWidth / FluffyThemes.columnWidth).floor();
|
||||
if (newColumns > maxColumns) newColumns = maxColumns;
|
||||
columnMode ??= newColumns > 1;
|
||||
_router ??= GlobalKey<VRouterState>();
|
||||
if (columnMode != newColumns > 1) {
|
||||
Logs().v('Set Column Mode = $columnMode');
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
setState(() {
|
||||
_initialUrl = _router?.currentState?.url;
|
||||
columnMode = newColumns > 1;
|
||||
_router = GlobalKey<VRouterState>();
|
||||
});
|
||||
});
|
||||
}
|
||||
return VRouter(
|
||||
key: _router,
|
||||
title: AppConfig.applicationName,
|
||||
theme: theme,
|
||||
scrollBehavior: CustomScrollBehavior(),
|
||||
logs: kReleaseMode ? VLogs.none : VLogs.info,
|
||||
darkTheme: darkTheme,
|
||||
localizationsDelegates: const [
|
||||
...L10n.localizationsDelegates,
|
||||
],
|
||||
supportedLocales: L10n.supportedLocales,
|
||||
initialUrl: _initialUrl ?? '/',
|
||||
routes: AppRoutes(columnMode ?? false).routes,
|
||||
builder: (context, child) {
|
||||
LoadingDialog.defaultTitle = L10n.of(context)!.loadingPleaseWait;
|
||||
LoadingDialog.defaultBackLabel = L10n.of(context)!.close;
|
||||
LoadingDialog.defaultOnError =
|
||||
(e) => (e as Object?)!.toLocalizedString(context);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
SystemChrome.setSystemUIOverlayStyle(
|
||||
SystemUiOverlayStyle(
|
||||
statusBarColor: Colors.transparent,
|
||||
systemNavigationBarColor:
|
||||
Theme.of(context).appBarTheme.backgroundColor,
|
||||
systemNavigationBarIconBrightness:
|
||||
Theme.of(context).brightness == Brightness.light
|
||||
? Brightness.dark
|
||||
: Brightness.light,
|
||||
),
|
||||
);
|
||||
});
|
||||
return Matrix(
|
||||
context: context,
|
||||
router: _router,
|
||||
clients: widget.clients,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
return DynamicColorBuilder(
|
||||
builder: (lightColorScheme, darkColorScheme) => AdaptiveTheme(
|
||||
light: FluffyThemes.light(lightColorScheme),
|
||||
dark: FluffyThemes.dark(darkColorScheme),
|
||||
initial: AdaptiveThemeMode.system,
|
||||
builder: (theme, darkTheme) => LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
const maxColumns = 3;
|
||||
var newColumns =
|
||||
(constraints.maxWidth / FluffyThemes.columnWidth).floor();
|
||||
if (newColumns > maxColumns) newColumns = maxColumns;
|
||||
columnMode ??= newColumns > 1;
|
||||
_router ??= GlobalKey<VRouterState>();
|
||||
if (columnMode != newColumns > 1) {
|
||||
Logs().v('Set Column Mode = $columnMode');
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
setState(() {
|
||||
_initialUrl = _router?.currentState?.url;
|
||||
columnMode = newColumns > 1;
|
||||
_router = GlobalKey<VRouterState>();
|
||||
});
|
||||
});
|
||||
}
|
||||
return VRouter(
|
||||
key: _router,
|
||||
title: AppConfig.applicationName,
|
||||
theme: theme,
|
||||
scrollBehavior: CustomScrollBehavior(),
|
||||
logs: kReleaseMode ? VLogs.none : VLogs.info,
|
||||
darkTheme: darkTheme,
|
||||
localizationsDelegates: const [
|
||||
...L10n.localizationsDelegates,
|
||||
],
|
||||
supportedLocales: L10n.supportedLocales,
|
||||
initialUrl: _initialUrl ?? '/',
|
||||
routes: AppRoutes(columnMode ?? false).routes,
|
||||
builder: (context, child) {
|
||||
LoadingDialog.defaultTitle =
|
||||
L10n.of(context)!.loadingPleaseWait;
|
||||
LoadingDialog.defaultBackLabel = L10n.of(context)!.close;
|
||||
LoadingDialog.defaultOnError =
|
||||
(e) => (e as Object?)!.toLocalizedString(context);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
SystemChrome.setSystemUIOverlayStyle(
|
||||
SystemUiOverlayStyle(
|
||||
statusBarColor: Colors.transparent,
|
||||
systemNavigationBarColor:
|
||||
Theme.of(context).appBarTheme.backgroundColor,
|
||||
systemNavigationBarIconBrightness:
|
||||
Theme.of(context).brightness == Brightness.light
|
||||
? Brightness.dark
|
||||
: Brightness.light,
|
||||
),
|
||||
);
|
||||
});
|
||||
return Matrix(
|
||||
context: context,
|
||||
router: _router,
|
||||
clients: widget.clients,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue