Skip to content

code fixes #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions example/lib/features.dart
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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(
Expand All @@ -98,7 +99,7 @@ class Features extends StatelessWidget {
children: <Widget>[
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),
],
Expand Down
12 changes: 7 additions & 5 deletions example/lib/features_modal/modal_confirm.dart
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -86,9 +87,9 @@ class _FeaturesModalConfirmState extends State<FeaturesModalConfirm> {
TextButton(
child: Text('OK (${state.selection?.length ?? 0})'),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color>(
backgroundColor: WidgetStateProperty.all<Color>(
Theme.of(context).primaryColor),
textStyle: MaterialStateProperty.all<TextStyle>(
textStyle: WidgetStateProperty.all<TextStyle>(
TextStyle(color: Colors.white)),
),
onPressed: (state.selection?.isValid ?? true)
Expand All @@ -109,7 +110,8 @@ class _FeaturesModalConfirmState extends State<FeaturesModalConfirm> {
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 '';
},
Expand Down Expand Up @@ -137,8 +139,8 @@ class _FeaturesModalConfirmState extends State<FeaturesModalConfirm> {
child: const Text('Send'),
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all<Color>(Colors.redAccent),
textStyle: MaterialStateProperty.all<TextStyle>(
WidgetStateProperty.all<Color>(Colors.redAccent),
textStyle: WidgetStateProperty.all<TextStyle>(
TextStyle(color: Colors.white)),
),
onPressed: () => state.closeModal(confirmed: true),
Expand Down
5 changes: 3 additions & 2 deletions example/lib/features_modal/modal_header.dart
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -56,7 +57,7 @@ class _FeaturesModalHeaderState extends State<FeaturesModalHeader> {
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,
),
Expand Down
11 changes: 6 additions & 5 deletions example/lib/features_modal/modal_selector.dart
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -71,9 +72,9 @@ class _FeaturesModalSelectorState extends State<FeaturesModalSelector> {
TextButton(
child: Text('OK (${state.selection?.length ?? 0})'),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color>(
backgroundColor: WidgetStateProperty.all<Color>(
Theme.of(context).primaryColor),
textStyle: MaterialStateProperty.all<TextStyle>(
textStyle: WidgetStateProperty.all<TextStyle>(
TextStyle(color: Colors.white)),
),
onPressed: (state.selection?.isValid ?? true)
Expand Down Expand Up @@ -249,9 +250,9 @@ class ActionButton extends StatelessWidget {
child: label,
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all<Color>(Theme.of(context).primaryColor),
textStyle: MaterialStateProperty.all<TextStyle>(
TextStyle(color: Colors.white)),
WidgetStateProperty.all<Color>(Theme.of(context).primaryColor),
textStyle:
WidgetStateProperty.all<TextStyle>(TextStyle(color: Colors.white)),
),
onPressed: onTap,
);
Expand Down
5 changes: 3 additions & 2 deletions example/lib/features_modal/modal_validation.dart
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -126,9 +127,9 @@ class _FeaturesModalValidationState extends State<FeaturesModalValidation> {
icon: Icon(Icons.check),
label: Text('OK (${state.selection?.length ?? 0})'),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color>(
backgroundColor: WidgetStateProperty.all<Color>(
Theme.of(context).primaryColor),
textStyle: MaterialStateProperty.all<TextStyle>(
textStyle: WidgetStateProperty.all<TextStyle>(
TextStyle(color: Colors.white)),
),
onPressed: (state.selection?.isValid ?? true)
Expand Down
6 changes: 3 additions & 3 deletions example/lib/features_modal/modal_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ class _FeaturesModalWidgetState extends State<FeaturesModalWidget> {
child: TextButton(
child: Text('Submit (${state.selection?.length})'),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color>(
backgroundColor: WidgetStateProperty.all<Color>(
Theme.of(context).primaryColor),
textStyle: MaterialStateProperty.all<TextStyle>(
textStyle: WidgetStateProperty.all<TextStyle>(
TextStyle(color: Colors.white)),
),
onPressed: (state.selection?.isValid ?? true)
Expand All @@ -163,7 +163,7 @@ class _FeaturesModalWidgetState extends State<FeaturesModalWidget> {
state,
hideValue: true,
leading: CircleAvatar(
backgroundColor: _question2 == null
backgroundColor: (_question2.isEmpty && _question2 == null)
? Colors.grey
: Theme.of(context).primaryColor,
child: const Text(
Expand Down
49 changes: 47 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:theme_patrol2/theme_patrol2.dart';

import 'features.dart';

void main() => runApp(MyApp());
Expand All @@ -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<Color?>(
(Set<WidgetState> states) {
if (states.contains(WidgetState.disabled)) {
return null;
}
if (states.contains(WidgetState.selected)) {
return Colors.red;
}
return null;
}),
),
radioTheme: RadioThemeData(
fillColor: WidgetStateProperty.resolveWith<Color?>(
(Set<WidgetState> states) {
if (states.contains(WidgetState.disabled)) {
return null;
}
if (states.contains(WidgetState.selected)) {
return Colors.red;
}
return null;
}),
),
switchTheme: SwitchThemeData(
thumbColor: WidgetStateProperty.resolveWith<Color?>(
(Set<WidgetState> states) {
if (states.contains(WidgetState.disabled)) {
return null;
}
if (states.contains(WidgetState.selected)) {
return Colors.red;
}
return null;
}),
trackColor: WidgetStateProperty.resolveWith<Color?>(
(Set<WidgetState> states) {
if (states.contains(WidgetState.disabled)) {
return null;
}
if (states.contains(WidgetState.selected)) {
return Colors.red;
}
return null;
}),
),
),
mode: ThemeMode.system,
builder: (context, theme) {
Expand Down
4 changes: 2 additions & 2 deletions example/lib/widgets/card_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ class CardTile extends StatelessWidget {
title,
style: Theme.of(context)
.textTheme
.headline6
.headlineSmall
?.merge(TextStyle(color: Colors.black54)),
),
Container(height: 5),
Text(
value,
style: Theme.of(context)
.textTheme
.subtitle2
.titleMedium
?.merge(TextStyle(color: Colors.black38)),
),
],
Expand Down
58 changes: 2 additions & 56 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
4 changes: 2 additions & 2 deletions lib/src/choices_empty.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Widget>[
children: <Widget>[
Icon(
Icons.search,
color: Colors.grey,
Expand Down
28 changes: 13 additions & 15 deletions lib/src/tile/tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -179,20 +179,18 @@ class S2Tile<T> extends StatelessWidget {

Widget? get _trailingWidget {
return isTwoLine != true && hideValue != true
? Container(
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
constraints: const BoxConstraints(maxWidth: 100),
child: _valueWidget,
),
Padding(
padding: const EdgeInsetsDirectional.only(start: 5),
child: _trailingIconWidget,
),
],
),
? Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
constraints: const BoxConstraints(maxWidth: 100),
child: _valueWidget,
),
Padding(
padding: const EdgeInsetsDirectional.only(start: 5),
child: _trailingIconWidget,
),
],
)
: _trailingIconWidget;
}
Expand All @@ -213,7 +211,7 @@ class S2Tile<T> 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,
Expand Down
3 changes: 1 addition & 2 deletions lib/src/widget/s2_single_state.dart
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
Loading