temp comment out some code

This commit is contained in:
julian 2023-05-09 14:47:00 -06:00
parent 2984b49178
commit 6d502ac01d
3 changed files with 361 additions and 371 deletions

View file

@ -1,13 +1,9 @@
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/pages/settings_views/global_settings_view/appearance_settings/system_brightness_theme_selection_view.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/appearance_settings/system_brightness_theme_selection_view.dart';
import 'package:stackwallet/providers/providers.dart';
import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/theme/color_theme.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart';
import 'package:stackwallet/widgets/conditional_parent.dart';
import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart';
class ThemeOptionsWidget extends ConsumerStatefulWidget { class ThemeOptionsWidget extends ConsumerStatefulWidget {
@ -18,82 +14,82 @@ class ThemeOptionsWidget extends ConsumerStatefulWidget {
} }
class _ThemeOptionsWidgetState extends ConsumerState<ThemeOptionsWidget> { class _ThemeOptionsWidgetState extends ConsumerState<ThemeOptionsWidget> {
final systemDefault = ThemeType.values.length; // final systemDefault = ThemeType.values.length;
late int _current; // late int _current;
//
void setTheme(int index) { // void setTheme(int index) {
if (index == _current) { // if (index == _current) {
return; // return;
} // }
//
if (index == systemDefault) { // if (index == systemDefault) {
// update current index // // update current index
_current = index; // _current = index;
//
// enable system brightness setting // // enable system brightness setting
ref.read(prefsChangeNotifierProvider).enableSystemBrightness = true; // ref.read(prefsChangeNotifierProvider).enableSystemBrightness = true;
//
// get theme // // get theme
final ThemeType theme; // final ThemeType theme;
switch (MediaQuery.of(context).platformBrightness) { // switch (MediaQuery.of(context).platformBrightness) {
case Brightness.dark: // case Brightness.dark:
theme = ref // theme = ref
.read(prefsChangeNotifierProvider.notifier) // .read(prefsChangeNotifierProvider.notifier)
.systemBrightnessDarkThemeId; // .systemBrightnessDarkThemeId;
break; // break;
case Brightness.light: // case Brightness.light:
theme = ref // theme = ref
.read(prefsChangeNotifierProvider.notifier) // .read(prefsChangeNotifierProvider.notifier)
.systemBrightnessLightThemeId; // .systemBrightnessLightThemeId;
break; // break;
} // }
//
// apply theme // // apply theme
//
throw Exception("bbbbbbbbbbbbbbbbb"); // throw Exception("bbbbbbbbbbbbbbbbb");
// ref.read(colorThemeProvider.notifier).state = // // ref.read(colorThemeProvider.notifier).state =
// StackColors.fromStackColorTheme( // // StackColors.fromStackColorTheme(
// theme.colorTheme, // // theme.colorTheme,
// ); // // );
//
// Assets.precache(context); // // Assets.precache(context);
} else { // } else {
if (_current == systemDefault) { // if (_current == systemDefault) {
// disable system brightness setting // // disable system brightness setting
ref.read(prefsChangeNotifierProvider).enableSystemBrightness = false; // ref.read(prefsChangeNotifierProvider).enableSystemBrightness = false;
} // }
//
// update current index // // update current index
_current = index; // _current = index;
//
// get theme // // get theme
final theme = ThemeType.values[index]; // final theme = ThemeType.values[index];
//
// save theme setting // // save theme setting
ref.read(prefsChangeNotifierProvider.notifier).themeId = theme; // ref.read(prefsChangeNotifierProvider.notifier).themeId = theme;
//
// apply theme // // apply theme
// ref.read(colorThemeProvider.notifier).state = // // ref.read(colorThemeProvider.notifier).state =
// StackColors.fromStackColorTheme( // // StackColors.fromStackColorTheme(
// theme.colorTheme, // // theme.colorTheme,
// ); // // );
//
throw Exception("bbbbbbbbbbbbbbbbb"); // throw Exception("bbbbbbbbbbbbbbbbb");
// Assets.precache(context); // // Assets.precache(context);
} // }
} // }
//
@override // @override
void initState() { // void initState() {
if (ref.read(prefsChangeNotifierProvider).enableSystemBrightness) { // if (ref.read(prefsChangeNotifierProvider).enableSystemBrightness) {
_current = ThemeType.values.length; // _current = ThemeType.values.length;
} else { // } else {
_current = ThemeType.values // _current = ThemeType.values
.indexOf(ref.read(prefsChangeNotifierProvider).themeId); // .indexOf(ref.read(prefsChangeNotifierProvider).themeId);
} // }
//
super.initState(); // super.initState();
} // }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -110,7 +106,7 @@ class _ThemeOptionsWidgetState extends ConsumerState<ThemeOptionsWidget> {
), ),
), ),
onPressed: () { onPressed: () {
setTheme(systemDefault); // setTheme(systemDefault);
}, },
child: SizedBox( child: SizedBox(
width: 200, width: 200,
@ -124,18 +120,18 @@ class _ThemeOptionsWidgetState extends ConsumerState<ThemeOptionsWidget> {
SizedBox( SizedBox(
width: 20, width: 20,
height: 26, height: 26,
child: Radio( // child: Radio(
activeColor: Theme.of(context) // activeColor: Theme.of(context)
.extension<StackColors>()! // .extension<StackColors>()!
.radioButtonIconEnabled, // .radioButtonIconEnabled,
value: ThemeType.values.length, // value: ThemeType.values.length,
groupValue: _current, // groupValue: _current,
onChanged: (newValue) { // onChanged: (newValue) {
if (newValue is int) { // if (newValue is int) {
setTheme(newValue); // setTheme(newValue);
} // }
}, // },
), // ),
), ),
const SizedBox( const SizedBox(
width: 14, width: 14,
@ -174,27 +170,27 @@ class _ThemeOptionsWidgetState extends ConsumerState<ThemeOptionsWidget> {
const SizedBox( const SizedBox(
height: 10, height: 10,
), ),
for (int i = 0; i < ThemeType.values.length; i++) // for (int i = 0; i < ThemeType.values.length; i++)
ConditionalParent( // ConditionalParent(
condition: i > 0, // condition: i > 0,
builder: (child) => Padding( // builder: (child) => Padding(
padding: const EdgeInsets.only(top: 10), // padding: const EdgeInsets.only(top: 10),
child: child, // child: child,
), // ),
child: ThemeOption( // child: ThemeOption(
label: ThemeType.values[i].prettyName, // label: ThemeType.values[i].prettyName,
onPressed: () { // onPressed: () {
setTheme(i); // setTheme(i);
}, // },
onChanged: (newValue) { // onChanged: (newValue) {
if (newValue is int) { // if (newValue is int) {
setTheme(newValue); // setTheme(newValue);
} // }
}, // },
value: i, // value: i,
groupValue: _current, // groupValue: _current,
), // ),
), // ),
], ],
); );
} }

