fix: selected theme on deleting themes changing

This commit is contained in:
julian 2023-05-12 15:05:40 -06:00
parent 147914f650
commit b715cf9535
2 changed files with 19 additions and 17 deletions

View file

@ -92,11 +92,6 @@ class _ThemeOptionsWidgetState extends ConsumerState<ThemeOptionsWidget> {
.installedThemes .installedThemes
.map((e) => Tuple2(e.themeId, e.name)) .map((e) => Tuple2(e.themeId, e.name))
.toList(); .toList();
}
@override
void initState() {
_updateInstalledList();
if (ref.read(prefsChangeNotifierProvider).enableSystemBrightness) { if (ref.read(prefsChangeNotifierProvider).enableSystemBrightness) {
_current = installedThemeIdNames.length; _current = installedThemeIdNames.length;
@ -110,6 +105,11 @@ class _ThemeOptionsWidgetState extends ConsumerState<ThemeOptionsWidget> {
} }
} }
} }
}
@override
void initState() {
_updateInstalledList();
_subscription = _subscription =
ref.read(mainDBProvider).isar.stackThemes.watchLazy().listen((_) { ref.read(mainDBProvider).isar.stackThemes.watchLazy().listen((_) {
@ -212,6 +212,7 @@ class _ThemeOptionsWidgetState extends ConsumerState<ThemeOptionsWidget> {
), ),
for (int i = 0; i < installedThemeIdNames.length; i++) for (int i = 0; i < installedThemeIdNames.length; i++)
ConditionalParent( ConditionalParent(
key: Key("installedTheme_${installedThemeIdNames[i].item1}"),
condition: i > 0, condition: i > 0,
builder: (child) => Padding( builder: (child) => Padding(
padding: const EdgeInsets.only(top: 10), padding: const EdgeInsets.only(top: 10),

View file

@ -272,18 +272,6 @@ class _ThemeToggle extends ConsumerState<ThemeToggle> {
.installedThemes .installedThemes
.map((e) => Tuple3(e.themeId, e.name, e.assets.themeSelector)) .map((e) => Tuple3(e.themeId, e.name, e.assets.themeSelector))
.toList(); .toList();
}
void _manageThemesPressed() {
showDialog<void>(
context: context,
builder: (_) => const DesktopManageThemesDialog(),
);
}
@override
void initState() {
_updateInstalledList();
if (ref.read(prefsChangeNotifierProvider).enableSystemBrightness) { if (ref.read(prefsChangeNotifierProvider).enableSystemBrightness) {
_current = installedThemeIdNames.length; _current = installedThemeIdNames.length;
@ -297,6 +285,18 @@ class _ThemeToggle extends ConsumerState<ThemeToggle> {
} }
} }
} }
}
void _manageThemesPressed() {
showDialog<void>(
context: context,
builder: (_) => const DesktopManageThemesDialog(),
);
}
@override
void initState() {
_updateInstalledList();
_subscription = _subscription =
ref.read(mainDBProvider).isar.stackThemes.watchLazy().listen((_) { ref.read(mainDBProvider).isar.stackThemes.watchLazy().listen((_) {
@ -326,6 +326,7 @@ class _ThemeToggle extends ConsumerState<ThemeToggle> {
children: [ children: [
for (int i = 0; i < installedThemeIdNames.length; i++) for (int i = 0; i < installedThemeIdNames.length; i++)
Padding( Padding(
key: Key("installedTheme_${installedThemeIdNames[i].item1}"),
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: MouseRegion( child: MouseRegion(
cursor: SystemMouseCursors.click, cursor: SystemMouseCursors.click,