Skip to content

Commit

Permalink
Fixed issues #83 and #85 (#86)
Browse files Browse the repository at this point in the history
* Fixed issues #83 and #85

* Renamed allowDragOnlyFromRevealedArea to preferDragFromRevealedArea and provided the required docs

* Updated and added Null Safety to example

* Minor doc reformating
  • Loading branch information
Prayag-X committed Feb 8, 2023
1 parent a5ae631 commit 0383542
Show file tree
Hide file tree
Showing 6 changed files with 275 additions and 109 deletions.
6 changes: 3 additions & 3 deletions example/android/app/build.gradle
Expand Up @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 30
compileSdkVersion flutter.compileSdkVersion

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand All @@ -35,8 +35,8 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.example"
minSdkVersion 16
targetSdkVersion 30
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Expand Down
2 changes: 1 addition & 1 deletion example/android/build.gradle
@@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.3.50'
ext.kotlin_version = '1.6.10'
repositories {
google()
jcenter()
Expand Down
143 changes: 111 additions & 32 deletions example/lib/main.dart
Expand Up @@ -6,8 +6,8 @@ import 'package:liquid_swipe/liquid_swipe.dart';
void main() {
/// Comment or uncomment to run both examples
runApp(
WithBuilder(),
//WithPages()
WithBuilder()
// WithPages()
);
}

Expand All @@ -30,8 +30,8 @@ class WithBuilder extends StatefulWidget {

class _WithBuilder extends State<WithBuilder> {
int page = 0;
LiquidController liquidController;
UpdateType updateType;
late LiquidController liquidController;
late UpdateType updateType;

List<ItemData> data = [
ItemData(Colors.blue, "assets/1.png", "Hi", "It's Me", "Sahdeep"),
Expand All @@ -40,6 +40,8 @@ class _WithBuilder extends State<WithBuilder> {
ItemData(Colors.green, "assets/1.png", "Liked?", "Fork!", "Give Star!"),
ItemData(Colors.yellow, "assets/1.png", "Can be", "Used for",
"Onboarding design"),
ItemData(
Colors.pink, "assets/1.png", "Example", "of a page", "with Gesture"),
ItemData(Colors.red, "assets/1.png", "Do", "try it", "Thank you"),
];

Expand Down Expand Up @@ -91,12 +93,19 @@ class _WithBuilder extends State<WithBuilder> {
children: <Widget>[
Image.asset(
data[index].image,
height: 400,
height: 300,
fit: BoxFit.contain,
),
Padding(
padding: EdgeInsets.all(20.0),
padding: EdgeInsets.all(index != 4 ? 24.0 : 0),
),
index == 4
? Padding(
padding:
const EdgeInsets.symmetric(horizontal: 70.0),
child: ExampleSlider(),
)
: SizedBox.shrink(),
Column(
children: <Widget>[
Text(
Expand Down Expand Up @@ -124,6 +133,7 @@ class _WithBuilder extends State<WithBuilder> {
liquidController: liquidController,
fullTransitionValue: 880,
enableSideReveal: true,
preferDragFromRevealedArea: true,
enableLoop: true,
ignoreUserGestureWhileAnimating: true,
),
Expand All @@ -143,29 +153,33 @@ class _WithBuilder extends State<WithBuilder> {
alignment: Alignment.bottomRight,
child: Padding(
padding: const EdgeInsets.all(25.0),
child: FlatButton(
child: TextButton(
onPressed: () {
liquidController.animateToPage(
page: data.length - 1, duration: 700);
},
child: Text("Skip to End"),
color: Colors.white.withOpacity(0.01),
style: TextButton.styleFrom(
backgroundColor: Colors.white.withOpacity(0.01),
foregroundColor: Colors.black),
),
),
),
Align(
alignment: Alignment.bottomLeft,
child: Padding(
padding: const EdgeInsets.all(25.0),
child: FlatButton(
child: TextButton(
onPressed: () {
liquidController.jumpToPage(
page: liquidController.currentPage + 1 > data.length - 1
? 0
: liquidController.currentPage + 1);
},
child: Text("Next"),
color: Colors.white.withOpacity(0.01),
style: TextButton.styleFrom(
backgroundColor: Colors.white.withOpacity(0.01),
foregroundColor: Colors.black),
),
),
)
Expand Down Expand Up @@ -196,18 +210,11 @@ class WithPages extends StatefulWidget {

class _WithPages extends State<WithPages> {
int page = 0;
LiquidController liquidController;
UpdateType updateType;

@override
void initState() {
liquidController = LiquidController();
super.initState();
}

late LiquidController liquidController;
late UpdateType updateType;
final pages = [
Container(
color: Colors.pink,
color: Colors.blue,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
Expand All @@ -218,7 +225,7 @@ class _WithPages extends State<WithPages> {
fit: BoxFit.cover,
),
Padding(
padding: EdgeInsets.all(20.0),
padding: EdgeInsets.all(24.0),
),
Column(
children: <Widget>[
Expand Down Expand Up @@ -251,7 +258,7 @@ class _WithPages extends State<WithPages> {
fit: BoxFit.cover,
),
Padding(
padding: EdgeInsets.all(20.0),
padding: EdgeInsets.all(24.0),
),
Column(
children: <Widget>[
Expand All @@ -273,7 +280,7 @@ class _WithPages extends State<WithPages> {
),
),
Container(
color: Colors.greenAccent,
color: Colors.green,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
Expand All @@ -284,7 +291,7 @@ class _WithPages extends State<WithPages> {
fit: BoxFit.cover,
),
Padding(
padding: EdgeInsets.all(20.0),
padding: EdgeInsets.all(24.0),
),
Column(
children: <Widget>[
Expand All @@ -306,7 +313,7 @@ class _WithPages extends State<WithPages> {
),
),
Container(
color: Colors.yellowAccent,
color: Colors.yellow,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
Expand All @@ -317,7 +324,7 @@ class _WithPages extends State<WithPages> {
fit: BoxFit.cover,
),
Padding(
padding: EdgeInsets.all(20.0),
padding: EdgeInsets.all(24.0),
),
Column(
children: <Widget>[
Expand All @@ -339,7 +346,41 @@ class _WithPages extends State<WithPages> {
),
),
Container(
color: Colors.redAccent,
color: Colors.pink,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Image.asset(
'assets/1.png',
fit: BoxFit.cover,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 70.0),
child: ExampleSlider(),
),
Column(
children: <Widget>[
Text(
"Example",
style: WithPages.style,
),
Text(
"of a page",
style: WithPages.style,
),
Text(
"with Gesture",
style: WithPages.style,
),
],
),
],
),
),
Container(
color: Colors.red,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
Expand All @@ -350,7 +391,7 @@ class _WithPages extends State<WithPages> {
fit: BoxFit.cover,
),
Padding(
padding: EdgeInsets.all(20.0),
padding: EdgeInsets.all(24.0),
),
Column(
children: <Widget>[
Expand All @@ -373,6 +414,12 @@ class _WithPages extends State<WithPages> {
),
];

@override
void initState() {
liquidController = LiquidController();
super.initState();
}

Widget _buildDot(int index) {
double selectedness = Curves.easeOut.transform(
max(
Expand Down Expand Up @@ -404,12 +451,16 @@ class _WithPages extends State<WithPages> {
children: <Widget>[
LiquidSwipe(
pages: pages,
positionSlideIcon: 0.8,
fullTransitionValue: 880,
slideIconWidget: Icon(Icons.arrow_back_ios),
onPageChangeCallback: pageChangeCallback,
waveType: WaveType.liquidReveal,
liquidController: liquidController,
preferDragFromRevealedArea: true,
enableSideReveal: true,
ignoreUserGestureWhileAnimating: true,
enableLoop: true,
),
Padding(
padding: EdgeInsets.all(20),
Expand All @@ -427,21 +478,23 @@ class _WithPages extends State<WithPages> {
alignment: Alignment.bottomRight,
child: Padding(
padding: const EdgeInsets.all(25.0),
child: FlatButton(
child: TextButton(
onPressed: () {
liquidController.animateToPage(
page: pages.length - 1, duration: 700);
},
child: Text("Skip to End"),
color: Colors.white.withOpacity(0.01),
style: TextButton.styleFrom(
backgroundColor: Colors.white.withOpacity(0.01),
foregroundColor: Colors.black),
),
),
),
Align(
alignment: Alignment.bottomLeft,
child: Padding(
padding: const EdgeInsets.all(25.0),
child: FlatButton(
child: TextButton(
onPressed: () {
liquidController.jumpToPage(
page:
Expand All @@ -450,7 +503,9 @@ class _WithPages extends State<WithPages> {
: liquidController.currentPage + 1);
},
child: Text("Next"),
color: Colors.white.withOpacity(0.01),
style: TextButton.styleFrom(
backgroundColor: Colors.white.withOpacity(0.01),
foregroundColor: Colors.black),
),
),
)
Expand All @@ -466,3 +521,27 @@ class _WithPages extends State<WithPages> {
});
}
}

class ExampleSlider extends StatefulWidget {
const ExampleSlider({Key? key}) : super(key: key);

@override
State<ExampleSlider> createState() => _ExampleSliderState();
}

class _ExampleSliderState extends State<ExampleSlider> {
double sliderVal = 0;

@override
Widget build(BuildContext context) {
return Slider(
value: sliderVal,
activeColor: Colors.white,
inactiveColor: Colors.red,
onChanged: (val) {
setState(() {
sliderVal = val;
});
});
}
}
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Expand Up @@ -3,7 +3,7 @@ description: Demonstrates how to use the liquid_swipe plugin.
publish_to: 'none'

environment:
sdk: ">=2.1.0 <3.0.0"
sdk: ">=2.12.0 <3.0.0"

dependencies:
flutter:
Expand Down

0 comments on commit 0383542

Please sign in to comment.