View file

@ -1,13 +1,10 @@
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/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/theme/color_theme.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/theme/stack_colors.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';
class SystemBrightnessThemeSelectionView extends ConsumerWidget { class SystemBrightnessThemeSelectionView extends ConsumerWidget {
const SystemBrightnessThemeSelectionView({ const SystemBrightnessThemeSelectionView({
@ -69,146 +66,146 @@ 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 * ThemeType.values.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, // ThemeType.values[i ~/ 2].prettyName,
onPressed: () { // onPressed: () {
_setTheme( // _setTheme(
context: context, // context: context,
isDark: false, // isDark: false,
type: ThemeType.values[i ~/ 2], // type: ThemeType.values[i ~/ 2],
ref: ref, // ref: ref,
); // );
}, // },
onChanged: (newValue) { // onChanged: (newValue) {
final value = // final value =
ThemeType.values[i ~/ 2]; // ThemeType.values[i ~/ 2];
if (newValue == value && // if (newValue == value &&
ref // ref
.read( // .read(
prefsChangeNotifierProvider) // prefsChangeNotifierProvider)
.systemBrightnessLightThemeId != // .systemBrightnessLightThemeId !=
value) { // value) {
_setTheme( // _setTheme(
context: context, // context: context,
isDark: false, // isDark: false,
type: value, // type: value,
ref: ref, // ref: ref,
); // );
} // }
}, // },
value: ThemeType.values[i ~/ 2], // value: ThemeType.values[i ~/ 2],
groupValue: ref.watch( // groupValue: ref.watch(
prefsChangeNotifierProvider.select( // prefsChangeNotifierProvider.select(
(value) => value // (value) => value
.systemBrightnessLightThemeId)), // .systemBrightnessLightThemeId)),
), // ),
], // ],
), // ),
), // ),
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 dark mode theme", // "Choose dark 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 * ThemeType.values.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, // ThemeType.values[i ~/ 2].prettyName,
onPressed: () { // onPressed: () {
_setTheme( // _setTheme(
context: context, // context: context,
isDark: true, // isDark: true,
type: ThemeType.values[i ~/ 2], // type: ThemeType.values[i ~/ 2],
ref: ref, // ref: ref,
); // );
}, // },
onChanged: (newValue) { // onChanged: (newValue) {
final value = // final value =
ThemeType.values[i ~/ 2]; // ThemeType.values[i ~/ 2];
if (newValue == value && // if (newValue == value &&
ref // ref
.read( // .read(
prefsChangeNotifierProvider) // prefsChangeNotifierProvider)
.systemBrightnessDarkThemeId != // .systemBrightnessDarkThemeId !=
value) { // value) {
_setTheme( // _setTheme(
context: context, // context: context,
isDark: true, // isDark: true,
type: value, // type: value,
ref: ref, // ref: ref,
); // );
} // }
}, // },
value: ThemeType.values[i ~/ 2], // value: ThemeType.values[i ~/ 2],
groupValue: ref.watch( // groupValue: ref.watch(
prefsChangeNotifierProvider.select( // prefsChangeNotifierProvider.select(
(value) => value // (value) => value
.systemBrightnessDarkThemeId)), // .systemBrightnessDarkThemeId)),
), // ),
], // ],
), // ),
), // ),
const SizedBox( // const SizedBox(
height: 16, // height: 16,
), // ),
], // ],
), // ),
), // ),
), // ),
), ),
); );
}, },

