Skip to content

Commit

Permalink
Support disabled and hidden option, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
davigmacode committed Jan 24, 2020
1 parent 6478491 commit e0b918d
Show file tree
Hide file tree
Showing 18 changed files with 550 additions and 309 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## [3.0.2] - 2020-01-22

* Support disabled and hidden option
* Customizable choices wrapper padding
* Single choice chips now use checkmark by default, can be configure by `choiceConfig.useCheckmark`
* Improve documentation
* Update example

## [3.0.0] - 2020-01-22

* Breaking changes, more type safety, add more features, and simplify few properties
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Smart select allows you to easily convert your usual form selects into dynamic p

For a complete usage, please see the [example](https://pub.dev/packages/smart_select#-example-tab-).

To read more about classes and other references used by `smart_select`, see the [documentation](https://pub.dev/documentation/smart_select/latest/).
To read more about classes and other references used by `smart_select`, see the [API Reference](https://pub.dev/documentation/smart_select/latest/).

## Single Choice

Expand Down Expand Up @@ -85,10 +85,10 @@ Widget build(BuildContext context) {

## Build Option List

`options` property is `List<SmartSelectOption<T>>`, it can be input directly as in the example below
`options` property is `List<SmartSelectOption<T>>`, it can be input directly as in the example below, more info about `SmartSelectOption` can be found on the [API Reference](https://pub.dev/documentation/smart_select/latest/smart_select/SmartSelectOption-class.html)

```
SmartSelect.single/multiple(
SmartSelect<T>.single/multiple(
...,
...,
options: <SmartSelectOption<int>>[
Expand All @@ -99,7 +99,7 @@ SmartSelect.single/multiple(
);
```

or it can be created from any list using helper provided by this package, like the example below
`options` also can be created from any list using helper provided by this package, like the example below

```
List<Map<String, String>> days = [
Expand All @@ -112,7 +112,7 @@ List<Map<String, String>> days = [
{ 'value': 'sun', 'title': 'Sunday' },
];
SmartSelect.single/multiple(
SmartSelect<T>.single/multiple(
...,
...,
options: SmartSelectOption.listFrom<Map<String, String>, String>(
Expand All @@ -128,7 +128,7 @@ SmartSelect.single/multiple(
By default SmartSelect will open choices modal in full page. You can change it by changing the `modalType` property with this value:

```
SmartSelect.single/multiple(
SmartSelect<T>.single/multiple(
...,
...,
// open in full page
Expand All @@ -145,7 +145,7 @@ SmartSelect.single/multiple(
By default SmartSelect will use radio for single choice and checkbox for multiple choice, but it can change by changing the `choiceType` with this value:

```
SmartSelect.single(
SmartSelect<T>.single(
...,
...,
// default use radio
Expand All @@ -155,7 +155,7 @@ SmartSelect.single(
);
```
```
SmartSelect.multiple(
SmartSelect<T>.multiple(
...,
...,
// default use checkbox
Expand Down
10 changes: 6 additions & 4 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@

## Customize Option

* [List of Map](https://github.com/davigmacode/flutter_smart_select/blob/master/example/lib/features_option/option_list_of_map.dart)
* [List of String](https://github.com/davigmacode/flutter_smart_select/blob/master/example/lib/features_option/option_list_of_string.dart)
* [List of List Of String](https://github.com/davigmacode/flutter_smart_select/blob/master/example/lib/features_option/option_list_of_list.dart)
* [Async Option & Custom Properties](https://github.com/davigmacode/flutter_smart_select/blob/master/example/lib/features_option/option_async.dart)
* [Disabled Options](https://github.com/davigmacode/flutter_smart_select/blob/master/example/lib/features_option/option_disabled.dart)
* [Hidden Options](https://github.com/davigmacode/flutter_smart_select/blob/master/example/lib/features_option/option_hidden.dart)
* [Build Options from List of String](https://github.com/davigmacode/flutter_smart_select/blob/master/example/lib/features_option/option_list_of_string.dart)
* [Build Options from List of Map](https://github.com/davigmacode/flutter_smart_select/blob/master/example/lib/features_option/option_list_of_map.dart)
* [Build Options from List of List Of String](https://github.com/davigmacode/flutter_smart_select/blob/master/example/lib/features_option/option_list_of_list.dart)
* [Async Option](https://github.com/davigmacode/flutter_smart_select/blob/master/example/lib/features_option/option_async.dart)

## Customize Modal

Expand Down
Binary file modified example/art/demo/SmartSelect.apk
Binary file not shown.
88 changes: 88 additions & 0 deletions example/lib/features_option/option_disabled.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import 'package:flutter/material.dart';
import 'package:smart_select/smart_select.dart';

class FeaturesOptionDisabled extends StatefulWidget {
@override
_FeaturesOptionDisabledState createState() => _FeaturesOptionDisabledState();
}

class _FeaturesOptionDisabledState extends State<FeaturesOptionDisabled> {

List _categories = [];

int _sort = 0;

List<String> _categoriesOption = [
'Electronics', 'Accessories', 'Smartwatch',
'Smartphone', 'Audio & Video', 'Scientific'
];

List<String> _sortOption = [
'Popular', 'Most Reviews', 'Newest',
'Low Price', 'High Price',
];

@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
Container(height: 7),
Card(
elevation: 3,
margin: EdgeInsets.all(10),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5.0),
),
child: Row(
children: <Widget>[
Expanded(
child: SmartSelect.multiple(
title: 'Categories',
value: _categories,
isTwoLine: true,
trailing: Icon(Icons.arrow_drop_down),
options: SmartSelectOption.listFrom<String, int>(
source: _categoriesOption,
value: (index, item) => index,
title: (index, item) => item,
disabled: (index, item) => [0, 2, 5].contains(index),
),
choiceType: SmartSelectChoiceType.switches,
modalType: SmartSelectModalType.popupDialog,
modalConfig: SmartSelectModalConfig(
useHeader: false,
),
onChange: (val) => setState(() => _categories = val),
),
),
Container(
height: 40,
child: VerticalDivider(),
),
Expanded(
child: SmartSelect.single(
title: 'Sort By',
value: _sort,
isTwoLine: true,
trailing: Icon(Icons.arrow_drop_down),
options: SmartSelectOption.listFrom<String, int>(
source: _sortOption,
value: (index, item) => index,
title: (index, item) => item,
disabled: (index, item) => item.toLowerCase().contains('price'),
),
modalType: SmartSelectModalType.popupDialog,
modalConfig: SmartSelectModalConfig(
useHeader: false,
),
onChange: (val) => setState(() => _sort = val),
),
),
],
),
),
Container(height: 7),
],
);
}
}
88 changes: 88 additions & 0 deletions example/lib/features_option/option_hidden.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import 'package:flutter/material.dart';
import 'package:smart_select/smart_select.dart';

class FeaturesOptionHidden extends StatefulWidget {
@override
_FeaturesOptionHiddenState createState() => _FeaturesOptionHiddenState();
}

class _FeaturesOptionHiddenState extends State<FeaturesOptionHidden> {

List _categories = [];

int _sort = 0;

List<String> _categoriesOption = [
'Electronics', 'Accessories', 'Smartwatch',
'Smartphone', 'Audio & Video', 'Scientific'
];

List<String> _sortOption = [
'Popular', 'Most Reviews', 'Newest',
'Low Price', 'High Price',
];

@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
Container(height: 7),
Card(
elevation: 3,
margin: EdgeInsets.all(10),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5.0),
),
child: Row(
children: <Widget>[
Expanded(
child: SmartSelect.multiple(
title: 'Categories',
value: _categories,
isTwoLine: true,
trailing: Icon(Icons.arrow_drop_down),
options: SmartSelectOption.listFrom<String, int>(
source: _categoriesOption,
value: (index, item) => index,
title: (index, item) => item,
hidden: (index, item) => [0, 2, 5].contains(index),
),
choiceType: SmartSelectChoiceType.switches,
modalType: SmartSelectModalType.popupDialog,
modalConfig: SmartSelectModalConfig(
useHeader: false,
),
onChange: (val) => setState(() => _categories = val),
),
),
Container(
height: 40,
child: VerticalDivider(),
),
Expanded(
child: SmartSelect.single(
title: 'Sort By',
value: _sort,
isTwoLine: true,
trailing: Icon(Icons.arrow_drop_down),
options: SmartSelectOption.listFrom<String, int>(
source: _sortOption,
value: (index, item) => index,
title: (index, item) => item,
hidden: (index, item) => item.toLowerCase().contains('price'),
),
modalType: SmartSelectModalType.popupDialog,
modalConfig: SmartSelectModalConfig(
useHeader: false,
),
onChange: (val) => setState(() => _sort = val),
),
),
],
),
),
Container(height: 7),
],
);
}
}
18 changes: 14 additions & 4 deletions example/lib/features_option/option_main.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import 'package:flutter/material.dart';
import 'package:sticky_headers/sticky_headers.dart';
import './option_list_of_map.dart';
import './option_disabled.dart';
import './option_hidden.dart';
import './option_list_of_string.dart';
import './option_list_of_map.dart';
import './option_list_of_list.dart';
import './option_async.dart';
import '../features_header.dart';
Expand All @@ -23,19 +25,27 @@ class _FeaturesOptionState extends State<FeaturesOption> with AutomaticKeepAlive
child: ListView(
children: <Widget>[
StickyHeader(
header: FeaturesHeader('Build Options from List of Map'),
content: FeaturesOptionListOfMap(),
header: FeaturesHeader('Disabled Options'),
content: FeaturesOptionDisabled(),
),
StickyHeader(
header: FeaturesHeader('Hidden Options'),
content: FeaturesOptionHidden(),
),
StickyHeader(
header: FeaturesHeader('Build Options from List of String'),
content: FeaturesOptionListOfString(),
),
StickyHeader(
header: FeaturesHeader('Build Options from List of Map'),
content: FeaturesOptionListOfMap(),
),
StickyHeader(
header: FeaturesHeader('Build Options from List of List'),
content: FeaturesOptionListOfList(),
),
StickyHeader(
header: FeaturesHeader('Async Options & Custom Properties'),
header: FeaturesHeader('Async Options'),
content: FeaturesOptionAsync(),
),
],
Expand Down
Loading

0 comments on commit e0b918d

Please sign in to comment.