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

1.0.0 #19

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
Binary file modified .DS_Store
Binary file not shown.
7 changes: 7 additions & 0 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
048680EA1D8E2BA9004B011E /* TZStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048680DC1D8E2BA9004B011E /* TZStackView.swift */; };
048680EB1D8E2BA9004B011E /* TZStackViewAlignment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048680DD1D8E2BA9004B011E /* TZStackViewAlignment.swift */; };
048680EC1D8E2BA9004B011E /* TZStackViewDistribution.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048680DE1D8E2BA9004B011E /* TZStackViewDistribution.swift */; };
45DD8E41268B452200C85E3D /* UILayoutPriority.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45DD8E40268B452200C85E3D /* UILayoutPriority.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -68,6 +69,7 @@
048680DC1D8E2BA9004B011E /* TZStackView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TZStackView.swift; sourceTree = "<group>"; };
048680DD1D8E2BA9004B011E /* TZStackViewAlignment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TZStackViewAlignment.swift; sourceTree = "<group>"; };
048680DE1D8E2BA9004B011E /* TZStackViewDistribution.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TZStackViewDistribution.swift; sourceTree = "<group>"; };
45DD8E40268B452200C85E3D /* UILayoutPriority.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UILayoutPriority.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -185,6 +187,7 @@
048680D81D8E2BA9004B011E /* PageItemView.swift */,
048680D91D8E2BA9004B011E /* PageView.swift */,
048680DA1D8E2BA9004B011E /* TZStackView */,
45DD8E40268B452200C85E3D /* UILayoutPriority.swift */,
);
name = Source;
path = ../../Source;
Expand Down Expand Up @@ -269,6 +272,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand Down Expand Up @@ -315,6 +319,7 @@
048680E11D8E2BA9004B011E /* CompletionObject.swift in Sources */,
048680E31D8E2BA9004B011E /* OnboardingView.swift in Sources */,
048680E21D8E2BA9004B011E /* OnboardingConfiguration.swift in Sources */,
45DD8E41268B452200C85E3D /* UILayoutPriority.swift in Sources */,
048680E61D8E2BA9004B011E /* PageControlView.swift in Sources */,
048680DF1D8E2BA9004B011E /* Anchor.swift in Sources */,
048680671D8E204C004B011E /* AppDelegate.swift in Sources */,
Expand Down Expand Up @@ -462,7 +467,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.athlee.OnboardingKit-Swift3";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -476,7 +481,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.athlee.OnboardingKit-Swift3";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
27 changes: 0 additions & 27 deletions OnboardingKit.podspec

This file was deleted.

31 changes: 31 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "OnboardingKit",
platforms: [
.iOS(.v13)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "OnboardingKit",
targets: ["OnboardingKit"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "OnboardingKit",
dependencies: []),
.testTarget(
name: "OnboardingKitTests",
dependencies: ["OnboardingKit"]),
]
)
100 changes: 1 addition & 99 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,101 +1,3 @@
# OnboardingKit

<p align="center">
<img src ="https://raw.githubusercontent.com/Athlee/OnboardingKit/master/Assets/onboardingdemox1.png" />
</p>

`OnboardingKit` is a simple and interactive framework for making iOS onboarding experience easy and fun!

