@@ -46,6 +46,14 @@ class OrderDetailsViewController: UIViewController {
4646 let infoRows : [ Row ] = billingIsHidden ? [ . shippingAddress] : [ . shippingAddress, . billingAddress, . billingPhone, . billingEmail]
4747 let infoSection = Section ( title: NSLocalizedString ( " CUSTOMER INFORMATION " , comment: " Customer info section title " ) , footer: infoFooter, rows: infoRows)
4848
49+ var noteRows : [ Row ] = [ . addOrderNote]
50+ if let notes = order. notes {
51+ for _ in notes {
52+ noteRows. append ( . orderNote)
53+ }
54+ }
55+ let orderNotesSection = Section ( title: NSLocalizedString ( " ORDER NOTES " , comment: " Order notes section title " ) , footer: nil , rows: noteRows)
56+
4957 let paymentSection = Section ( title: NSLocalizedString ( " PAYMENT " , comment: " Payment section title " ) , footer: nil , rows: [ . payment] )
5058
5159 // FIXME: this is temporary
@@ -54,10 +62,10 @@ class OrderDetailsViewController: UIViewController {
5462 // but order has customerNote as an optional property right now
5563 guard let customerNote = order. customerNote,
5664 !customerNote. isEmpty else {
57- sections = [ summarySection, infoSection, paymentSection]
65+ sections = [ summarySection, infoSection, paymentSection, orderNotesSection ]
5866 return
5967 }
60- sections = [ summarySection, customerNoteSection, infoSection, paymentSection]
68+ sections = [ summarySection, customerNoteSection, infoSection, paymentSection, orderNotesSection ]
6169 }
6270
6371 func configureNibs( ) {
@@ -87,7 +95,7 @@ extension OrderDetailsViewController: UITableViewDataSource {
8795 func tableView( _ tableView: UITableView , cellForRowAt indexPath: IndexPath ) -> UITableViewCell {
8896 let row = sections [ indexPath. section] . rows [ indexPath. row]
8997 let cell = tableView. dequeueReusableCell ( withIdentifier: row. reuseIdentifier, for: indexPath)
90- configure ( cell, for: row)
98+ configure ( cell, for: row, at : indexPath )
9199 return cell
92100 }
93101
@@ -136,13 +144,17 @@ extension OrderDetailsViewController: UITableViewDataSource {
136144extension OrderDetailsViewController : UITableViewDelegate {
137145 func tableView( _ tableView: UITableView , didSelectRowAt indexPath: IndexPath ) {
138146 tableView. deselectRow ( at: indexPath, animated: true )
147+
148+ if sections [ indexPath. section] . rows [ indexPath. row] == . addOrderNote {
149+ // TODO: present modal for Add Note screen
150+ }
139151 }
140152}
141153
142154// MARK: - Extension
143155//
144156extension OrderDetailsViewController {
145- private func configure( _ cell: UITableViewCell , for row: Row ) {
157+ private func configure( _ cell: UITableViewCell , for row: Row , at indexPath : IndexPath ) {
146158 switch cell {
147159 case let cell as SummaryTableViewCell :
148160 cell. configure ( with: viewModel)
@@ -158,6 +170,10 @@ extension OrderDetailsViewController {
158170 configure ( cell, for: . billingEmail)
159171 case let cell as PaymentTableViewCell :
160172 cell. configure ( with: viewModel)
173+ case let cell as AddItemTableViewCell :
174+ cell. configure ( image: viewModel. addNoteIcon, text: viewModel. addNoteText)
175+ case let cell as OrderNoteTableViewCell where row == . orderNote:
176+ cell. configure ( with: viewModel. orderNotes [ indexPath. row - 1 ] )
161177 default :
162178 fatalError ( " Unidentified customer info row type " )
163179 }
@@ -282,6 +298,8 @@ private extension OrderDetailsViewController {
282298 case billingAddress
283299 case billingPhone
284300 case billingEmail
301+ case addOrderNote
302+ case orderNote
285303 case payment
286304
287305 var reuseIdentifier : String {
@@ -298,6 +316,10 @@ private extension OrderDetailsViewController {
298316 return BillingDetailsTableViewCell . reuseIdentifier
299317 case . billingEmail:
300318 return BillingDetailsTableViewCell . reuseIdentifier
319+ case . addOrderNote:
320+ return AddItemTableViewCell . reuseIdentifier
321+ case . orderNote:
322+ return OrderNoteTableViewCell . reuseIdentifier
301323 case . payment:
302324 return PaymentTableViewCell . reuseIdentifier
303325 }
0 commit comments