View file

@ -2,11 +2,8 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:stackwallet/providers/global/prefs_provider.dart'; import 'package:stackwallet/providers/global/prefs_provider.dart';
import 'package:stackwallet/themes/theme_providers.dart';
import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/theme/color_theme.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart';
import 'package:stackwallet/widgets/custom_buttons/draggable_switch_button.dart'; import 'package:stackwallet/widgets/custom_buttons/draggable_switch_button.dart';
import 'package:stackwallet/widgets/rounded_white_container.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart';
@ -197,28 +194,28 @@ class ThemeToggle extends ConsumerStatefulWidget {
} }
class _ThemeToggle extends ConsumerState<ThemeToggle> { class _ThemeToggle extends ConsumerState<ThemeToggle> {
String assetNameFor(ThemeType type) { // String assetNameFor(ThemeType type) {
switch (type) { // switch (type) {
case ThemeType.light: // case ThemeType.light:
return Assets.svg.themeLight; // return Assets.svg.themeLight;
case ThemeType.dark: // case ThemeType.dark:
return ref.watch(themeProvider).assets.themePreview; // return ref.watch(themeProvider).assets.themePreview;
case ThemeType.darkChans: // case ThemeType.darkChans:
return Assets.svg.themeDarkChan; // return Assets.svg.themeDarkChan;
case ThemeType.oceanBreeze: // case ThemeType.oceanBreeze:
return Assets.svg.themeOcean; // return Assets.svg.themeOcean;
case ThemeType.oledBlack: // case ThemeType.oledBlack:
return Assets.svg.themeOledBlack; // return Assets.svg.themeOledBlack;
case ThemeType.orange: // case ThemeType.orange:
return Assets.svg.orange; // return Assets.svg.orange;
case ThemeType.fruitSorbet: // case ThemeType.fruitSorbet:
return Assets.svg.themeFruit; // return Assets.svg.themeFruit;
case ThemeType.forest: // case ThemeType.forest:
return Assets.svg.themeForest; // return Assets.svg.themeForest;
case ThemeType.chan: // case ThemeType.chan:
return Assets.svg.themeChan; // return Assets.svg.themeChan;
} // }
} // }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -226,95 +223,95 @@ class _ThemeToggle extends ConsumerState<ThemeToggle> {
spacing: 16, spacing: 16,
runSpacing: 16, runSpacing: 16,
children: [ children: [
for (int i = 0; i < ThemeType.values.length; i++) // for (int i = 0; i < ThemeType.values.length; i++)
Padding( // Padding(
padding: const EdgeInsets.all(8.0), // padding: const EdgeInsets.all(8.0),
child: MouseRegion( // child: MouseRegion(
cursor: SystemMouseCursors.click, // cursor: SystemMouseCursors.click,
child: GestureDetector( // child: GestureDetector(
onTap: () { // onTap: () {
if (ref.read(themeProvider.notifier).state.themeType != // if (ref.read(themeProvider.notifier).state.themeType !=
ThemeType.values[i]) { // ThemeType.values[i]) {
ref.read(prefsChangeNotifierProvider.notifier).themeId = // ref.read(prefsChangeNotifierProvider.notifier).themeId =
ThemeType.values[i]; // ThemeType.values[i];
//
throw Exception( // throw Exception(
"TODO: set theme here properly once implemented"); // "TODO: set theme here properly once implemented");
// ref.read(themeProvider.notifier).state = // // ref.read(themeProvider.notifier).state =
// StackColors.fromStackColorTheme( // // StackColors.fromStackColorTheme(
// ThemeType.values[i].colorTheme); // // ThemeType.values[i].colorTheme);
} // }
}, // },
child: Container( // child: Container(
width: 200, // width: 200,
color: Colors.transparent, // color: Colors.transparent,
child: Column( // child: Column(
mainAxisSize: MainAxisSize.min, // mainAxisSize: MainAxisSize.min,
children: [ // children: [
Container( // Container(
decoration: BoxDecoration( // decoration: BoxDecoration(
border: Border.all( // border: Border.all(
width: 2.5, // width: 2.5,
color: ref // color: ref
.read(themeProvider.notifier) // .read(themeProvider.notifier)
.state // .state
.themeType == // .themeType ==
ThemeType.values[i] // ThemeType.values[i]
? Theme.of(context) // ? Theme.of(context)
.extension<StackColors>()! // .extension<StackColors>()!
.infoItemIcons // .infoItemIcons
: Theme.of(context) // : Theme.of(context)
.extension<StackColors>()! // .extension<StackColors>()!
.popupBG, // .popupBG,
), // ),
borderRadius: BorderRadius.circular( // borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius, // Constants.size.circularBorderRadius,
), // ),
), // ),
child: SvgPicture.asset( // child: SvgPicture.asset(
assetNameFor(ThemeType.values[i]), // assetNameFor(ThemeType.values[i]),
height: 160, // height: 160,
width: 200, // width: 200,
), // ),
), // ),
const SizedBox( // const SizedBox(
height: 12, // height: 12,
), // ),
Row( // Row(
children: [ // children: [
SizedBox( // SizedBox(
width: 20, // width: 20,
height: 20, // height: 20,
child: Radio<ThemeType>( // child: Radio<ThemeType>(
activeColor: Theme.of(context) // activeColor: Theme.of(context)
.extension<StackColors>()! // .extension<StackColors>()!
.radioButtonIconEnabled, // .radioButtonIconEnabled,
value: ThemeType.values[i], // value: ThemeType.values[i],
groupValue: // groupValue:
ref.read(themeProvider.state).state.themeType, // ref.read(themeProvider.state).state.themeType,
onChanged: (_) {}, // onChanged: (_) {},
), // ),
), // ),
const SizedBox( // const SizedBox(
width: 14, // width: 14,
), // ),
Text( // Text(
ThemeType.values[i].prettyName, // ThemeType.values[i].prettyName,
style: STextStyles.desktopTextExtraSmall(context) // style: STextStyles.desktopTextExtraSmall(context)
.copyWith( // .copyWith(
color: Theme.of(context) // color: Theme.of(context)
.extension<StackColors>()! // .extension<StackColors>()!
.textDark, // .textDark,
), // ),
), // ),
], // ],
), // ),
], // ],
), // ),
), // ),
), // ),
), // ),
) // )
], ],
); );
} }