Skip to content

Commit

Permalink
Merge pull request #36 from iamSahdeep/1.5.0VDEV
Browse files Browse the repository at this point in the history
v1.5.0-dev.1
  • Loading branch information
iamSahdeep authored Jun 19, 2020
2 parents d9a2074 + 0367655 commit 7c32328
Show file tree
Hide file tree
Showing 9 changed files with 285 additions and 85 deletions.
15 changes: 13 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
#ChangeLog

# ChangeLog

## 1.5.0-dev.1
* Making Pages of Type Widget [724dc31b687319f66db362b55e2b7c6c2cabbcd7](https://github.com/iamSahdeep/liquid_swipe_flutter/commit/724dc31b687319f66db362b55e2b7c6c2cabbcd7)
* LiquidController & jump to page
[ed3328ae734b2528f1e02a20b134f7bbcca274ef](https://github.com/iamSahdeep/liquid_swipe_flutter/commit/ed3328ae734b2528f1e02a20b134f7bbcca274ef)
* Animating the Page with Controller
[354825e952186bc84117cba403a33e096fbdf331](https://github.com/iamSahdeep/liquid_swipe_flutter/commit/354825e952186bc84117cba403a33e096fbdf331)
* Get Current Page from Controller [9d9f585ebf6899354ba10eadd88daa35d232f9cf](https://github.com/iamSahdeep/liquid_swipe_flutter/commit/9d9f585ebf6899354ba10eadd88daa35d232f9cf)
* Add support for vertically scrollable childs
[df22e79e525e6b4fb9fdd95e3a61e6c4c394ac25](https://github.com/iamSahdeep/liquid_swipe_flutter/commit/df22e79e525e6b4fb9fdd95e3a61e6c4c394ac25)
* Additional Callback for sliding percentage
[6d5da5d7f52815199bd5263047c252494ed1675f](https://github.com/iamSahdeep/liquid_swipe_flutter/commit/6d5da5d7f52815199bd5263047c252494ed1675f)

## 1.4.3
* Might Fix : https://github.com/iamSahdeep/liquid_swipe_flutter/issues/32
Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Download sample apk as shown in example from releases.
* Add this to your pubspec.yaml
```
dependencies:
liquid_swipe: ^1.4.3
liquid_swipe: ^1.5.0-dev.1
```
* Get the package from Pub:
Expand All @@ -53,7 +53,7 @@ Download sample apk as shown in example from releases.

## Usage

- *`Liquid Swipe`* just requires the list of [`containers`](https://api.flutter.dev/flutter/widgets/Container-class.html). Just to provide flexibity to the developer to design its own view through it.
- *`Liquid Swipe`* just requires the list of [`Widgets like Container`](https://api.flutter.dev/flutter/widgets/Container-class.html). Just to provide flexibity to the developer to design its own view through it.
```
final pages = [
Container(...),
Expand Down Expand Up @@ -92,12 +92,22 @@ Download sample apk as shown in example from releases.
| waveType |`WaveType` | Select the type of reveal you want. | WaveType.liquidReveal | You can use circularReveal, more coming soon. Import Helpers.dart file if Autoimport doesn't work. |
| onPageChangeCallback |`CallBack` | Pass your method as a callback, it will return a pageNo. | None | see Example |
| currentUpdateTypeCallback |`CallBack` | same Callback but returns an UpdateType | None | see Example |
| slidePercentCallback |`CallBack` | returns SlidePercent both horizontal & vertical | None | see Example |


### Additional

From v1.5.0-dev.1 we can use LiquidController class to create its instance and use it from controlling pages programmatically.
Features/Methods added but will not be limited to :
- jumpToPage({int page}) : It will jump to the mentioned page but without animation or swipe.
- animateToPage({int page, int duration = 600}) : It will animate to the mentioned page in given time with animation of swipes.
- currentPage : This getter will return the current Page which is being displayed.

Please look at the Example in this project for detailed usage.

# Contributors

Thanks to all these wonderful people and everyone that created issues.
Thanks to all these wonderful people and everyone that created issues or contributed in any way possible.
([emoji key](https://allcontributors.org/docs/en/emoji-key)):

<table>
Expand Down
50 changes: 42 additions & 8 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ class MyApp extends StatefulWidget {

class _MyAppState extends State<MyApp> {
int page = 0;

LiquidController liquidController;
UpdateType updateType;

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

final pages = [
Container(
color: Colors.pink,
Expand Down Expand Up @@ -225,12 +231,12 @@ class _MyAppState extends State<MyApp> {
LiquidSwipe(
pages: pages,
fullTransitionValue: 200,
enableSlideIcon: true,
enableSlideIcon: false,
enableLoop: true,
positionSlideIcon: 0.5,
onPageChangeCallback: pageChangeCallback,
currentUpdateTypeCallback: updateTypeCallback,
waveType: WaveType.liquidReveal,
liquidController: liquidController,
slidePercentCallback: slidePercentCallback,
),
Padding(
padding: EdgeInsets.all(20),
Expand All @@ -239,25 +245,53 @@ class _MyAppState extends State<MyApp> {
Expanded(child: SizedBox()),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: List<Widget>.generate(5, _buildDot),
children: List<Widget>.generate(pages.length, _buildDot),
),
],
),
),
Align(
alignment: Alignment.bottomRight,
child: Padding(
padding: const EdgeInsets.all(25.0),
child: FlatButton(
onPressed: () {
liquidController.animateToPage(
page: pages.length - 1, duration: 500);
},
child: Text("Skip to End"),
color: Colors.white.withOpacity(0.1),
),
),
),
Align(
alignment: Alignment.bottomLeft,
child: Padding(
padding: const EdgeInsets.all(25.0),
child: FlatButton(
onPressed: () {
liquidController.jumpToPage(
page: liquidController.currentPage + 1);
},
child: Text("Next"),
color: Colors.white.withOpacity(0.1),
),
),
)
],
),
),
);
}

pageChangeCallback(int lpage) {
print(lpage);
print(liquidController.currentPage);
setState(() {
page = lpage;
});
}

updateTypeCallback(UpdateType updateType) {
print(updateType);
slidePercentCallback(double hor, double ver) {
print(hor.toInt().toString() + " " + ver.toString());
}
}
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.4.3"
version: "1.5.0-dev.1"
matcher:
dependency: transitive
description:
Expand Down
27 changes: 27 additions & 0 deletions lib/PageHelpers/LiquidController.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import 'package:flutter/material.dart';
import 'package:liquid_swipe/Provider/iamariderprovider.dart';
import 'package:provider/provider.dart';

class LiquidController {
BuildContext context;

LiquidController();

setContext(BuildContext c) {
context = c;
}

jumpToPage({int page}) {
Provider.of<IAmARiderProvider>(context, listen: false).jumpToPage(page);
}

animateToPage({int page, int duration = 600}) {
Provider.of<IAmARiderProvider>(context, listen: false)
.animateToPage(page, duration);
}

int get currentPage =>
Provider
.of<IAmARiderProvider>(context, listen: false)
.activePageIndex;
}
50 changes: 25 additions & 25 deletions lib/PageHelpers/page_dragger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class _PageDraggerState extends State<PageDragger> {
slidePercentVer = (dy / 500).abs().clamp(0.0, 1.25);
}

// Adding to slideUpdateStream
Provider.of<IAmARiderProvider>(context, listen: false)
.updateSlide(SlideUpdate(
slideDirection,
Expand All @@ -73,7 +72,6 @@ class _PageDraggerState extends State<PageDragger> {

// This method executes when user ends dragging.
onDragEnd(DragEndDetails details) {
// Adding to slideUpdateStream
Provider.of<IAmARiderProvider>(context, listen: false)
.updateSlide(SlideUpdate(
SlideDirection.none,
Expand All @@ -91,33 +89,35 @@ class _PageDraggerState extends State<PageDragger> {
@override
Widget build(BuildContext context) {
//Gesture Detector for horizontal drag
final model = Provider.of<IAmARiderProvider>(context, listen: false);

return GestureDetector(
behavior: HitTestBehavior.translucent,
onHorizontalDragStart: onDragStart,
onHorizontalDragUpdate: onDragUpdate,
onHorizontalDragEnd: onDragEnd,
onVerticalDragStart: onDragStart,
onVerticalDragEnd: onDragEnd,
onVerticalDragUpdate: onDragUpdate,
onHorizontalDragStart: model.isInProgress ? null : onDragStart,
onHorizontalDragUpdate: model.isInProgress ? null : onDragUpdate,
onHorizontalDragEnd: model.isInProgress ? null : onDragEnd,
//onVerticalDragStart: model.isInProgress ? null : onDragStart,
// onVerticalDragEnd: model.isInProgress ? null : onDragEnd,
// onVerticalDragUpdate: model.isInProgress ? null : onDragUpdate,
child: widget.enableSlideIcon
? Align(
alignment: Alignment(
1 - slidePercentHor + 0.005,
widget.iconPosition + widget.iconPosition / 10,
),
child: Opacity(
opacity: 1 - slidePercentHor,
child: FloatingActionButton(
onPressed: null,
backgroundColor: Colors.transparent,
elevation: 0.0,
child: slideDirection != SlideDirection.leftToRight
? widget.slideIconWidget
: null,
foregroundColor: Colors.black,
),
),
)
alignment: Alignment(
1 - slidePercentHor + 0.005,
widget.iconPosition + widget.iconPosition / 10,
),
child: Opacity(
opacity: 1 - slidePercentHor,
child: FloatingActionButton(
onPressed: null,
backgroundColor: Colors.transparent,
elevation: 0.0,
child: slideDirection != SlideDirection.leftToRight
? widget.slideIconWidget
: null,
foregroundColor: Colors.black,
),
),
)
: null,
);
}
Expand Down
Loading

0 comments on commit 7c32328

Please sign in to comment.