Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Global Skip showcase #472

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
13 changes: 8 additions & 5 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -136,7 +136,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "The Chromium Authors";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down Expand Up @@ -181,10 +181,12 @@
/* Begin PBXShellScriptBuildPhase section */
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
name = "Thin Binary";
outputPaths = (
Expand All @@ -195,6 +197,7 @@
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand Down Expand Up @@ -280,7 +283,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down Expand Up @@ -359,7 +362,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -406,7 +409,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 2 additions & 0 deletions example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,7 @@
<false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict>
</plist>
16 changes: 14 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:showcaseview/showcaseview.dart';

void main() => runApp(const MyApp());
void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
MyApp({Key? key}) : super(key: key);

final GlobalKey<ShowCaseWidgetState> _myWidgetKey =
GlobalKey<ShowCaseWidgetState>();

@override
Widget build(BuildContext context) {
Expand All @@ -20,6 +23,15 @@ class MyApp extends StatelessWidget {
debugShowCheckedModeBanner: false,
home: Scaffold(
body: ShowCaseWidget(
key: _myWidgetKey,
skipShowcaseWidget: Positioned(
bottom: 10,
left: 10,
child: ElevatedButton(
child: const Text('Skip Showcase'),
onPressed: () => _myWidgetKey.currentState?.dismiss(),
),
),
onStart: (index, key) {
log('onStart: $index, $key');
},
Expand Down
1 change: 1 addition & 0 deletions lib/src/showcase.dart
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@ class _ShowcaseState extends State<Showcase> {
tooltipBackgroundColor: widget.tooltipBackgroundColor,
textColor: widget.textColor,
showArrow: widget.showArrow,
staticContainer: showCaseWidgetState.skipShowcaseWidget,
contentHeight: widget.height,
contentWidth: widget.width,
onTooltipTap: _getOnTooltipTap,
Expand Down
43 changes: 27 additions & 16 deletions lib/src/showcase_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ import '../showcaseview.dart';
class ShowCaseWidget extends StatefulWidget {
final WidgetBuilder builder;

/// Creates a button that can be used to skip showCase. For onTap: create a
/// global key (final showCaseKey = GlobalKey<ShowCaseWidgetState>()
/// assign the key to ShowCaseWidget and use it like this:
/// onTap: () => showcaseKey.currentState?.dismiss();
final Positioned? skipShowcaseWidget;

/// Triggered when all the showcases are completed.
final VoidCallback? onFinish;

Expand Down Expand Up @@ -83,22 +89,25 @@ class ShowCaseWidget extends StatefulWidget {
/// Enable/disable showcase globally. Enabled by default.
final bool enableShowcase;

const ShowCaseWidget({
required this.builder,
this.onFinish,
this.onStart,
this.onComplete,
this.autoPlay = false,
this.autoPlayDelay = const Duration(milliseconds: 2000),
this.enableAutoPlayLock = false,
this.blurValue = 0,
this.scrollDuration = const Duration(milliseconds: 300),
this.disableMovingAnimation = false,
this.disableScaleAnimation = false,
this.enableAutoScroll = false,
this.disableBarrierInteraction = false,
this.enableShowcase = true,
});
const ShowCaseWidget(
{required this.builder,
this.onFinish,
this.onStart,
this.onComplete,
this.autoPlay = false,
this.autoPlayDelay = const Duration(milliseconds: 2000),
this.enableAutoPlayLock = false,
this.blurValue = 0,
this.scrollDuration = const Duration(milliseconds: 300),
this.disableMovingAnimation = false,
this.disableScaleAnimation = false,
this.enableAutoScroll = false,
this.disableBarrierInteraction = false,
this.enableShowcase = true,
this.skipShowcaseWidget,
super.key});

void dismiss() {}

static GlobalKey? activeTargetWidget(BuildContext context) {
return context
Expand Down Expand Up @@ -149,6 +158,8 @@ class ShowCaseWidgetState extends State<ShowCaseWidget> {
/// Returns value of [ShowCaseWidget.blurValue]
double get blurValue => widget.blurValue;

get skipShowcaseWidget => widget.skipShowcaseWidget;

@override
void initState() {
super.initState();
Expand Down
Loading
Loading