Skip to content

Commit 2467726

Browse files
committed
Fully rewrite code
1 parent 2b48b7a commit 2467726

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+3260
-1067
lines changed

.gitignore

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# The .vscode folder contains launch configuration and tasks you configure in
1919
# VS Code which you may wish to be included in version control, so this line
2020
# is commented out by default.
21-
#.vscode/
21+
.vscode/
2222

2323
# Flutter/Dart/Pub related
2424
**/doc/api/
@@ -28,46 +28,13 @@
2828
.pub-cache/
2929
.pub/
3030
build/
31+
coverage/
3132

3233
# Android related
33-
**/android/**/gradle-wrapper.jar
34-
**/android/.gradle
35-
**/android/captures/
36-
**/android/gradlew
37-
**/android/gradlew.bat
38-
**/android/local.properties
39-
**/android/**/GeneratedPluginRegistrant.java
34+
android/
4035

4136
# iOS/XCode related
42-
**/ios/**/*.mode1v3
43-
**/ios/**/*.mode2v3
44-
**/ios/**/*.moved-aside
45-
**/ios/**/*.pbxuser
46-
**/ios/**/*.perspectivev3
47-
**/ios/**/*sync/
48-
**/ios/**/.sconsign.dblite
49-
**/ios/**/.tags*
50-
**/ios/**/.vagrant/
51-
**/ios/**/DerivedData/
52-
**/ios/**/Icon?
53-
**/ios/**/Pods/
54-
**/ios/**/.symlinks/
55-
**/ios/**/profile
56-
**/ios/**/xcuserdata
57-
**/ios/.generated/
58-
**/ios/Flutter/App.framework
59-
**/ios/Flutter/Flutter.framework
60-
**/ios/Flutter/Generated.xcconfig
61-
**/ios/Flutter/app.flx
62-
**/ios/Flutter/app.zip
63-
**/ios/Flutter/flutter_assets/
64-
**/ios/Flutter/flutter_export_environment.sh
65-
**/ios/ServiceDefinitions.json
66-
**/ios/Runner/GeneratedPluginRegistrant.*
37+
ios/
6738

68-
# Exceptions to above rules.
69-
!**/ios/**/default.mode1v3
70-
!**/ios/**/default.mode2v3
71-
!**/ios/**/default.pbxuser
72-
!**/ios/**/default.perspectivev3
73-
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
39+
# Remove the following pattern if you wish to check in your lock file
40+
pubspec.lock

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
## [1.0.1] - 2019-12-11
2+
3+
* Fully rewrite code
4+
* Support filterable option item
5+
* Support grouping options with sticky header
6+
* Support stats loading
7+
* More customizable trigger widget
8+
* Support customize option header widget (theme or builder)
9+
* Support customize option item widget (theme or builder)
10+
* Support customize option item divider widget
11+
* Support customizable label, value, and group field
12+
113
## [0.1.1] - 2019-11-26
214

315
* Add values field to SmartMultiSelectBuilderInfo class

README.md

Lines changed: 241 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,243 @@
11
# smart_select
22

