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 #10 from nodes-ios/issue/appearence
Browse files Browse the repository at this point in the history
Added ability to place toastview top, center or bottom, plus possibility for adjustments
  • Loading branch information
pbodsk authored May 3, 2019
2 parents 8d8a5be + 650ec0e commit 88abb08
Show file tree
Hide file tree
Showing 48 changed files with 616 additions and 824 deletions.
Binary file added ReachabilityUI/.DS_Store
Binary file not shown.
Binary file modified ReachabilityUI/ReachabilityUI.framework.zip
Binary file not shown.
361 changes: 361 additions & 0 deletions ReachabilityUI/ReachabilityUI.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Binary file added ReachabilityUI/ReachabilityUI/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ public class ReachabilityCoordinator {
/// - dependencies
/// - height of the UIViewController. Default value is 30
///
public init(window: UIWindow, reachabilityListenerFactory: ReachabilityListenerFactoryProtocol, hasNavigationBar: Bool = true, configuration: ReachabilityConfiguration) {
public init(window: UIWindow,
reachabilityListenerFactory: ReachabilityListenerFactoryProtocol,
hasNavigationBar: Bool = true,
configuration: ReachabilityConfiguration) {

self.window = window
self.hasNavigationBar = hasNavigationBar
self.reachabilityListenerFactory = reachabilityListenerFactory
Expand Down
132 changes: 98 additions & 34 deletions ReachabilityUI/ReachabilityUI/Reachability/ReachabilityModels.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,51 +23,115 @@ extension Reachability.ReachabilityListener {
}
}


public struct ReachabilityConfiguration {
let noConnectionTitle: String
let noConnectionTitleColor: UIColor
let noConnectionBackgroundColor: UIColor
let title: String
let titleColor: UIColor
let backgroundColor: UIColor
let height: CGFloat
let font: UIFont
let textAlignment: NSTextAlignment
let animation: Animation
let noConnectionTitle: String
let options: [ReachabilityConfiguration.Key : Any]
let defaultOptionsDict: [ReachabilityConfiguration.Key : Any] = [.titleColor : UIColor.white,
.noConnectionTitleColor : UIColor.white,
.noConnectionBackgroundColor : UIColor.red.withAlphaComponent(0.6),
.backgroundColor : UIColor.green.withAlphaComponent(0.6),
.height : CGFloat(30),
.font : UIFont.systemFont(ofSize: 12),
.textAlignment: NSTextAlignment.center,
.animation : Animation.fadeInOut,
.appearance : Appearance.top,
.appearanceAdjustment : CGFloat(0)]

public init(noConnectionTitle: String,
noConnectionTitleColor: UIColor,
noConnectionBackgroundColor: UIColor,
title: String,
titleColor: UIColor,
backgroundColor: UIColor,
height: CGFloat,
font: UIFont,
textAlignment: NSTextAlignment,
animation: Animation) {
self.noConnectionTitle = noConnectionTitle
self.noConnectionTitleColor = noConnectionTitleColor
self.noConnectionBackgroundColor = noConnectionBackgroundColor
public init(title: String, noConnectionTitle: String, options: [ReachabilityConfiguration.Key : Any]?) {
self.title = title
self.titleColor = titleColor
self.backgroundColor = backgroundColor
self.height = height
self.font = font
self.textAlignment = textAlignment
self.animation = animation
self.noConnectionTitle = noConnectionTitle

var finalOptionsDict = defaultOptionsDict

if let options = options {
//titleColor
if let titleColor = options[.titleColor] as? UIColor {
finalOptionsDict[.titleColor] = titleColor
}

//noConnectionTitleColor
if let noConnectionTitleColor = options[.noConnectionTitleColor] as? UIColor {
finalOptionsDict[.noConnectionTitleColor] = noConnectionTitleColor
}

//noConnectionBackgroundColor
if let noConnectionBackgroundColor = options[.noConnectionBackgroundColor] as? UIColor {
finalOptionsDict[.noConnectionBackgroundColor] = noConnectionBackgroundColor
}

//backgroundColor
if let backgroundColor = options[.backgroundColor] as? UIColor {
finalOptionsDict[.backgroundColor] = backgroundColor
}

//height
if let height = options[.height] as? CGFloat {
finalOptionsDict[.height] = height
}

//font
if let font = options[.font] as? UIFont {
finalOptionsDict[.font] = font
}

//textAlignment
if let textAlignment = options[.textAlignment] as? NSTextAlignment {
finalOptionsDict[.textAlignment] = textAlignment
}

//animation
if let animation = options[.animation] as? Animation {
finalOptionsDict[.animation] = animation
}

//appearance
if let appearance = options[.appearance] as? Appearance {
finalOptionsDict[.appearance] = appearance
}

//appearanceAdjustment
if let appearanceAdjustment = options[.appearanceAdjustment] as? CGFloat {
finalOptionsDict[.appearanceAdjustment] = appearanceAdjustment
}
}

self.options = finalOptionsDict
}
}

extension ReachabilityConfiguration {

public enum Key: String {
case titleColor ///Has to be of type UIColor
case noConnectionTitleColor ///Has to be of type UIColor
case noConnectionBackgroundColor ///Has to be of type UIColor
case backgroundColor ///Has to be of type UIColor
case height ///Has to be of type CGFloat
case font ///Has to be of type UIFont
case textAlignment ///Has to be of type NSTextAlignment
case animation ///Has to be of type ReachabilityConfiguration.Animation
case appearance ///Has to be of type ReachabilityConfiguration.Appearance
case appearanceAdjustment ///Has to be of type CGFloat
}

public enum Animation {
/// the banner will appear/dissapear from the screen by changing the view's alpha value
/// the banner will appear/disappear from the screen by changing the view's alpha value
case fadeInOut
/// the banner will appear/dissapear from the screen by moving it's frame on and off the view
case slideInOut
/// the banner will appear/dissapear from the screen by moving it's frame on and off the view while simulatiously changing it's alpha values
case slideAndFadeInOut
/// the banner will appear/disappear from the screen by moving it's frame on and off the view from the top
case slideInOutFromTop
/// the banner will appear/disappear from the screen by moving it's frame on and off the view from the top, while simulatiously changing it's alpha values
case slideAndFadeInOutFromTop
/// the banner will appear/disappear from the screen by moving it's frame on and off the view from the bottom
case slideInOutFromBottom
/// the banner will appear/disappear from the screen by moving it's frame on and off the view from the bottom, while simulatiously changing it's alpha values
case slideAndFadeInOutFromBottom
}

public enum Appearance {
case top
case center
case bottom
}

}
Loading

0 comments on commit 88abb08

Please sign in to comment.