Skip to content

Commit 0aec6e6

Browse files
authored
Merge pull request #340 from tradingticket/os/#156672415/brandingOnOrderScreen
Display all Order Sections on Order Screen
2 parents 6dbcec8 + 8a68807 commit 0aec6e6

File tree

3 files changed

+25
-20
lines changed

3 files changed

+25
-20
lines changed

TradeItIosTicketSDK2/TradeItBrandedAccountNameCell.xib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
</label>
3131
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="xRZ-8i-od2">
3232
<rect key="frame" x="16" y="11" width="150" height="28"/>
33+
<accessibility key="accessibilityConfiguration" identifier="UiImage-BrokerLogo"/>
3334
<constraints>
3435
<constraint firstAttribute="width" constant="150" id="6iH-qE-1XT"/>
3536
<constraint firstAttribute="height" constant="28" id="EOb-5Q-FhW"/>
@@ -47,7 +48,6 @@
4748
<constraint firstAttribute="topMargin" secondItem="iL0-PU-Cph" secondAttribute="top" id="A2I-u9-Kfj"/>
4849
<constraint firstItem="58j-a5-DPU" firstAttribute="leading" secondItem="xRZ-8i-od2" secondAttribute="leading" id="Q4v-lp-y9f"/>
4950
<constraint firstItem="58j-a5-DPU" firstAttribute="centerY" secondItem="xRZ-8i-od2" secondAttribute="centerY" id="U2F-nC-s4z"/>
50-
<constraint firstAttribute="bottomMargin" secondItem="xRZ-8i-od2" secondAttribute="bottom" id="WOT-Wh-XwD"/>
5151
<constraint firstAttribute="trailingMargin" secondItem="iL0-PU-Cph" secondAttribute="trailing" id="X8r-eE-TLh"/>
5252
<constraint firstItem="xRZ-8i-od2" firstAttribute="centerY" secondItem="csI-fC-Lxk" secondAttribute="centerY" id="auK-OS-aIF"/>
5353
<constraint firstItem="iL0-PU-Cph" firstAttribute="leading" secondItem="58j-a5-DPU" secondAttribute="trailing" constant="10" id="f5Z-d1-ZQP"/>

TradeItIosTicketSDK2/TradeItOrdersTableViewManager.swift

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class TradeItOrdersTableViewManager: NSObject, UITableViewDelegate, UITableViewD
4747
self.orderSectionPresenters = []
4848

