diff --git a/example/lib/features.dart b/example/lib/features.dart index 70c40e4..470e362 100644 --- a/example/lib/features.dart +++ b/example/lib/features.dart @@ -1,12 +1,13 @@ import 'package:flutter/material.dart'; -import 'features_single/single_main.dart'; -import 'features_multi/multi_main.dart'; -import 'features_tile/tile_main.dart'; -import 'features_option/option_main.dart'; -import 'features_modal/modal_main.dart'; -import 'features_choices/choices_main.dart'; + import 'features_brightness.dart'; +import 'features_choices/choices_main.dart'; import 'features_color.dart'; +import 'features_modal/modal_main.dart'; +import 'features_multi/multi_main.dart'; +import 'features_option/option_main.dart'; +import 'features_single/single_main.dart'; +import 'features_tile/tile_main.dart'; // import 'features_theme.dart'; import 'keep_alive.dart'; @@ -81,7 +82,7 @@ class Features extends StatelessWidget { ListTile( title: Text( 'flutter_awesome_select', - style: Theme.of(context).textTheme.headline5, + style: Theme.of(context).textTheme.headlineLarge, ), subtitle: Text('by davigmacode'), trailing: IconButton( @@ -98,7 +99,7 @@ class Features extends StatelessWidget { children: [ Text( 'Smart select allows you to easily convert your usual form selects to dynamic pages with grouped radio or checkbox inputs. This widget is inspired by Smart Select component from Framework7', - style: Theme.of(context).textTheme.bodyText2, + style: Theme.of(context).textTheme.bodyMedium, ), Container(height: 15), ], diff --git a/example/lib/features_modal/modal_confirm.dart b/example/lib/features_modal/modal_confirm.dart index 623c20d..dcec355 100644 --- a/example/lib/features_modal/modal_confirm.dart +++ b/example/lib/features_modal/modal_confirm.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_awesome_select/flutter_awesome_select.dart'; + import '../choices.dart' as choices; class FeaturesModalConfirm extends StatefulWidget { @@ -86,9 +87,9 @@ class _FeaturesModalConfirmState extends State { TextButton( child: Text('OK (${state.selection?.length ?? 0})'), style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( + backgroundColor: WidgetStateProperty.all( Theme.of(context).primaryColor), - textStyle: MaterialStateProperty.all( + textStyle: WidgetStateProperty.all( TextStyle(color: Colors.white)), ), onPressed: (state.selection?.isValid ?? true) @@ -109,7 +110,8 @@ class _FeaturesModalConfirmState extends State { choiceActiveStyle: const S2ChoiceStyle(color: Colors.redAccent), modalType: S2ModalType.bottomSheet, modalValidation: (selected) { - if (selected == null) return 'Select at least one'; + if (selected.isEmpty && selected == null) + return 'Select at least one'; if (selected.value == 'iro') return 'Ironman is busy'; return ''; }, @@ -137,8 +139,8 @@ class _FeaturesModalConfirmState extends State { child: const Text('Send'), style: ButtonStyle( backgroundColor: - MaterialStateProperty.all(Colors.redAccent), - textStyle: MaterialStateProperty.all( + WidgetStateProperty.all(Colors.redAccent), + textStyle: WidgetStateProperty.all( TextStyle(color: Colors.white)), ), onPressed: () => state.closeModal(confirmed: true), diff --git a/example/lib/features_modal/modal_header.dart b/example/lib/features_modal/modal_header.dart index 0e0acfd..3af6f34 100644 --- a/example/lib/features_modal/modal_header.dart +++ b/example/lib/features_modal/modal_header.dart @@ -1,7 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_awesome_select/flutter_awesome_select.dart'; -import '../widgets/icon_badge.dart'; + import '../choices.dart' as choices; +import '../widgets/icon_badge.dart'; class FeaturesModalHeader extends StatefulWidget { @override @@ -56,7 +57,7 @@ class _FeaturesModalHeaderState extends State { type: S2ModalType.popupDialog, headerStyle: S2ModalHeaderStyle( backgroundColor: Theme.of(context).primaryColor, - textStyle: Theme.of(context).primaryTextTheme.headline6, + textStyle: Theme.of(context).primaryTextTheme.headlineSmall, centerTitle: true, elevation: 0, ), diff --git a/example/lib/features_modal/modal_selector.dart b/example/lib/features_modal/modal_selector.dart index 31cfb2e..392407c 100644 --- a/example/lib/features_modal/modal_selector.dart +++ b/example/lib/features_modal/modal_selector.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_awesome_select/flutter_awesome_select.dart'; + import '../choices.dart' as choices; class FeaturesModalSelector extends StatefulWidget { @@ -71,9 +72,9 @@ class _FeaturesModalSelectorState extends State { TextButton( child: Text('OK (${state.selection?.length ?? 0})'), style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( + backgroundColor: WidgetStateProperty.all( Theme.of(context).primaryColor), - textStyle: MaterialStateProperty.all( + textStyle: WidgetStateProperty.all( TextStyle(color: Colors.white)), ), onPressed: (state.selection?.isValid ?? true) @@ -249,9 +250,9 @@ class ActionButton extends StatelessWidget { child: label, style: ButtonStyle( backgroundColor: - MaterialStateProperty.all(Theme.of(context).primaryColor), - textStyle: MaterialStateProperty.all( - TextStyle(color: Colors.white)), + WidgetStateProperty.all(Theme.of(context).primaryColor), + textStyle: + WidgetStateProperty.all(TextStyle(color: Colors.white)), ), onPressed: onTap, ); diff --git a/example/lib/features_modal/modal_validation.dart b/example/lib/features_modal/modal_validation.dart index 9e29d32..56e2af2 100644 --- a/example/lib/features_modal/modal_validation.dart +++ b/example/lib/features_modal/modal_validation.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_awesome_select/flutter_awesome_select.dart'; + import '../choices.dart' as choices; class FeaturesModalValidation extends StatefulWidget { @@ -126,9 +127,9 @@ class _FeaturesModalValidationState extends State { icon: Icon(Icons.check), label: Text('OK (${state.selection?.length ?? 0})'), style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( + backgroundColor: WidgetStateProperty.all( Theme.of(context).primaryColor), - textStyle: MaterialStateProperty.all( + textStyle: WidgetStateProperty.all( TextStyle(color: Colors.white)), ), onPressed: (state.selection?.isValid ?? true) diff --git a/example/lib/features_modal/modal_widget.dart b/example/lib/features_modal/modal_widget.dart index e6328f4..ec776db 100644 --- a/example/lib/features_modal/modal_widget.dart +++ b/example/lib/features_modal/modal_widget.dart @@ -135,9 +135,9 @@ class _FeaturesModalWidgetState extends State { child: TextButton( child: Text('Submit (${state.selection?.length})'), style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( + backgroundColor: WidgetStateProperty.all( Theme.of(context).primaryColor), - textStyle: MaterialStateProperty.all( + textStyle: WidgetStateProperty.all( TextStyle(color: Colors.white)), ), onPressed: (state.selection?.isValid ?? true) @@ -163,7 +163,7 @@ class _FeaturesModalWidgetState extends State { state, hideValue: true, leading: CircleAvatar( - backgroundColor: _question2 == null + backgroundColor: (_question2.isEmpty && _question2 == null) ? Colors.grey : Theme.of(context).primaryColor, child: const Text( diff --git a/example/lib/main.dart b/example/lib/main.dart index 4ab19f9..7e879dd 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:theme_patrol2/theme_patrol2.dart'; + import 'features.dart'; void main() => runApp(MyApp()); @@ -21,9 +22,53 @@ class MyApp extends StatelessWidget { primarySwatch: Colors.red, primaryColor: Colors.red, colorScheme: ColorScheme.dark(secondary: Colors.red), - // accentColor: Colors.red, - toggleableActiveColor: Colors.red, visualDensity: VisualDensity.adaptivePlatformDensity, + checkboxTheme: CheckboxThemeData( + fillColor: WidgetStateProperty.resolveWith( + (Set states) { + if (states.contains(WidgetState.disabled)) { + return null; + } + if (states.contains(WidgetState.selected)) { + return Colors.red; + } + return null; + }), + ), + radioTheme: RadioThemeData( + fillColor: WidgetStateProperty.resolveWith( + (Set states) { + if (states.contains(WidgetState.disabled)) { + return null; + } + if (states.contains(WidgetState.selected)) { + return Colors.red; + } + return null; + }), + ), + switchTheme: SwitchThemeData( + thumbColor: WidgetStateProperty.resolveWith( + (Set states) { + if (states.contains(WidgetState.disabled)) { + return null; + } + if (states.contains(WidgetState.selected)) { + return Colors.red; + } + return null; + }), + trackColor: WidgetStateProperty.resolveWith( + (Set states) { + if (states.contains(WidgetState.disabled)) { + return null; + } + if (states.contains(WidgetState.selected)) { + return Colors.red; + } + return null; + }), + ), ), mode: ThemeMode.system, builder: (context, theme) { diff --git a/example/lib/widgets/card_tile.dart b/example/lib/widgets/card_tile.dart index 4723398..6ea8500 100644 --- a/example/lib/widgets/card_tile.dart +++ b/example/lib/widgets/card_tile.dart @@ -41,7 +41,7 @@ class CardTile extends StatelessWidget { title, style: Theme.of(context) .textTheme - .headline6 + .headlineSmall ?.merge(TextStyle(color: Colors.black54)), ), Container(height: 5), @@ -49,7 +49,7 @@ class CardTile extends StatelessWidget { value, style: Theme.of(context) .textTheme - .subtitle2 + .titleMedium ?.merge(TextStyle(color: Colors.black38)), ), ], diff --git a/example/pubspec.yaml b/example/pubspec.yaml index aa317d3..0fb92a1 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,20 +1,8 @@ name: awesomeselect description: Few example for Smart Select package. -# The following line prevents the package from being accidentally published to -# pub.dev using `pub publish`. This is preferred for private packages. -publish_to: 'none' # Remove this line if you wish to publish to pub.dev +publish_to: 'none' -# The following defines the version and build number for your application. -# A version number is three numbers separated by dots, like 1.2.43 -# followed by an optional build number separated by a +. -# Both the version and the builder number may be overridden in flutter -# build by specifying --build-name and --build-number, respectively. -# In Android, build-name is used as versionName while build-number used as versionCode. -# Read more about Android versioning at https://developer.android.com/studio/publish/versioning -# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. -# Read more about iOS versioning at -# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html version: 1.0.0+1 environment: @@ -26,56 +14,14 @@ dependencies: flutter_awesome_select: path: ../ theme_patrol2: ^0.1.0 - dio: ^4.0.6 + dio: ^5.4.3+1 sticky_headers: ^0.3.0+2 - # The following adds the Cupertino Icons font to your application. - # Use with the CupertinoIcons class for iOS style icons. - # cupertino_icons: ^0.1.2 dev_dependencies: flutter_test: sdk: flutter - -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - -# The following section is specific to Flutter. flutter: - # The following line ensures that the Material Icons font is - # included with your application, so that you can use the icons in - # the material Icons class. uses-material-design: true - - # To add assets to your application, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware. - - # For details regarding adding assets from package dependencies, see - # https://flutter.dev/assets-and-images/#from-packages - - # To add custom fonts to your application, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts from package dependencies, - # see https://flutter.dev/custom-fonts/#from-packages diff --git a/lib/src/choices_empty.dart b/lib/src/choices_empty.dart index adfbfb1..7cf4e9e 100644 --- a/lib/src/choices_empty.dart +++ b/lib/src/choices_empty.dart @@ -7,10 +7,10 @@ class S2ChoicesEmpty extends StatelessWidget { @override Widget build(BuildContext context) { - return Center( + return const Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, - children: const [ + children: [ Icon( Icons.search, color: Colors.grey, diff --git a/lib/src/tile/tile.dart b/lib/src/tile/tile.dart index bc40964..f7189b8 100644 --- a/lib/src/tile/tile.dart +++ b/lib/src/tile/tile.dart @@ -179,20 +179,18 @@ class S2Tile extends StatelessWidget { Widget? get _trailingWidget { return isTwoLine != true && hideValue != true - ? Container( - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Container( - constraints: const BoxConstraints(maxWidth: 100), - child: _valueWidget, - ), - Padding( - padding: const EdgeInsetsDirectional.only(start: 5), - child: _trailingIconWidget, - ), - ], - ), + ? Row( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + constraints: const BoxConstraints(maxWidth: 100), + child: _valueWidget, + ), + Padding( + padding: const EdgeInsetsDirectional.only(start: 5), + child: _trailingIconWidget, + ), + ], ) : _trailingIconWidget; } @@ -213,7 +211,7 @@ class S2Tile extends StatelessWidget { return DefaultTextStyle.merge( child: isLoading == true ? _loadingWidget : value, style: isError == true - ? TextStyle(color: Theme.of(context).errorColor) + ? TextStyle(color: Theme.of(context).colorScheme.error) : null, overflow: TextOverflow.ellipsis, maxLines: 1, diff --git a/lib/src/widget/s2_single_state.dart b/lib/src/widget/s2_single_state.dart index d667a7c..415adf8 100644 --- a/lib/src/widget/s2_single_state.dart +++ b/lib/src/widget/s2_single_state.dart @@ -1,5 +1,4 @@ -import 'package:collection/collection.dart' - show IterableExtension, ListEquality; +import 'package:collection/collection.dart' show IterableExtension; import 'package:flutter/material.dart'; import 'package:flutter_awesome_select/flutter_awesome_select.dart'; diff --git a/lib/src/widget/s2_state.dart b/lib/src/widget/s2_state.dart index bcb63b1..ca4f86a 100644 --- a/lib/src/widget/s2_state.dart +++ b/lib/src/widget/s2_state.dart @@ -1,15 +1,16 @@ import 'package:collection/collection.dart' show ListEquality; import 'package:flutter/material.dart'; import 'package:flutter_awesome_select/flutter_awesome_select.dart'; -import '../state/choices.dart'; -import '../state/filter.dart'; -import '../choices_resolver.dart'; -import '../utils/debouncer.dart'; -import '../choices_list.dart'; + import '../choices_empty.dart'; +import '../choices_list.dart'; +import '../choices_resolver.dart'; import '../modal.dart'; import '../pagination.dart'; +import '../state/choices.dart'; +import '../state/filter.dart'; import '../text_error.dart'; +import '../utils/debouncer.dart'; /// Smart Select State abstract class S2State extends State> { @@ -138,8 +139,8 @@ abstract class S2State extends State> { backgroundColor: widget.modalConfig.isFullPage != true ? theme.cardColor : null, textStyle: widget.modalConfig.isFullPage != true - ? theme.textTheme.headline6 - : theme.primaryTextTheme.headline6, + ? theme.textTheme.headlineSmall + : theme.primaryTextTheme.headlineSmall, iconTheme: widget.modalConfig.isFullPage != true ? theme.iconTheme : null, errorStyle: const TextStyle( @@ -242,7 +243,7 @@ abstract class S2State extends State> { /// Returns the modal title widget Widget get modalTitle { String title = modalConfig.title ?? widget.title ?? widget.placeholder!; - return Container(child: Text(title, style: modalHeaderStyle.textStyle)); + return Text(title, style: modalHeaderStyle.textStyle); } void modalErrorShake() { @@ -348,10 +349,10 @@ abstract class S2State extends State> { icon: modalConfig.confirmIcon!, label: modalConfig.confirmLabel!, style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( + backgroundColor: WidgetStateProperty.all( modalConfig.confirmIsDark ? modalConfig.confirmColor : null, ), - textStyle: MaterialStateProperty.all( + textStyle: WidgetStateProperty.all( TextStyle( color: modalConfig.confirmIsLight ? modalConfig.confirmColor @@ -369,11 +370,11 @@ abstract class S2State extends State> { const EdgeInsets.fromLTRB(0, 0, 10, 0), child: TextButton( style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( + backgroundColor: WidgetStateProperty.all( modalConfig.confirmIsDark ? modalConfig.confirmColor ?? Colors.blueGrey : null), - textStyle: MaterialStateProperty.all( + textStyle: WidgetStateProperty.all( TextStyle( color: modalConfig.confirmIsLight ? modalConfig.confirmColor @@ -575,12 +576,12 @@ abstract class S2State extends State> { itemBuilder: (context, i) { return choices!.isAppending && i == choiceList.length ? const Center( - child: SizedBox( - width: 24, - height: 24, - child: CircularProgressIndicator(), - ), - ) + child: SizedBox( + width: 24, + height: 24, + child: CircularProgressIndicator(), + ), + ) : choiceListBuilder(choiceList[i])!; }, dividerBuilder: builder.choiceDivider, diff --git a/pubspec.yaml b/pubspec.yaml index cd4dae5..ba2a223 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,7 +10,7 @@ environment: dependencies: flutter: sdk: flutter - collection: ^1.16.0 + collection: ^1.18.0 dev_dependencies: flutter_test: