Skip to content

Commit

Permalink
release version 2.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
ledgecrucible committed Sep 5, 2019
1 parent 2b1e5b4 commit ef62048
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 8 deletions.
4 changes: 2 additions & 2 deletions AptoUISDK.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

Pod::Spec.new do |s|
s.name = "AptoUISDK"
s.version = "2.0.8"
s.version = "2.0.9"
s.summary = "The Apto UI platform iOS SDK."
s.description = <<-DESC
Apto iOS UI SDK
DESC
s.homepage = "https://github.com/ShiftFinancial/apto-ui-sdk-ios.git"
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.authors = { "Ivan Oliver" => "ivan@aptopayments.com", "Takeichi Kanzaki" => "takeichi@aptopayments.com" }
s.source = { :git => "https://github.com/ShiftFinancial/apto-ui-sdk-ios.git", :tag => "2.0.8" }
s.source = { :git => "https://github.com/ShiftFinancial/apto-ui-sdk-ios.git", :tag => "2.0.9" }

s.platform = :ios
s.ios.deployment_target = '10.0'
Expand Down
2 changes: 1 addition & 1 deletion Example/Demo/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>BuildDate</key>
<date>2019-09-02T13:55:21Z</date>
<date>2019-09-05T18:51:56Z</date>
<key>BuildType</key>
<string>Local</string>
<key>CFBundleDevelopmentRegion</key>
Expand Down
53 changes: 53 additions & 0 deletions Example/UnitTests/ledgefoundation/Manager/AptoPlatformUITest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import AptoSDK
@testable import AptoUISDK

class AptoPlatformUITest: XCTestCase {

// SUT
private var sut: AptoPlatform = AptoPlatform.defaultManager()
// Collaborators
private let uiDelegate = AptoPlatformUIDelegateSpy()

func test() {
// Given
Expand All @@ -22,4 +26,53 @@ class AptoPlatformUITest: XCTestCase {
// Then
XCTAssertEqual(googleMapsApiKey, sut.googleMapsApiKey)
}

func testUIDelegateCalledWhenNoNetworkDetected() {
// Given
sut.uiDelegate = uiDelegate

// When
NotificationCenter.default.post(Notification(name: .NetworkNotReachableNotification))

// Then
XCTAssertTrue(uiDelegate.shouldShowNoNetworkUICalled)
}

func testUIDelegateCalledWhenNetworkRecovered() {
// Given
sut.uiDelegate = uiDelegate

// When
NotificationCenter.default.post(Notification(name: .NetworkReachableNotification))

// Then
XCTAssertTrue(uiDelegate.shouldShowNoNetworkUICalled)
}

func testUIDelegateCalledWhenServerMaintenanceDetected() {
// Given
sut.uiDelegate = uiDelegate

// When
NotificationCenter.default.post(Notification(name: .ServerMaintenanceNotification))

// Then
XCTAssertTrue(uiDelegate.shouldShowServerMaintenanceUICalled)
}
}

private class AptoPlatformUIDelegateSpy: AptoPlatformUIDelegate {
var uiDelegate: AptoPlatformUIDelegate?

private(set) var shouldShowNoNetworkUICalled = false
func shouldShowNoNetworkUI() -> Bool {
shouldShowNoNetworkUICalled = true
return true
}

private(set) var shouldShowServerMaintenanceUICalled = false
func shouldShowServerMaintenanceUI() -> Bool {
shouldShowServerMaintenanceUICalled = true
return true
}
}
12 changes: 12 additions & 0 deletions Pod/Classes/ui/AptoPlatformUI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import AptoSDK
// Extensions do not allow properties, instead of getting crazy with associated objects we create private propeties.
// This properties are made lazy by the compiler.
private var _initialModule: UIModuleProtocol? = nil
private var _uiDelegate: AptoPlatformUIDelegate? = nil
private let lockingQueue = DispatchQueue(label: "com.aptotpayments.ios.sdk.locking")
private var isPresentingNetworkNotReachable = false
private var fontRegistered = false
Expand All @@ -33,6 +34,14 @@ extension AptoPlatform {
_initialModule = newValue
}
}
public var uiDelegate: AptoPlatformUIDelegate? {
get {
return _uiDelegate
}
set {
_uiDelegate = newValue
}
}

public func startCardFlow(from: UIViewController, mode: ShiftCardModuleMode, initialUserData: DataPointList? = nil,
options: CardOptions? = nil, googleMapsApiKey: String? = nil,
Expand Down Expand Up @@ -102,6 +111,7 @@ extension AptoPlatform {
// MARK: Network connection error

@objc private func didRestoreNetworkConnectionUI() {
if uiDelegate?.shouldShowNoNetworkUI?() == false { return }
dismissNetworkNotReachableError()
}

Expand All @@ -113,6 +123,7 @@ extension AptoPlatform {
}

@objc private func didLoseNetworkConnectionUI() {
if uiDelegate?.shouldShowNoNetworkUI?() == false { return }
presentNetworkNotReachableError()
}

Expand All @@ -131,6 +142,7 @@ extension AptoPlatform {
}

@objc private func didLoseConnectionToServerUI() {
if uiDelegate?.shouldShowServerMaintenanceUI?() == false { return }
presentServerMaintenanceError()
}

Expand Down
23 changes: 23 additions & 0 deletions Pod/Classes/ui/AptoPlatformUIProtocol.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// AptoPlatformUIProtocol.swift
// AptoSDK
//
// Created by Ivan Oliver Martínez on 04/09/2019.
//

import Foundation

@objc public protocol AptoPlatformUIDelegate {
/**
* Called when a no network situation is detected, to ask the delegate if the UI SDK should show specific UI
* to explain the user that the network is not available. Used too when the network is restored to know if the
* UI SDK should dismiss the No network UI.
*/
@objc optional func shouldShowNoNetworkUI() -> Bool

/**
* Called when a network request fails because our server is not available, to ask the delegate if the UI SDK should
* show specific UI to explain the user that the server is in maintenance mode.
*/
@objc optional func shouldShowServerMaintenanceUI() -> Bool
}
5 changes: 0 additions & 5 deletions Pod/Classes/ui/UIKit/Base/UILabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
import Foundation

extension UILabel {
override open func layoutSubviews() {
super.layoutSubviews()
self.preferredMaxLayoutWidth = self.bounds.size.width
}

func updateAttributedText(_ text: String?) {
guard let text = text else {
self.text = ""
Expand Down

0 comments on commit ef62048

Please sign in to comment.