From 2637e3ac7ce51e5936626d0e3a4a2fedc27356d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?book=E8=AF=97=E6=84=8F?= Date: Wed, 19 Jul 2023 18:08:14 +0800 Subject: [PATCH 01/10] Added PlatformScrollbar Based on `Scrollbar` and `CupertinoScrollbar` --- example/lib/platform_page.dart.dart | 647 ++++++++++++++-------------- lib/flutter_platform_widgets.dart | 1 + lib/src/platform_scrollbar.dart | 187 ++++++++ 3 files changed, 513 insertions(+), 322 deletions(-) create mode 100644 lib/src/platform_scrollbar.dart diff --git a/example/lib/platform_page.dart.dart b/example/lib/platform_page.dart.dart index 9aa37f12..428c4993 100644 --- a/example/lib/platform_page.dart.dart +++ b/example/lib/platform_page.dart.dart @@ -17,389 +17,392 @@ class PlatformPage extends StatelessWidget { appBar: PlatformAppBar( title: Text('Flutter Platform Widgets'), ), - body: ListView( - children: [ - FlutterPlatformWidgetsLogo(size: 60), - Divider(thickness: 10), - Padding( - padding: const EdgeInsets.all(8.0), - child: PlatformElevatedButton( - child: PlatformText('Change Platform'), - onPressed: () { - final p = PlatformProvider.of(context)!; - - isMaterial(context) - ? p.changeToCupertinoPlatform() - : p.changeToMaterialPlatform(); - }), - ), - if (isMaterial(context)) + body: PlatformScrollbar( + thumbVisibility: true, + child: ListView( + children: [ + FlutterPlatformWidgetsLogo(size: 60), + Divider(thickness: 10), Padding( padding: const EdgeInsets.all(8.0), child: PlatformElevatedButton( - child: PlatformText( - 'Change to Material${Theme.of(context).useMaterial3 ? "" : " 3"}'), + child: PlatformText('Change Platform'), onPressed: () { - final isMaterial3 = Theme.of(context).useMaterial3; + final p = PlatformProvider.of(context)!; - isMaterial3 - ? PlatformTheme.of(context)?.changeToMaterial2( - applyToBothDarkAndLightTheme: true) - : PlatformTheme.of(context)?.changeToMaterial3( - applyToBothDarkAndLightTheme: true); + isMaterial(context) + ? p.changeToCupertinoPlatform() + : p.changeToMaterialPlatform(); }), ), - Padding( - padding: const EdgeInsets.all(8.0), - child: PlatformElevatedButton( - child: PlatformText( - 'Theme mode${_getThemeMode(PlatformTheme.of(context)?.themeMode)}'), - onPressed: () { - final mode = PlatformTheme.of(context)?.themeMode; - final newMode = _cycleThemeMode(mode); + if (isMaterial(context)) + Padding( + padding: const EdgeInsets.all(8.0), + child: PlatformElevatedButton( + child: PlatformText( + 'Change to Material${Theme.of(context).useMaterial3 ? "" : " 3"}'), + onPressed: () { + final isMaterial3 = Theme.of(context).useMaterial3; - PlatformTheme.of(context)?.themeMode = newMode; - }), - ), - Divider(thickness: 10), - // ! PlatformSearchBar - PlatformWidgetExample( - title: - 'PlatformSearchBar ${isMaterial(context) ? " (Material 3 only)" : ""}', - builder: (context, platform) => PlatformSearchBar( - onChanged: (value) => - print('${platform.text} SearchBar changed: $value'), - onTap: () => print('${platform.text} SearchBar tapped'), - hintText: '${platform.text} SearchBar', - ), - ), - // ! PlatformListTile - PlatformWidgetExample( - title: 'PlatformListTile', - builder: (_, platform) => PlatformListTile( - leading: Icon(context.platformIcons.book), - title: PlatformText("title"), - subtitle: PlatformText("subtitle"), - trailing: Icon(context.platformIcons.rightChevron), - onTap: () => print('${platform.text} PlatformListTile'), + isMaterial3 + ? PlatformTheme.of(context)?.changeToMaterial2( + applyToBothDarkAndLightTheme: true) + : PlatformTheme.of(context)?.changeToMaterial3( + applyToBothDarkAndLightTheme: true); + }), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: PlatformElevatedButton( + child: PlatformText( + 'Theme mode${_getThemeMode(PlatformTheme.of(context)?.themeMode)}'), + onPressed: () { + final mode = PlatformTheme.of(context)?.themeMode; + final newMode = _cycleThemeMode(mode); + + PlatformTheme.of(context)?.themeMode = newMode; + }), ), - ), - // ! PlatformText - PlatformWidgetExample( - title: 'PlatformText', - builder: (_, platform) => PlatformText( - '${platform.text} Text', - textAlign: TextAlign.center, + Divider(thickness: 10), + // ! PlatformSearchBar + PlatformWidgetExample( + title: + 'PlatformSearchBar ${isMaterial(context) ? " (Material 3 only)" : ""}', + builder: (context, platform) => PlatformSearchBar( + onChanged: (value) => + print('${platform.text} SearchBar changed: $value'), + onTap: () => print('${platform.text} SearchBar tapped'), + hintText: '${platform.text} SearchBar', + ), ), - ), - // ! PlatformWidget - PlatformWidgetExample( - title: 'PlatformWidget', - builder: (_, platform) => PlatformWidget( - material: (_, __) => Text( - 'Showing ${platform.text}', - textAlign: TextAlign.center, + // ! PlatformListTile + PlatformWidgetExample( + title: 'PlatformListTile', + builder: (_, platform) => PlatformListTile( + leading: Icon(context.platformIcons.book), + title: PlatformText("title"), + subtitle: PlatformText("subtitle"), + trailing: Icon(context.platformIcons.rightChevron), + onTap: () => print('${platform.text} PlatformListTile'), ), - cupertino: (_, __) => Text( - 'Showing ${platform.text}', + ), + // ! PlatformText + PlatformWidgetExample( + title: 'PlatformText', + builder: (_, platform) => PlatformText( + '${platform.text} Text', textAlign: TextAlign.center, ), ), - ), - // ! PlatformCheckbox - PlatformWidgetExample( - title: 'PlatformCheckbox', - builder: (_, __) => StateProvider( - initialValue: false, - builder: (_, value, setValue) => PlatformCheckbox( - value: value, - onChanged: (newValue) { - setValue(newValue!); - }, + // ! PlatformWidget + PlatformWidgetExample( + title: 'PlatformWidget', + builder: (_, platform) => PlatformWidget( + material: (_, __) => Text( + 'Showing ${platform.text}', + textAlign: TextAlign.center, + ), + cupertino: (_, __) => Text( + 'Showing ${platform.text}', + textAlign: TextAlign.center, + ), ), ), - ), - // ! PlatformRadio - PlatformWidgetExample( - title: 'PlatformRadio', - builder: (_, platform) => StateProvider( - initialValue: 'One', - builder: (_, value, setValue) => Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - PlatformRadio( - value: 'One', - groupValue: value, - onChanged: (dynamic newValue) { - setValue(newValue as String); - }, - ), - PlatformRadio( - value: 'Two', - groupValue: value, - onChanged: (dynamic newValue) { - setValue(newValue as String); - }, - ), - PlatformRadio( - value: 'Three', - groupValue: value, - onChanged: (dynamic newValue) { - setValue(newValue as String); - }, - ), - ], + // ! PlatformCheckbox + PlatformWidgetExample( + title: 'PlatformCheckbox', + builder: (_, __) => StateProvider( + initialValue: false, + builder: (_, value, setValue) => PlatformCheckbox( + value: value, + onChanged: (newValue) { + setValue(newValue!); + }, + ), ), ), - ), - // ! PlatformElevatedButton - PlatformWidgetExample( - title: 'PlatformElevatedButton', - builder: (_, platform) => PlatformElevatedButton( - child: Text(platform.text), - onPressed: () => print('${platform.text} PlatformButton'), - padding: const EdgeInsets.all(8), - color: Colors.orange, + // ! PlatformRadio + PlatformWidgetExample( + title: 'PlatformRadio', + builder: (_, platform) => StateProvider( + initialValue: 'One', + builder: (_, value, setValue) => Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + PlatformRadio( + value: 'One', + groupValue: value, + onChanged: (dynamic newValue) { + setValue(newValue as String); + }, + ), + PlatformRadio( + value: 'Two', + groupValue: value, + onChanged: (dynamic newValue) { + setValue(newValue as String); + }, + ), + PlatformRadio( + value: 'Three', + groupValue: value, + onChanged: (dynamic newValue) { + setValue(newValue as String); + }, + ), + ], + ), + ), ), - ), - PlatformWidgetExample( - title: 'PlatformElevatedButton Icon', - builder: (_, platform) => PlatformElevatedButton( - child: Text(platform.text), - onPressed: () => print('${platform.text} PlatformButton'), - padding: const EdgeInsets.all(8), - material: (_, __) => MaterialElevatedButtonData( - icon: Icon(Icons.home), + // ! PlatformElevatedButton + PlatformWidgetExample( + title: 'PlatformElevatedButton', + builder: (_, platform) => PlatformElevatedButton( + child: Text(platform.text), + onPressed: () => print('${platform.text} PlatformButton'), + padding: const EdgeInsets.all(8), + color: Colors.orange, ), - cupertino: (_, __) => CupertinoElevatedButtonData( - originalStyle: true, + ), + PlatformWidgetExample( + title: 'PlatformElevatedButton Icon', + builder: (_, platform) => PlatformElevatedButton( + child: Text(platform.text), + onPressed: () => print('${platform.text} PlatformButton'), + padding: const EdgeInsets.all(8), + material: (_, __) => MaterialElevatedButtonData( + icon: Icon(Icons.home), + ), + cupertino: (_, __) => CupertinoElevatedButtonData( + originalStyle: true, + ), ), ), - ), - // ! PlatformTextButton - PlatformWidgetExample( - title: 'PlatformTextButton', - builder: (_, platform) => PlatformTextButton( - child: Text(platform.text), - onPressed: () => print('${platform.text} PlatformButton'), - padding: const EdgeInsets.all(8), + // ! PlatformTextButton + PlatformWidgetExample( + title: 'PlatformTextButton', + builder: (_, platform) => PlatformTextButton( + child: Text(platform.text), + onPressed: () => print('${platform.text} PlatformButton'), + padding: const EdgeInsets.all(8), + ), ), - ), - PlatformWidgetExample( - title: 'PlatformTextButton Icon', - builder: (_, platform) => PlatformTextButton( - child: Text(platform.text), - onPressed: () => print('${platform.text} PlatformButton'), - padding: const EdgeInsets.all(8), - material: (_, __) => MaterialTextButtonData( - icon: Icon(Icons.home), + PlatformWidgetExample( + title: 'PlatformTextButton Icon', + builder: (_, platform) => PlatformTextButton( + child: Text(platform.text), + onPressed: () => print('${platform.text} PlatformButton'), + padding: const EdgeInsets.all(8), + material: (_, __) => MaterialTextButtonData( + icon: Icon(Icons.home), + ), + cupertino: (_, __) => CupertinoTextButtonData( + originalStyle: true, + ), ), - cupertino: (_, __) => CupertinoTextButtonData( - originalStyle: true, + ), + // ! PlatformSwitch + PlatformWidgetExample( + title: 'PlatformSwitch', + builder: (_, __) => StateProvider( + initialValue: false, + builder: (_, value, setValue) => PlatformSwitch( + onChanged: setValue, + value: value, + ).center, ), ), - ), - // ! PlatformSwitch - PlatformWidgetExample( - title: 'PlatformSwitch', - builder: (_, __) => StateProvider( - initialValue: false, - builder: (_, value, setValue) => PlatformSwitch( - onChanged: setValue, - value: value, - ).center, + // ! PlatformSlider + PlatformWidgetExample( + title: 'PlatformSlider', + builder: (_, __) => StateProvider( + initialValue: 0.5, + builder: (_, value, setValue) => PlatformSlider( + onChanged: setValue, + value: value, + ), + ), ), - ), - // ! PlatformSlider - PlatformWidgetExample( - title: 'PlatformSlider', - builder: (_, __) => StateProvider( - initialValue: 0.5, - builder: (_, value, setValue) => PlatformSlider( - onChanged: setValue, - value: value, + // ! PlatformIconButton + PlatformWidgetExample( + title: 'PlatformIconButton', + builder: (context, __) => PlatformIconButton( + icon: Icon(context.platformIcons.folder), + onPressed: () {}, ), ), - ), - // ! PlatformIconButton - PlatformWidgetExample( - title: 'PlatformIconButton', - builder: (context, __) => PlatformIconButton( - icon: Icon(context.platformIcons.folder), - onPressed: () {}, + // ! PlatformTextField + PlatformWidgetExample( + title: 'PlatformTextField', + builder: (_, platform) => + PlatformTextField(hintText: platform.text), ), - ), - // ! PlatformTextField - PlatformWidgetExample( - title: 'PlatformTextField', - builder: (_, platform) => - PlatformTextField(hintText: platform.text), - ), - PlatformWidgetExample( - title: 'PlatformTextField multiline', - builder: (_, platform) => SizedBox( - height: 100, - child: PlatformTextField( - hintText: platform.text, - expands: true, - maxLines: null, + PlatformWidgetExample( + title: 'PlatformTextField multiline', + builder: (_, platform) => SizedBox( + height: 100, + child: PlatformTextField( + hintText: platform.text, + expands: true, + maxLines: null, + ), ), ), - ), - // ! PlatformTextFormField - PlatformWidgetExample( - title: 'PlatformTextFormField', - builder: (_, platform) => PlatformTextFormField( - hintText: 'hint', - validator: (value) => - (value?.length ?? 0) < 3 ? 'Not enough' : null, - autovalidateMode: AutovalidateMode.always, + // ! PlatformTextFormField + PlatformWidgetExample( + title: 'PlatformTextFormField', + builder: (_, platform) => PlatformTextFormField( + hintText: 'hint', + validator: (value) => + (value?.length ?? 0) < 3 ? 'Not enough' : null, + autovalidateMode: AutovalidateMode.always, + ), ), - ), - // ! PlatformCircularProgressIndicator - // _PlatformWidgetExample( - // title: 'PlatformCircularProgressIndicator', - // builder: (_) => PlatformCircularProgressIndicator().center, - // ), - // ! PlatformWidgetBuilder - PlatformWidgetExample( - title: 'PlatformWidgetBuilder', - builder: (_, platform) => PlatformWidgetBuilder( - cupertino: (_, child, __) => GestureDetector( - child: child, - onTap: () => print('Cupertino PlatformWidgetBuilder'), - ), - material: (_, child, __) => InkWell( - child: child, - onTap: () => print('Material PlatformWidgetBuilder'), - ), - child: Container( - padding: const EdgeInsets.all(12), - decoration: BoxDecoration( - color: Colors.grey[200], - borderRadius: BorderRadius.circular(20), + // ! PlatformCircularProgressIndicator + // _PlatformWidgetExample( + // title: 'PlatformCircularProgressIndicator', + // builder: (_) => PlatformCircularProgressIndicator().center, + // ), + // ! PlatformWidgetBuilder + PlatformWidgetExample( + title: 'PlatformWidgetBuilder', + builder: (_, platform) => PlatformWidgetBuilder( + cupertino: (_, child, __) => GestureDetector( + child: child, + onTap: () => print('Cupertino PlatformWidgetBuilder'), + ), + material: (_, child, __) => InkWell( + child: child, + onTap: () => print('Material PlatformWidgetBuilder'), + ), + child: Container( + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + color: Colors.grey[200], + borderRadius: BorderRadius.circular(20), + ), + child: PlatformText('Tap me (${platform.text})').center, ), - child: PlatformText('Tap me (${platform.text})').center, - ), - ), - ), - // ! platformThemeData - PlatformWidgetExample( - title: 'platformThemeData', - builder: (context, platform) => Text( - platform.text, - textAlign: TextAlign.center, - style: platformThemeData( - context, - material: (data) => data.textTheme.headlineSmall, - cupertino: (data) => data.textTheme.navTitleTextStyle, ), ), - ), - // ! Popup Menu - PlatformWidgetExample( - title: 'Popup Menu', - builder: (_, platform) => PlatformPopupMenu( - icon: Icon( - context.platformIcon( - material: Icons.more_vert_rounded, - cupertino: CupertinoIcons.ellipsis, + // ! platformThemeData + PlatformWidgetExample( + title: 'platformThemeData', + builder: (context, platform) => Text( + platform.text, + textAlign: TextAlign.center, + style: platformThemeData( + context, + material: (data) => data.textTheme.headlineSmall, + cupertino: (data) => data.textTheme.navTitleTextStyle, ), ), - options: [ - PopupMenuOption(label: 'One'), - PopupMenuOption( - label: 'Two', - material: (_, __) => MaterialPopupMenuOptionData( - withDivider: true, + ), + // ! Popup Menu + PlatformWidgetExample( + title: 'Popup Menu', + builder: (_, platform) => PlatformPopupMenu( + icon: Icon( + context.platformIcon( + material: Icons.more_vert_rounded, + cupertino: CupertinoIcons.ellipsis, ), ), - PopupMenuOption(label: 'Three'), - ], - ), - ), - // ! Date Picker - PlatformWidgetExample( - title: 'showPlatformDatePicker', - builder: (_, platform) => PlatformElevatedButton( - child: Text(platform.text), - onPressed: () => _showDatePicker(context), + options: [ + PopupMenuOption(label: 'One'), + PopupMenuOption( + label: 'Two', + material: (_, __) => MaterialPopupMenuOptionData( + withDivider: true, + ), + ), + PopupMenuOption(label: 'Three'), + ], + ), ), - ), - // ! Date Picker with Custom iOS - PlatformWidgetExample( - title: 'showPlatformDatePicker (Custom Cupertino 1 )', - builder: (_, platform) => PlatformElevatedButton( - child: Text(platform.text), - onPressed: () => showDatePickerWithCustomCupertino(context), + // ! Date Picker + PlatformWidgetExample( + title: 'showPlatformDatePicker', + builder: (_, platform) => PlatformElevatedButton( + child: Text(platform.text), + onPressed: () => _showDatePicker(context), + ), ), - ), - PlatformWidgetExample( - title: 'showPlatformDatePicker (Custom Cupertino 2)', - builder: (_, platform) => PlatformElevatedButton( - child: Text(platform.text), - onPressed: () => - showDatePickerWithCustomCupertinoStateful(context), + // ! Date Picker with Custom iOS + PlatformWidgetExample( + title: 'showPlatformDatePicker (Custom Cupertino 1 )', + builder: (_, platform) => PlatformElevatedButton( + child: Text(platform.text), + onPressed: () => showDatePickerWithCustomCupertino(context), + ), ), - ), - // ! Dialogs - PlatformWidgetExample( - title: 'showPlatformDialog', - builder: (context, platform) => PlatformElevatedButton( - child: Text(platform.text), - onPressed: () => _showExampleDialog(context, platform.text), + PlatformWidgetExample( + title: 'showPlatformDatePicker (Custom Cupertino 2)', + builder: (_, platform) => PlatformElevatedButton( + child: Text(platform.text), + onPressed: () => + showDatePickerWithCustomCupertinoStateful(context), + ), ), - ), - // ! Bottomsheet - PlatformWidgetExample( - title: 'showPlatformModalSheet', - builder: (context, platform) => PlatformElevatedButton( - child: Text(platform.text), - onPressed: () => _showPopupSheet(context, platform.text), + // ! Dialogs + PlatformWidgetExample( + title: 'showPlatformDialog', + builder: (context, platform) => PlatformElevatedButton( + child: Text(platform.text), + onPressed: () => _showExampleDialog(context, platform.text), + ), ), - ), - // ! Tab pages - Padding( - padding: const EdgeInsets.all(8.0), - child: PlatformElevatedButton( - child: Text('Show Tabbed Pages'), - onPressed: () => Navigator.of(context).push( - platformPageRoute( - context: context, - builder: (context) => TabImplementationPage(), - ), + // ! Bottomsheet + PlatformWidgetExample( + title: 'showPlatformModalSheet', + builder: (context, platform) => PlatformElevatedButton( + child: Text(platform.text), + onPressed: () => _showPopupSheet(context, platform.text), ), ), - ), - // ! Icons - Padding( - padding: const EdgeInsets.all(8.0), - child: PlatformElevatedButton( - child: Text('Show Platform Icons'), - onPressed: () => Navigator.of(context).push( - platformPageRoute( - context: context, - builder: (context) => IconsPage(), + // ! Tab pages + Padding( + padding: const EdgeInsets.all(8.0), + child: PlatformElevatedButton( + child: Text('Show Tabbed Pages'), + onPressed: () => Navigator.of(context).push( + platformPageRoute( + context: context, + builder: (context) => TabImplementationPage(), + ), ), ), ), - ), - // ! Material on iOS - if (isCupertino(context)) + // ! Icons Padding( padding: const EdgeInsets.all(8.0), child: PlatformElevatedButton( - child: Text('Show Material on iOS'), + child: Text('Show Platform Icons'), onPressed: () => Navigator.of(context).push( platformPageRoute( context: context, - builder: (context) => IosMaterialPage(), + builder: (context) => IconsPage(), ), ), ), ), - ], + // ! Material on iOS + if (isCupertino(context)) + Padding( + padding: const EdgeInsets.all(8.0), + child: PlatformElevatedButton( + child: Text('Show Material on iOS'), + onPressed: () => Navigator.of(context).push( + platformPageRoute( + context: context, + builder: (context) => IosMaterialPage(), + ), + ), + ), + ), + ], + ), ), ); } diff --git a/lib/flutter_platform_widgets.dart b/lib/flutter_platform_widgets.dart index b033d502..31bb836f 100644 --- a/lib/flutter_platform_widgets.dart +++ b/lib/flutter_platform_widgets.dart @@ -38,6 +38,7 @@ export 'src/platform_provider.dart'; export 'src/platform_radio.dart'; export 'src/platform_search_bar.dart'; export 'src/platform_scaffold.dart'; +export 'src/platform_scrollbar.dart'; export 'src/platform_slider.dart'; export 'src/platform_switch.dart'; export 'src/platform_tab_scaffold.dart'; diff --git a/lib/src/platform_scrollbar.dart b/lib/src/platform_scrollbar.dart new file mode 100644 index 00000000..89b44cc3 --- /dev/null +++ b/lib/src/platform_scrollbar.dart @@ -0,0 +1,187 @@ +/* + * flutter_platform_widgets + * Copyright (c) 2018 Lance Johnstone. All rights reserved. + * See LICENSE for distribution and usage details. + */ + +import 'package:flutter/cupertino.dart' show CupertinoScrollbar; +import 'package:flutter/material.dart' show Scrollbar; +import 'package:flutter/widgets.dart'; + +import 'platform.dart'; +import 'widget_base.dart'; + +abstract class _BaseData { + _BaseData({ + // Common + this.widgetKey, + required this.child, + this.controller, + this.thumbVisibility, + this.thickness, + this.radius, + this.notificationPredicate, + this.scrollbarOrientation, + this.isAlwaysShown, + }); + final Key? widgetKey; + final Widget child; + final ScrollController? controller; + final bool? thumbVisibility; + final double? thickness; + final Radius? radius; + final bool Function(ScrollNotification)? notificationPredicate; + final ScrollbarOrientation? scrollbarOrientation; + final bool? isAlwaysShown; +} + +class MaterialScrollbarData extends _BaseData { + MaterialScrollbarData({ + // Common + super.widgetKey, + required super.child, + super.controller, + super.thumbVisibility, + super.thickness, + super.radius, + super.notificationPredicate, + super.scrollbarOrientation, + super.isAlwaysShown, + + // Material + this.trackVisibility, + this.interactive, + @Deprecated( + 'Use ScrollbarThemeData.trackVisibility to resolve based on the current state instead. ' + 'This feature was deprecated after v3.4.0-19.0.pre.', + ) + this.showTrackOnHover, + @Deprecated( + 'Use ScrollbarThemeData.thickness to resolve based on the current state instead. ' + 'This feature was deprecated after v2.9.0-1.0.pre.', + ) + this.hoverThickness, + }) : assert( + thumbVisibility == null || isAlwaysShown == null, + 'Scrollbar thumb appearance should only be controlled with thumbVisibility, ' + 'isAlwaysShown is deprecated.'); + + final bool? trackVisibility; + final bool? interactive; + final bool? showTrackOnHover; + final double? hoverThickness; +} + +class CupertinoScrollbarData extends _BaseData { + CupertinoScrollbarData({ + // Common + super.widgetKey, + required super.child, + super.controller, + super.thumbVisibility, + super.thickness, + super.radius, + super.notificationPredicate, + super.scrollbarOrientation, + super.isAlwaysShown, + + // Cupertino + this.thicknessWhileDragging, + this.radiusWhileDragging, + }) : assert(thickness! < double.infinity), + assert(thicknessWhileDragging! < double.infinity), + assert( + isAlwaysShown == null || thumbVisibility == null, + 'Scrollbar thumb appearance should only be controlled with thumbVisibility, ' + 'isAlwaysShown is deprecated.'); + final double? thicknessWhileDragging; + final Radius? radiusWhileDragging; +} + +class PlatformScrollbar + extends PlatformWidgetBase { + //Common + final Key? widgetKey; + final Widget child; + final ScrollController? controller; + final bool? thumbVisibility; + final double? thickness; + final Radius? radius; + final bool Function(ScrollNotification)? notificationPredicate; + final ScrollbarOrientation? scrollbarOrientation; + final bool? isAlwaysShown; + + //Platform + final PlatformBuilder? material; + final PlatformBuilder? cupertino; + + PlatformScrollbar({ + //Common + super.key, + this.widgetKey, + required this.child, + this.controller, + this.thumbVisibility, + this.thickness, + this.radius, + this.notificationPredicate, + this.scrollbarOrientation, + @Deprecated( + 'Use thumbVisibility instead. ' + 'This feature was deprecated after v2.9.0-1.0.pre.', + ) + this.isAlwaysShown, + //Platform + this.material, + this.cupertino, + }); + + @override + Scrollbar createMaterialWidget(BuildContext context) { + final data = material?.call(context, platform(context)); + return Scrollbar( + //Common + key: data?.widgetKey ?? widgetKey, + child: data?.child ?? child, + controller: data?.controller ?? controller, + thumbVisibility: data?.thumbVisibility ?? thumbVisibility, + thickness: data?.thickness ?? thickness, + radius: data?.radius ?? radius, + notificationPredicate: + data?.notificationPredicate ?? notificationPredicate, + scrollbarOrientation: data?.scrollbarOrientation ?? scrollbarOrientation, + isAlwaysShown: data?.isAlwaysShown ?? isAlwaysShown, + + //Material only + trackVisibility: data?.trackVisibility, + interactive: data?.interactive, + showTrackOnHover: data?.showTrackOnHover, + hoverThickness: data?.hoverThickness, + ); + } + + @override + CupertinoScrollbar createCupertinoWidget(BuildContext context) { + final data = cupertino?.call(context, platform(context)); + return CupertinoScrollbar( + //Common + key: data?.widgetKey ?? widgetKey, + controller: data?.controller ?? controller, + child: data?.child ?? child, + thumbVisibility: data?.thumbVisibility ?? thumbVisibility, + thickness: + data?.thickness ?? thickness ?? CupertinoScrollbar.defaultThickness, + radius: data?.radius ?? radius ?? CupertinoScrollbar.defaultRadius, + notificationPredicate: + data?.notificationPredicate ?? notificationPredicate, + scrollbarOrientation: data?.scrollbarOrientation ?? scrollbarOrientation, + isAlwaysShown: data?.isAlwaysShown ?? isAlwaysShown, + + //Cupertino only + thicknessWhileDragging: data?.thicknessWhileDragging ?? + CupertinoScrollbar.defaultThicknessWhileDragging, + radiusWhileDragging: data?.radiusWhileDragging ?? + CupertinoScrollbar.defaultRadiusWhileDragging, + ); + } +} From da54d456a83481a61b0cd0940340d4c04233735b Mon Sep 17 00:00:00 2001 From: Lance Johnstone Date: Fri, 10 Nov 2023 21:39:20 +1300 Subject: [PATCH 02/10] Update widgets with flutter 3.13 properties --- lib/src/platform_checkbox.dart | 3 + .../platform_circular_progress_indicator.dart | 7 +++ lib/src/platform_date_picker.dart | 60 ++++++++++++------- lib/src/platform_dialog_action.dart | 3 + lib/src/platform_radio.dart | 3 + lib/src/platform_search_bar.dart | 3 + lib/src/platform_slider.dart | 9 ++- lib/src/platform_switch.dart | 36 ++++++++--- lib/src/platform_text_button.dart | 30 ++++++---- lib/src/platform_text_form_field.dart | 33 ++++++++++ 10 files changed, 141 insertions(+), 46 deletions(-) diff --git a/lib/src/platform_checkbox.dart b/lib/src/platform_checkbox.dart index 31706576..b699d92c 100644 --- a/lib/src/platform_checkbox.dart +++ b/lib/src/platform_checkbox.dart @@ -62,6 +62,7 @@ class MaterialCheckboxData extends _BaseData { this.materialTapTargetSize, this.visualDensity, this.isError = false, + this.semanticLabel, }); final MouseCursor? mouseCursor; @@ -72,6 +73,7 @@ class MaterialCheckboxData extends _BaseData { final MaterialTapTargetSize? materialTapTargetSize; final VisualDensity? visualDensity; final bool isError; + final String? semanticLabel; } class CupertinoCheckboxData extends _BaseData { @@ -161,6 +163,7 @@ class PlatformCheckbox extends PlatformWidgetBase { autofocus: data?.autofocus ?? autofocus, shape: data?.shape ?? shape, side: data?.side ?? side, + semanticLabel: data?.semanticLabel, ); } diff --git a/lib/src/platform_circular_progress_indicator.dart b/lib/src/platform_circular_progress_indicator.dart index 36a84328..7db3207d 100644 --- a/lib/src/platform_circular_progress_indicator.dart +++ b/lib/src/platform_circular_progress_indicator.dart @@ -33,6 +33,8 @@ class MaterialProgressIndicatorData extends _BaseData { this.valueColor, this.semanticsLabel, this.semanticsValue, + this.strokeAlign, + this.strokeCap, }); final Color? backgroundColor; @@ -41,6 +43,8 @@ class MaterialProgressIndicatorData extends _BaseData { final Animation? valueColor; final String? semanticsLabel; final String? semanticsValue; + final double? strokeAlign; + final StrokeCap? strokeCap; } class CupertinoProgressIndicatorData extends _BaseData { @@ -82,6 +86,9 @@ class PlatformCircularProgressIndicator extends PlatformWidgetBase< semanticsLabel: data?.semanticsLabel, semanticsValue: data?.semanticsValue, color: data?.color, + strokeAlign: + data?.strokeAlign ?? CircularProgressIndicator.strokeAlignCenter, + strokeCap: data?.strokeCap, ); } diff --git a/lib/src/platform_date_picker.dart b/lib/src/platform_date_picker.dart index 45d0aea0..7f59863f 100644 --- a/lib/src/platform_date_picker.dart +++ b/lib/src/platform_date_picker.dart @@ -13,6 +13,10 @@ import 'platform.dart'; import 'platform_text_button.dart'; import 'widget_base.dart'; +// Values derived from https://developer.apple.com/design/resources/ and on iOS +// simulators with "Debug View Hierarchy". +const double _kItemExtent = 32.0; + class DatePickerContentData { final DateTime? initialDate; final DateTime? firstDate; @@ -44,29 +48,32 @@ abstract class _BaseData { } class MaterialDatePickerData extends _BaseData { - MaterialDatePickerData( - {super.initialDate, - super.firstDate, - super.lastDate, - this.currentDate, - this.initialEntryMode, - this.selectableDayPredicate, - this.helpText, - this.cancelText, - this.confirmText, - this.locale, - this.useRootNavigator, - this.routeSettings, - this.textDirection, - this.builder, - this.initialDatePickerMode, - this.errorFormatText, - this.errorInvalidText, - this.fieldHintText, - this.fieldLabelText, - this.anchorPoint, - this.keyboardType, - this.onDatePickerModeChange}); + MaterialDatePickerData({ + super.initialDate, + super.firstDate, + super.lastDate, + this.currentDate, + this.initialEntryMode, + this.selectableDayPredicate, + this.helpText, + this.cancelText, + this.confirmText, + this.locale, + this.useRootNavigator, + this.routeSettings, + this.textDirection, + this.builder, + this.initialDatePickerMode, + this.errorFormatText, + this.errorInvalidText, + this.fieldHintText, + this.fieldLabelText, + this.anchorPoint, + this.keyboardType, + this.onDatePickerModeChange, + this.switchToCalendarEntryModeIcon, + this.switchToInputEntryModeIcon, + }); final DateTime? currentDate; final DatePickerEntryMode? initialEntryMode; @@ -87,6 +94,8 @@ class MaterialDatePickerData extends _BaseData { final Offset? anchorPoint; final TextInputType? keyboardType; final ValueChanged? onDatePickerModeChange; + final Icon? switchToCalendarEntryModeIcon; + final Icon? switchToInputEntryModeIcon; } class CupertinoDatePickerData extends _BaseData { @@ -106,6 +115,7 @@ class CupertinoDatePickerData extends _BaseData { this.doneLabel, this.cancelLabel, this.showDayOfWeek, + this.itemExtent, }); final Key? key; @@ -120,6 +130,7 @@ class CupertinoDatePickerData extends _BaseData { final String? doneLabel; final String? cancelLabel; final bool? showDayOfWeek; + final double? itemExtent; } Future showPlatformDatePicker({ @@ -157,6 +168,8 @@ Future showPlatformDatePicker({ anchorPoint: data?.anchorPoint, keyboardType: data?.keyboardType, onDatePickerModeChange: data?.onDatePickerModeChange, + switchToCalendarEntryModeIcon: data?.switchToCalendarEntryModeIcon, + switchToInputEntryModeIcon: data?.switchToInputEntryModeIcon, ); } else { final data = cupertino?.call(context, platform(context)); @@ -254,6 +267,7 @@ class DefaultCupertinoDatePicker extends StatelessWidget { minuteInterval: data?.minuteInterval ?? 1, use24hFormat: data?.use24hFormat ?? false, showDayOfWeek: data?.showDayOfWeek ?? false, + itemExtent: data?.itemExtent ?? _kItemExtent, ), Row( children: [ diff --git a/lib/src/platform_dialog_action.dart b/lib/src/platform_dialog_action.dart index 9bfaf23a..b1b6f406 100644 --- a/lib/src/platform_dialog_action.dart +++ b/lib/src/platform_dialog_action.dart @@ -49,6 +49,7 @@ class MaterialDialogActionData extends _BaseData { this.onHover, this.onFocusChange, this.statesController, + this.isSemanticButton, }); final FocusNode? focusNode; @@ -58,6 +59,7 @@ class MaterialDialogActionData extends _BaseData { final ValueChanged? onHover; final ValueChanged? onFocusChange; final MaterialStatesController? statesController; + final bool? isSemanticButton; } class MaterialDialogFlatActionData extends _BaseData { @@ -182,6 +184,7 @@ class PlatformDialogAction onFocusChange: data?.onFocusChange, onHover: data?.onHover, statesController: data?.statesController, + isSemanticButton: data?.isSemanticButton ?? true, ); } diff --git a/lib/src/platform_radio.dart b/lib/src/platform_radio.dart index 0d095fa0..5e4125ef 100644 --- a/lib/src/platform_radio.dart +++ b/lib/src/platform_radio.dart @@ -71,6 +71,7 @@ class CupertinoRadioData extends _BaseData { //Cupertino this.inactiveColor, this.fillColor, + this.useCheckmarkStyle, //Common super.widgetKey, super.value, @@ -85,6 +86,7 @@ class CupertinoRadioData extends _BaseData { final Color? inactiveColor; final Color? fillColor; + final bool? useCheckmarkStyle; } class PlatformRadio extends PlatformWidgetBase { @@ -160,6 +162,7 @@ class PlatformRadio extends PlatformWidgetBase { focusColor: data?.focusColor ?? focusColor, autofocus: data?.autofocus ?? autofocus, focusNode: data?.focusNode ?? focusNode, + useCheckmarkStyle: data?.useCheckmarkStyle ?? false, ); } } diff --git a/lib/src/platform_search_bar.dart b/lib/src/platform_search_bar.dart index 8f87112f..ca6e80e1 100644 --- a/lib/src/platform_search_bar.dart +++ b/lib/src/platform_search_bar.dart @@ -54,6 +54,7 @@ class MaterialSearchBarData extends _BaseData { this.hintStyle, this.textStyle, this.hintText, + this.onSubmitted, }); // final String? hintText; @@ -71,6 +72,7 @@ class MaterialSearchBarData extends _BaseData { final MaterialStateProperty? hintStyle; final MaterialStateProperty? textStyle; final String? hintText; + final ValueChanged? onSubmitted; } class CupertinoSearchBarData extends _BaseData { @@ -223,6 +225,7 @@ class PlatformSearchBar side: data?.side, shape: data?.shape, padding: data?.padding, + onSubmitted: data?.onSubmitted, ); } diff --git a/lib/src/platform_slider.dart b/lib/src/platform_slider.dart index 75358533..3c728325 100644 --- a/lib/src/platform_slider.dart +++ b/lib/src/platform_slider.dart @@ -6,7 +6,11 @@ import 'package:flutter/cupertino.dart' show CupertinoColors, CupertinoSlider; import 'package:flutter/material.dart' - show MaterialStateProperty, SemanticFormatterCallback, Slider; + show + MaterialStateProperty, + SemanticFormatterCallback, + Slider, + SliderInteraction; import 'package:flutter/widgets.dart'; import 'platform.dart'; @@ -59,6 +63,7 @@ class MaterialSliderData extends _BaseData { this.overlayColor, this.secondaryActiveColor, this.secondaryTrackValue, + this.allowedInteraction, }); final Color? inactiveColor; @@ -70,6 +75,7 @@ class MaterialSliderData extends _BaseData { final MaterialStateProperty? overlayColor; final Color? secondaryActiveColor; final double? secondaryTrackValue; + final SliderInteraction? allowedInteraction; } class CupertinoSliderData extends _BaseData { @@ -144,6 +150,7 @@ class PlatformSlider extends PlatformWidgetBase { overlayColor: data?.overlayColor, secondaryActiveColor: data?.secondaryActiveColor, secondaryTrackValue: data?.secondaryTrackValue, + allowedInteraction: data?.allowedInteraction, ); } diff --git a/lib/src/platform_switch.dart b/lib/src/platform_switch.dart index d37b97a9..7e49f702 100644 --- a/lib/src/platform_switch.dart +++ b/lib/src/platform_switch.dart @@ -20,6 +20,9 @@ abstract class _BaseData { this.onChanged, this.activeColor, this.dragStartBehavior, + this.focusNode, + this.autofocus, + this.onFocusChange, }); final Key? widgetKey; @@ -27,6 +30,9 @@ abstract class _BaseData { final Color? activeColor; final void Function(bool)? onChanged; final DragStartBehavior? dragStartBehavior; + final FocusNode? focusNode; + final bool? autofocus; + final ValueChanged? onFocusChange; } class MaterialSwitchData extends _BaseData { @@ -36,6 +42,9 @@ class MaterialSwitchData extends _BaseData { super.onChanged, super.activeColor, super.dragStartBehavior, + super.focusNode, + super.autofocus, + super.onFocusChange, this.activeTrackColor, this.inactiveThumbColor, this.inactiveTrackColor, @@ -44,8 +53,6 @@ class MaterialSwitchData extends _BaseData { this.materialTapTargetSize, this.focusColor, this.hoverColor, - this.focusNode, - this.autofocus, this.onActiveThumbImageError, this.onInactiveThumbImageError, this.mouseCursor, @@ -53,9 +60,9 @@ class MaterialSwitchData extends _BaseData { this.splashRadius, this.thumbColor, this.trackColor, - this.onFocusChange, this.thumbIcon, this.trackOutlineColor, + this.trackOutlineWidth, }); final Color? activeTrackColor; @@ -66,8 +73,6 @@ class MaterialSwitchData extends _BaseData { final MaterialTapTargetSize? materialTapTargetSize; final Color? focusColor; final Color? hoverColor; - final FocusNode? focusNode; - final bool? autofocus; final ImageErrorListener? onActiveThumbImageError; final ImageErrorListener? onInactiveThumbImageError; final MouseCursor? mouseCursor; @@ -75,9 +80,9 @@ class MaterialSwitchData extends _BaseData { final double? splashRadius; final MaterialStateProperty? thumbColor; final MaterialStateProperty? trackColor; - final ValueChanged? onFocusChange; final MaterialStateProperty? thumbIcon; final MaterialStateProperty? trackOutlineColor; + final MaterialStateProperty? trackOutlineWidth; } class CupertinoSwitchData extends _BaseData { @@ -87,6 +92,9 @@ class CupertinoSwitchData extends _BaseData { super.onChanged, super.activeColor, super.dragStartBehavior, + super.focusNode, + super.autofocus, + super.onFocusChange, this.trackColor, this.thumbColor, this.applyTheme, @@ -106,6 +114,9 @@ class PlatformSwitch extends PlatformWidgetBase { final Color? activeColor; final void Function(bool)? onChanged; final DragStartBehavior? dragStartBehavior; + final bool? autofocus; + final FocusNode? focusNode; + final ValueChanged? onFocusChange; final PlatformBuilder? material; final PlatformBuilder? cupertino; @@ -117,6 +128,9 @@ class PlatformSwitch extends PlatformWidgetBase { required this.onChanged, this.dragStartBehavior, this.activeColor, + this.autofocus, + this.focusNode, + this.onFocusChange, this.material, this.cupertino, }); @@ -139,9 +153,9 @@ class PlatformSwitch extends PlatformWidgetBase { dragStartBehavior: data?.dragStartBehavior ?? dragStartBehavior ?? DragStartBehavior.start, - autofocus: data?.autofocus ?? false, + autofocus: data?.autofocus ?? autofocus ?? false, focusColor: data?.focusColor, - focusNode: data?.focusNode, + focusNode: data?.focusNode ?? focusNode, hoverColor: data?.hoverColor, onActiveThumbImageError: data?.onActiveThumbImageError, onInactiveThumbImageError: data?.onInactiveThumbImageError, @@ -150,9 +164,10 @@ class PlatformSwitch extends PlatformWidgetBase { splashRadius: data?.splashRadius, thumbColor: data?.thumbColor, trackColor: data?.trackColor, - onFocusChange: data?.onFocusChange, + onFocusChange: data?.onFocusChange ?? onFocusChange, thumbIcon: data?.thumbIcon, trackOutlineColor: data?.trackOutlineColor, + trackOutlineWidth: data?.trackOutlineWidth, ); } @@ -172,6 +187,9 @@ class PlatformSwitch extends PlatformWidgetBase { thumbColor: data?.thumbColor, applyTheme: data?.applyTheme, focusColor: data?.focusColor, + autofocus: data?.autofocus ?? autofocus ?? false, + focusNode: data?.focusNode ?? focusNode, + onFocusChange: data?.onFocusChange ?? onFocusChange, ); } } diff --git a/lib/src/platform_text_button.dart b/lib/src/platform_text_button.dart index 8b7ec24c..53ae5e4b 100644 --- a/lib/src/platform_text_button.dart +++ b/lib/src/platform_text_button.dart @@ -28,19 +28,21 @@ abstract class _BaseData { } class MaterialTextButtonData extends _BaseData { - MaterialTextButtonData( - {super.widgetKey, - super.child, - super.onPressed, - this.onLongPress, - this.focusNode, - this.style, - this.autofocus, - this.clipBehavior, - this.icon, - this.onHover, - this.onFocusChange, - this.statesController}); + MaterialTextButtonData({ + super.widgetKey, + super.child, + super.onPressed, + this.onLongPress, + this.focusNode, + this.style, + this.autofocus, + this.clipBehavior, + this.icon, + this.onHover, + this.onFocusChange, + this.statesController, + this.isSemanticButton, + }); final VoidCallback? onLongPress; final FocusNode? focusNode; @@ -51,6 +53,7 @@ class MaterialTextButtonData extends _BaseData { final ValueChanged? onHover; final ValueChanged? onFocusChange; final MaterialStatesController? statesController; + final bool? isSemanticButton; } class CupertinoTextButtonData extends _BaseData { @@ -150,6 +153,7 @@ class PlatformTextButton extends PlatformWidgetBase { onHover: data?.onHover, onFocusChange: data?.onFocusChange, statesController: data?.statesController, + isSemanticButton: data?.isSemanticButton ?? true, ); } diff --git a/lib/src/platform_text_form_field.dart b/lib/src/platform_text_form_field.dart index 1f36e051..42ca289e 100644 --- a/lib/src/platform_text_form_field.dart +++ b/lib/src/platform_text_form_field.dart @@ -3,6 +3,7 @@ import 'package:flutter/cupertino.dart' CupertinoAdaptiveTextSelectionToolbar, CupertinoColors, CupertinoTextFormFieldRow; +import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart' show AdaptiveTextSelectionToolbar, @@ -11,6 +12,7 @@ import 'package:flutter/material.dart' TextFormField; import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; +import 'dart:ui' as ui show BoxHeightStyle, BoxWidthStyle; import 'platform.dart'; import 'widget_base.dart'; @@ -123,6 +125,16 @@ class MaterialTextFormFieldData extends _BaseData { final TapRegionCallback? onTapOutside; final TextMagnifierConfiguration? magnifierConfiguration; final SpellCheckConfiguration? spellCheckConfiguration; + final bool? canRequestFocus; + final Clip? clipBehavior; + final ContentInsertionConfiguration? contentInsertionConfiguration; + final bool? cursorOpacityAnimates; + final DragStartBehavior? dragStartBehavior; + final AppPrivateCommandCallback? onAppPrivateCommand; + final bool? scribbleEnabled; + final ui.BoxHeightStyle? selectionHeightStyle; + final ui.BoxWidthStyle? selectionWidthStyle; + final UndoHistoryController? undoController; MaterialTextFormFieldData({ super.widgetKey, @@ -180,6 +192,16 @@ class MaterialTextFormFieldData extends _BaseData { this.onTapOutside, this.magnifierConfiguration, this.spellCheckConfiguration, + this.canRequestFocus, + this.clipBehavior, + this.contentInsertionConfiguration, + this.cursorOpacityAnimates, + this.dragStartBehavior, + this.onAppPrivateCommand, + this.scribbleEnabled, + this.selectionHeightStyle, + this.selectionWidthStyle, + this.undoController, }); } @@ -436,6 +458,17 @@ class PlatformTextFormField onTapOutside: data?.onTapOutside, magnifierConfiguration: data?.magnifierConfiguration, spellCheckConfiguration: data?.spellCheckConfiguration, + canRequestFocus: data?.canRequestFocus ?? true, + clipBehavior: data?.clipBehavior ?? Clip.hardEdge, + contentInsertionConfiguration: data?.contentInsertionConfiguration, + cursorOpacityAnimates: data?.cursorOpacityAnimates, + dragStartBehavior: data?.dragStartBehavior ?? DragStartBehavior.start, + onAppPrivateCommand: data?.onAppPrivateCommand, + scribbleEnabled: data?.scribbleEnabled ?? true, + selectionHeightStyle: + data?.selectionHeightStyle ?? ui.BoxHeightStyle.tight, + selectionWidthStyle: data?.selectionWidthStyle ?? ui.BoxWidthStyle.tight, + undoController: data?.undoController, // toolbarOptions: , Deprecated ); } From baf94aef3e8152b6671ca8b3a3f855036b626bd7 Mon Sep 17 00:00:00 2001 From: Lance Johnstone Date: Fri, 10 Nov 2023 21:39:39 +1300 Subject: [PATCH 03/10] Bump version to 5.0.0 --- CHANGELOG.md | 7 +++++++ pubspec.yaml | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f5f01d2..6f19a5f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [5.0.0] + +#### (Flutter version support: v3.13.0 - 3.13.9) + +- Upgrade to flutter version 3.13.0 and sets the Dart min value to 3.1 +- Adds all the flutter 3.13 additional properties for platform widgets + ## [4.0.0-beta.2] #### (Flutter version support: v3.10.0) diff --git a/pubspec.yaml b/pubspec.yaml index 1eb8a32a..cc438ae6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,18 +1,18 @@ name: flutter_platform_widgets description: Simplifying the use of both Material and Cupertino widgets with a single widget -version: 4.0.0-beta.3 +version: 5.0.0 homepage: https://github.com/stryder-dev/flutter_platform_widgets documentation: https://github.com/stryder-dev/flutter_platform_widgets/wiki environment: - sdk: ">=3.0.0-0 <4.0.0" - flutter: ">=3.10.0" + sdk: ">=3.1.0-0 <4.0.0" + flutter: ">=3.13.0" dependencies: flutter: sdk: flutter - cupertino_icons: ^1.0.5 + cupertino_icons: ^1.0.6 dev_dependencies: flutter_test: From 9740f95f7b2a1fd2d9eab0209765dd83ad16b972 Mon Sep 17 00:00:00 2001 From: Kishor Mainali Date: Thu, 16 Nov 2023 15:19:43 +0545 Subject: [PATCH 04/10] fixes: updated to support flutter 3.16 --- lib/src/platform_app_bar.dart | 4 ++-- lib/src/platform_icons.dart | 20 ++++++++++++-------- lib/src/platform_text_field.dart | 8 ++++---- lib/src/platform_theme.dart | 16 ++++++---------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/src/platform_app_bar.dart b/lib/src/platform_app_bar.dart index d2bd2941..ef2abb36 100644 --- a/lib/src/platform_app_bar.dart +++ b/lib/src/platform_app_bar.dart @@ -10,10 +10,10 @@ import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; import 'extensions.dart'; +import 'parent_widget_finder.dart'; import 'platform.dart'; import 'platform_provider.dart'; import 'widget_base.dart'; -import 'parent_widget_finder.dart'; //the default has alpha which will cause the content to slide under the header for ios const Color _kDefaultNavBarBorderColor = const Color(0x4C000000); @@ -322,7 +322,7 @@ class PlatformAppBar final middleWithMediaQuery = MediaQuery( data: MediaQueryData( - textScaleFactor: MediaQuery.textScaleFactorOf(context)), + textScaler: TextScaler.linear(MediaQuery.textScaleFactorOf(context))), child: middleLocal, ); diff --git a/lib/src/platform_icons.dart b/lib/src/platform_icons.dart index 87f8645b..61f8baf6 100644 --- a/lib/src/platform_icons.dart +++ b/lib/src/platform_icons.dart @@ -188,20 +188,24 @@ class PlatformIcons { isMaterial(context) ? Icons.cloud : CupertinoIcons.cloud_fill; /// Icons: Icons.cloud_download_outlined : CupertinoIcons.cloud_download - IconData get cloudDownload => - isMaterial(context) ? Icons.cloud_download_outlined : CupertinoIcons.cloud_download; + IconData get cloudDownload => isMaterial(context) + ? Icons.cloud_download_outlined + : CupertinoIcons.cloud_download; /// Icons: Icons.cloud_download : CupertinoIcons.cloud_download_fill - IconData get cloudDownloadSolid => - isMaterial(context) ? Icons.cloud_download : CupertinoIcons.cloud_download_fill; + IconData get cloudDownloadSolid => isMaterial(context) + ? Icons.cloud_download + : CupertinoIcons.cloud_download_fill; /// Icons: Icons.cloud_upload_outlined : CupertinoIcons.cloud_upload - IconData get cloudUpload => - isMaterial(context) ? Icons.cloud_upload_outlined : CupertinoIcons.cloud_upload; + IconData get cloudUpload => isMaterial(context) + ? Icons.cloud_upload_outlined + : CupertinoIcons.cloud_upload; /// Icons: Icons.cloud_upload : CupertinoIcons.cloud_upload_fill - IconData get cloudUploadSolid => - isMaterial(context) ? Icons.cloud_upload : CupertinoIcons.cloud_upload_fill; + IconData get cloudUploadSolid => isMaterial(context) + ? Icons.cloud_upload + : CupertinoIcons.cloud_upload_fill; /// Icons: Icons.collections : CupertinoIcons.collections IconData get collections => diff --git a/lib/src/platform_text_field.dart b/lib/src/platform_text_field.dart index c9b29306..29505bd9 100644 --- a/lib/src/platform_text_field.dart +++ b/lib/src/platform_text_field.dart @@ -70,7 +70,7 @@ abstract class _BaseData { this.onEditingComplete, this.onSubmitted, this.inputFormatters, - this.enabled, + this.enabled = true, this.cursorWidth, this.cursorRadius, this.cursorColor, @@ -139,7 +139,7 @@ abstract class _BaseData { final void Function()? onEditingComplete; final void Function(String)? onSubmitted; final List? inputFormatters; - final bool? enabled; + final bool enabled; final double? cursorWidth; final Radius? cursorRadius; final Color? cursorColor; @@ -348,7 +348,7 @@ class PlatformTextField final void Function()? onEditingComplete; final void Function(String)? onSubmitted; final List? inputFormatters; - final bool? enabled; + final bool enabled; final double? cursorWidth; final Radius? cursorRadius; final DragStartBehavior? dragStartBehavior; @@ -425,7 +425,7 @@ class PlatformTextField this.onEditingComplete, this.onSubmitted, this.inputFormatters, - this.enabled, + this.enabled = true, this.cursorWidth, this.cursorRadius, this.cursorColor, diff --git a/lib/src/platform_theme.dart b/lib/src/platform_theme.dart index 848f4469..c64d43db 100644 --- a/lib/src/platform_theme.dart +++ b/lib/src/platform_theme.dart @@ -47,10 +47,10 @@ class _PlatformThemeState extends State _themeMode = widget.themeMode; _materialLightTheme = _useMaterial3Light == null ? widget.materialLightTheme - : widget.materialLightTheme?.copyWith(useMaterial3: _useMaterial3Light); + : widget.materialLightTheme?.copyWith(); _materialDarkTheme = _useMaterial3Dark == null ? widget.materialDarkTheme - : widget.materialDarkTheme?.copyWith(useMaterial3: _useMaterial3Dark); + : widget.materialDarkTheme?.copyWith(); _cupertinoLightTheme = widget.cupertinoLightTheme; _cupertinoDarkTheme = widget.cupertinoDarkTheme; _matchCupertinoSystemChromeBrightness = @@ -136,19 +136,15 @@ class _PlatformThemeState extends State setState(() { if (applyToBothDarkAndLightTheme) { _useMaterial3Dark = _useMaterial3Light = useMaterial3; - _materialDarkTheme = - _materialDarkTheme?.copyWith(useMaterial3: useMaterial3); - _materialLightTheme = - _materialLightTheme?.copyWith(useMaterial3: useMaterial3); + _materialDarkTheme = _materialDarkTheme?.copyWith(); + _materialLightTheme = _materialLightTheme?.copyWith(); } else { isDark ? _useMaterial3Dark = useMaterial3 : _useMaterial3Light = useMaterial3; isDark - ? _materialDarkTheme = - _materialDarkTheme?.copyWith(useMaterial3: useMaterial3) - : _materialLightTheme = - _materialLightTheme?.copyWith(useMaterial3: useMaterial3); + ? _materialDarkTheme = _materialDarkTheme?.copyWith() + : _materialLightTheme = _materialLightTheme?.copyWith(); } }); } From dae88591af21fcce377f5c1d547f66e06cc656fc Mon Sep 17 00:00:00 2001 From: Kishor Mainali Date: Thu, 16 Nov 2023 15:50:15 +0545 Subject: [PATCH 05/10] fixes --- lib/src/platform_app_bar.dart | 3 +-- lib/src/platform_text.dart | 7 ++++++- lib/src/platform_theme.dart | 27 ++++++--------------------- 3 files changed, 13 insertions(+), 24 deletions(-) diff --git a/lib/src/platform_app_bar.dart b/lib/src/platform_app_bar.dart index ef2abb36..003e97d3 100644 --- a/lib/src/platform_app_bar.dart +++ b/lib/src/platform_app_bar.dart @@ -321,8 +321,7 @@ class PlatformAppBar } final middleWithMediaQuery = MediaQuery( - data: MediaQueryData( - textScaler: TextScaler.linear(MediaQuery.textScaleFactorOf(context))), + data: MediaQueryData(textScaler: MediaQuery.textScalerOf(context)), child: middleLocal, ); diff --git a/lib/src/platform_text.dart b/lib/src/platform_text.dart index 45bb8c85..b42b2203 100644 --- a/lib/src/platform_text.dart +++ b/lib/src/platform_text.dart @@ -32,7 +32,12 @@ class PlatformText extends StatelessWidget { TextDirection? textDirection, bool? softWrap, TextOverflow? overflow, + @Deprecated( + 'Use textScaler instead. ' + 'This feature was removed after version 3.16', + ) double? textScaleFactor, + TextScaler? textScaler, int? maxLines, Locale? locale, String? semanticsLabel, @@ -51,7 +56,7 @@ class PlatformText extends StatelessWidget { textDirection: textDirection, softWrap: softWrap, overflow: overflow, - textScaleFactor: textScaleFactor, + textScaler: textScaler, maxLines: maxLines, locale: locale, semanticsLabel: semanticsLabel, diff --git a/lib/src/platform_theme.dart b/lib/src/platform_theme.dart index c64d43db..540ae6f6 100644 --- a/lib/src/platform_theme.dart +++ b/lib/src/platform_theme.dart @@ -45,21 +45,12 @@ class _PlatformThemeState extends State void _init() { _themeMode = widget.themeMode; - _materialLightTheme = _useMaterial3Light == null - ? widget.materialLightTheme - : widget.materialLightTheme?.copyWith(); - _materialDarkTheme = _useMaterial3Dark == null - ? widget.materialDarkTheme - : widget.materialDarkTheme?.copyWith(); + _materialLightTheme = widget.materialLightTheme; + _materialDarkTheme = widget.materialDarkTheme; _cupertinoLightTheme = widget.cupertinoLightTheme; _cupertinoDarkTheme = widget.cupertinoDarkTheme; _matchCupertinoSystemChromeBrightness = widget.matchCupertinoSystemChromeBrightness; - - _useMaterial3Light = - _useMaterial3Light ?? widget.materialLightTheme?.useMaterial3; - _useMaterial3Dark = - _useMaterial3Dark ?? widget.materialDarkTheme?.useMaterial3; } @override @@ -111,8 +102,6 @@ class _PlatformThemeState extends State : themeMode == ThemeMode.dark; } - bool? _useMaterial3Light; - bool? _useMaterial3Dark; void changeToMaterial3({bool applyToBothDarkAndLightTheme = false}) => _setMaterialThemeType( useMaterial3: true, @@ -135,16 +124,12 @@ class _PlatformThemeState extends State }) { setState(() { if (applyToBothDarkAndLightTheme) { - _useMaterial3Dark = _useMaterial3Light = useMaterial3; - _materialDarkTheme = _materialDarkTheme?.copyWith(); - _materialLightTheme = _materialLightTheme?.copyWith(); + _materialDarkTheme = _materialDarkTheme; + _materialLightTheme = _materialLightTheme; } else { isDark - ? _useMaterial3Dark = useMaterial3 - : _useMaterial3Light = useMaterial3; - isDark - ? _materialDarkTheme = _materialDarkTheme?.copyWith() - : _materialLightTheme = _materialLightTheme?.copyWith(); + ? _materialDarkTheme = _materialDarkTheme + : _materialLightTheme = _materialLightTheme; } }); } From 0fd05c859ec085fd356f32c824522f92278d3ae7 Mon Sep 17 00:00:00 2001 From: Lance Johnstone Date: Fri, 17 Nov 2023 14:34:13 +1300 Subject: [PATCH 06/10] Update to Flutter 3.16 and bump version to 6.0.1 --- CHANGELOG.md | 6 ++++++ example/ios/Runner.xcodeproj/project.pbxproj | 2 +- .../Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme | 2 +- lib/src/platform_text_field.dart | 4 ++-- pubspec.yaml | 6 +++--- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f19a5f2..8a4f9a2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## [6.0.1] + +#### (Flutter version support: v3.16.0) + +- Fixed `PlatformTextField` that had a breaking argument due to Flutter 3.16 (thanks kishormainali) + ## [5.0.0] #### (Flutter version support: v3.13.0 - 3.13.9) diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 59260eda..6b8f839a 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -127,7 +127,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1430; ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 3db53b6e..b52b2e69 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ ? inputFormatters; - final bool enabled; + final bool? enabled; final double? cursorWidth; final Radius? cursorRadius; final Color? cursorColor; diff --git a/pubspec.yaml b/pubspec.yaml index cc438ae6..d252aac0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,12 +1,12 @@ name: flutter_platform_widgets description: Simplifying the use of both Material and Cupertino widgets with a single widget -version: 5.0.0 +version: 6.0.1 homepage: https://github.com/stryder-dev/flutter_platform_widgets documentation: https://github.com/stryder-dev/flutter_platform_widgets/wiki environment: - sdk: ">=3.1.0-0 <4.0.0" - flutter: ">=3.13.0" + sdk: ">=3.2.0-0 <4.0.0" + flutter: ">=3.16.0" dependencies: flutter: From 53fca27c0a4df0b9de837c59f3bdcbb5090ddedf Mon Sep 17 00:00:00 2001 From: Lance Johnstone Date: Fri, 17 Nov 2023 16:42:13 +1300 Subject: [PATCH 07/10] Add Flutter 3.16 extra widget params --- lib/src/platform.dart | 3 +++ lib/src/platform_app.dart | 37 ++++++++++++++++++++++++------- lib/src/platform_date_picker.dart | 9 ++++++++ lib/src/platform_page_route.dart | 7 ++++++ lib/src/platform_popup_menu.dart | 3 +++ lib/src/platform_search_bar.dart | 4 ++++ lib/src/platform_switch.dart | 6 +++++ lib/src/platform_text.dart | 1 + 8 files changed, 62 insertions(+), 8 deletions(-) diff --git a/lib/src/platform.dart b/lib/src/platform.dart index 6c7e5fa6..5ee2b259 100644 --- a/lib/src/platform.dart +++ b/lib/src/platform.dart @@ -132,6 +132,7 @@ abstract class _DialogBaseData { class MaterialDialogData extends _DialogBaseData { final bool? useSafeArea; final Color? barrierColor; + final TraversalEdgeBehavior? traversalEdgeBehavior; MaterialDialogData({ super.builder, @@ -142,6 +143,7 @@ class MaterialDialogData extends _DialogBaseData { super.anchorPoint, this.useSafeArea, this.barrierColor, + this.traversalEdgeBehavior, }); } @@ -181,6 +183,7 @@ Future showPlatformDialog({ barrierColor: material?.barrierColor ?? Colors.black54, barrierLabel: material?.barrierLabel ?? barrierLabel, anchorPoint: material?.anchorPoint ?? anchorPoint, + traversalEdgeBehavior: material?.traversalEdgeBehavior, ); } else { assert(cupertino?.builder != null || builder != null); diff --git a/lib/src/platform_app.dart b/lib/src/platform_app.dart index 5d66fb66..3089521c 100644 --- a/lib/src/platform_app.dart +++ b/lib/src/platform_app.dart @@ -52,6 +52,7 @@ abstract class _BaseData { this.highContrastTheme, this.restorationScopeId, this.scrollBehavior, + this.onNavigationNotification, }); final Key? widgetKey; @@ -83,6 +84,8 @@ abstract class _BaseData { final ThemeData? highContrastTheme; final String? restorationScopeId; final ScrollBehavior? scrollBehavior; + final NotificationListenerCallback? + onNavigationNotification; } abstract class _BaseRouterData { @@ -117,6 +120,7 @@ abstract class _BaseRouterData { // ignore: unused_element this.restorationScopeId, this.scrollBehavior, + this.onNavigationNotification, }); final Key? widgetKey; @@ -158,6 +162,9 @@ abstract class _BaseRouterData { final String? restorationScopeId; final ScrollBehavior? scrollBehavior; + + final NotificationListenerCallback? + onNavigationNotification; } class MaterialAppData extends _BaseData { @@ -189,13 +196,14 @@ class MaterialAppData extends _BaseData { super.onGenerateInitialRoutes, super.restorationScopeId, super.scrollBehavior, + super.onNavigationNotification, this.theme, this.debugShowMaterialGrid, this.darkTheme, this.themeMode, this.scaffoldMessengerKey, - this.themeAnimationCurve = Curves.linear, - this.themeAnimationDuration = kThemeAnimationDuration, + this.themeAnimationCurve, + this.themeAnimationDuration, }); final ThemeData? theme; @@ -203,8 +211,8 @@ class MaterialAppData extends _BaseData { final ThemeData? darkTheme; final ThemeMode? themeMode; final GlobalKey? scaffoldMessengerKey; - final Curve themeAnimationCurve; - final Duration themeAnimationDuration; + final Curve? themeAnimationCurve; + final Duration? themeAnimationDuration; } class MaterialAppRouterData extends _BaseRouterData { @@ -232,13 +240,14 @@ class MaterialAppRouterData extends _BaseRouterData { super.actions, super.onGenerateInitialRoutes, super.scrollBehavior, + super.onNavigationNotification, this.theme, this.debugShowMaterialGrid, this.darkTheme, this.themeMode, this.scaffoldMessengerKey, - this.themeAnimationCurve = Curves.linear, - this.themeAnimationDuration = kThemeAnimationDuration, + this.themeAnimationCurve, + this.themeAnimationDuration, }); final ThemeData? theme; @@ -246,8 +255,8 @@ class MaterialAppRouterData extends _BaseRouterData { final ThemeData? darkTheme; final ThemeMode? themeMode; final GlobalKey? scaffoldMessengerKey; - final Curve themeAnimationCurve; - final Duration themeAnimationDuration; + final Curve? themeAnimationCurve; + final Duration? themeAnimationDuration; } class CupertinoAppData extends _BaseData { @@ -342,6 +351,8 @@ class PlatformApp extends PlatformWidgetBase { final Map? shortcuts; final Map>? actions; final InitialRouteListFactory? onGenerateInitialRoutes; + final NotificationListenerCallback? + onNavigationNotification; final PlatformBuilder? material; final PlatformBuilder? cupertino; @@ -396,6 +407,7 @@ class PlatformApp extends PlatformWidgetBase { this.onGenerateInitialRoutes, this.restorationScopeId, this.scrollBehavior, + this.onNavigationNotification, this.material, this.cupertino, }) : routeInformationProvider = null, @@ -432,6 +444,7 @@ class PlatformApp extends PlatformWidgetBase { this.actions, this.restorationScopeId, this.scrollBehavior, + this.onNavigationNotification, PlatformBuilder? material, PlatformBuilder? cupertino, }) : navigatorObservers = null, @@ -521,6 +534,8 @@ class PlatformApp extends PlatformWidgetBase { themeAnimationCurve: dataRouter?.themeAnimationCurve ?? Curves.linear, themeAnimationDuration: dataRouter?.themeAnimationDuration ?? kThemeAnimationDuration, + onNavigationNotification: + dataRouter?.onNavigationNotification ?? onNavigationNotification, // useInheritedMediaQuery: , Deprecated ); } else { @@ -585,6 +600,8 @@ class PlatformApp extends PlatformWidgetBase { themeAnimationCurve: data?.themeAnimationCurve ?? Curves.linear, themeAnimationDuration: data?.themeAnimationDuration ?? kThemeAnimationDuration, + onNavigationNotification: + data?.onNavigationNotification ?? onNavigationNotification, // useInheritedMediaQuery: , Deprecated ); } @@ -649,6 +666,8 @@ class PlatformApp extends PlatformWidgetBase { restorationScopeId: dataRouter?.restorationScopeId ?? restorationScopeId, scrollBehavior: dataRouter?.scrollBehavior ?? scrollBehavior, + onNavigationNotification: + dataRouter?.onNavigationNotification ?? onNavigationNotification, // useInheritedMediaQuery: , Deprecated ); } else { @@ -699,6 +718,8 @@ class PlatformApp extends PlatformWidgetBase { data?.onGenerateInitialRoutes ?? onGenerateInitialRoutes, restorationScopeId: data?.restorationScopeId ?? restorationScopeId, scrollBehavior: data?.scrollBehavior ?? scrollBehavior, + onNavigationNotification: + data?.onNavigationNotification ?? onNavigationNotification, // useInheritedMediaQuery: , Deprecated ); } diff --git a/lib/src/platform_date_picker.dart b/lib/src/platform_date_picker.dart index 7f59863f..3f9a8c7f 100644 --- a/lib/src/platform_date_picker.dart +++ b/lib/src/platform_date_picker.dart @@ -73,6 +73,9 @@ class MaterialDatePickerData extends _BaseData { this.onDatePickerModeChange, this.switchToCalendarEntryModeIcon, this.switchToInputEntryModeIcon, + this.barrierColor, + this.barrierDismissible, + this.barrierLabel, }); final DateTime? currentDate; @@ -96,6 +99,9 @@ class MaterialDatePickerData extends _BaseData { final ValueChanged? onDatePickerModeChange; final Icon? switchToCalendarEntryModeIcon; final Icon? switchToInputEntryModeIcon; + final Color? barrierColor; + final bool? barrierDismissible; + final String? barrierLabel; } class CupertinoDatePickerData extends _BaseData { @@ -170,6 +176,9 @@ Future showPlatformDatePicker({ onDatePickerModeChange: data?.onDatePickerModeChange, switchToCalendarEntryModeIcon: data?.switchToCalendarEntryModeIcon, switchToInputEntryModeIcon: data?.switchToInputEntryModeIcon, + barrierColor: data?.barrierColor, + barrierDismissible: data?.barrierDismissible ?? true, + barrierLabel: data?.barrierLabel, ); } else { final data = cupertino?.call(context, platform(context)); diff --git a/lib/src/platform_page_route.dart b/lib/src/platform_page_route.dart index 207267e4..2084814b 100644 --- a/lib/src/platform_page_route.dart +++ b/lib/src/platform_page_route.dart @@ -18,6 +18,7 @@ class _BasePageRouteData { final bool? maintainState; final bool? fullscreenDialog; final bool? allowSnapshotting; + final bool? barrierDismissible; _BasePageRouteData({ this.builder, @@ -25,6 +26,7 @@ class _BasePageRouteData { this.maintainState, this.fullscreenDialog, this.allowSnapshotting, + this.barrierDismissible, }); } @@ -35,6 +37,7 @@ class MaterialPageRouteData extends _BasePageRouteData { super.maintainState, super.fullscreenDialog, super.allowSnapshotting, + super.barrierDismissible, }); } @@ -45,6 +48,7 @@ class CupertinoPageRouteData extends _BasePageRouteData { super.maintainState, super.fullscreenDialog, super.allowSnapshotting, + super.barrierDismissible, }); } @@ -56,6 +60,7 @@ PageRoute platformPageRoute({ bool? fullscreenDialog, String? iosTitle, bool allowSnapshotting = true, + bool barrierDismissible = false, PlatformBuilder? material, PlatformBuilder? cupertino, }) { @@ -68,6 +73,7 @@ PageRoute platformPageRoute({ maintainState: data?.maintainState ?? maintainState ?? true, fullscreenDialog: data?.fullscreenDialog ?? fullscreenDialog ?? false, allowSnapshotting: data?.allowSnapshotting ?? allowSnapshotting, + barrierDismissible: data?.barrierDismissible ?? barrierDismissible, ); } else { final data = cupertino?.call(context, platform(context)); @@ -79,6 +85,7 @@ PageRoute platformPageRoute({ fullscreenDialog: data?.fullscreenDialog ?? fullscreenDialog ?? false, title: iosTitle, allowSnapshotting: data?.allowSnapshotting ?? allowSnapshotting, + barrierDismissible: data?.barrierDismissible ?? barrierDismissible, ); } } diff --git a/lib/src/platform_popup_menu.dart b/lib/src/platform_popup_menu.dart index 71acf0cf..b961a0d1 100644 --- a/lib/src/platform_popup_menu.dart +++ b/lib/src/platform_popup_menu.dart @@ -107,6 +107,7 @@ class MaterialPopupMenuData { final VoidCallback? onOpened; final Color? shadowColor; final Color? surfaceTintColor; + final Color? iconColor; MaterialPopupMenuData({ this.key, @@ -131,6 +132,7 @@ class MaterialPopupMenuData { this.onOpened, this.shadowColor, this.surfaceTintColor, + this.iconColor, }); } @@ -299,6 +301,7 @@ class PlatformPopupMenu extends StatelessWidget { onOpened: data?.onOpened, shadowColor: data?.shadowColor, surfaceTintColor: data?.surfaceTintColor, + iconColor: data?.iconColor, ); } } diff --git a/lib/src/platform_search_bar.dart b/lib/src/platform_search_bar.dart index ca6e80e1..4ffcb942 100644 --- a/lib/src/platform_search_bar.dart +++ b/lib/src/platform_search_bar.dart @@ -11,6 +11,7 @@ import 'package:flutter/cupertino.dart' OverlayVisibilityMode, CupertinoIcons; import 'package:flutter/material.dart' show MaterialStateProperty, SearchBar; +import 'package:flutter/services.dart' show TextCapitalization; import 'package:flutter/widgets.dart'; import 'platform.dart'; @@ -55,6 +56,7 @@ class MaterialSearchBarData extends _BaseData { this.textStyle, this.hintText, this.onSubmitted, + this.textCapitalization, }); // final String? hintText; @@ -73,6 +75,7 @@ class MaterialSearchBarData extends _BaseData { final MaterialStateProperty? textStyle; final String? hintText; final ValueChanged? onSubmitted; + final TextCapitalization? textCapitalization; } class CupertinoSearchBarData extends _BaseData { @@ -226,6 +229,7 @@ class PlatformSearchBar shape: data?.shape, padding: data?.padding, onSubmitted: data?.onSubmitted, + textCapitalization: data?.textCapitalization, ); } diff --git a/lib/src/platform_switch.dart b/lib/src/platform_switch.dart index 7e49f702..94e3baa5 100644 --- a/lib/src/platform_switch.dart +++ b/lib/src/platform_switch.dart @@ -99,12 +99,16 @@ class CupertinoSwitchData extends _BaseData { this.thumbColor, this.applyTheme, this.focusColor, + this.offLabelColor, + this.onLabelColor, }); final Color? trackColor; final Color? thumbColor; final bool? applyTheme; final Color? focusColor; + final Color? offLabelColor; + final Color? onLabelColor; } class PlatformSwitch extends PlatformWidgetBase { @@ -190,6 +194,8 @@ class PlatformSwitch extends PlatformWidgetBase { autofocus: data?.autofocus ?? autofocus ?? false, focusNode: data?.focusNode ?? focusNode, onFocusChange: data?.onFocusChange ?? onFocusChange, + offLabelColor: data?.offLabelColor, + onLabelColor: data?.onLabelColor, ); } } diff --git a/lib/src/platform_text.dart b/lib/src/platform_text.dart index b42b2203..e9e6e7d1 100644 --- a/lib/src/platform_text.dart +++ b/lib/src/platform_text.dart @@ -64,6 +64,7 @@ class PlatformText extends StatelessWidget { textWidthBasis: textWidthBasis, textHeightBehavior: textHeightBehavior, selectionColor: selectionColor, + //deprecated textScaleFactor: textScaleFactor, )); } From 757f77da365d1f90c7903eadd91fa9d00d39cea6 Mon Sep 17 00:00:00 2001 From: Lance Johnstone Date: Fri, 17 Nov 2023 16:55:11 +1300 Subject: [PATCH 08/10] Bump version to 6.0.2 --- CHANGELOG.md | 7 +++++++ pubspec.yaml | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a4f9a2b..77080723 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,14 @@ +## [6.0.2] + +#### (Flutter version support: v3.16.0) + +- Adds all the flutter 3.16 additional properties for platform widgets + ## [6.0.1] #### (Flutter version support: v3.16.0) +- Upgrade to flutter version 3.16.0 and sets the Dart min value to 3.2 - Fixed `PlatformTextField` that had a breaking argument due to Flutter 3.16 (thanks kishormainali) ## [5.0.0] diff --git a/pubspec.yaml b/pubspec.yaml index d252aac0..934e956d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_platform_widgets description: Simplifying the use of both Material and Cupertino widgets with a single widget -version: 6.0.1 +version: 6.0.2 homepage: https://github.com/stryder-dev/flutter_platform_widgets documentation: https://github.com/stryder-dev/flutter_platform_widgets/wiki From 880c9a1e437182730a49c4f21bc85aafa97a04b7 Mon Sep 17 00:00:00 2001 From: fdwl Date: Wed, 20 Dec 2023 11:01:32 +0800 Subject: [PATCH 09/10] Update platform_date_picker.dart update modalColor --- lib/src/platform_date_picker.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/src/platform_date_picker.dart b/lib/src/platform_date_picker.dart index 3f9a8c7f..739cce62 100644 --- a/lib/src/platform_date_picker.dart +++ b/lib/src/platform_date_picker.dart @@ -224,6 +224,7 @@ Widget _renderManagedCupertinoDatePicker({ return DefaultCupertinoDatePicker( contentData: contentData, data: data, + modalColor: data?.backgroundColor, onDateTimeChanged: (newDate) => setState(() => selectedDate = newDate), ); }, From e15af3e3102ae6337b2507abc1af4a47a383721a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Etienne=20Th=C3=A9odore?= Date: Fri, 22 Dec 2023 12:17:38 +0100 Subject: [PATCH 10/10] feat: adding icon exit_to_app --- lib/src/platform_icons.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/src/platform_icons.dart b/lib/src/platform_icons.dart index 61f8baf6..8238b081 100644 --- a/lib/src/platform_icons.dart +++ b/lib/src/platform_icons.dart @@ -741,4 +741,9 @@ class PlatformIcons { /// Icons: Icons.wifi_off : CupertinoIcons.wifi_slash IconData get wifiOff => isMaterial(context) ? Icons.wifi_off : CupertinoIcons.wifi_slash; + + /// Icons: Icons.exit_to_app : CupertinoIcons.square_arrow_right + IconData get exit_to_app => isMaterial(context) + ? Icons.exit_to_app + : CupertinoIcons.square_arrow_right; }