3-
Smart select allows you to easily convert your usual form selects to dynamic pages with grouped radio or checkbox inputs.
3+
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](https://framework7.io/).
4+
5+
To read more about `smart_select`, see the [documentation](https://pub.dev/documentation/smart_select/latest/).
6+
7+
# Features
8+
9+
* Select single or multiple choice
10+
* Open options in page, bottom sheet, or popup dialog
11+
* Grouping options with sticky header
12+
* Customizable trigger widget
13+
* Customizable options item widget
14+
* Customizable label, value, and group field
15+
* Filterable option item
16+
17+
# Usage
18+
19+
## Single Choice
20+
21+
```
22+
String value = 'flutter';
23+
List options = [
24+
{ 'value': 'ionic', 'label': 'Ionic' },
25+
{ 'value': 'flutter', 'label': 'Flutter' },
26+
{ 'value': 'react', 'label': 'React Native' },
27+
];
28+
29+
@override
30+
Widget build(BuildContext context) {
31+
return SmartSelect(
32+
title: 'Frameworks',
33+
value: value,
34+
option: SmartSelectOption(options),
35+
onChange: (val) => setState(() => value = val),
36+
);
37+
}
38+
```
39+
40+
## Multiple Choice
41+
42+
```
43+
List value = ['flutter'];
44+
List options = [
45+
{ 'value': 'ionic', 'label': 'Ionic' },
46+
{ 'value': 'flutter', 'label': 'Flutter' },
47+
{ 'value': 'react', 'label': 'React Native' },
48+
];
49+
50+
@override
51+
Widget build(BuildContext context) {
52+
return SmartSelect(
53+
title: 'Frameworks',
54+
value: value,
55+
option: SmartSelectOption(options),
56+
isMultiChoice: true,
57+
onChange: (val) => setState(() => value = val),
58+
);
59+
}
60+
```
61+
62+
## Open in Page
63+
64+
By default SmartSelect open options in page.
65+
66+
```
67+
String value = 'flutter';
68+
List options = [
69+
{ 'value': 'ionic', 'label': 'Ionic' },
70+
{ 'value': 'flutter', 'label': 'Flutter' },
71+
{ 'value': 'react', 'label': 'React Native' },
72+
];
73+
74+
@override
75+
Widget build(BuildContext context) {
76+
return SmartSelect(
77+
title: 'Frameworks',
78+
value: value,
79+
option: SmartSelectOption(options),
80+
target: SmartSelectTarget.page,
81+
onChange: (val) => setState(() => value = val),
82+
);
83+
}
84+
```
85+
86+
## Open in Bottom Sheet
87+
88+
```
89+
String value = 'flutter';
90+
List options = [
91+
{ 'value': 'ionic', 'label': 'Ionic' },
92+
{ 'value': 'flutter', 'label': 'Flutter' },
93+
{ 'value': 'react', 'label': 'React Native' },
94+
];
95+
96+
@override
97+
Widget build(BuildContext context) {
98+
return SmartSelect.sheet(
99+
title: 'Frameworks',
100+
value: value,
101+
option: SmartSelectOption(options),
102+
onChange: (val) => setState(() => value = val),
103+
);
104+
}
105+
```
106+
107+
## Open in Popup Dialog
108+
109+
```
110+
String value = 'flutter';
111+
List options = [
112+
{ 'value': 'ionic', 'label': 'Ionic' },
113+
{ 'value': 'flutter', 'label': 'Flutter' },
114+
{ 'value': 'react', 'label': 'React Native' },
115+
];
116+
117+
@override
118+
Widget build(BuildContext context) {
119+
return SmartSelect.popup(
120+
title: 'Frameworks',
121+
value: value,
122+
option: SmartSelectOption(options),
123+
onChange: (val) => setState(() => value = val),
124+
);
125+
}
126+
```
127+
128+
## Custom Trigger Widget
129+
130+
```
131+
String value = 'flutter';
132+
List options = [
133+
{ 'value': 'ionic', 'label': 'Ionic' },
134+
{ 'value': 'flutter', 'label': 'Flutter' },
135+
{ 'value': 'react', 'label': 'React Native' },
136+
];
137+
138+
@override
139+
Widget build(BuildContext context) {
140+
return SmartSelect.popup(
141+
title: 'Frameworks',
142+
value: value,
143+
option: SmartSelectOption(options),
144+
builder: (context, state) {
145+
return ListTile(
146+
title: Text(state.title),
147+
subtitle: Text(
148+
state.valueDisplay,
149+
style: TextStyle(color: Colors.grey),
150+
overflow: TextOverflow.ellipsis,
151+
maxLines: 1,
152+
),
153+
leading: CircleAvatar(
154+
backgroundColor: Colors.blue,
155+
child: Text(
156+
'${state.valueDisplay[0]}',
157+
style: TextStyle(color: Colors.white)
158+
),
159+
),
160+
trailing: Icon(Icons.keyboard_arrow_right, color: Colors.grey),
161+
onTap: () => state.showOptions(context),
162+
);
163+
},
164+
onChange: (val) => setState(() => value = val),
165+
);
166+
}
167+
```
168+
169+
## Custom Key Label and Value
170+
171+
```
172+
String value = 'flutter';
173+
List options = [
174+
{ 'id': 'ionic', 'text': 'Ionic' },
175+
{ 'id': 'flutter', 'text': 'Flutter' },
176+
{ 'id': 'react', 'text': 'React Native' },
177+
];
178+
179+
@override
180+
Widget build(BuildContext context) {
181+
return SmartSelect.popup(
182+
title: 'Frameworks',
183+
value: value,
184+
option: SmartSelectOption(
185+
options,
186+
label: 'id',
187+
value: 'text',
188+
),
189+
onChange: (val) => setState(() => value = val),
190+
);
191+
}
192+
```
193+
194+
# Reference
195+
196+
| Name | Type | Description |
197+
|------|------|-------------|
198+
| SmartSelect | Class | General usage |
199+
| SmartSelectTile | Class | Default trigger widget |
200+
| SmartSelectOption | Class | Configure option |
201+
| SmartSelectState | Class | Current state |
202+
| SmartSelectTarget | Enum | Modal type to open option |
203+
| SmartSelectOnChange | Typedef | Callback to handle change of value widget |
204+
| SmartSelectBuilder | Typedef | Builder for custom trigger widget |
205+
| SmartSelectOptionItemBuilder | Typedef | Builder for custom option item |
206+
| SmartSelectOptionItemOnChange | Typedef | Callback to handle stats of each custom option item |
207+
| SmartSelectOptionDividerBuilder | Typedef | Builder for custom option divider |
208+
| SmartSelectOptionGroupHeaderBuilder | Typedef | Builder for custom option group header |
209+
| SmartSelectOptionConfirmationBuilder | Typedef | Builder for custom confirmation widget |
210+
| SmartSelectOptionHeaderTheme | Class | Configure option header theme |
211+
| SmartSelectOptionItemTheme | Class | Configure option item theme |
212+
| SmartSelectOptionGroupHeaderTheme | Class | Configure option group header theme |
213+
214+
# Thanks
215+
216+
* [Framework7](https://framework7.io/)
217+
218+
# TODO
219+
220+
* Use chip as option item
221+
* Support dark mode
222+
223+
# License
224+
225+
Copyright (c) 2019 Irfan Vigma Taufik
226+
227+
Permission is hereby granted, free of charge, to any person obtaining a copy
228+
of this software and associated documentation files (the "Software"), to deal
229+
in the Software without restriction, including without limitation the rights
230+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
231+
copies of the Software, and to permit persons to whom the Software is
232+
furnished to do so, subject to the following conditions:
233+
234+
The above copyright notice and this permission notice shall be included in all
235+
copies or substantial portions of the Software.
236+
237+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
238+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
239+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
240+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
241+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
242+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
243+
SOFTWARE.

example/README.md

Lines changed: 0 additions & 16 deletions
This file was deleted.

example/android/app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
22
package="com.example.example">
33

4+
<uses-permission android:name="android.permission.INTERNET"/>
5+
46
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
57
calls FlutterMain.startInitialization(this); in its onCreate method.
68
In most cases you can leave this as-is, but you if you want to provide

example/android/gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
org.gradle.jvmargs=-Xmx1536M
22

3+
android.enableR8=true

0 commit comments

Comments
 (0)