From 2fa21299142fd3b82df13beacba898282c2a824f Mon Sep 17 00:00:00 2001 From: Nicolai Harbo Date: Wed, 17 Apr 2019 12:58:41 +0200 Subject: [PATCH 1/3] Update README.md --- README.md | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 591a13f..0996315 100644 --- a/README.md +++ b/README.md @@ -52,18 +52,9 @@ To be able to get the Reachability banner on top of your views, in your `AppDele ```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 @@ -91,6 +82,31 @@ func subscribe() { ``` +#### Change configurations if needed +```swift + + let configuration = ReachabilityConfiguration(title: "Connected", + noConnectionTitle: "No Connection", + options: [.appearance : ReachabilityConfiguration.Appearance.bottom, + .appearanceAdjustment : CGFloat(-100), + .animation : ReachabilityConfiguration.Animation.slideAndFadeInOutFromBottom]) + +``` + +The following options can be set: +* titleColor //Has to be of type UIColor +* noConnectionTitleColor //Has to be of type UIColor +* noConnectionBackgroundColor //Has to be of type UIColor +* backgroundColor //Has to be of type UIColor +* height //Has to be of type CGFloat +* font //Has to be of type UIFont +* textAlignment //Has to be of type NSTextAlignment +* animation //Has to be of type ReachabilityConfiguration.Animation +* appearance //Has to be of type ReachabilityConfiguration.Appearance +* appearanceAdjustment //Has to be of type 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). From 9ec9aa3743355ce265f2798a7c2bee7cb503f6d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20B=C3=B8dskov?= Date: Thu, 18 Apr 2019 15:33:46 +0200 Subject: [PATCH 2/3] updates to README --- README.md | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 0996315..1f3ce36 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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: @@ -45,16 +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(title: "Connected", - noConnectionTitle: "No Connection", - options: nil) + noConnectionTitle: "No Connection", + options: nil) // create the ReachabilityCoordinator and pass it along the previously // created ReachabilityConfiguration together with the ReachabilityListenerFactoryProtocol @@ -68,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! @@ -93,17 +96,17 @@ func subscribe() { ``` -The following options can be set: -* titleColor //Has to be of type UIColor -* noConnectionTitleColor //Has to be of type UIColor -* noConnectionBackgroundColor //Has to be of type UIColor -* backgroundColor //Has to be of type UIColor -* height //Has to be of type CGFloat -* font //Has to be of type UIFont -* textAlignment //Has to be of type NSTextAlignment -* animation //Has to be of type ReachabilityConfiguration.Animation -* appearance //Has to be of type ReachabilityConfiguration.Appearance -* appearanceAdjustment //Has to be of type CGFloat +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. From f75d2fe7ec4fcbf3f2c9312ac667d7fded3d6bf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20B=C3=B8dskov?= Date: Thu, 18 Apr 2019 15:39:26 +0200 Subject: [PATCH 3/3] changes to readme --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1f3ce36..fef7582 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,8 @@ func subscribe() { ``` -#### Change configurations if needed +#### Change Configurations +You can change the various options in the `ReachabilityConfiguration` to tailor the component to your needs. ```swift let configuration = ReachabilityConfiguration(title: "Connected",