Skip to content

Commit

Permalink
add: add skip button on sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
rezamagnet committed Jan 25, 2020
1 parent 64954ce commit d9413d6
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 10 deletions.
2 changes: 1 addition & 1 deletion MaterialShowcase.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ s.author = { 'Quang Nguyen' => 'quangnguyen@aromajoin.com' }
s.source = { :git => 'https://github.com/aromajoin/material-showcase-ios.git', :tag => s.version.to_s }

s.swift_version = '5.0'
s.ios.deployment_target = '8.0'
s.ios.deployment_target = '10.0'
s.source_files = 'MaterialShowcase/*.swift'

end
Expand Down
8 changes: 4 additions & 4 deletions MaterialShowcase.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -398,7 +398,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
Expand All @@ -423,7 +423,7 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = MaterialShowcase/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 0.7.1;
ONLY_ACTIVE_ARCH = NO;
Expand All @@ -449,7 +449,7 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = MaterialShowcase/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 0.7.1;
ONLY_ACTIVE_ARCH = NO;
Expand Down
51 changes: 48 additions & 3 deletions MaterialShowcase/MaterialShowcase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ open class MaterialShowcase: UIView {
var offsetThreshold: CGFloat = 88

// MARK: Private view properties
var closeButton : UIButton!

var containerView: UIView!
var targetView: UIView!
var backgroundView: UIView!
Expand All @@ -52,9 +54,13 @@ open class MaterialShowcase: UIView {
var targetCopyView: UIView!
var instructionView: MaterialShowcaseInstructionView!


public var skipButton: (() -> Void)?
var onTapThrough: (() -> Void)?

// MARK: Public Properties
// setSkipImage
public var skipImage = "HintClose"

// Background
@objc public var backgroundAlpha: CGFloat = 1.0
Expand Down Expand Up @@ -179,8 +185,12 @@ extension MaterialShowcase {
targetHolderRadius = 0
}

@objc func dismissTutorialButtonDidTouch() {
skipButton?()
}

/// Shows it over current screen after completing setup process
@objc public func show(animated: Bool = true, completion handler: (()-> Void)?) {
@objc public func show(animated: Bool = true,hasShadow: Bool = true, hasSkipButton: Bool = true, completion handler: (()-> Void)?) {
initViews()
alpha = 0.0
containerView.addSubview(self)
Expand All @@ -191,6 +201,36 @@ extension MaterialShowcase {

backgroundView.transform = CGAffineTransform(scaleX: scale, y: scale) // Initial set to support animation
backgroundView.center = targetHolderView.center





if hasSkipButton {

closeButton = UIButton()

closeButton.setImage(UIImage(named: skipImage), for: .normal)
addSubview(closeButton)
closeButton.addTarget(self, action: #selector(dismissTutorialButtonDidTouch), for: .touchUpInside)

let margins = layoutMarginsGuide
closeButton.translatesAutoresizingMaskIntoConstraints = false
closeButton.topAnchor.constraint(equalTo: margins.topAnchor, constant: 0).isActive = true
closeButton.rightAnchor.constraint(equalTo: margins.rightAnchor, constant: -8).isActive = true
closeButton.widthAnchor.constraint(equalTo: widthAnchor, multiplier: 0.13).isActive = true
closeButton.heightAnchor.constraint(equalTo: closeButton.widthAnchor, multiplier: 1.0/1.0).isActive = true
}


if hasShadow {
backgroundView.layer.shadowColor = UIColor.black.cgColor
backgroundView.layer.shadowRadius = 5.0
backgroundView.layer.shadowOpacity = 0.5
backgroundView.layer.shadowOffset = .zero
backgroundView.clipsToBounds = false
}

if animated {
UIView.animate(withDuration: aniComeInDuration, animations: {
self.targetHolderView.transform = CGAffineTransform(scaleX: 1, y: 1)
Expand Down Expand Up @@ -329,16 +369,21 @@ extension MaterialShowcase {
}

let center = targetRippleView.center

backgroundView = UIView(frame: CGRect(x: 0, y: 0, width: radius * 2,height: radius * 2))
backgroundView.center = center
backgroundView.asCircle()



case .full:
backgroundView = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width,height: UIScreen.main.bounds.height))
}


backgroundView.backgroundColor = backgroundPromptColor.withAlphaComponent(backgroundPromptColorAlpha)
insertSubview(backgroundView, belowSubview: targetRippleView)
addBackgroundMask(with: targetHolderRadius, in: backgroundView)

// addBackgroundMask(with: targetHolderRadius, in: backgroundView)
}

private func getDefaultBackgroundRadius() -> CGFloat {
Expand Down
4 changes: 2 additions & 2 deletions Sample/MaterialShowcaseSample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = 4V6HDFWSR4;
INFOPLIST_FILE = MaterialShowcaseSample/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.aromajoin.MaterialShowcaseSample;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -326,7 +326,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = 4V6HDFWSR4;
INFOPLIST_FILE = MaterialShowcaseSample/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.aromajoin.MaterialShowcaseSample;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1130"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "CE9F24871EC2907700444781"
BuildableName = "MaterialShowcaseSample.app"
BlueprintName = "MaterialShowcaseSample"
ReferencedContainer = "container:MaterialShowcaseSample.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "CE9F24871EC2907700444781"
BuildableName = "MaterialShowcaseSample.app"
BlueprintName = "MaterialShowcaseSample"
ReferencedContainer = "container:MaterialShowcaseSample.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "CE9F24871EC2907700444781"
BuildableName = "MaterialShowcaseSample.app"
BlueprintName = "MaterialShowcaseSample"
ReferencedContainer = "container:MaterialShowcaseSample.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "HintClose.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file not shown.
4 changes: 4 additions & 0 deletions Sample/MaterialShowcaseSample/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ class ViewController: UIViewController {
showcase.show(completion: {
print("==== completion Action 1 ====")
// You can save showcase state here
showcase.skipButton = {
debugPrint("---hit point---")
}
})
}

Expand Down Expand Up @@ -101,6 +104,7 @@ class ViewController: UIViewController {
// You can save showcase state here
print("==== completion Action 2 ====")
})

}

@IBAction func showTabBar(_ sender: Any) {
Expand Down

0 comments on commit d9413d6

Please sign in to comment.