Skip to content
This repository has been archived by the owner on Mar 10, 2022. It is now read-only.

Commit

Permalink
Merge pull request #13 from nodes-ios/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
pbodsk authored May 3, 2019
2 parents b664e6e + 64dd34a commit c7600da
Show file tree
Hide file tree
Showing 50 changed files with 660 additions and 853 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ xcuserdata/
*.ipa
*.dSYM.zip
*.dSYM
.DS_Store

## Playgrounds
timeline.xctimeline
Expand Down
60 changes: 40 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/nodes-ios/Reachability-UI/blob/master/LICENSE)
### Intro

Demo Project + Framework showcasing the integration of the ReachabilityUI framework in a Nodes like VIPER architecture.
ReachabilityUI is a framework meant to help informing the user when an app loses connection to the internet.

With ReachabilityUI you can even register a `ReachabilityListener` instance that will allow you to get notified about the connection drop. This can be used to adjust your application's UI so that the content won't overlap the banner, or for any other action you might need to take when the connectivity drops.

Please refer to the demo project for a showcase on how to integrate the ReachabilityUI framework in a Nodes like VIPER architecture.

ReachabilityUI is a framework that is meant to help displaying the Network connection banner when the user loses connection to the internet in an app.
With ReachabilityUI you can even register a `ReachabilityListener` instance that will allow you to get notified about the connection drop. This can be used to adjust your application's UI so that the content won't overlap the banner, or for any other action you might need to take when the connectivy drops.

## 📝 Requirements

Expand All @@ -15,14 +17,14 @@ With ReachabilityUI you can even register a `ReachabilityListener` instance that

## 📦 Installation

### Carthage
### Carthage
~~~bash
github "nodes-ios/Reachability-UI"
~~~

## 💻 Usage

#### Initialise the ReachabilityUI dependencies
#### Initialize the ReachabilityUI Dependencies

Conform to `HasReachabilityListenerRepository` and create a `ReachabilityUIManager` instance:

Expand All @@ -45,25 +47,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
extension AppDelegate: HasReachabilityListenerRepository {}
```

#### Initialise the ReachabilityUI banner
#### Initialize the ReachabilityUI Banner

To be able to get the Reachability banner on top of your views, in your `AppDelegate.swift` you will need to add the following code snippet:
To enable the Reachability banner in your views, add the following code snippet to your `AppDelegate.swift`:

```swift
private func addReachability() {
// create a ReachabilityConfiguration instance
let configuration = ReachabilityConfiguration(
noConnectionTitle: "No Connection",
noConnectionTitleColor: .white,
noConnectionBackgroundColor: UIColor.red.withAlphaComponent(0.6),
title: "Connected",
titleColor: .white,
backgroundColor: UIColor.green.withAlphaComponent(0.6),
height: 30,
font: UIFont.systemFont(ofSize: 12),
textAlignment: .center,
animation: .fadeInOut)
)
let configuration = ReachabilityConfiguration(title: "Connected",
noConnectionTitle: "No Connection",
options: nil)

// create the ReachabilityCoordinator and pass it along the previously
// created ReachabilityConfiguration together with the ReachabilityListenerFactoryProtocol
Expand All @@ -77,7 +70,8 @@ private func addReachability() {
}
```

#### Subscribe to ReachabilityUI callback in order to get notified about the connectivity change and adjust your layout.
#### Listen for Reachability Changes
To get notified about connectivity changes you must create a `listener` and start listening in order to get notified about the connectivity changes.

```swift
private var listener: ReachabilityListenerProtocol!
Expand All @@ -91,6 +85,32 @@ func subscribe() {

```

#### Change Configurations
You can change the various options in the `ReachabilityConfiguration` to tailor the component to your needs.
```swift

let configuration = ReachabilityConfiguration(title: "Connected",
noConnectionTitle: "No Connection",
options: [.appearance : ReachabilityConfiguration.Appearance.bottom,
.appearanceAdjustment : CGFloat(-100),
.animation : ReachabilityConfiguration.Animation.slideAndFadeInOutFromBottom])

```

The following keys can be used in the `options` dictionary:
* `.titleColor` (must be a `UIColor`)
* `.noConnectionTitleColor` (must be a `UIColor`)
* `.noConnectionBackgroundColor` (must be a `UIColor`)
* `.backgroundColor` (must be a `UIColor`)
* `.height` (must be a `CGFloat`)
* `.font` (must be a `UIFont`)
* `.textAlignment` (must be a `NSTextAlignment`)
* `.animation` (must be a `ReachabilityConfiguration.Animation`)
* `.appearance` (must be a `ReachabilityConfiguration.Appearance`)
* `.appearanceAdjustment` (must be a `CGFloat`)

If options are set to `nil`, default options will be used. Any options set, will override the default state.

## 👥 Credits
Made with ❤️ at [Nodes](http://nodesagency.com).

Expand Down
Binary file added ReachabilityUI/.DS_Store
Binary file not shown.
Binary file modified ReachabilityUI/ReachabilityUI.framework.zip
Binary file not shown.
Loading

0 comments on commit c7600da

Please sign in to comment.