Skip to content
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
114 changes: 50 additions & 64 deletions example/lib/bounce_demo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,73 +12,59 @@ class SimpleBounceDemoState extends State<SimpleBounceDemo> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Simple Bounce Demo',
style: TextStyle(color: Colors.white)),
centerTitle: true
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Bounce(
onPressed: null,
duration: Duration(milliseconds: _duration),
child: Container(
decoration: BoxDecoration(
color: Theme.of(context).primaryColor,
shape: BoxShape.circle,
),
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Icon(Icons.add, color: Colors.white)
),
appBar: AppBar(
title: Text('Simple Bounce Demo',
style: TextStyle(color: Colors.white)),
centerTitle: true),
body: Center(
child:
Column(mainAxisAlignment: MainAxisAlignment.center, children: [
Bounce(
onPressed: () {},
duration: Duration(milliseconds: _duration),
child: Container(
decoration: BoxDecoration(
color: Theme.of(context).primaryColor,
shape: BoxShape.circle,
),
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Icon(Icons.add, color: Colors.white)),
),
SizedBox(height: 30.0),
Bounce(
duration: Duration(milliseconds: _duration),
onPressed: null,
),
SizedBox(height: 30.0),
Bounce(
duration: Duration(milliseconds: _duration),
onPressed: () {},
child: Container(
height: 50.0,
width: MediaQuery.of(context).size.width * 0.5,
decoration: BoxDecoration(
color: Theme.of(context).primaryColor,
borderRadius: BorderRadius.circular(80.0)
),
child: Center(
child: Text('Click to bounce',
style: TextStyle(color: Colors.white, fontSize: 18.0)
))
)
),
SizedBox(height: 20.0),
Container(
height: 50.0,
width: MediaQuery.of(context).size.width * 0.5,
decoration: BoxDecoration(
color: Theme.of(context).primaryColor,
borderRadius: BorderRadius.circular(80.0)),
child: Center(
child: Text('Click to bounce',
style: TextStyle(
color: Colors.white, fontSize: 18.0))))),
SizedBox(height: 20.0),
Container(
width: MediaQuery.of(context).size.width * .5,
child: Slider(
activeColor: Theme.of(context).primaryColor,
min: 50,
max: 300,
value: _duration.toDouble(),
onChanged: (newValue) {
setState(() {
_duration = newValue.toInt();
});
}
)
),
Center(
child: Text(
"Duration = $_duration ms",
style: TextStyle(
color: Theme.of(context).primaryColor,
fontSize: 18,
)
)
)
]
)
)
);
activeColor: Theme.of(context).primaryColor,
min: 50,
max: 300,
value: _duration.toDouble(),
onChanged: (newValue) {
setState(() {
_duration = newValue.toInt();
});
})),
Center(
child: Text("Duration = $_duration ms",
style: TextStyle(
color: Theme.of(context).primaryColor,
fontSize: 18,
)))
])));
}
}
}
105 changes: 45 additions & 60 deletions example/lib/bounce_scroll.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ import 'package:flutter/material.dart';
import 'package:flutter_bounce/flutter_bounce.dart';

class BounceScroll extends StatelessWidget {

//This is the widget for showing up in scroll
List<Widget> get verticalList{
List<Widget> get verticalList {
List<Widget> _widget = [SizedBox(height: 20.0)];

for(int i=0; i<10; i++){
for (int i = 0; i < 10; i++) {
_widget.add(verticalListCards);
_widget.add(SizedBox(height: 10.0));
}
Expand All @@ -16,80 +15,66 @@ class BounceScroll extends StatelessWidget {
}

//This is the widget
Widget get verticalListCards{
Widget get verticalListCards {
return Bounce(
duration: Duration(milliseconds: 110),
onPressed: null,
child: Container(
height: 80.0,
decoration: BoxDecoration(
color: Colors.indigo[400],
borderRadius: BorderRadius.circular(10.0)
)
)
);
duration: Duration(milliseconds: 110),
onPressed: () {},
child: Container(
height: 80.0,
decoration: BoxDecoration(
color: Colors.indigo[400],
borderRadius: BorderRadius.circular(10.0))));
}

//This is for horizontal list
List<Widget> get horizontalList{
List<Widget> get horizontalList {
List<Widget> _view = [SizedBox(width: 20.0)];

for(int i=0; i<10; i++){
for (int i = 0; i < 10; i++) {
_view.add(horizontalListWidget);
_view.add(SizedBox(width: 10.0));
}

return _view;
}

Widget get horizontalListWidget{
Widget get horizontalListWidget {
return Bounce(
duration: Duration(milliseconds: 110),
onPressed: null,
child: Container(
height: 70.0,
width: 200.0,
decoration: BoxDecoration(
color: Colors.indigo[400],
borderRadius: BorderRadius.circular(10.0)
)
)
);
duration: Duration(milliseconds: 110),
onPressed: () {},
child: Container(
height: 70.0,
width: 200.0,
decoration: BoxDecoration(
color: Colors.indigo[400],
borderRadius: BorderRadius.circular(10.0))));
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Bounce with Scroll Demo',
style: TextStyle(color: Colors.white)),
centerTitle: true
),
body: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Container(
padding: EdgeInsets.symmetric(horizontal: 15.0),
height: MediaQuery.of(context).size.height * 0.5,
child: ListView(
shrinkWrap: true,
scrollDirection: Axis.vertical,
children: this.verticalList
)
),
Expanded(
child: Container(
padding: EdgeInsets.symmetric(vertical: 15.0),
child: ListView(
shrinkWrap: true,
scrollDirection: Axis.horizontal,
children: this.horizontalList
)
)
)
]
)
);
appBar: AppBar(
title: Text('Bounce with Scroll Demo',
style: TextStyle(color: Colors.white)),
centerTitle: true),
body: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Container(
padding: EdgeInsets.symmetric(horizontal: 15.0),
height: MediaQuery.of(context).size.height * 0.5,
child: ListView(
shrinkWrap: true,
scrollDirection: Axis.vertical,
children: this.verticalList)),
Expanded(
child: Container(
padding: EdgeInsets.symmetric(vertical: 15.0),
child: ListView(
shrinkWrap: true,
scrollDirection: Axis.horizontal,
children: this.horizontalList)))
]));
}
}
}
61 changes: 28 additions & 33 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,48 +23,43 @@ class MyApp extends StatelessWidget {
}

class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;

@override
_MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

@override
Widget build(BuildContext context) {

return Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
RaisedButton(
onPressed: (){ Navigator.push(context, new MaterialPageRoute(
builder: (context) => SimpleBounceDemo())
); },
elevation: 5.0,
color: Theme.of(context).primaryColor,
textColor: Colors.white,
child: Text('Simple Bounce Demo')
),
SizedBox(height: 20.0),
RaisedButton(
elevation: 5.0,
onPressed: (){ Navigator.push(context, new MaterialPageRoute(
builder: (context) => BounceScroll())); },
textColor: Colors.white,
color: Theme.of(context).primaryColor,
child: Text('Bounce with Scroll')
)
]
)
) // This trailing comma makes auto-formatting nicer for build methods.
);
appBar: AppBar(
centerTitle: true,
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
ElevatedButton(
onPressed: () {
Navigator.push(
context,
new MaterialPageRoute(
builder: (context) => SimpleBounceDemo()));
},
child: Text('Simple Bounce Demo')),
SizedBox(height: 20.0),
ElevatedButton(
onPressed: () {
Navigator.push(
context,
new MaterialPageRoute(
builder: (context) => BounceScroll()));
},
child: Text('Bounce with Scroll'))
])) // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
Loading