Skip to content

Commit

Permalink
added back color switching
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecoomber committed Sep 4, 2024
1 parent 18401ac commit fb6aa8c
Show file tree
Hide file tree
Showing 6 changed files with 241 additions and 240 deletions.
99 changes: 54 additions & 45 deletions example/lib/utils/theme_color_switch.dart
Original file line number Diff line number Diff line change
@@ -1,49 +1,58 @@
// TODO(mikecoomber): Re implement this widget
// import 'package:flutter/material.dart';
// import 'package:zeta_flutter/zeta_flutter.dart';
import 'package:flutter/material.dart';
import 'package:zeta_flutter/zeta_flutter.dart';

// class ZetaThemeColorSwitch extends StatelessWidget {
// ZetaThemeColorSwitch({super.key});
class ZetaThemeColorSwitch extends StatefulWidget {
ZetaThemeColorSwitch({super.key});

// @override
// Widget build(BuildContext context) {
// final zeta = Zeta.of(context);
@override
State<ZetaThemeColorSwitch> createState() => _ZetaThemeColorSwitchState();
}

// ZetaColors primary(ZetaThemeData data) {
// if (zeta.brightness == Brightness.light) {
// return data.colorsLight;
// } else {
// return data.colorsDark;
// }
// }
class _ZetaThemeColorSwitchState extends State<ZetaThemeColorSwitch> {
String currentTheme = "default";

// return DropdownButtonHideUnderline(
// child: DropdownButton<String>(
// value: zeta.themeData?.identifier,
// elevation: 0,
// padding: EdgeInsets.all(8),
// icon: Nothing(),
// dropdownColor: zeta.colors.borderDisabled,
// items: appThemes.entries.map((e) {
// final zetaColors = primary(appThemes[e.key]!);
// final color = zetaColors.primary;
// return DropdownMenuItem<String>(
// value: e.value.identifier,
// alignment: Alignment.center,
// child: ZetaAvatar(
// size: ZetaAvatarSize.xxs,
// backgroundColor: color.surface,
// image: ZetaIcon(Icons.color_lens, color: color),
// ),
// );
// }).toList(),
// onChanged: (value) {
// final theme = appThemes[value];
// if (theme != null) {
// ZetaProvider.of(context).updateThemeData(theme);
// }
// },
// ),
// );
// }
// }
final Map<String, ZetaColorSwatch> appThemes = {
"default": ZetaPrimitivesLight().blue,
"teal": ZetaPrimitivesLight().teal,
"yellow": ZetaPrimitivesLight().yellow,
"red": ZetaPrimitivesLight().red,
"purple": ZetaPrimitivesLight().purple,
};

@override
Widget build(BuildContext context) {
final zeta = Zeta.of(context);

return DropdownButtonHideUnderline(
child: DropdownButton<String>(
value: currentTheme,
elevation: 0,
padding: EdgeInsets.all(8),
icon: Nothing(),
dropdownColor: zeta.colors.borderDisabled,
items: appThemes.entries.map((e) {
final color = e.value;
final name = e.key;
return DropdownMenuItem<String>(
value: name,
alignment: Alignment.center,
child: ZetaAvatar(
size: ZetaAvatarSize.xxs,
backgroundColor: color,
image: ZetaIcon(Icons.color_lens, color: color),
),
);
}).toList(),
onChanged: (value) {
final theme = appThemes[value];
if (theme != null && value != null) {
ZetaProvider.of(context).updateThemeData(primary: theme);
setState(() {
currentTheme = value;
});
}
},
),
);
}
}
3 changes: 2 additions & 1 deletion example/lib/widgets.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:zeta_example/utils/rounded_switch.dart';
import 'package:zeta_example/utils/theme_color_switch.dart';
import 'package:zeta_example/utils/theme_constrast_switch.dart';
import 'package:zeta_example/utils/theme_mode_switch.dart';

Expand Down Expand Up @@ -36,7 +37,7 @@ class ExampleScaffold extends StatelessWidget {
ZetaRoundedSwitch(),
ZetaThemeModeSwitch(),
ZetaThemeContrastSwitch(),
// ZetaThemeColorSwitch(),
ZetaThemeColorSwitch(),
],
),
backgroundColor: colors.surface,
Expand Down
Loading

0 comments on commit fb6aa8c

Please sign in to comment.