Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/GitHub/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
peppesapienza committed Oct 30, 2019
2 parents cc78985 + 9d87d93 commit 71bccf1
Showing 1 changed file with 57 additions and 58 deletions.
115 changes: 57 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

Rockert Alert resolve the problem of being distracted by a boring AlertView with a user-friendly boarding process similar to a Chat Bot.

![alt text](https://media.giphy.com/media/5QLxkjz2nq5cHBENqr/giphy.gif)![alt text](https://media.giphy.com/media/9u15NC295RsZIKCDWj/giphy.gif)
![alt text](https://media.giphy.com/media/LT7FHIDeQCiFxZy0yW/giphy.gif)
![alt text](https://media.giphy.com/media/SUusanPotO5KePn78W/giphy.gif)

Would you like to improve your User Experience's while asking user to do some action?

With a modern style and a powerful personalization RocketAlert could help you to increase your conversion rate.
With a modern style and a powerful personalization RocketAlert will help you to increase your conversion rate.

- [Installation](./README.md#installation)
- [Communication](./README.md#communication)
Expand Down Expand Up @@ -37,7 +38,7 @@ platform :ios, '10.0'
use_frameworks!
target '<Your Target Name>' do
pod 'RocketAlert', '1.0-beta.2'
pod 'RocketAlert', '1.0-beta.3'
end
```

Expand All @@ -50,21 +51,21 @@ $ pod install
## Communication

- If you need help, use [Stack Overflow](https://stackoverflow.com/questions/tagged/rocketalert). (Tag 'rocketalert')
- If you found a bug or you have a feature request open an issue.
- If you find a bug or you have a feature request open an issue.
- If **you are an :it: iOS Italian Developer follow us** on [Slack](https://www.xcoding.it/community) or [Facebook Group](https://www.facebook.com/groups/mobile.developers.it)
- If you want to contribute, submit a pull request.


## Usage

**You can instantiate a `Rocket` by passing to his parameters a `RocketAuthor` and a `RocketBlock` object.** After that, you can **present the `Rocket` by performing the method `show()`**:
**You can instantiate a `Rocket` by passing to its parameters a `RocketAuthor` and a `RocketBlock` object.** After that, you can **present the `Rocket` by performing the method `show()`**:

```swift
import RocketAlert

let author = RocketAuthor.init(image: yourUIImage, style: RocketImageStyle.round)
let textBlock = TextRocketBlock.init(text: "This is your first Block")
let rocket = Rocket.init(author: author, block: textBlock)
let author = RocketAuthor(image: yourUIImage, style: RocketImageStyle.round)
let textBlock = TextRocketBlock(text: "This is your first Block")
let rocket = Rocket(author: author, block: textBlock)

rocket.show()
```
Expand All @@ -77,9 +78,9 @@ rocket.dismiss()

## RocketBlock

**`RocketBlock` is a container of data and functionality** and under the hood `RocketBlock` is nothing else a simple `UITableViewCell`.
**`RocketBlock` is a container of data and functionality** and under the hood `RocketBlock` is nothing else than a simple `UITableViewCell`.

**Depends on block type a user can interact with a block by *Tap*, *Control Events*** (for example button click) **and *Input Events*** (at the moment only text input). **After an event `Rocket` could show the next block** that has been attached to the interacted block.
**Depends on block type a user can interact with a block by *Tap*, *Control Events*** (for example button click) **and *Input Events*** (at the moment only text input). **After an event `Rocket` can show the next block** that has been attached to the interacted block.

**`RocketBlock` is a protocol that gives to all blocks a `var id: String? {get set}` property** (created to be used in some advanced circumstances). There is also a `var cellIdentifier: String {get}` which is used internally to match the block with a reusable cell.

Expand All @@ -90,14 +91,14 @@ public protocol RocketBlock {
}
```

**The `RocketBlock` protocol is never used as the base protocol of the implemented class.** Instead, you will use the inherited protocols that give to the blocks some useful stuff.
**The `RocketBlock` protocol is never used as the base protocol of the implemented class.** However, you will use the inherited protocols that give the blocks some useful stuff.

**IMPORTANT:** When a next block has been presented the interaction over the previous block will be disabled.
**IMPORTANT:** When a next block has been presented, the interaction over the previous block will be disabled.


## TappableRocketBlock

The `TappableRocketBlock` is an inherited protocol from `RocketBlock`. The `TappableRocketBlock` protocol describes the block that could be tapped by the user. He gives to the implemented class two properties:
The `TappableRocketBlock` is an inherited protocol of `RocketBlock`. The `TappableRocketBlock` protocol describes the block that can be tapped by the user. It gives to the implemented class two properties:

```swift
protocol TappableRocketBlock: RocketBlock {
Expand All @@ -106,7 +107,7 @@ protocol TappableRocketBlock: RocketBlock {
}
```

1. The `next` property represents the next `RocketBlock` that will be shown after the tap.
1. The `next` property represent the next `RocketBlock` that will be shown after the tap.
2. The `showNextAfter` property allows the next block, if presented, to be shown automatically after an amount of time. If you provide a value the `TapGestureRecognizer` will be disabled.


Expand All @@ -125,22 +126,22 @@ TextRocketBlock.init(text: String, next: RocketBlock? = nil, showNextAfter: Time
And you can use it like that:

```swift
let secondBlock = TextRocketBlock.init(text: "This is your second block")
let firstBlock = TextRocketBlock.init(text: "This is your first block", next: secondBlock)
let secondBlock = TextRocketBlock(text: "This is your second block")
let firstBlock = TextRocketBlock(text: "This is your first block", next: secondBlock)

let rocket = Rocket.init(author: author, block: firstBlock)
let rocket = Rocket(author: author, block: firstBlock)
rocket.show()
```
The `secondBlock` will be presented after the tap on the `firstBlock`. Note that I passed the `firstBlock` to the `rocket`.
The `secondBlock` will be presented after the tap on the `firstBlock`. Pay attention that I passed the `firstBlock` to the `rocket block` parameter.

#### Flat style

Use this style when you have a lot of blocks and you want maintain your code clear:
Use this style when you have a lot of blocks and you want to maintain your code clear:

```swift
let firstBlock = TextRocketBlock.init(text: "First")
let secondBlock = TextRocketBlock.init(text: "Second")
let thirdBlock = TextRocketBlock.init(text: "Third")
let firstBlock = TextRocketBlock(text: "First")
let secondBlock = TextRocketBlock(text: "Second")
let thirdBlock = TextRocketBlock(text: "Third")

firstBlock.next = second

Expand All @@ -151,8 +152,8 @@ secondBlock.font = RocketFont.textBold
#### `showNextAfter` property

```swift
let firstBlock = TextRocketBlock.init(text: "First")
let secondBlock = TextRocketBlock.init(text: "Second")
let firstBlock = TextRocketBlock(text: "First")
let secondBlock = TextRocketBlock(text: "Second")

firstBlock.next = second
firstBlock.showNextAfter = 2.0
Expand All @@ -170,8 +171,8 @@ The `thirdBlock` will be shown automatically after 2.0 seconds and after the `se
You can change the `UIFont` by providing a `RocketFont` object to the `font` property.

```swift
let firstBlock = TextRocketBlock.init(text: "First", next: secondBlock)
firstBlock.font = RocketFont.init(font: UIFont, color: UIColor)
let firstBlock = TextRocketBlock(text: "First", next: secondBlock)
firstBlock.font = RocketFont(font: UIFont, color: UIColor)
// or
firstBlock.font = RocketFont.text // the default
```
Expand All @@ -189,16 +190,16 @@ block.font = RocketFont.cancel

### ImageRocketBlock

**You can use `ImageRocketBlock` object to show an Image with or without text.** The **`ImageRocketBlock` is a subclass of `TextRocketBlock`** class, so you can editing the same properties.
**You can use `ImageRocketBlock` object to show an Image with or without text.** The **`ImageRocketBlock` is a subclass of the `TextRocketBlock`** one, so you can edit the same properties.

You can create an `ImageRocketBlock` by using one of these init:
You can instatiate an `ImageRocketBlock` by using one of these init:

```swift
ImageRocketBlock.init(image: UIImage, text: String?)
ImageRocketBlock.init(image: UIImage, text: String?, next: RocketBlock?, showNextAfter: TimeInterval?, id: String?)
```

**You can add a padding to the internal `ImageView`** by editing the properties `paddingLeft` and `paddingRight`. **The default padding value is 0**:
**You can add a padding to the internal `ImageView`** by changing the properties `paddingLeft` and `paddingRight`. **The default padding value is 0**:

```
imageBlock.paddingLeft = 10
Expand All @@ -216,11 +217,11 @@ imageBlock.imageStyle = .square

## ControlRocketBlock

The `ControlRocketBlock` is an inherited protocol from `RocketBlock`. The `ControlRocketBlock` protocol describes the interactable blocks.
The `ControlRocketBlock` is an inherited protocol of `RocketBlock`. The `ControlRocketBlock` protocol describes the interactable blocks.

### ButtonRocketBlock

**Use `ButtonRocketBlock` object to show a single button.** You can't define a `next`block directly. **Instead you need to provide a `TapRocketHandler` that let you define a custom action and the next block** that will be fired after the `TouchUpInside` event.
**Use `ButtonRocketBlock` object to show a single button.** Inside the init you won't be able to define a `next` block directly. **However, you'll need to provide a `TapRocketHandler` object which will let you define a custom action and the next block** (it will be fired after the `TouchUpInside` event).

You can create a `ButtonRocketBlock` using one of these init:

Expand All @@ -234,41 +235,39 @@ The default `RocketFont` is `.button`.
#### `TapRocketHandler`

```swift
let button = ButtonRocketBlock.init(title: "PRESS THERE")
let afterTheTapOnButton = TextRocketBlock.init(text: "You press the button!!")
let button = ButtonRocketBlock(title: "PRESS HERE")
let afterTheTapOnButton = TextRocketBlock(text: "You press the button!!")

button.tapHandler = TapRocketHandler.init(next: afterTheTapOnButton, action: {
button.tapHandler = TapRocketHandler(next: afterTheTapOnButton, action: {
print("the user click the button")

UNUserNotificationCenter.current().requestAuthorization(options:[.badge, .alert, .sound]) { (granted, error) in

}
})

let rocket = Rocket.init(author: author, block: button)
let rocket = Rocket(author: author, block: button)
rocket.show()
```
![alt text](https://media.giphy.com/media/wHf4k5qvG6bz8XvP7f/giphy.gif)


### DoubleButtonRocketBlock

**Use the `DoubleButtonRocketBlock` when you want to show two options.** You can initialize a `DoubleButtonRocketBlock` passing to it init two `ButtonRocketBlock`. It's important to know that **when a user taps to one of the buttons the touch over the block will be disabled.**
**Use the `DoubleButtonRocketBlock` whenever you want to show two options.** You can initialize a `DoubleButtonRocketBlock` passing to its init two `ButtonRocketBlock`. It's important to know that **the touch over the block will be disabled when a user taps to one of the buttons.**

```swift
let leftButton = ButtonRocketBlock.init(title: "Left Button")
let leftButton = ButtonRocketBlock(title: "Left Button")
leftButton.font = .button // the default

let rightButton = ButtonRocketBlock.init(title: "Right Button")
let rightButton = ButtonRocketBlock(title: "Right Button")
rightButton.font = .lightButton
rightButton.tapHandler = // remember to set a tapHandler if you want to show a block or if you want perform an action

let doubleButton = DoubleButtonRocketBlock.init(left: leftButton, right: rightButton)
let doubleButton = DoubleButtonRocketBlock(left: leftButton, right: rightButton)
```

## InputRocketBlock

The `InputRocketBlock` is an inherited protocol from `RocketBlock`. **The `InputRocketBlock` protocol describes the block that has an input field.** He gives to the implemented class an `InputRocketHandler<InputType>` properties:
The `InputRocketBlock` is an inherited protocol of `RocketBlock`. **The `InputRocketBlock` protocol describes the block that has an input field.** It gives to the implemented class an `InputRocketHandler<InputType>` properties:

```swift
protocol InputRocketBlock: RocketBlock {
Expand All @@ -291,43 +290,43 @@ public struct InputRocketHandler<T> {

### TextInputRocketBlock

**Use the `TextInputRocketBlock` when you want to ask the user to enter some String information.** The `TextInputRocketBlock` is an implemented class of the `InputRocketBlock` protocol.
**Use the `TextInputRocketBlock` whenever you want to ask the user to enter some String information.** The `TextInputRocketBlock` is an implemented class of the `InputRocketBlock` protocol.

You can create a `TextInputRocketBlock` by using one of these init:

```swift
TextInputRocketBlock.init(text: String, buttonTitle: String)
TextInputRocketBlock.init(text: text, buttonTitle: buttonTitle, inputHandler: InputRocketHandler<String>?)
TextInputRocketBlock.init(text: String, buttonTitle: String, inputHandler: InputRocketHandler<String>?)
TextInputRocketBlock.init(text: String, buttonTitle: String, inputHandler: InputRocketHandler<String>?, id: String? = nil, font: RocketFont? = RocketFont.text, buttonStyle: RocketFont? = RocketFont.lightButton)
```

In it basic form you can use it like that:
This is an easy way you can use it:

```swift
let input = TextInputRocketBlock.init(text: "Describe your problem:", buttonTitle: "Send")
let input = TextInputRocketBlock(text: "Describe your problem:", buttonTitle: "Send")

input.handler = InputRocketHandler<String>.init(action: { (input) -> RocketBlock? in
return TextRocketBlock.init(text: "Thanks you so much!")
input.handler = InputRocketHandler<String>(action: { (input) -> RocketBlock? in
return TextRocketBlock(text: "Thanks you so much!")
})
```

#### Return different blocks

If you want to handle differently the user's input, **you can return a different block based on the value of the `InputRocketHandler`:**
If you want to handle the user's input in a different way, **you can return a block based on the value of the `InputRocketHandler`:**

```swift
let input = TextInputRocketBlock.init(text: "Describe your problem:", buttonTitle: "Send")
let input = TextInputRocketBlock(text: "Describe your problem:", buttonTitle: "Send")

input.handler = InputRocketHandler<String>.init(action: { (input) -> RocketBlock? in
input.handler = InputRocketHandler<String>(action: { (input) -> RocketBlock? in
if (input.isEmpty) {
return TextRocketBlock.init(text: "Why haven't added a text? :(")
return TextRocketBlock(text: "Why haven't added a text? :(")
}

if (input == "SecretKey") {
return TextRocketBlock.init(text: "Awesome!! you know the secret key")
return TextRocketBlock(text: "Awesome!! you know the secret key")
}

let block = TextRocketBlock.init(text: "Thanks you so much!")
let block = TextRocketBlock(text: "Thanks you so much!")
/* you can concatenate more blocks if you want */
return block
})
Expand All @@ -337,12 +336,12 @@ input.handler = InputRocketHandler<String>.init(action: { (input) -> RocketBlock

### rocketBlockAddedEvent

**You can subscribe your object as observers of the `Notification.Name.rocketBlockAddedEvent`.** This event will be fired after a block is displayed on the screen.
**You can subscribe your objects at `Notification.Name.rocketBlockAddedEvent`.** to perform some custom actions. This event will be fired after a block is displayed on the screen.

The `userInfo` bring with itself the `index` and the `block` presented.
The `userInfo` will bring with itself the `index` and the `block` presented.

```swift
// subscribe to the Notification.Name.addedNewRocketBlock
// subscribe to the Notification.Name.rocketBlockAddedEvent
NotificationCenter
.default
.addObserver(self,
Expand All @@ -364,7 +363,7 @@ NotificationCenter

### rocketDismissEvent

**`rocketDismissEvent` will be fired when rocket is dismissed** (after the last block or after click to the close button). Inside the `userInfo` you will find the `count` of all blocks displayed and the `blocks` array:
**`rocketDismissEvent` will be fired when rocket is dismissed** (after the last block or after clicking to the close button). Inside the `userInfo` you will find the `count` of all blocks displayed and the `blocks` array:

```swift
NotificationCenter
Expand Down

0 comments on commit 71bccf1

Please sign in to comment.