|
|
|
@ -1,12 +1,9 @@
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
|
|
import 'package:collection/collection.dart';
|
|
|
|
|
import 'package:dynamic_color/dynamic_color.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
|
import 'package:system_theme/system_theme.dart';
|
|
|
|
|
|
|
|
|
|
import 'package:fluffychat/config/app_config.dart';
|
|
|
|
|
import 'package:fluffychat/utils/platform_infos.dart';
|
|
|
|
|
|
|
|
|
|
class ThemeBuilder extends StatefulWidget {
|
|
|
|
|
final Widget Function(
|
|
|
|
@ -89,28 +86,16 @@ class ThemeController extends State<ThemeBuilder> {
|
|
|
|
|
super.initState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Color get systemAccentColor {
|
|
|
|
|
if (PlatformInfos.isLinux) return AppConfig.chatColor;
|
|
|
|
|
try {
|
|
|
|
|
// a bad plugin implementation
|
|
|
|
|
// https://github.com/bdlukaa/system_theme/issues/10
|
|
|
|
|
final accentColor = SystemTheme.accentColor;
|
|
|
|
|
final color = accentColor.accent;
|
|
|
|
|
return color;
|
|
|
|
|
} catch (_) {
|
|
|
|
|
return AppConfig.chatColor;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Provider(
|
|
|
|
|
create: (_) => this,
|
|
|
|
|
child: widget.builder(
|
|
|
|
|
context,
|
|
|
|
|
themeMode,
|
|
|
|
|
primaryColor ?? systemAccentColor,
|
|
|
|
|
),
|
|
|
|
|
child: DynamicColorBuilder(
|
|
|
|
|
builder: (light, _) => widget.builder(
|
|
|
|
|
context,
|
|
|
|
|
themeMode,
|
|
|
|
|
primaryColor ?? light?.primary,
|
|
|
|
|
)),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|