Skip to content
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

iconData to Widget #401

Open
wants to merge 4 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
32 changes: 24 additions & 8 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,18 @@ class MyApp extends StatelessWidget {
onPressed: doNothing,
backgroundColor: Color(0xFFFE4A49),
foregroundColor: Colors.white,
icon: Icons.delete,
icon: SizedBox(
child: Icon(Icons.delete),
),
label: 'Delete',
),
SlidableAction(
onPressed: doNothing,
backgroundColor: Color(0xFF21B7CA),
foregroundColor: Colors.white,
icon: Icons.share,
icon: SizedBox(
child: Icon(Icons.share),
),
label: 'Share',
),
],
Expand All @@ -57,14 +61,18 @@ class MyApp extends StatelessWidget {
onPressed: doNothing,
backgroundColor: Color(0xFF7BC043),
foregroundColor: Colors.white,
icon: Icons.archive,
icon: SizedBox(
child: Icon(Icons.archive),
),
label: 'Archive',
),
SlidableAction(
onPressed: doNothing,
backgroundColor: Color(0xFF0392CF),
foregroundColor: Colors.white,
icon: Icons.save,
icon: SizedBox(
child: Icon(Icons.save),
),
label: 'Save',
),
],
Expand All @@ -90,14 +98,18 @@ class MyApp extends StatelessWidget {
onPressed: doNothing,
backgroundColor: Color(0xFFFE4A49),
foregroundColor: Colors.white,
icon: Icons.delete,
icon: SizedBox(
child: Icon(Icons.delete),
),
label: 'Delete',
),
SlidableAction(
onPressed: doNothing,
backgroundColor: Color(0xFF21B7CA),
foregroundColor: Colors.white,
icon: Icons.share,
icon: SizedBox(
child: Icon(Icons.share),
),
label: 'Share',
),
],
Expand All @@ -114,14 +126,18 @@ class MyApp extends StatelessWidget {
onPressed: doNothing,
backgroundColor: Color(0xFF7BC043),
foregroundColor: Colors.white,
icon: Icons.archive,
icon: SizedBox(
child: Icon(Icons.archive),
),
label: 'Archive',
),
SlidableAction(
onPressed: doNothing,
backgroundColor: Color(0xFF0392CF),
foregroundColor: Colors.white,
icon: Icons.save,
icon: SizedBox(
child: Icon(Icons.save),
),
label: 'Save',
),
],
Expand Down
204 changes: 170 additions & 34 deletions example/lib/main_demo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,32 @@ class _MyHomePageState extends State<MyHomePage> {
closeThreshold: 0.4,
motion: BehindMotion(),
children: [
SlideAction(color: Colors.green, icon: Icons.share),
SlideAction(color: Colors.amber, icon: Icons.delete),
SlideAction(
color: Colors.green,
icon: SizedBox(
child: Icon(Icons.share),
)),
SlideAction(
color: Colors.amber,
icon: SizedBox(
child: Icon(Icons.delete),
)),
],
),
endActionPane: const ActionPane(
motion: BehindMotion(),
children: [
SlideAction(color: Colors.red, icon: Icons.delete_forever),
SlideAction(color: Colors.blue, icon: Icons.alarm, flex: 2),
SlideAction(
color: Colors.red,
icon: SizedBox(
child: Icon(Icons.delete),
)),
SlideAction(
color: Colors.blue,
icon: SizedBox(
child: Icon(Icons.alarm),
),
flex: 2),
],
),
child: const Tile(color: Colors.grey, text: 'hello'),
Expand All @@ -79,15 +96,32 @@ class _MyHomePageState extends State<MyHomePage> {
startActionPane: const ActionPane(
motion: StretchMotion(),
children: [
SlideAction(color: Colors.green, icon: Icons.share),
SlideAction(color: Colors.amber, icon: Icons.delete),
SlideAction(
color: Colors.green,
icon: SizedBox(
child: Icon(Icons.share),
)),
SlideAction(
color: Colors.amber,
icon: SizedBox(
child: Icon(Icons.delete),
)),
],
),
endActionPane: const ActionPane(
motion: StretchMotion(),
children: [
SlideAction(color: Colors.red, icon: Icons.delete_forever),
SlideAction(color: Colors.blue, icon: Icons.alarm, flex: 3),
SlideAction(
color: Colors.red,
icon: SizedBox(
child: Icon(Icons.delete),
)),
SlideAction(
color: Colors.blue,
icon: SizedBox(
child: Icon(Icons.alarm),
),
flex: 3),
],
),
child: const Tile(color: Colors.pink, text: 'hello 2'),
Expand All @@ -98,15 +132,32 @@ class _MyHomePageState extends State<MyHomePage> {
startActionPane: const ActionPane(
motion: ScrollMotion(),
children: [
SlideAction(color: Colors.green, icon: Icons.share),
SlideAction(color: Colors.amber, icon: Icons.delete),
SlideAction(
color: Colors.green,
icon: SizedBox(
child: Icon(Icons.share),
)),
SlideAction(
color: Colors.amber,
icon: SizedBox(
child: Icon(Icons.delete),
)),
],
),
endActionPane: const ActionPane(
motion: ScrollMotion(),
children: [
SlideAction(color: Colors.red, icon: Icons.delete_forever),
SlideAction(color: Colors.blue, icon: Icons.alarm, flex: 2),
SlideAction(
color: Colors.red,
icon: SizedBox(
child: Icon(Icons.delete),
)),
SlideAction(
color: Colors.blue,
icon: SizedBox(
child: Icon(Icons.alarm),
),
flex: 2),
],
),
child: const Tile(color: Colors.yellow, text: 'hello 3'),
Expand Down Expand Up @@ -152,15 +203,32 @@ class _MyHomePageState extends State<MyHomePage> {
},
),
children: const [
SlideAction(color: Colors.green, icon: Icons.share),
SlideAction(color: Colors.amber, icon: Icons.delete),
SlideAction(
color: Colors.green,
icon: SizedBox(
child: Icon(Icons.share),
)),
SlideAction(
color: Colors.amber,
icon: SizedBox(
child: Icon(Icons.delete),
)),
],
),
endActionPane: const ActionPane(
motion: DrawerMotion(),
children: [
SlideAction(color: Colors.red, icon: Icons.delete_forever),
SlideAction(color: Colors.blue, icon: Icons.alarm, flex: 2),
SlideAction(
color: Colors.red,
icon: SizedBox(
child: Icon(Icons.delete),
)),
SlideAction(
color: Colors.blue,
icon: SizedBox(
child: Icon(Icons.alarm),
),
flex: 2),
],
),
child: const Tile(color: Colors.lime, text: 'hello 4'),
Expand All @@ -171,15 +239,32 @@ class _MyHomePageState extends State<MyHomePage> {
startActionPane: const ActionPane(
motion: BehindMotion(),
children: [
SlideAction(color: Colors.green, icon: Icons.share),
SlideAction(color: Colors.amber, icon: Icons.delete),
SlideAction(
color: Colors.green,
icon: SizedBox(
child: Icon(Icons.share),
)),
SlideAction(
color: Colors.amber,
icon: SizedBox(
child: Icon(Icons.delete),
)),
],
),
endActionPane: const ActionPane(
motion: BehindMotion(),
children: [
SlideAction(color: Colors.red, icon: Icons.delete_forever),
SlideAction(color: Colors.blue, icon: Icons.alarm, flex: 2),
SlideAction(
color: Colors.red,
icon: SizedBox(
child: Icon(Icons.delete),
)),
SlideAction(
color: Colors.blue,
icon: SizedBox(
child: Icon(Icons.alarm),
),
flex: 2),
],
),
child: const Tile(color: Colors.grey, text: 'hello'),
Expand All @@ -190,15 +275,32 @@ class _MyHomePageState extends State<MyHomePage> {
startActionPane: const ActionPane(
motion: BehindMotion(),
children: [
SlideAction(color: Colors.green, icon: Icons.share),
SlideAction(color: Colors.amber, icon: Icons.delete),
SlideAction(
color: Colors.green,
icon: SizedBox(
child: Icon(Icons.share),
)),
SlideAction(
color: Colors.amber,
icon: SizedBox(
child: Icon(Icons.delete),
)),
],
),
endActionPane: const ActionPane(
motion: BehindMotion(),
children: [
SlideAction(color: Colors.red, icon: Icons.delete_forever),
SlideAction(color: Colors.blue, icon: Icons.alarm, flex: 2),
SlideAction(
color: Colors.red,
icon: SizedBox(
child: Icon(Icons.delete),
)),
SlideAction(
color: Colors.blue,
icon: SizedBox(
child: Icon(Icons.alarm),
),
flex: 2),
],
),
child: const Tile(color: Colors.grey, text: 'hello'),
Expand All @@ -209,15 +311,32 @@ class _MyHomePageState extends State<MyHomePage> {
startActionPane: const ActionPane(
motion: BehindMotion(),
children: [
SlideAction(color: Colors.green, icon: Icons.share),
SlideAction(color: Colors.amber, icon: Icons.delete),
SlideAction(
color: Colors.green,
icon: SizedBox(
child: Icon(Icons.share),
)),
SlideAction(
color: Colors.amber,
icon: SizedBox(
child: Icon(Icons.delete),
)),
],
),
endActionPane: const ActionPane(
motion: BehindMotion(),
children: [
SlideAction(color: Colors.red, icon: Icons.delete_forever),
SlideAction(color: Colors.blue, icon: Icons.alarm, flex: 2),
SlideAction(
color: Colors.red,
icon: SizedBox(
child: Icon(Icons.delete),
)),
SlideAction(
color: Colors.blue,
icon: SizedBox(
child: Icon(Icons.alarm),
),
flex: 2),
],
),
child: const Tile(color: Colors.grey, text: 'hello'),
Expand All @@ -228,15 +347,32 @@ class _MyHomePageState extends State<MyHomePage> {
startActionPane: const ActionPane(
motion: BehindMotion(),
children: [
SlideAction(color: Colors.green, icon: Icons.share),
SlideAction(color: Colors.amber, icon: Icons.delete),
SlideAction(
color: Colors.green,
icon: SizedBox(
child: Icon(Icons.share),
)),
SlideAction(
color: Colors.amber,
icon: SizedBox(
child: Icon(Icons.delete),
)),
],
),
endActionPane: const ActionPane(
motion: BehindMotion(),
children: [
SlideAction(color: Colors.red, icon: Icons.delete_forever),
SlideAction(color: Colors.blue, icon: Icons.alarm, flex: 2),
SlideAction(
color: Colors.red,
icon: SizedBox(
child: Icon(Icons.delete),
)),
SlideAction(
color: Colors.blue,
icon: SizedBox(
child: Icon(Icons.alarm),
),
flex: 2),
],
),
child: const Tile(color: Colors.grey, text: 'hello'),
Expand All @@ -257,7 +393,7 @@ class SlideAction extends StatelessWidget {
}) : super(key: key);

final Color color;
final IconData icon;
final Widget icon;
final int flex;

@override
Expand Down Expand Up @@ -291,7 +427,7 @@ class Tile extends StatelessWidget {
return ActionTypeListener(
child: GestureDetector(
onTap: () {
print('$text');
print(text);
},
onLongPress: () => Slidable.of(context)!.openEndActionPane(),
child: Container(
Expand Down
Loading