-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Order: Displaying Notes #73
Conversation
… error or order notes not available
super.awakeFromNib() | ||
imageView?.tintColor = StyleManager.wooCommerceBrandColor | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)
|
||
// Configure the view for the selected state | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)
case let cell as AddItemTableViewCell: | ||
cell.configure(image: viewModel.addNoteIcon, text: viewModel.addNoteText) | ||
case let cell as OrderNoteTableViewCell where row == .orderNote: | ||
cell.configure(with: viewModel.orderNotes[indexPath.row - 1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how to express this better. it's [indexPath.row - 1]
because the first indexPath.row is the "Add a note" row.
@@ -0,0 +1,32 @@ | |||
/// WooCommerce API Credentials. Generated on May 29, 2018 at 11:16:32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be in git ignore
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is in git ignore. Not sure what happened, but please please 🔥
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UI looking great! Few incoming comments, thanks Thuy!!
@@ -0,0 +1,32 @@ | |||
/// WooCommerce API Credentials. Generated on May 29, 2018 at 11:16:32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is in git ignore. Not sure what happened, but please please 🔥
|
||
/// WordPress.com Auth Callback Scheme (AKA Magic Link!) | ||
/// | ||
#define DOTCOM_AUTH_SCHEME woocommerce |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above. The entire DerivedSources
is in gitignore, please please, remove, and make sure not to commit that, never. It's all good for now, since the project is closed. But if this was OSS, this would probably not be good!
@@ -20,7 +20,7 @@ struct Order: Decodable { | |||
let items: [OrderItem] | |||
let currency: String | |||
let total: String | |||
let notes: [OrderNote]? | |||
var notes: [OrderNote]? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(It's okay, no need to change anything here!!). We're using immutable data models, which means that the app itself should never update / modify fields directly.
Ideally speaking, the Service Layer ("Yosemite.framework") posts changes to the backend, and the data flows back from the Networking layer (OR service layer itself) to the UI .
Nevertheless, since we're removing this file in a little bit, and this is only for testing purposes, super OK to leave it this way!
} | ||
} | ||
|
||
return array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Swifty snippet:
guard let notes = notes else {
return []
}
return notes.map { note in
return OrderNoteViewModel(with: note)
}
(If notes
wasn't optional, the guard wouldn't even be needed)
// "date_created": "2017-03-21T16:46:41", | ||
let format = DateFormatter() | ||
format.dateFormat = "yyyy-MM-dd'T'HH:mm:ss" | ||
date = format.date(from: orderNote.dateCreated)! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please replace with DateFormatter.Defaults.dateTimeFormatter
(which should do the same).
Perhaps the date
field should be optional, itself? (it'd be a very very good idea to remove the !
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dateTimeFormatter
method is an extension only found in the Networking
subproject. Do I copy it over to the main project or is there somewhere else I should add it?
This reverts commit 99a42f8.
@jleandroperez thank you for the review! It's ready for a second look. |
This reverts commit 3c8140b.
Adds initial Fabric / Crashlytics integration
YosemiteTests: Fixing Runtime Errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few nipticky comments, and one crash. Steps:
- Launch WC
- Press over the
Orders
TabBar button - Press over the first row
As a result, the app is crashing. Stack trace below!
706F150-66CA-4CB4-9CB5-697716718DE2/WooCommerce.app> (loaded)' with name 'AddItemTableViewCell''
*** First throw call stack:
(
0 CoreFoundation 0x0000000109a091e6 __exceptionPreprocess + 294
1 libobjc.A.dylib 0x0000000108b5c031 objc_exception_throw + 48
2 CoreFoundation 0x0000000109a7e975 +[NSException raise:format:] + 197
3 UIKit 0x0000000105d192e9 -[UINib instantiateWithOwner:options:] + 501
4 UIKit 0x00000001059d2cc4 -[UITableView _dequeueReusableViewOfType:withIdentifier:] + 613
5 UIKit 0x00000001059d31bb -[UITableView _dequeueReusableCellWithIdentifier:forIndexPath:usingPresentationValues:] + 148
6 UIKit 0x00000001059d30f3 -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:] + 91
7 WooCommerce 0x00000001044ab7da _T011WooCommerce26OrderDetailsViewControllerC05tableE0So07UITableE4CellCSo0hE0C_10Foundation9IndexPathV12cellForRowAttF + 634
8 WooCommerce 0x00000001044aca0c _T011WooCommerce26OrderDetailsViewControllerC05tableE0So07UITableE4CellCSo0hE0C_10Foundation9IndexPathV12cellForRowAttFTo + 92
9 UIKit 0x00000001059ee567 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 783
10 UIKit 0x00000001059eeae4 -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 74
11 UIKit 0x00000001059b5eaa -[UITableView _updateVisibleCellsNow:isRecursive:] + 3168
12 UIKit 0x00000001059d67e0 -[UITableView layoutSubviews] + 176
13 UIKit 0x00000001059607a8 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1515
14 QuartzCore 0x0000000110b81456 -[CALayer layoutSublayers] + 177
15 QuartzCore 0x0000000110b85667 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 395
16 QuartzCore 0x0000000110b0c0fb _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 343
17 QuartzCore 0x0000000110b3979c _ZN2CA11Transaction6commitEv + 568
18 UIKit 0x00000001058b9f2c _afterCACommitHandler + 272
19 CoreFoundation 0x00000001099ab607 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
20 CoreFoundation 0x00000001099ab55e __CFRunLoopDoObservers + 430
21 CoreFoundation 0x000000010998fb81 __CFRunLoopRun + 1537
22 CoreFoundation 0x000000010998f30b CFRunLoopRunSpecific + 635
23 GraphicsServices 0x000000010f68aa73 GSEventRunModal + 62
24 UIKit 0x0000000105891057 UIApplicationMain + 159
25 WooCommerce 0x0000000104489387 main + 55
26 libdyld.dylib 0x000000010b111955 start + 1
27 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Podfile
Outdated
@@ -1,4 +1,4 @@ | |||
source 'https://github.com/CocoaPods/Specs.git' | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mind nuking the two empty spaces at the top?
statusText = NSLocalizedString("Private note", comment: "Labels an order note to let the user know it's private and not seen by the customer") | ||
} | ||
|
||
// "date_created": "2017-03-21T16:46:41", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we nuke this one?
|
||
// "date_created": "2017-03-21T16:46:41", | ||
let format = DateFormatter.Defaults.dateTimeFormatter | ||
date = format.date(from: orderNote.dateCreated)! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably a bad idea to use an Implicitly Unwrapped Optional here. Whenever there's a parsing issue, the app will crash.
Can we turn the date
field into an Optional instead?
formatter.timeStyle = .short | ||
|
||
let formattedDateString = formatter.string(from: date) | ||
return formattedDateString |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return formatter.string(from: date)
} catch { | ||
print("error:\(error)") | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to change this, since it's testing code, and it's going away supersoon!. But in general, you may wanna avoid nested levels.
A simple way to express this, in a "flattened fashion" would be:
guard let path = Bundle.main.url(forResource: resource, withExtension: "json") else {
return basicOrder
}
do {
let json = try Data(contentsOf: path)
let decoder = JSONDecoder()
let orderNotesFromJson = try decoder.decode([OrderNote].self, from: json)
var order = basicOrder
order.notes = orderNotesFromJson
return order
} catch {
DDLogError("error:\(error)")
}
(The lesser indentation levels, the better, since it really aids readability)
…), remove extra lines in podfile, make dateCreated an optional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All clear!!!
Thanks Jorge! |
Fixes #13
To test:
Notes: The table cells are using default separator styles, which looks different compared to the mockups.