### Requirements
- Swift 3 & Xcode 8.x.x (check out v0.0.3 & [swift2](https://github.com/Athlee/OnboardingKit/tree/swift2) branch for previous version)
- iOS 8+

### Features
- [x] Customizable page views
- [x] Customizable background images
- [x] Customizable containers' background images
- [x] Animatable page control
- [x] Animatable transitions between pages on swipes

# Installation
### CocoaPods

`OnboardingKit` is available for installation using the [CocoaPods](https://cocoapods.org).

Add the following code to your `Podfile`:
```ruby
pod 'OnboardingKit'
```

# Usage
Import the module.

```swift
import OnboardingKit
```

Add a `UIView` instance that inherits from `OnboardingView`. Traditionally, you do this through Storyboard or manually.

Implement `OnboardingViewDataSource` and `OnboardingViewDelegate` protocols with required methods. What you have to do is to let `OnboardingView` know how many pages it should build and provide configurations for these pages.

```swift
extension DataModel: OnboardingViewDataSource, OnboardingViewDelegate {
func numberOfPages() -> Int {
return 1
}

func onboardingView(_ onboardingView: OnboardingView, configurationForPage page: Int) -> OnboardingConfiguration {
return OnboardingConfiguration(
image: UIImage(named: "DemoImage")!,
itemImage: UIImage(named: "DemoIcon")!,
pageTitle: "Demo Title",
pageDescription: "Demo Description Text!",
backgroundImage: UIImage(named: "DemoBackground"),
topBackgroundImage: nil, // your image here
bottomBackgroundImage: nil // your image here
)
}
```

`OnboardingConfiguration` is implemented this way:

```swift
public struct OnboardingConfiguration {
let image: UIImage
let itemImage: UIImage
let pageTitle: String
let pageDescription: String

let backgroundImage: UIImage?
let topBackgroundImage: UIImage?
let bottomBackgroundImage: UIImage?
}
```

If you need a custom configuration for a `PageView` this is possible with a delegate's method `onboardingView(_:, configurePageView _:, atPage _:)`.

```swift
func onboardingView(_ onboardingView: OnboardingView, configurePageView pageView: PageView, atPage page: Int) {
pageView.titleLabel.textColor = UIColor.white
pageView.titleLabel.layer.shadowOpacity = 0.6
pageView.titleLabel.layer.shadowColor = UIColor.black.cgColor
pageView.titleLabel.layer.shadowOffset = CGSize(width: 0, height: 1)
pageView.titleLabel.layer.shouldRasterize = true
pageView.titleLabel.layer.rasterizationScale = UIScreen.main.scale

if DeviceTarget.IS_IPHONE_4 {
pageView.titleLabel.font = UIFont.boldSystemFont(ofSize: 30)
pageView.descriptionLabel.font = UIFont.systemFont(ofSize: 15)
}
}
```

That's it. :]

# Community
* For help & feedback please use [issues](https://github.com/Athlee/OnboardingKit/issues).
* Got a new feature? Please submit a [pull request](https://github.com/Athlee/OnboardingKit/pulls).
* Email us with urgent queries.

# License
`OnboardingKit` is available under the MIT license, see the [LICENSE](https://github.com/Athlee/OnboardingKit/blob/master/LICENSE) file for more information.
A description of this package.
Binary file removed Source/.DS_Store
Binary file not shown.
Binary file removed Source/TZStackView/.DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions Source/Anchor.swift → Sources/OnboardingKit/Anchor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ public struct Anchors {
open class LayoutAnchor {

internal var item:View
internal var attribute:NSLayoutAttribute
internal var attribute:NSLayoutConstraint.Attribute

internal init(item:View, attribute:NSLayoutAttribute) {
internal init(item:View, attribute:NSLayoutConstraint.Attribute) {
self.item = item
self.attribute = attribute
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal protocol Completion {
}

internal final class CompletionObject: Completion {
internal var completion: ((Void) -> Void)?
internal var completion: (() -> ())?

internal static let sharedInstance = CompletionObject()

Expand Down
3 changes: 3 additions & 0 deletions Sources/OnboardingKit/OnboardingKit.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
struct OnboardingKit {
var text = "Hello, World!"
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ public final class OnboardingView: UIView, CAAnimationDelegate {
addGestureRecognizer(rightSwipeRecognizer)
}

internal func didRecognizeSwipe(_ recognizer: UISwipeGestureRecognizer) {
@objc internal func didRecognizeSwipe(_ recognizer: UISwipeGestureRecognizer) {
switch recognizer.direction {
case UISwipeGestureRecognizerDirection.left:
case UISwipeGestureRecognizer.Direction.left:
guard pageControlView.currentPage + 1 < pageControlView.pages else {
return
}
Expand All @@ -192,7 +192,7 @@ public final class OnboardingView: UIView, CAAnimationDelegate {
animateSubviews(current)
animatePageView(previous, forState: .fadeIn)

case UISwipeGestureRecognizerDirection.right:
case UISwipeGestureRecognizer.Direction.right:
guard pageControlView.currentPage - 1 >= 0 else {
return
}
Expand Down Expand Up @@ -279,7 +279,7 @@ public final class OnboardingView: UIView, CAAnimationDelegate {
arcCenter: center,
radius: state == .expanded ? frame.height * 2 : 0.1,
startAngle: 0,
endAngle: CGFloat(M_PI) * 2,
endAngle: CGFloat(Double.pi) * 2,
clockwise: false
)
}
Expand All @@ -290,15 +290,15 @@ public final class OnboardingView: UIView, CAAnimationDelegate {
pageView.layer.mask = shape
}

func animatePageView(_ pageView: PageView, forState state: State, completion: ((Void) -> Void)? = nil) {
func animatePageView(_ pageView: PageView, forState state: State, completion: (() -> ())? = nil) {
if state == .expanded || state == .folded {
if let shapeLayer = pageView.layer.mask as? CAShapeLayer {
let animation = CABasicAnimation(keyPath: "path")
animation.toValue = pathForState(state).cgPath
animation.duration = 0.7
animation.isRemovedOnCompletion = false
animation.fillMode = kCAFillModeBoth
animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseIn)
animation.fillMode = CAMediaTimingFillMode.both
animation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeIn)

if let completion = completion {
animation.delegate = self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public final class PageItemView: UIView {
UIView.animate(
withDuration: 0.5,
delay: 0,
options: UIViewAnimationOptions(),
options: UIView.AnimationOptions(),
animations: animations,
completion: nil
)
Expand All @@ -97,7 +97,7 @@ public final class PageItemView: UIView {
UIView.animate(
withDuration: 0.5,
delay: 0,
options: UIViewAnimationOptions(),
options: UIView.AnimationOptions(),
animations: animations,
completion: nil
)
Expand Down
File renamed without changes.
Loading