Skip to content

Commit 6dbcec8

Browse files
Merge pull request #338 from tradingticket/os/#156885801/makeUiConfigOptional
Make UiConfig (Branding) optional at the SDK level
2 parents 8a95214 + 34607fd commit 6dbcec8

8 files changed

+40
-24
lines changed

ExampleApp/ExampleViewController.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ class Action {
1313
init(
1414
label: String,
1515
action: @escaping () -> Void,
16-
oAuthCallbackUrl: String = "tradeItExampleScheme://completeOAuth"
16+
oAuthCallbackUrl: String = "tradeItExampleScheme://completeOAuth",
17+
isUiConfigServiceEnabled: Bool = true
1718
) {
1819
self.label = label
1920
self.action = {
2021
TradeItSDK.oAuthCallbackUrl = URL(string: oAuthCallbackUrl)!
2122
action()
23+
TradeItSDK.uiConfigService.isEnabled = isUiConfigServiceEnabled
2224
}
2325
}
2426
}
@@ -27,12 +29,14 @@ class YahooAction: Action {
2729
override init(
2830
label: String,
2931
action: @escaping () -> Void,
30-
oAuthCallbackUrl: String = "tradeItExampleScheme://completeYahooOAuth"
32+
oAuthCallbackUrl: String = "tradeItExampleScheme://completeYahooOAuth",
33+
isUiConfigServiceEnabled: Bool = false
3134
) {
3235
super.init(
3336
label: label,
3437
action: action,
35-
oAuthCallbackUrl: oAuthCallbackUrl
38+
oAuthCallbackUrl: oAuthCallbackUrl,
39+
isUiConfigServiceEnabled: isUiConfigServiceEnabled
3640
)
3741
}
3842
}

TradeItIosEmsApi/TradeItUiConfigResult.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,13 @@
22

33
@implementation TradeItUiConfigResult
44

5+
6+
-(id)init {
7+
if (self = [super init]) {
8+
self.brokers = [NSArray<TradeItUiBrokerConfig> new];
9+
}
10+
11+
return self;
12+
};
13+
514
@end

TradeItIosTicketSDK2/TradeItBrokerLogoService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class TradeItBrokerLogoService {
2828
return Promise(
2929
error: TradeItErrorResult(
3030
title: "Logo not found",
31-
message: "No logo is available for this broker."
31+
message: "No logo is enabled for this broker."
3232
)
3333
)
3434
}

TradeItIosTicketSDK2/TradeItLauncher.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ protocol OAuthCompletionListener {
1818
static var accountSelectionCallback: ((TradeItLinkedBrokerAccount) -> Void)? // Ew, gross. No other way to do this.
1919
static var accountSelectionTitle: String? // Ew, gross. No other way to do this.
2020

21-
override internal init() {}
21+
override internal init() {
22+
TradeItSDK.uiConfigService.isEnabled = true
23+
}
2224

2325
public func handleOAuthCallback(
2426
onTopmostViewController topMostViewController: UIViewController,

TradeItIosTicketSDK2/TradeItSelectionDetailCellTableViewCell.swift

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,31 @@ class TradeItSelectionDetailCellTableViewCell: BrandedTableViewCell {
1313
detailPrimaryText: String?,
1414
detailSecondaryText: String?,
1515
altTitleText: String,
16-
linkedBroker: TradeItLinkedBroker? = nil,
17-
isBrandingEnabled: Bool = true
16+
linkedBroker: TradeItLinkedBroker? = nil
1817
) {
1918
self.detailPrimaryLabel.text = detailPrimaryText
2019
self.detailSecondaryLabel.text = detailSecondaryText
2120
setBrokerNameAsTextState(altTitleText: altTitleText)
22-
if isBrandingEnabled {
23-
TradeItSDK.brokerLogoService.loadLogo(
24-
forBrokerId: linkedBroker?.brokerName,
25-
withSize: .small,
26-
onSuccess: { image in
27-
self.setBrokerNameAsLogoState(logo: image)
28-
},
29-
onFailure: { }
30-
)
31-
}
21+
TradeItSDK.brokerLogoService.loadLogo(
22+
forBrokerId: linkedBroker?.brokerName,
23+
withSize: .small,
24+
onSuccess: { image in
25+
self.setBrokerNameAsLogoState(logo: image)
26+
},
27+
onFailure: { }
28+
)
3229
}
3330

3431
func configure(
3532
detailPrimaryText: String?,
3633
detailSecondaryText: String?,
37-
linkedBroker: TradeItLinkedBroker? = nil,
38-
isBrandingEnabled: Bool = true
34+
linkedBroker: TradeItLinkedBroker? = nil
3935
) {
4036
self.configure(
4137
detailPrimaryText: detailPrimaryText,
4238
detailSecondaryText: detailSecondaryText,
4339
altTitleText: linkedBroker?.brokerLongName ?? "Unknown broker",
44-
linkedBroker: linkedBroker,
45-
isBrandingEnabled: isBrandingEnabled
40+
linkedBroker: linkedBroker
4641
)
4742
}
4843
}

TradeItIosTicketSDK2/TradeItUiConfigService.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@ import PromiseKit
33
class TradeItUiConfigService: NSObject {
44
private let connector: TradeItConnector
55
private var uiConfigPromise: Promise<TradeItUiConfigResult>? = nil
6+
var isEnabled = true
67

78
init(connector: TradeItConnector) {
89
self.connector = connector
910
}
1011

1112
func getUiConfigPromise() -> Promise<TradeItUiConfigResult> {
13+
if !isEnabled {
14+
return Promise(value: TradeItUiConfigResult())
15+
}
16+
1217
if let uiConfigPromise = self.uiConfigPromise { return uiConfigPromise }
1318

1419
let uiConfigRequest = TradeItUiConfigRequest(apiKey: connector.apiKey)

TradeItIosTicketSDK2/TradeItYahooLauncher.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import SafariServices
1010
private let linkBrokerUIFlow = TradeItYahooLinkBrokerUIFlow()
1111
private let alertManager = TradeItAlertManager()
1212

13-
override internal init() {}
13+
override internal init() {
14+
TradeItSDK.uiConfigService.isEnabled = false
15+
}
1416

1517
public func launchOAuth(fromViewController viewController: UIViewController) {
1618
self.launchOAuth(

TradeItIosTicketSDK2/TradeItYahooTradingTicketViewController.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,7 @@ class TradeItYahooTradingTicketViewController: TradeItYahooViewController, UITab
475475
detailCell.configure(
476476
detailPrimaryText: self.order.linkedBrokerAccount?.getFormattedAccountName(),
477477
detailSecondaryText: accountSecondaryText(),
478-
altTitleText: ticketRow.getTitle(forOrder: self.order),
479-
isBrandingEnabled: false
478+
altTitleText: ticketRow.getTitle(forOrder: self.order)
480479
)
481480
}
482481

0 commit comments

Comments
 (0)