From 6d9ad765129d8921b45713e23bfbbad27a293412 Mon Sep 17 00:00:00 2001 From: Genoveva Georgieva <151932404+genovevageorgieva@users.noreply.github.com> Date: Tue, 5 Dec 2023 13:01:25 +0200 Subject: [PATCH] Checkbox (#9) * checkbox * remove comment * widgetbook * widgetbook --- example/lib/pages/theme/color_example.dart | 18 ++--- example/lib/pages/theme_color_switch.dart | 69 ------------------ example/lib/pages/theme_constrast_switch.dart | 56 -------------- example/lib/pages/theme_mode_switch.dart | 60 --------------- .../Flutter/GeneratedPluginRegistrant.swift | 16 ++++ example/widgetbook/widgetbook.dart | 5 +- lib/src/assets/fonts/zeta-icons-other.ttf | Bin 1088 -> 0 bytes .../bottom sheets/bottom_sheet.dart | 5 +- lib/src/components/buttons/fab.dart | 2 +- 9 files changed, 28 insertions(+), 203 deletions(-) delete mode 100644 example/lib/pages/theme_color_switch.dart delete mode 100644 example/lib/pages/theme_constrast_switch.dart delete mode 100644 example/lib/pages/theme_mode_switch.dart create mode 100644 example/macos/Flutter/GeneratedPluginRegistrant.swift delete mode 100644 lib/src/assets/fonts/zeta-icons-other.ttf diff --git a/example/lib/pages/theme/color_example.dart b/example/lib/pages/theme/color_example.dart index 9d962a9e..da441b7c 100644 --- a/example/lib/pages/theme/color_example.dart +++ b/example/lib/pages/theme/color_example.dart @@ -123,15 +123,15 @@ class _ColorExampleState extends State { }; final Map primaries = { - 'primaryColor': colors.primary, - 'secondaryColor': colors.secondary, + 'primaryColor': colors.primary.text, + 'secondaryColor': colors.secondary.text, }; final Map alerts = { - 'positive': colors.positive, - 'negative': colors.negative, - 'warning': colors.warning, - 'info': colors.info, + 'positive': colors.positive.text, + 'negative': colors.negative.text, + 'warning': colors.warning.text, + 'info': colors.info.text, }; return ExampleScaffold( @@ -291,12 +291,6 @@ class MyRow extends StatelessWidget { } } -extension StringExtension on Color { - String get toHexString { - return toString().substring(10, 16).toUpperCase(); - } -} - Color calculateTextColor(Color background) { return ThemeData.estimateBrightnessForColor(background) == Brightness.light ? Colors.black : Colors.white; } diff --git a/example/lib/pages/theme_color_switch.dart b/example/lib/pages/theme_color_switch.dart deleted file mode 100644 index 98ebbeec..00000000 --- a/example/lib/pages/theme_color_switch.dart +++ /dev/null @@ -1,69 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:zeta_flutter/zeta_flutter.dart'; - -late final appThemes = { - "default": ZetaThemeData(), - "teal": ZetaThemeData( - identifier: 'teal', - primary: ZetaColorBase.teal, - ), - "yellow": ZetaThemeData( - identifier: 'yellow', - primary: ZetaColorBase.yellow, - ), - "red": ZetaThemeData( - identifier: 'red', - primary: ZetaColorBase.red, - ), - "purple": ZetaThemeData( - identifier: 'purple', - primary: ZetaColorBase.purple, - ), -}; - -class ZetaThemeColorSwitch extends StatelessWidget { - ZetaThemeColorSwitch({super.key}); - - @override - Widget build(BuildContext context) { - var zeta = Zeta.of(context); - - ZetaColors primary(ZetaThemeData data) { - if (zeta.brightness == Brightness.light) { - return data.colorsLight; - } else { - return data.colorsDark; - } - } - - return DropdownButtonHideUnderline( - child: DropdownButton( - value: zeta.themeData.identifier, - elevation: 0, - isDense: true, - alignment: Alignment.center, - icon: SizedBox(width: 8), - dropdownColor: zeta.colors.borderDisabled, - items: appThemes.entries.map((e) { - var zetaColors = primary(appThemes[e.key]!); - var color = zetaColors.primary; - return DropdownMenuItem( - value: e.value.identifier, - alignment: Alignment.center, - child: CircleAvatar( - backgroundColor: color.surface, - foregroundColor: color, - child: Icon(Icons.color_lens, color: color), - ), - ); - }).toList(), - onChanged: (value) { - final theme = appThemes[value]; - if (theme != null) { - ZetaProvider.of(context).updateThemeData(theme); - } - }, - ), - ); - } -} diff --git a/example/lib/pages/theme_constrast_switch.dart b/example/lib/pages/theme_constrast_switch.dart deleted file mode 100644 index 9d36c28f..00000000 --- a/example/lib/pages/theme_constrast_switch.dart +++ /dev/null @@ -1,56 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:zeta_flutter/zeta_flutter.dart'; - -class ZetaThemeContrastSwitch extends StatelessWidget { - ZetaThemeContrastSwitch({super.key}); - - late final _themes = [ - ZetaContrast.aa, - ZetaContrast.aaa, - ]; - - @override - Widget build(BuildContext context) { - var zeta = Zeta.of(context); - - ZetaColors zetaColors(ZetaContrast contrast) { - if (zeta.brightness == Brightness.light) { - return zeta.themeData.apply(contrast: contrast).colorsLight; - } else { - return zeta.themeData.apply(contrast: contrast).colorsDark; - } - } - - return DropdownButtonHideUnderline( - child: DropdownButton( - value: zeta.contrast, - elevation: 0, - isDense: true, - alignment: Alignment.center, - icon: SizedBox(width: 8), - dropdownColor: zeta.colors.borderDisabled, - items: _themes.map((e) { - final colors = zetaColors(e); - return DropdownMenuItem( - value: e, - alignment: Alignment.center, - child: CircleAvatar( - backgroundColor: colors.primary.surface, - foregroundColor: colors.primary, - child: ZetaText.bodyMedium( - e == ZetaContrast.aa ? 'AA' : 'AAA', - textColor: colors.primary, - fontWeight: FontWeight.w700, - ), - ), - ); - }).toList(), - onChanged: (value) { - if (value != null) { - ZetaProvider.of(context).updateContrast(value); - } - }, - ), - ); - } -} diff --git a/example/lib/pages/theme_mode_switch.dart b/example/lib/pages/theme_mode_switch.dart deleted file mode 100644 index 392d7e12..00000000 --- a/example/lib/pages/theme_mode_switch.dart +++ /dev/null @@ -1,60 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:zeta_flutter/zeta_flutter.dart'; - -class ZetaThemeModeSwitch extends StatelessWidget { - ZetaThemeModeSwitch({super.key}); - - late final _themes = [ - ThemeMode.system, - ThemeMode.light, - ThemeMode.dark, - ]; - - @override - Widget build(BuildContext context) { - var zeta = Zeta.of(context); - - ZetaColors zetaColors(ThemeMode mode) { - if ((mode == ThemeMode.system && MediaQuery.of(context).platformBrightness == Brightness.light) || - mode == ThemeMode.light) { - return zeta.themeData.colorsLight; - } else { - return zeta.themeData.colorsDark; - } - } - - return DropdownButtonHideUnderline( - child: DropdownButton( - value: zeta.themeMode, - elevation: 0, - isDense: true, - alignment: Alignment.center, - icon: SizedBox(width: 8), - dropdownColor: zeta.colors.borderDisabled, - items: _themes.map((e) { - final colors = zetaColors(e); - return DropdownMenuItem( - value: e, - alignment: Alignment.center, - child: CircleAvatar( - backgroundColor: colors.primary.surface, - foregroundColor: colors.primary, - child: Icon( - e == ThemeMode.system - ? Icons.system_security_update_good - : e == ThemeMode.light - ? Icons.light_mode - : Icons.dark_mode, - color: colors.primary), - ), - ); - }).toList(), - onChanged: (value) { - if (value != null) { - ZetaProvider.of(context).updateThemeMode(value); - } - }, - ), - ); - } -} diff --git a/example/macos/Flutter/GeneratedPluginRegistrant.swift b/example/macos/Flutter/GeneratedPluginRegistrant.swift new file mode 100644 index 00000000..eefcc6d7 --- /dev/null +++ b/example/macos/Flutter/GeneratedPluginRegistrant.swift @@ -0,0 +1,16 @@ +// +// Generated file. Do not edit. +// + +import FlutterMacOS +import Foundation + +import path_provider_foundation +import shared_preferences_foundation +import sqflite + +func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) + SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) + SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) +} diff --git a/example/widgetbook/widgetbook.dart b/example/widgetbook/widgetbook.dart index 3417104f..507d869a 100644 --- a/example/widgetbook/widgetbook.dart +++ b/example/widgetbook/widgetbook.dart @@ -42,10 +42,7 @@ class HotReload extends StatelessWidget { WidgetbookCategory( name: 'Theme', isInitiallyExpanded: false, - children: [ - textWidgetBook(), - colorWidgetBook(), - ], + children: [textWidgetBook(), colorWidgetBook(), checkboxWidgetBook()], ), ], addons: [ diff --git a/lib/src/assets/fonts/zeta-icons-other.ttf b/lib/src/assets/fonts/zeta-icons-other.ttf deleted file mode 100644 index ba841bf80e29331887cdca0c3d6550b2310c5adb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1088 zcma)5O=}ZT6g_V~k~Rrxk=THwI@Yw6EMkahwICRR6be>D)ojfqohE@~W=v8@7eW?- zE))x{1YNjwA^rdtS?R`&{s9qJ#kEU`=gmw@3@&`(y?f5N_r81Q&IAHL6ho-U-M(`v zKX*#cQ2D@Jt#?c}S^4@H5GnGz4YTLc&XY?!(`X;;Z9IJYhI~N&s%e?K%b%X9fRZ3z zZ&C=C)Q{vh$r~jq$naXqDil4YFX2~a)n4e@47l9+Fqwxqum79v3#qlycAgjrp zqR+Q1>2VELX(Q}c;ZMLg!ua=iObsVkjDI9G=1tx!AQ&|#HCASQX5-3+7xKRvGsYuz z$lNG9gUGM16;>`Rg-$0Hl1t&Z2!|HM`L)7oR;;clD7$W1?p&!f$YfMxGJ{e{6n(Mm zR%5YTI-RRl?inV9PfgA1^Dg*tRNg@%QvPY7w8&sJ-|BW zC3$RLkEx;OaGr&3)nC-`hsNV>11O+^8)g8Ns z78`J2qgS!Iy_RDe`D_6dSga|X(q$lzEDBTcQ*_5_?6=J>c9`10KH4zRor>9X?7q>k zY^!VbtzDybU~JW$ZO5^**z_v(S*yVdY_GnFKJ6~G8V-1Fd97|UQg)T)oV@>=Klp#0 Fe*o3hoJ{}# diff --git a/lib/src/components/bottom sheets/bottom_sheet.dart b/lib/src/components/bottom sheets/bottom_sheet.dart index 9af8c853..db1447c2 100644 --- a/lib/src/components/bottom sheets/bottom_sheet.dart +++ b/lib/src/components/bottom sheets/bottom_sheet.dart @@ -66,7 +66,10 @@ class ZetaBottomSheet extends StatelessWidget { style: ZetaTextStyles.titleMedium, ), ), - Material(child: body ?? const SizedBox()), + Material( + color: colors.surfaceSecondary, + child: body ?? const SizedBox(), + ), ], ), ); diff --git a/lib/src/components/buttons/fab.dart b/lib/src/components/buttons/fab.dart index 6e383829..2d7eb2b7 100644 --- a/lib/src/components/buttons/fab.dart +++ b/lib/src/components/buttons/fab.dart @@ -125,7 +125,7 @@ class _ZetaFABState extends State { padding: EdgeInsets.zero, shape: widget.shape.buttonShape(isExpanded: _isExpanded, size: widget.size), backgroundColor: backgroundColor, - foregroundColor: colors.shade60.onColor, + foregroundColor: backgroundColor.onColor, ).copyWith( overlayColor: MaterialStateProperty.resolveWith((Set states) { if (states.contains(MaterialState.hovered)) return colors.hover;