diff --git a/MaterialShowcase.podspec b/MaterialShowcase.podspec index 2d3e32b..c231a80 100644 --- a/MaterialShowcase.podspec +++ b/MaterialShowcase.podspec @@ -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 diff --git a/MaterialShowcase.xcodeproj/project.pbxproj b/MaterialShowcase.xcodeproj/project.pbxproj index 3f3899a..fbd4c42 100644 --- a/MaterialShowcase.xcodeproj/project.pbxproj +++ b/MaterialShowcase.xcodeproj/project.pbxproj @@ -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; @@ -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"; @@ -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; @@ -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; diff --git a/MaterialShowcase/MaterialShowcase.swift b/MaterialShowcase/MaterialShowcase.swift index f458653..748027e 100644 --- a/MaterialShowcase/MaterialShowcase.swift +++ b/MaterialShowcase/MaterialShowcase.swift @@ -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! @@ -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 @@ -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) @@ -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) @@ -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 { diff --git a/Sample/MaterialShowcaseSample.xcodeproj/project.pbxproj b/Sample/MaterialShowcaseSample.xcodeproj/project.pbxproj index 3b1d0c9..5f15680 100644 --- a/Sample/MaterialShowcaseSample.xcodeproj/project.pbxproj +++ b/Sample/MaterialShowcaseSample.xcodeproj/project.pbxproj @@ -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)"; @@ -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)"; diff --git a/Sample/MaterialShowcaseSample.xcodeproj/xcshareddata/xcschemes/MaterialShowcaseSample.xcscheme b/Sample/MaterialShowcaseSample.xcodeproj/xcshareddata/xcschemes/MaterialShowcaseSample.xcscheme new file mode 100644 index 0000000..3b94bc1 --- /dev/null +++ b/Sample/MaterialShowcaseSample.xcodeproj/xcshareddata/xcschemes/MaterialShowcaseSample.xcscheme @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Sample/MaterialShowcaseSample/Assets.xcassets/HintClose.imageset/Contents.json b/Sample/MaterialShowcaseSample/Assets.xcassets/HintClose.imageset/Contents.json new file mode 100644 index 0000000..25aa132 --- /dev/null +++ b/Sample/MaterialShowcaseSample/Assets.xcassets/HintClose.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "HintClose.pdf" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Sample/MaterialShowcaseSample/Assets.xcassets/HintClose.imageset/HintClose.pdf b/Sample/MaterialShowcaseSample/Assets.xcassets/HintClose.imageset/HintClose.pdf new file mode 100644 index 0000000..683d931 Binary files /dev/null and b/Sample/MaterialShowcaseSample/Assets.xcassets/HintClose.imageset/HintClose.pdf differ diff --git a/Sample/MaterialShowcaseSample/ViewController.swift b/Sample/MaterialShowcaseSample/ViewController.swift index a77d1e3..b850e89 100644 --- a/Sample/MaterialShowcaseSample/ViewController.swift +++ b/Sample/MaterialShowcaseSample/ViewController.swift @@ -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---") + } }) } @@ -101,6 +104,7 @@ class ViewController: UIViewController { // You can save showcase state here print("==== completion Action 2 ====") }) + } @IBAction func showTabBar(_ sender: Any) {