Skip to content

Commit

Permalink
adding the ability to change slide Icon
Browse files Browse the repository at this point in the history
  • Loading branch information
Yasser Omar Jammeli committed Sep 19, 2019
1 parent 97525ba commit 5cbd32c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 24 deletions.
30 changes: 17 additions & 13 deletions lib/Animation_Gesture/page_dragger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import '../liquid_swipe.dart';
class PageDragger extends StatefulWidget {
final double fullTransitionPX;
final bool enableSlideIcon;
final Widget slideIconWidget;

//Stream controller
final StreamController<SlideUpdate> slideUpdateStream;
Expand All @@ -19,6 +20,7 @@ class PageDragger extends StatefulWidget {
this.slideUpdateStream,
this.fullTransitionPX = FULL_TARNSITION_PX,
this.enableSlideIcon = false,
this.slideIconWidget,
}) : assert(fullTransitionPX != null);

@override
Expand Down Expand Up @@ -87,19 +89,21 @@ class _PageDraggerState extends State<PageDragger> {
onHorizontalDragStart: onDragStart,
onHorizontalDragUpdate: onDragUpdate,
onHorizontalDragEnd: onDragEnd,
child: widget.enableSlideIcon ? Align(
alignment: Alignment(1 - slidePercent + 0.005, 0.54),
child: Opacity(
opacity: 1 - slidePercent,
child: FloatingActionButton(
onPressed: null,
backgroundColor: Colors.transparent,
elevation: 0.0,
child: slideDirection == SlideDirection.leftToRight
? null
: Icon(Icons.arrow_back_ios),
foregroundColor: Colors.black,
))) : null,
child: widget.enableSlideIcon
? Align(
alignment: Alignment(1 - slidePercent + 0.005, 0.54),
child: Opacity(
opacity: 1 - slidePercent,
child: FloatingActionButton(
onPressed: null,
backgroundColor: Colors.transparent,
elevation: 0.0,
child: slideDirection == SlideDirection.leftToRight
? null
: widget.slideIconWidget,
foregroundColor: Colors.black,
)))
: null,
);
}
}
26 changes: 15 additions & 11 deletions lib/liquid_swipe.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,25 @@ import 'package:liquid_swipe/page.dart';
import 'Animation_Gesture/page_reveal.dart';

final key = new GlobalKey<_LiquidSwipe>();

class LiquidSwipe extends StatefulWidget {
final List<Container> pages;
final double fullTransitionValue;
final int initialPage;
final bool enableSlideIcon;
final Widget slideIconWidget;

const LiquidSwipe({
Key key,
@required this.pages,
this.fullTransitionValue = FULL_TARNSITION_PX,
this.initialPage = 0,
this.enableSlideIcon = false,
})
: assert(pages != null),
this.slideIconWidget = const Icon(Icons.arrow_back_ios),
}) : assert(pages != null),
assert(fullTransitionValue != null),
assert(initialPage != null && initialPage >= 0 &&
assert(initialPage != null &&
initialPage >= 0 &&
initialPage < pages.length),
super(key: key);

Expand All @@ -38,20 +41,20 @@ class SlideUpdate {
final SlideDirection direction;
final double slidePercent;

SlideUpdate(this.direction,
this.slidePercent,
this.updateType,);
SlideUpdate(
this.direction,
this.slidePercent,
this.updateType,
);
}

class _LiquidSwipe extends State<LiquidSwipe> with TickerProviderStateMixin {


StreamController<SlideUpdate>
// ignore: close_sinks
slideUpdateStream; //Stream controller is used to get all the updates when user slides across screen.
// ignore: close_sinks
slideUpdateStream; //Stream controller is used to get all the updates when user slides across screen.

AnimatedPageDragger
animatedPageDragger; //When user stops dragging then by using this page automatically drags.
animatedPageDragger; //When user stops dragging then by using this page automatically drags.

int activePageIndex = 0; //active page index
int nextPageIndex = 0; //next page index
Expand Down Expand Up @@ -171,6 +174,7 @@ class _LiquidSwipe extends State<LiquidSwipe> with TickerProviderStateMixin {
fullTransitionPX: widget.fullTransitionValue,
slideUpdateStream: this.slideUpdateStream,
enableSlideIcon: widget.enableSlideIcon,
slideIconWidget: widget.slideIconWidget,
), //PageDragger
], //Widget
), //Stack
Expand Down

0 comments on commit 5cbd32c

Please sign in to comment.