4949
let openOrders = orders.filter { $0.belongsToOpenCategory()}
50-
if openOrders.count > 0 {
50+
if !openOrders.isEmpty {
5151
let openOrdersPresenter = getOrdersPresenter(orders: openOrders)
5252
self.orderSectionPresenters.append(
5353
OrderSectionPresenter(
@@ -60,7 +60,7 @@ class TradeItOrdersTableViewManager: NSObject, UITableViewDelegate, UITableViewD
6060
}
6161

6262
let partiallyFilledOrders = orders.filter { $0.belongsToPartiallyFilledCategory() }
63-
if partiallyFilledOrders.count > 0 {
63+
if !partiallyFilledOrders.isEmpty {
6464
let partiallyFilledOrdersPresenter = getOrdersPresenter(orders: partiallyFilledOrders)
6565
self.orderSectionPresenters.append(
6666
OrderSectionPresenter(
@@ -73,7 +73,7 @@ class TradeItOrdersTableViewManager: NSObject, UITableViewDelegate, UITableViewD
7373
}
7474

7575
let filledOrders = orders.filter { $0.belongsToFilledCategory() }
76-
if filledOrders.count > 0 {
76+
if !filledOrders.isEmpty {
7777
let filledOrdersPresenter = getOrdersPresenter(orders: filledOrders)
7878
self.orderSectionPresenters.append(
7979
OrderSectionPresenter(
@@ -85,7 +85,7 @@ class TradeItOrdersTableViewManager: NSObject, UITableViewDelegate, UITableViewD
8585
}
8686

8787
let otherOrders = orders.filter { $0.belongsToOtherCategory() }
88-
if otherOrders.count > 0 {
88+
if !otherOrders.isEmpty {
8989
let otherOrdersPresenter = getOrdersPresenter(orders: otherOrders)
9090
self.orderSectionPresenters.append(
9191
OrderSectionPresenter(
@@ -103,11 +103,11 @@ class TradeItOrdersTableViewManager: NSObject, UITableViewDelegate, UITableViewD
103103
// MARK: UITableViewDelegate
104104

105105
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
106-
return self.orderSectionPresenters[safe: section]?.title
106+
return getOrderSectionPresenter(forSection: section)?.title
107107
}
108108

109109
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
110-
if isAccountInfoSection(section) {
110+
if Section(rawValue: section) == Section.accountInfo {
111111
guard let cell = tableView.dequeueReusableCell(withIdentifier: "BRANDED_ACCOUNT_NAME_CELL_ID") as? TradeItPreviewBrandedAccountNameCell else {
112112
return UITableViewCell()
113113
}
@@ -117,24 +117,24 @@ class TradeItOrdersTableViewManager: NSObject, UITableViewDelegate, UITableViewD
117117
return cell
118118
}
119119

120-
return self.orderSectionPresenters[safe: section]?.header(forTableView: tableView)
120+
return getOrderSectionPresenter(forSection: section)?.header(forTableView: tableView)
121121
}
122122

123123
// MARK: UITableViewDataSource
124124
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
125-
if isAccountInfoSection(indexPath.section) {
125+
if Section(rawValue: indexPath.section) == Section.accountInfo {
126126
return UITableViewCell()
127127
} else {
128-
return self.orderSectionPresenters[safe: indexPath.section]?.cell(forTableView: tableView, andRow: indexPath.row) ?? UITableViewCell()
128+
return getOrderSectionPresenter(forSection: indexPath.section)?.cell(forTableView: tableView, andRow: indexPath.row) ?? UITableViewCell()
129129
}
130130
}
131131

132132
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
133-
if isAccountInfoSection(section) {
133+
if Section(rawValue: section) == Section.accountInfo {
134134
return 0
135135
}
136136

137-
guard let orderSectionPresenter = self.orderSectionPresenters[safe: section] else { return 0 }
137+
guard let orderSectionPresenter = getOrderSectionPresenter(forSection: section) else { return 0 }
138138
return orderSectionPresenter.numberOfRows()
139139
}
140140

@@ -147,15 +147,15 @@ class TradeItOrdersTableViewManager: NSObject, UITableViewDelegate, UITableViewD
147147
}
148148

149149
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
150-
guard let orderPresenter = self.orderSectionPresenters[safe: indexPath.section]?.ordersPresenter[safe: indexPath.row]
150+
guard let orderPresenter = getOrderSectionPresenter(forSection: indexPath.section)?.ordersPresenter[safe: indexPath.row]
151151
, !orderPresenter.isGroupOrderHeader else {
152152
return TradeItOrdersTableViewManager.GROUP_ORDER_HEADER_HEIGHT
153153
}
154154
return UITableViewAutomaticDimension
155155
}
156156

157157
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
158-
guard let orderPresenter = self.orderSectionPresenters[safe: indexPath.section]?.ordersPresenter[safe: indexPath.row]
158+
guard let orderPresenter = getOrderSectionPresenter(forSection: indexPath.section)?.ordersPresenter[safe: indexPath.row]
159159
, !orderPresenter.isGroupOrderHeader else {
160160
return TradeItOrdersTableViewManager.GROUP_ORDER_HEADER_HEIGHT
161161
}
@@ -168,7 +168,7 @@ class TradeItOrdersTableViewManager: NSObject, UITableViewDelegate, UITableViewD
168168

169169
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
170170
let cancelAction = UITableViewRowAction(style: .normal, title: "Cancel") { (action, indexPath: IndexPath) in
171-
guard let orderPresenter = self.orderSectionPresenters[safe: indexPath.section]?.ordersPresenter[safe: indexPath.row]
171+
guard let orderPresenter = self.getOrderSectionPresenter(forSection: indexPath.section)?.ordersPresenter[safe: indexPath.row]
172172
, let ordernumber = orderPresenter.getOrderNumber() else {
173173
return
174174
}
@@ -182,7 +182,7 @@ class TradeItOrdersTableViewManager: NSObject, UITableViewDelegate, UITableViewD
182182
}
183183

184184
func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
185-
guard let orderPresenter = self.orderSectionPresenters[safe: indexPath.section]?.ordersPresenter[safe: indexPath.row] else {
185+
guard let orderPresenter = getOrderSectionPresenter(forSection: indexPath.section)?.ordersPresenter[safe: indexPath.row] else {
186186
return false
187187
}
188188
return orderPresenter.isCancelable()
@@ -191,10 +191,16 @@ class TradeItOrdersTableViewManager: NSObject, UITableViewDelegate, UITableViewD
191191
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
192192
// nothing to do but need to be defined to display the actions
193193
}
194-
194+
195195
// MARK: Private
196-
private func isAccountInfoSection(_ section: Int) -> Bool {
197-
return section == 0
196+
fileprivate enum Section: Int {
197+
case accountInfo = 0, firstOrderCategory
198+
}
199+
200+
private func getOrderSectionPresenter(forSection section: Int) -> OrderSectionPresenter? {
201+
let indexOfOrderCategory = section - Section.firstOrderCategory.rawValue
202+
203+
return orderSectionPresenters[safe: indexOfOrderCategory]
198204
}
199205

200206
private func addRefreshControl(toTableView tableView: UITableView) {

TradeItIosTicketSDK2/TradeItPortfolioAccountDetailsViewController.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class TradeItPortfolioAccountDetailsViewController: TradeItViewController, Trade
2222
}
2323

2424
self.tableViewManager = TradeItPortfolioAccountDetailsTableViewManager(account: linkedBrokerAccount)
25-
self.navigationItem.title = linkedBrokerAccount.linkedBroker?.brokerLongName
2625

2726
self.tableViewManager.delegate = self
2827
self.tableViewManager.table = self.table

0 commit comments

Comments
 (0)