fix: mobile system default theme options

This commit is contained in:
julian 2023-05-10 11:01:25 -06:00
parent 2f895c12a7
commit 6e381ef280
2 changed files with 183 additions and 157 deletions

View file

@ -1,5 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:stackwallet/pages/settings_views/global_settings_view/appearance_settings/manage_themes.dart';
import 'package:stackwallet/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/theme_options_widget.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/theme_options_widget.dart';
import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/providers/providers.dart';
import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/stack_colors.dart';
@ -11,8 +12,6 @@ import 'package:stackwallet/widgets/custom_buttons/draggable_switch_button.dart'
import 'package:stackwallet/widgets/desktop/secondary_button.dart'; import 'package:stackwallet/widgets/desktop/secondary_button.dart';
import 'package:stackwallet/widgets/rounded_white_container.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart';
import 'manage_themes.dart';
class AppearanceSettingsView extends ConsumerWidget { class AppearanceSettingsView extends ConsumerWidget {
const AppearanceSettingsView({Key? key}) : super(key: key); const AppearanceSettingsView({Key? key}) : super(key: key);

View file

@ -1,18 +1,30 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:stackwallet/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/theme_option.dart';
import 'package:stackwallet/providers/global/prefs_provider.dart'; import 'package:stackwallet/providers/global/prefs_provider.dart';
import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/themes/theme_providers.dart';
import 'package:stackwallet/themes/theme_service.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/widgets/background.dart'; import 'package:stackwallet/widgets/background.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
import 'package:stackwallet/widgets/rounded_white_container.dart';
import 'package:tuple/tuple.dart';
class SystemBrightnessThemeSelectionView extends ConsumerWidget { class SystemBrightnessThemeSelectionView extends ConsumerStatefulWidget {
const SystemBrightnessThemeSelectionView({ const SystemBrightnessThemeSelectionView({Key? key}) : super(key: key);
Key? key,
}) : super(key: key);
static const String routeName = "/chooseSystemTheme"; static const String routeName = "/chooseSystemTheme";
@override
ConsumerState<SystemBrightnessThemeSelectionView> createState() =>
_SystemBrightnessThemeSelectionViewState();
}
class _SystemBrightnessThemeSelectionViewState
extends ConsumerState<SystemBrightnessThemeSelectionView> {
List<Tuple2<String, String>> installedThemeIdNames = [];
void _setTheme({ void _setTheme({
required BuildContext context, required BuildContext context,
required bool isDark, required bool isDark,
@ -24,27 +36,34 @@ class SystemBrightnessThemeSelectionView extends ConsumerWidget {
ref.read(prefsChangeNotifierProvider).systemBrightnessDarkThemeId = ref.read(prefsChangeNotifierProvider).systemBrightnessDarkThemeId =
themeId; themeId;
if (brightness == Brightness.dark) { if (brightness == Brightness.dark) {
throw Exception("aaaaaaaaaaaaaaaa"); // apply theme
// ref.read(themeProvider.notifier).state = ref.read(themeProvider.notifier).state =
// StackColors.fromStackColorTheme( ref.read(pThemeService).getTheme(themeId: themeId)!;
// type.colorTheme,
// );
} }
} else { } else {
ref.read(prefsChangeNotifierProvider).systemBrightnessLightThemeId = ref.read(prefsChangeNotifierProvider).systemBrightnessLightThemeId =
themeId; themeId;
if (brightness == Brightness.light) { if (brightness == Brightness.light) {
throw Exception("aaaaaaaaaaaaaaaa"); // apply theme
// ref.read(colorThemeProvider.notifier).state = ref.read(themeProvider.notifier).state =
// StackColors.fromStackColorTheme( ref.read(pThemeService).getTheme(themeId: themeId)!;
// type.colorTheme,
// );
} }
} }
} }
@override @override
Widget build(BuildContext context, WidgetRef ref) { void initState() {
installedThemeIdNames = ref
.read(pThemeService)
.installedThemes
.map((e) => Tuple2(e.themeId, e.name))
.toList();
super.initState();
}
@override
Widget build(BuildContext context) {
return Background( return Background(
child: Scaffold( child: Scaffold(
backgroundColor: Theme.of(context).extension<StackColors>()!.background, backgroundColor: Theme.of(context).extension<StackColors>()!.background,
@ -66,146 +85,154 @@ class SystemBrightnessThemeSelectionView extends ConsumerWidget {
constraints: BoxConstraints( constraints: BoxConstraints(
minHeight: constraints.maxHeight, minHeight: constraints.maxHeight,
), ),
// child: IntrinsicHeight( child: IntrinsicHeight(
// child: Padding( child: Padding(
// padding: const EdgeInsets.symmetric(horizontal: 16), padding: const EdgeInsets.symmetric(horizontal: 16),
// child: Column( child: Column(
// crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
// children: [ children: [
// const SizedBox( const SizedBox(
// height: 16, height: 16,
// ), ),
// RoundedWhiteContainer( RoundedWhiteContainer(
// child: Text( child: Text(
// "Select a light and dark theme that will be" "Select a light and dark theme that will be"
// " activated automatically when your phone system" " activated automatically when your phone system"
// " switches light and dark mode.", " switches light and dark mode.",
// style: STextStyles.smallMed12(context), style: STextStyles.smallMed12(context),
// ), ),
// ), ),
// const SizedBox( const SizedBox(
// height: 10, height: 10,
// ), ),
// RoundedWhiteContainer( RoundedWhiteContainer(
// child: Column( child: Column(
// crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
// children: [ children: [
// Text( Text(
// "Choose light mode theme", "Choose light mode theme",
// style: STextStyles.titleBold12(context), style: STextStyles.titleBold12(context),
// ), ),
// const SizedBox( const SizedBox(
// height: 18, height: 18,
// ), ),
// for (int i = 0; for (int i = 0;
// i < (2 * ThemeType.values.length) - 1; i < (2 * installedThemeIdNames.length) - 1;
// i++) i++)
// (i % 2 == 1) (i % 2 == 1)
// ? const SizedBox( ? const SizedBox(
// height: 10, height: 10,
// ) )
// : ThemeOption( : ThemeOption(
// label: label:
// ThemeType.values[i ~/ 2].prettyName, installedThemeIdNames[i ~/ 2].item2,
// onPressed: () { onPressed: () {
// _setTheme( _setTheme(
// context: context, context: context,
// isDark: false, isDark: false,
// type: ThemeType.values[i ~/ 2], themeId:
// ref: ref, installedThemeIdNames[i ~/ 2]
// ); .item1,
// }, ref: ref,
// onChanged: (newValue) { );
// final value = },
// ThemeType.values[i ~/ 2]; onChanged: (newValue) {
// if (newValue == value && final value =
// ref installedThemeIdNames[i ~/ 2]
// .read( .item1;
// prefsChangeNotifierProvider) if (newValue == value &&
// .systemBrightnessLightThemeId != ref
// value) { .read(
// _setTheme( prefsChangeNotifierProvider)
// context: context, .systemBrightnessLightThemeId !=
// isDark: false, value) {
// type: value, _setTheme(
// ref: ref, context: context,
// ); isDark: false,
// } themeId: value,
// }, ref: ref,
// value: ThemeType.values[i ~/ 2], );
// groupValue: ref.watch( }
// prefsChangeNotifierProvider.select( },
// (value) => value value:
// .systemBrightnessLightThemeId)), installedThemeIdNames[i ~/ 2].item1,
// ), groupValue: ref.watch(
// ], prefsChangeNotifierProvider.select(
// ), (value) => value
// ), .systemBrightnessLightThemeId)),
// const SizedBox( ),
// height: 10, ],
// ), ),
// RoundedWhiteContainer( ),
// child: Column( const SizedBox(
// crossAxisAlignment: CrossAxisAlignment.start, height: 10,
// children: [ ),
// Text( RoundedWhiteContainer(
// "Choose dark mode theme", child: Column(
// style: STextStyles.titleBold12(context), crossAxisAlignment: CrossAxisAlignment.start,
// ), children: [
// const SizedBox( Text(
// height: 18, "Choose dark mode theme",
// ), style: STextStyles.titleBold12(context),
// for (int i = 0; ),
// i < (2 * ThemeType.values.length) - 1; const SizedBox(
// i++) height: 18,
// (i % 2 == 1) ),
// ? const SizedBox( for (int i = 0;
// height: 10, i < (2 * installedThemeIdNames.length) - 1;
// ) i++)
// : ThemeOption( (i % 2 == 1)
// label: ? const SizedBox(
// ThemeType.values[i ~/ 2].prettyName, height: 10,
// onPressed: () { )
// _setTheme( : ThemeOption(
// context: context, label:
// isDark: true, installedThemeIdNames[i ~/ 2].item2,
// type: ThemeType.values[i ~/ 2], onPressed: () {
// ref: ref, _setTheme(
// ); context: context,
// }, isDark: true,
// onChanged: (newValue) { themeId:
// final value = installedThemeIdNames[i ~/ 2]
// ThemeType.values[i ~/ 2]; .item1,
// if (newValue == value && ref: ref,
// ref );
// .read( },
// prefsChangeNotifierProvider) onChanged: (newValue) {
// .systemBrightnessDarkThemeId != final value =
// value) { installedThemeIdNames[i ~/ 2]
// _setTheme( .item1;
// context: context, if (newValue == value &&
// isDark: true, ref
// type: value, .read(
// ref: ref, prefsChangeNotifierProvider)
// ); .systemBrightnessDarkThemeId !=
// } value) {
// }, _setTheme(
// value: ThemeType.values[i ~/ 2], context: context,
// groupValue: ref.watch( isDark: true,
// prefsChangeNotifierProvider.select( themeId: value,
// (value) => value ref: ref,
// .systemBrightnessDarkThemeId)), );
// ), }
// ], },
// ), value:
// ), installedThemeIdNames[i ~/ 2].item1,
// const SizedBox( groupValue: ref.watch(
// height: 16, prefsChangeNotifierProvider.select(
// ), (value) => value
// ], .systemBrightnessDarkThemeId)),
// ), ),
// ), ],
// ), ),
),
const SizedBox(
height: 16,
),
],
),
),
),
), ),
); );
}, },