Skip to content

Commit

Permalink
Add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ericdallo committed Apr 1, 2020
1 parent ad09438 commit 9f9e7a5
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
35 changes: 35 additions & 0 deletions lib/ripple_effect.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
/// This library allows apply a ripple effect to the app screen.
///
/// It requires to wrap the page or the area where the ripple effect
/// will happen with the [RipplePage] widget, then wrap the start point of
/// the effect with the [RippleEffect] widget, finally, to start the animation,
/// use [RippleEffect.start].
///
/// ```dart
/// class Stateless extends StatelessWidget {
/// final pageKey = RipplePage.createGlobalKey();
/// final effectKey = RippleEffect.createGlobalKey();
///
/// @override
/// Widget build(BuildContext context) {
/// return RipplePage(
/// child: Scaffold(
/// body: Center(),
/// floatingActionButton: RippleEffect(
/// pageKey: pageKey,
/// effectKey: effectKey,
/// color: Colors.blue,
/// child: FloatingActionButton(
/// backgroundColor: Colors.blue,
/// onPressed: () =>
/// RippleEffect.start(effectKey, () => toNextPage(context)),
/// child: Icon(Icons.arrow_back),
/// ),
/// )
/// ),
/// );
/// }
/// }
///
/// ```
library ripple_effect;

export 'src/ripple_effect.dart' show RipplePage, RippleEffect;
Expand Down
40 changes: 40 additions & 0 deletions lib/src/ripple_effect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,28 @@ import 'package:rect_getter/rect_getter.dart';

import 'ripple_data.dart';

/// Wrap your screen with this widget.
///
/// The ripple effect will growth until reaches this widget.
/// It requires a [GlobalKey] that can be generated
/// via [RipplePage.createGlobalKey()].
///
/// This should be used with the [RippleEffect] widget to work.
///
/// ```dart
/// class Stateless extends StatelessWidget {
///
/// final pageKey = RipplePage.createGlobalKey();
///
/// @override
/// Widget build(BuildContext context) {
/// return RipplePage(
/// child: Scaffold(body: MyPage()),
/// pageKey: pageKey,
/// );
/// }
/// }
/// ```
class RipplePage extends StatefulWidget {
RipplePage({
@required GlobalKey<_RipplePageState> pageKey,
Expand Down Expand Up @@ -50,6 +72,23 @@ class _RipplePageState extends State<RipplePage> {
}
}

/// Responsible to wrap the origin point of the ripple effect.
///
/// Often this should wrap a button widget or the animation
/// start widget.
/// It requires to call [RippleEffect.start] to start the animation.
///
/// ```dart
/// RippleEffect(
/// pageKey: pageKey,
/// effectKey: effectKey,
/// color: Colors.blue,
/// child: FloatingActionButton(
/// child: Icon(Icons.arrow_back),
/// onPressed: () => RippleEffect.start(effectKey, toNextPage),
/// ),
/// )
/// ```
class RippleEffect extends StatefulWidget {
RippleEffect({
@required this.pageKey,
Expand Down Expand Up @@ -77,6 +116,7 @@ class RippleEffect extends StatefulWidget {
static GlobalKey<_RippleEffectState> createGlobalKey() =>
new GlobalKey<_RippleEffectState>();

/// Start the animation and call [callback] after the animation.
static Future<void> start(
GlobalKey<_RippleEffectState> rippleEffectKey,
VoidCallback callback,
Expand Down
10 changes: 10 additions & 0 deletions lib/src/transition.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import 'package:flutter/widgets.dart';

/// A common used fade transition to use with [RippleEffect] on navigation.
///
/// ```dart
/// Future<void> toNextPage(BuildContext context) =>
/// Navigator.of(context).push(
/// FadeRouteBuilder(
/// page: MyNextPage(),
/// ),
/// );
/// ```
class FadeRouteBuilder<T> extends PageRouteBuilder<T> {
final Widget page;

Expand Down

0 comments on commit 9f9e7a5

Please sign in to comment.