From 700faafe8ef12d6d42a8b8ad769e23dc00dc11a3 Mon Sep 17 00:00:00 2001 From: kmahmood74 Date: Fri, 4 Oct 2024 12:59:24 -0700 Subject: [PATCH] https://github.com/EnsembleUI/ensemble/issues/1678 moving to flutter 3.24+ --- .../device_preview/lib/src/views/theme.dart | 52 +++++++++++++++++-- .../views/tool_panel/sections/section.dart | 2 +- .../views/tool_panel/sections/settings.dart | 4 +- .../sections/subsections/device_model.dart | 2 +- .../lib/src/views/tool_panel/tool_panel.dart | 2 +- modules/ensemble/lib/ensemble_theme.dart | 47 ++++++++--------- modules/ensemble/lib/widget/carousel.dart | 2 +- .../lib/widget/visualization/barchart.dart | 4 +- .../widget/visualization/chart_defaults.dart | 2 +- modules/ensemble/pubspec.yaml | 6 +-- starter/pubspec.yaml | 2 +- 11 files changed, 84 insertions(+), 41 deletions(-) diff --git a/modules/device_preview/lib/src/views/theme.dart b/modules/device_preview/lib/src/views/theme.dart index 837d01211..4f368b380 100644 --- a/modules/device_preview/lib/src/views/theme.dart +++ b/modules/device_preview/lib/src/views/theme.dart @@ -28,7 +28,6 @@ extension ThemeToolbarExtension on DevicePreviewToolBarThemeData { primaryColor: accentColor, primaryColorDark: accentColor, indicatorColor: accentColor, - toggleableActiveColor: accentColor, highlightColor: accentColor.withOpacity(0.1), sliderTheme: base.sliderTheme.copyWith( thumbColor: accentColor, @@ -37,7 +36,30 @@ extension ThemeToolbarExtension on DevicePreviewToolBarThemeData { activeTickMarkColor: accentColor, inactiveTickMarkColor: accentColor, overlayColor: accentColor.withOpacity(0.12), - ), + ), checkboxTheme: CheckboxThemeData( + fillColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.disabled)) { return null; } + if (states.contains(MaterialState.selected)) { return accentColor; } + return null; + }), + ), radioTheme: RadioThemeData( + fillColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.disabled)) { return null; } + if (states.contains(MaterialState.selected)) { return accentColor; } + return null; + }), + ), switchTheme: SwitchThemeData( + thumbColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.disabled)) { return null; } + if (states.contains(MaterialState.selected)) { return accentColor; } + return null; + }), + trackColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.disabled)) { return null; } + if (states.contains(MaterialState.selected)) { return accentColor; } + return null; + }), + ), ); case DevicePreviewToolBarThemeData.light: final base = ThemeData.light(); @@ -51,7 +73,6 @@ extension ThemeToolbarExtension on DevicePreviewToolBarThemeData { primaryColor: accentColor, primaryColorDark: accentColor, indicatorColor: accentColor, - toggleableActiveColor: accentColor, highlightColor: accentColor, appBarTheme: base.appBarTheme.copyWith( color: barColor, @@ -63,7 +84,30 @@ extension ThemeToolbarExtension on DevicePreviewToolBarThemeData { activeTickMarkColor: accentColor, inactiveTickMarkColor: accentColor, overlayColor: accentColor.withOpacity(0.12), - ), + ), checkboxTheme: CheckboxThemeData( + fillColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.disabled)) { return null; } + if (states.contains(MaterialState.selected)) { return accentColor; } + return null; + }), + ), radioTheme: RadioThemeData( + fillColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.disabled)) { return null; } + if (states.contains(MaterialState.selected)) { return accentColor; } + return null; + }), + ), switchTheme: SwitchThemeData( + thumbColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.disabled)) { return null; } + if (states.contains(MaterialState.selected)) { return accentColor; } + return null; + }), + trackColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.disabled)) { return null; } + if (states.contains(MaterialState.selected)) { return accentColor; } + return null; + }), + ), ); } } diff --git a/modules/device_preview/lib/src/views/tool_panel/sections/section.dart b/modules/device_preview/lib/src/views/tool_panel/sections/section.dart index 059ef69ac..fe354211e 100644 --- a/modules/device_preview/lib/src/views/tool_panel/sections/section.dart +++ b/modules/device_preview/lib/src/views/tool_panel/sections/section.dart @@ -36,7 +36,7 @@ class ToolPanelSection extends StatelessWidget { ), child: Text( title.toUpperCase(), - style: theme.textTheme.subtitle2?.copyWith( + style: theme.textTheme.titleSmall?.copyWith( color: theme.hintColor, ), ), diff --git a/modules/device_preview/lib/src/views/tool_panel/sections/settings.dart b/modules/device_preview/lib/src/views/tool_panel/sections/settings.dart index eaf9f2799..dadf1d5a9 100644 --- a/modules/device_preview/lib/src/views/tool_panel/sections/settings.dart +++ b/modules/device_preview/lib/src/views/tool_panel/sections/settings.dart @@ -53,7 +53,7 @@ class SettingsSection extends StatelessWidget { shape: BoxShape.circle, color: background.scaffoldBackgroundColor, border: Border.all( - color: toolbar.backgroundColor, + color: Theme.of(context).colorScheme.surface, width: 1, ), ), @@ -84,7 +84,7 @@ class SettingsSection extends StatelessWidget { shape: BoxShape.circle, color: toolbar.scaffoldBackgroundColor, border: Border.all( - color: toolbar.backgroundColor, + color: Theme.of(context).colorScheme.surface, width: 1, ), ), diff --git a/modules/device_preview/lib/src/views/tool_panel/sections/subsections/device_model.dart b/modules/device_preview/lib/src/views/tool_panel/sections/subsections/device_model.dart index 8199e8ff9..a50ee934f 100644 --- a/modules/device_preview/lib/src/views/tool_panel/sections/subsections/device_model.dart +++ b/modules/device_preview/lib/src/views/tool_panel/sections/subsections/device_model.dart @@ -172,7 +172,7 @@ class _TypeSectionHeader extends StatelessWidget { } }() .toUpperCase(), - style: theme.textTheme.subtitle2?.copyWith( + style: theme.textTheme.titleSmall?.copyWith( color: theme.hintColor, ), ), diff --git a/modules/device_preview/lib/src/views/tool_panel/tool_panel.dart b/modules/device_preview/lib/src/views/tool_panel/tool_panel.dart index 9c2ee146d..d9d7b5f4d 100644 --- a/modules/device_preview/lib/src/views/tool_panel/tool_panel.dart +++ b/modules/device_preview/lib/src/views/tool_panel/tool_panel.dart @@ -80,7 +80,7 @@ class _ToolPanel extends StatelessWidget { appBar: AppBar( title: Text( 'Device preview', - style: theme.textTheme.headline6?.copyWith( + style: theme.textTheme.titleLarge?.copyWith( fontSize: 14, fontWeight: FontWeight.bold, color: (theme.colorScheme.brightness == Brightness.dark diff --git a/modules/ensemble/lib/ensemble_theme.dart b/modules/ensemble/lib/ensemble_theme.dart index 8b289ba5c..624bf7f0c 100644 --- a/modules/ensemble/lib/ensemble_theme.dart +++ b/modules/ensemble/lib/ensemble_theme.dart @@ -42,13 +42,13 @@ class EnsembleTheme { } static const TextTheme textTheme = TextTheme( - headline4: display1, - headline5: headline, - headline6: title, - subtitle2: subtitle, - bodyText1: body2, - bodyText2: body1, - caption: caption, + headlineMedium: display1, + headlineSmall: headline, + titleLarge: title, + titleSmall: subtitle, + bodyLarge: body2, + bodyMedium: body1, + bodySmall: caption, ); static const TextStyle display1 = TextStyle( @@ -118,19 +118,19 @@ class EnsembleTheme { static TextTheme _buildTextThemeOld(TextTheme base) { const String fontName = 'WorkSans'; return base.copyWith( - headline1: base.headline1?.copyWith(fontFamily: fontName), - headline2: base.headline2?.copyWith(fontFamily: fontName), - headline3: base.headline3?.copyWith(fontFamily: fontName), - headline4: base.headline4?.copyWith(fontFamily: fontName), - headline5: base.headline5?.copyWith(fontFamily: fontName), - headline6: base.headline6?.copyWith(fontFamily: fontName), - button: base.button?.copyWith(fontFamily: fontName), - caption: base.caption?.copyWith(fontFamily: fontName), - bodyText1: base.bodyText1?.copyWith(fontFamily: fontName), - bodyText2: base.bodyText2?.copyWith(fontFamily: fontName), - subtitle1: base.subtitle1?.copyWith(fontFamily: fontName), - subtitle2: base.subtitle2?.copyWith(fontFamily: fontName), - overline: base.overline?.copyWith(fontFamily: fontName), + displayLarge: base.displayLarge?.copyWith(fontFamily: fontName), + displayMedium: base.displayMedium?.copyWith(fontFamily: fontName), + displaySmall: base.displaySmall?.copyWith(fontFamily: fontName), + headlineMedium: base.headlineMedium?.copyWith(fontFamily: fontName), + headlineSmall: base.headlineSmall?.copyWith(fontFamily: fontName), + titleLarge: base.titleLarge?.copyWith(fontFamily: fontName), + labelLarge: base.labelLarge?.copyWith(fontFamily: fontName), + bodySmall: base.bodySmall?.copyWith(fontFamily: fontName), + bodyLarge: base.bodyLarge?.copyWith(fontFamily: fontName), + bodyMedium: base.bodyMedium?.copyWith(fontFamily: fontName), + titleMedium: base.titleMedium?.copyWith(fontFamily: fontName), + titleSmall: base.titleSmall?.copyWith(fontFamily: fontName), + labelSmall: base.labelSmall?.copyWith(fontFamily: fontName), ); } @@ -140,19 +140,18 @@ class EnsembleTheme { final ColorScheme colorScheme = const ColorScheme.light().copyWith( primary: primaryColor, secondary: secondaryColor, + surface: Colors.white, + error: const Color(0xFFB00020), ); final ThemeData base = ThemeData.light(); return base.copyWith( - colorScheme: colorScheme, primaryColor: primaryColor, indicatorColor: Colors.white, splashColor: Colors.white24, splashFactory: InkRipple.splashFactory, //accentColor: secondaryColor, canvasColor: Colors.white, - backgroundColor: const Color(0xFFFFFFFF), scaffoldBackgroundColor: const Color(0xFFF6F6F6), - errorColor: const Color(0xFFB00020), buttonTheme: ButtonThemeData( colorScheme: colorScheme, textTheme: ButtonTextTheme.primary, @@ -160,7 +159,7 @@ class EnsembleTheme { textTheme: _buildTextThemeOld(base.textTheme), primaryTextTheme: _buildTextThemeOld(base.primaryTextTheme), //accentTextTheme: _buildTextThemeOld(base.accentTextTheme), - platform: TargetPlatform.iOS, + platform: TargetPlatform.iOS, colorScheme: colorScheme.copyWith(background: const Color(0xFFFFFFFF)), ); } } diff --git a/modules/ensemble/lib/widget/carousel.dart b/modules/ensemble/lib/widget/carousel.dart index a38bc8ca0..a8ad23a8a 100644 --- a/modules/ensemble/lib/widget/carousel.dart +++ b/modules/ensemble/lib/widget/carousel.dart @@ -199,7 +199,7 @@ class MyController extends BoxController { int selectedItemIndex = 0; int? indicatorMaxCount; - final e.CarouselController _carouselController = e.CarouselController(); + final e.CarouselSliderController _carouselController = e.CarouselSliderController(); } class CarouselState extends EWidgetState diff --git a/modules/ensemble/lib/widget/visualization/barchart.dart b/modules/ensemble/lib/widget/visualization/barchart.dart index 11f2e0336..86ebc0b6b 100644 --- a/modules/ensemble/lib/widget/visualization/barchart.dart +++ b/modules/ensemble/lib/widget/visualization/barchart.dart @@ -131,7 +131,7 @@ class EnsembleBarChartState extends BaseWidgetState return BarTouchData( enabled: true, touchTooltipData: BarTouchTooltipData( - tooltipBgColor: Colors.orangeAccent, + getTooltipColor: (group) => Colors.orangeAccent, tooltipPadding: const EdgeInsets.all(0), tooltipMargin: 8, getTooltipItem: ( @@ -170,7 +170,7 @@ class EnsembleBarChartState extends BaseWidgetState BarTouchData get barTouchData => BarTouchData( enabled: true, touchTooltipData: BarTouchTooltipData( - tooltipBgColor: Colors.orangeAccent, + getTooltipColor: (group) => Colors.orangeAccent, tooltipPadding: const EdgeInsets.all(0), tooltipMargin: 8, getTooltipItem: ( diff --git a/modules/ensemble/lib/widget/visualization/chart_defaults.dart b/modules/ensemble/lib/widget/visualization/chart_defaults.dart index 31db5a957..a313d0837 100644 --- a/modules/ensemble/lib/widget/visualization/chart_defaults.dart +++ b/modules/ensemble/lib/widget/visualization/chart_defaults.dart @@ -58,7 +58,7 @@ mixin ChartDefaults { LineTouchData get lineTouchData => LineTouchData( handleBuiltInTouches: true, touchTooltipData: LineTouchTooltipData( - tooltipBgColor: Colors.blueGrey.withOpacity(0.8), + getTooltipColor: (group) => Colors.blueGrey.withOpacity(0.8), ), ); FlGridData get gridData => FlGridData(show: true); diff --git a/modules/ensemble/pubspec.yaml b/modules/ensemble/pubspec.yaml index e4f9c8444..c82e52457 100644 --- a/modules/ensemble/pubspec.yaml +++ b/modules/ensemble/pubspec.yaml @@ -19,7 +19,7 @@ version: 1.0.9 environment: sdk: ">=3.0.6 <4.0.0" - flutter: '<=3.19.6' + flutter: '>=3.24.0' dependencies: flutter: @@ -39,7 +39,7 @@ dependencies: cupertino_icons: ^1.0.2 http: ^1.2.1 flutter_rating_bar: ^4.0.0 - fl_chart: ^0.62.0 + fl_chart: ^0.69.0 signature: ^5.5.0 ensemble_icons: @@ -75,7 +75,7 @@ dependencies: flutter_svg_provider: ^1.0.4 qr_flutter: ^4.1.0 device_info_plus: ^9.1.2 - carousel_slider: ^4.1.1 + carousel_slider: ^5.0.0 fluttertoast: 8.2.2 video_player: ^2.6.1 lottie: ^3.0.0 diff --git a/starter/pubspec.yaml b/starter/pubspec.yaml index 1be2be720..6064a89b7 100644 --- a/starter/pubspec.yaml +++ b/starter/pubspec.yaml @@ -18,7 +18,7 @@ version: 1.0.0+1 environment: sdk: ">=3.0.6 <4.0.0" - flutter: '<=3.19.6' + flutter: '>=3.24.0' # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions