-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
07d7d09
commit a84957f
Showing
18 changed files
with
507 additions
and
483 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:spotlight_ant/src/spotlight_ant.dart'; | ||
|
||
class SpotlightActionConfig { | ||
/// Ordering actions by [SpotlightAntAction]. | ||
/// | ||
/// send empty list for disabling default actions. | ||
final List<SpotlightAntAction> enabled; | ||
|
||
/// Build the actions wrapper. | ||
/// | ||
/// Default using: | ||
/// ```dart | ||
/// Positioned( | ||
/// bottom: 16, | ||
/// left: 16, | ||
/// right: 16, | ||
/// child: Row( | ||
/// mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
/// children: actions.toList(), | ||
/// ), | ||
/// ); | ||
/// ``` | ||
final Widget Function(BuildContext context, Iterable<Widget> actions)? builder; | ||
|
||
/// Pressed the action widget will go to next spotlight. | ||
/// | ||
/// Default using: | ||
/// ```dart | ||
/// IconButton( | ||
/// onPressed: () => prev(), | ||
/// tooltip: 'Next spotlight', | ||
/// color: Colors.white, | ||
/// icon: const Icon(Icons.arrow_forward_ios_sharp), | ||
/// ); | ||
/// ``` | ||
final Widget? next; | ||
|
||
/// Pressed the action widget will go to previous spotlight. | ||
/// | ||
/// Default using: | ||
/// ```dart | ||
/// IconButton( | ||
/// onPressed: () => prev(), | ||
/// tooltip: 'Previous spotlight', | ||
/// color: Colors.white, | ||
/// icon: const Icon(Icons.arrow_back_ios_sharp), | ||
/// ); | ||
/// ``` | ||
final Widget? prev; | ||
|
||
/// Pressed the action widget will skip all spotlights. | ||
/// | ||
/// Default using: | ||
/// ```dart | ||
/// IconButton( | ||
/// onPressed: () => skip(), | ||
/// tooltip: 'Skip spotlight show', | ||
/// color: Colors.white, | ||
/// icon: const Icon(Icons.close_sharp), | ||
/// ); | ||
/// ``` | ||
final Widget? skip; | ||
|
||
const SpotlightActionConfig({ | ||
this.enabled = const [SpotlightAntAction.skip], | ||
this.builder, | ||
this.next, | ||
this.prev, | ||
this.skip, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class SpotlightBackdropConfig { | ||
/// Set to false will not build backdrop. | ||
/// | ||
/// Backdrop is use to close the spotlight when tapping anywhere. | ||
final bool silent; | ||
|
||
/// Using [InkWell] or [GestureDetector] on backdrop. | ||
final bool usingInkwell; | ||
|
||
/// Backdrop inkwell splash color. | ||
/// | ||
/// Setting null to use default color (control by the app theme). | ||
/// | ||
/// Only useful when [silent] is false. | ||
final Color? splashColor; | ||
|
||
const SpotlightBackdropConfig({ | ||
this.silent = false, | ||
this.usingInkwell = true, | ||
this.splashColor, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:spotlight_ant/src/spotlights/spotlight_builder.dart'; | ||
import 'package:spotlight_ant/src/spotlights/spotlight_circular_builder.dart'; | ||
import 'package:spotlight_ant/src/spotlights/spotlight_rect_builder.dart'; | ||
|
||
class SpotlightConfig { | ||
/// Building painter for spotlight. | ||
/// | ||
/// Default is using [SpotlightCircularBuilder]. | ||
/// You can use [SpotlightRectBuilder] for rectangle. | ||
/// | ||
/// See also: | ||
/// | ||
/// * [SpotlightBuilder], which provide an interface for custom painter. | ||
final SpotlightBuilder builder; | ||
|
||
/// Padding of spotlight. | ||
final EdgeInsets padding; | ||
|
||
/// Listen `onTap` event on the spotlight to dismiss the tutorial. | ||
/// | ||
/// Setting true will make it unable to go next when tapping the spotlight. | ||
final bool silent; | ||
|
||
/// Using [InkWell] or [GestureDetector] on spotlight. | ||
final bool usingInkwell; | ||
|
||
/// Spotlight inkwell splash color. | ||
/// | ||
/// Setting null to use default color (control by the app theme). | ||
/// | ||
/// Only useful when [silent] is false. | ||
final Color? splashColor; | ||
|
||
const SpotlightConfig({ | ||
this.builder = const SpotlightCircularBuilder(), | ||
this.padding = const EdgeInsets.all(8), | ||
this.silent = false, | ||
this.usingInkwell = true, | ||
this.splashColor, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class SpotlightContentLayoutConfig { | ||
/// Alignment of content. | ||
/// | ||
/// Setting null will auto-detected by the center position. | ||
final Alignment? alignment; | ||
|
||
/// Prefer content shown in which side. | ||
/// | ||
/// If set [preferHorizontal] and [preferVertical] set to false, | ||
/// it will choose the largest ratio compare to window. | ||
/// | ||
/// For example, target is at `(0.7 * window_width, 0.4 * window_height)` | ||
/// it will align to [Alignment.centerLeft], since | ||
/// `|0.7 - 0.5| > |0.4 - 0.5|` | ||
/// | ||
/// If [preferVertical] set to true, it will choose | ||
/// [Alignment.topCenter] or [Alignment.bottomCenter] | ||
/// | ||
/// If both [preferHorizontal] and [preferVertical] set to true, | ||
/// [preferHorizontal] will take the procedure. | ||
final ContentPreferLayout prefer; | ||
|
||
const SpotlightContentLayoutConfig({ | ||
this.alignment, | ||
this.prefer = ContentPreferLayout.vertical, | ||
}); | ||
} | ||
|
||
enum ContentPreferLayout { | ||
/// it will choose [Alignment.topCenter] or [Alignment.bottomCenter] | ||
vertical, | ||
|
||
/// it will choose [Alignment.centerLeft] or [Alignment.centerRight] | ||
horizontal, | ||
|
||
/// it will choose the larger ratio compare to window's ratio | ||
/// | ||
/// For example, target is at `(0.7 * window_width, 0.4 * window_height)` | ||
/// it will align to [Alignment.centerLeft], since | ||
/// `|0.7 - 0.5| > |0.4 - 0.5|` | ||
largerRatio, | ||
} | ||
|
||
extension PreferLayoutExtension on ContentPreferLayout { | ||
bool isPreferHorizontal(double xRatio, double yRatio) { | ||
switch (this) { | ||
case ContentPreferLayout.horizontal: | ||
return true; | ||
case ContentPreferLayout.vertical: | ||
return false; | ||
case ContentPreferLayout.largerRatio: | ||
return xRatio.abs() > yRatio.abs(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
class SpotlightDurationConfig { | ||
/// Duration for zoom in the spotlight (start). | ||
final Duration zoomIn; | ||
|
||
/// Duration for zoom out the spotlight (finish). | ||
final Duration zoomOut; | ||
|
||
/// Duration for bump forward and reverse. | ||
/// | ||
/// One cycle of bumping(forward + reverse) will cost 2 * [bump]. | ||
final Duration bump; | ||
|
||
/// Duration of fading in the content after zoom-in. | ||
final Duration contentFadeIn; | ||
|
||
const SpotlightDurationConfig({ | ||
this.zoomIn = const Duration(milliseconds: 600), | ||
this.zoomOut = const Duration(milliseconds: 600), | ||
this.bump = const Duration(milliseconds: 500), | ||
this.contentFadeIn = const Duration(milliseconds: 200), | ||
}); | ||
|
||
// All zero, let it easy to test. | ||
static const SpotlightDurationConfig zero = SpotlightDurationConfig( | ||
zoomIn: Duration.zero, | ||
zoomOut: Duration.zero, | ||
bump: Duration(milliseconds: 500), | ||
contentFadeIn: Duration.zero, | ||
); | ||
} |
Oops, something went wrong.