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

View file

@ -1,13 +1,10 @@
import 'package:flutter/material.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/utilities/text_styles.dart';
import 'package:stackwallet/utilities/theme/color_theme.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart';
import 'package:stackwallet/widgets/background.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
import 'package:stackwallet/widgets/rounded_white_container.dart';
class SystemBrightnessThemeSelectionView extends ConsumerWidget {
const SystemBrightnessThemeSelectionView({
@ -69,146 +66,146 @@ class SystemBrightnessThemeSelectionView extends ConsumerWidget {
constraints: BoxConstraints(
minHeight: constraints.maxHeight,
),
child: IntrinsicHeight(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const SizedBox(
height: 16,
),
RoundedWhiteContainer(
child: Text(
"Select a light and dark theme that will be"
" activated automatically when your phone system"
" switches light and dark mode.",
style: STextStyles.smallMed12(context),
),
),
const SizedBox(
height: 10,
),
RoundedWhiteContainer(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Choose light mode theme",
style: STextStyles.titleBold12(context),
),
const SizedBox(
height: 18,
),
for (int i = 0;
i < (2 * ThemeType.values.length) - 1;
i++)
(i % 2 == 1)
? const SizedBox(
height: 10,
)
: ThemeOption(
label:
ThemeType.values[i ~/ 2].prettyName,
onPressed: () {
_setTheme(
context: context,
isDark: false,
type: ThemeType.values[i ~/ 2],
ref: ref,
);
},
onChanged: (newValue) {
final value =
ThemeType.values[i ~/ 2];
if (newValue == value &&
ref
.read(
prefsChangeNotifierProvider)
.systemBrightnessLightThemeId !=
value) {
_setTheme(
context: context,
isDark: false,
type: value,
ref: ref,
);
}
},
value: ThemeType.values[i ~/ 2],
groupValue: ref.watch(
prefsChangeNotifierProvider.select(
(value) => value
.systemBrightnessLightThemeId)),
),
],
),
),
const SizedBox(
height: 10,
),
RoundedWhiteContainer(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Choose dark mode theme",
style: STextStyles.titleBold12(context),
),
const SizedBox(
height: 18,
),
for (int i = 0;
i < (2 * ThemeType.values.length) - 1;
i++)
(i % 2 == 1)
? const SizedBox(
height: 10,
)
: ThemeOption(
label:
ThemeType.values[i ~/ 2].prettyName,
onPressed: () {
_setTheme(
context: context,
isDark: true,
type: ThemeType.values[i ~/ 2],
ref: ref,
);
},
onChanged: (newValue) {
final value =
ThemeType.values[i ~/ 2];
if (newValue == value &&
ref
.read(
prefsChangeNotifierProvider)
.systemBrightnessDarkThemeId !=
value) {
_setTheme(
context: context,
isDark: true,
type: value,
ref: ref,
);
}
},
value: ThemeType.values[i ~/ 2],
groupValue: ref.watch(
prefsChangeNotifierProvider.select(
(value) => value
.systemBrightnessDarkThemeId)),
),
],
),
),
const SizedBox(
height: 16,
),
],
),
),
),
// child: IntrinsicHeight(
// child: Padding(
// padding: const EdgeInsets.symmetric(horizontal: 16),
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.stretch,
// children: [
// const SizedBox(
// height: 16,
// ),
// RoundedWhiteContainer(
// child: Text(
// "Select a light and dark theme that will be"
// " activated automatically when your phone system"
// " switches light and dark mode.",
// style: STextStyles.smallMed12(context),
// ),
// ),
// const SizedBox(
// height: 10,
// ),
// RoundedWhiteContainer(
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Text(
// "Choose light mode theme",
// style: STextStyles.titleBold12(context),
// ),
// const SizedBox(
// height: 18,
// ),
// for (int i = 0;
// i < (2 * ThemeType.values.length) - 1;
// i++)
// (i % 2 == 1)
// ? const SizedBox(
// height: 10,
// )
// : ThemeOption(
// label:
// ThemeType.values[i ~/ 2].prettyName,
// onPressed: () {
// _setTheme(
// context: context,
// isDark: false,
// type: ThemeType.values[i ~/ 2],
// ref: ref,
// );
// },
// onChanged: (newValue) {
// final value =
// ThemeType.values[i ~/ 2];
// if (newValue == value &&
// ref
// .read(
// prefsChangeNotifierProvider)
// .systemBrightnessLightThemeId !=
// value) {
// _setTheme(
// context: context,
// isDark: false,
// type: value,
// ref: ref,
// );
// }
// },
// value: ThemeType.values[i ~/ 2],
// groupValue: ref.watch(
// prefsChangeNotifierProvider.select(
// (value) => value
// .systemBrightnessLightThemeId)),
// ),
// ],
// ),
// ),
// const SizedBox(
// height: 10,
// ),
// RoundedWhiteContainer(
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Text(
// "Choose dark mode theme",
// style: STextStyles.titleBold12(context),
// ),
// const SizedBox(
// height: 18,
// ),
// for (int i = 0;
// i < (2 * ThemeType.values.length) - 1;
// i++)
// (i % 2 == 1)
// ? const SizedBox(
// height: 10,
// )
// : ThemeOption(
// label:
// ThemeType.values[i ~/ 2].prettyName,
// onPressed: () {
// _setTheme(
// context: context,
// isDark: true,
// type: ThemeType.values[i ~/ 2],
// ref: ref,
// );
// },
// onChanged: (newValue) {
// final value =
// ThemeType.values[i ~/ 2];
// if (newValue == value &&
// ref
// .read(
// prefsChangeNotifierProvider)
// .systemBrightnessDarkThemeId !=
// value) {
// _setTheme(
// context: context,
// isDark: true,
// type: value,
// ref: ref,
// );
// }
// },
// value: ThemeType.values[i ~/ 2],
// groupValue: ref.watch(
// prefsChangeNotifierProvider.select(
// (value) => value
// .systemBrightnessDarkThemeId)),
// ),
// ],
// ),
// ),
// const SizedBox(
// height: 16,
// ),
// ],
// ),
// ),
// ),
),
);
},

View file

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