Conversation
40b4f80 to
be2d069
Compare
9f55883 to
a0b7312
Compare
| let checkmark: UILabel = { | ||
| let checkmark = UILabel() | ||
| checkmark.text = "✓" | ||
| checkmark.font = UIFont.systemFont(ofSize: 15) |
There was a problem hiding this comment.
Should this be bigger?
There was a problem hiding this comment.
Indeed, It's a bit small but I wonder if this shouldn't be a separate class. For example perhaps a VLCSettingSheetCell?
There was a problem hiding this comment.
Also, open thought, I'm aware that on Figma the checkmark is on the right but shouldn't we consider putting the check mark on the left like the edit mode? Might just be a personal preference but I think it will be nicer 😅
There was a problem hiding this comment.
Do other actionsheet cells need checkmarks? If not, it would definitely make sense to create a new class. Also, if other actionsheet cells need both images and checkmarks, I think it would be better to keep the checkmark on the right for consistency.
| image | text | checkmark | or
| null | text | checkmark |
There was a problem hiding this comment.
Not all ActionSheet cells need/will need checkmarks.
There was a problem hiding this comment.
So for the few that need both checkmarks and images, it should be placed on the right, no?
There was a problem hiding this comment.
Just subclassed it to VLCSettingSheetCell and it makes more sense :D
e7a85d0 to
b42bf75
Compare
b42bf75 to
a96e95b
Compare
a96e95b to
a0d4510
Compare
|
|
||
| static let identifier = "VLCActionSheetCell" | ||
| @objc static var identifier: String { | ||
| return String(describing: self) |
There was a problem hiding this comment.
That's interesting! Today I learned :) We should do that everywhere
carolanitz
left a comment
There was a problem hiding this comment.
Some comments are small some are bigger :) Overall the code looks very clean 👍 Did you or @Mikanbu test these changes with the chromecast actionsheet?
Also I noticed that the title header is supposed to be in bold font ^^
|
|
||
| specifierManager = [[VLCSettingsSpecifierManager alloc] initWithSpecifier:specifier settingsReader:self.settingsReader settingsStore:self.settingsStore]; | ||
| actionSheet.delegate = specifierManager; | ||
| actionSheet.dataSource = specifierManager; |
There was a problem hiding this comment.
It should be enough to create the Actionsheet and specifierManager once. Right now you do it on every tab of the cell.
Sources/VLCSettingsController.m
Outdated
| actionSheet.delegate = specifierManager; | ||
| actionSheet.dataSource = specifierManager; | ||
|
|
||
| [actionSheet setActionWithClosure:^(id item) { |
There was a problem hiding this comment.
can we use something else than id here?
There was a problem hiding this comment.
I don't think so because the closure is receiving bunch of different types as item. But even if we were able to type check item as something like long, InAppSettings doesn't provide a set___ method for all types
Sources/VLCSettingsController.m
Outdated
| NSDictionary *info = [NSDictionary dictionaryWithObject:item forKey:[specifier key]]; | ||
| [[NSNotificationCenter defaultCenter] postNotificationName:kIASKAppSettingChanged | ||
| object:[specifier key] | ||
| userInfo:info]; |
There was a problem hiding this comment.
do you need to fire the notification here? Is it not done in the setter of the settingsstore?
There was a problem hiding this comment.
Wow, I didn't know that :D
It works without the 2 lines.
| selectionStyle = .default | ||
| default: | ||
| assertionFailure("\(reuseIdentifier) has not been defined for VLCSettingsTableViewCell") | ||
| accessoryType = .none |
There was a problem hiding this comment.
Can we handle it explicitly for the known cases and keep the assertionFailure?
There was a problem hiding this comment.
Yes! Don't know what I was thinking :p
| } | ||
|
|
||
| var selectedIndex: IndexPath { | ||
| var index: Int |
There was a problem hiding this comment.
you can make that a let since it will definitely be set in the if else part
| return | ||
| } | ||
|
|
||
| updateCollectionViewCellApparence(cell: oldCell, highlighted: false) |
There was a problem hiding this comment.
instead of highlighted does the cell maybe know that it's highlighted or selected itself? Maybe you can overwrite the setter if that's the case
| } | ||
|
|
||
| let titles = specifier.multipleTitles() | ||
| cell.name.text = settingsReader.title(forStringId: titles?[indexPath.row] as? String) |
There was a problem hiding this comment.
can we add a check for indexPath.row < titles.count? Otherwise we crash here and maybe as well that the object is of type String otherwise we fail here silently
Sources/VLCSettingsSheetCell.swift
Outdated
| * VLCSettingSheetCell.swift | ||
| * | ||
| * Copyright © 2018 VLC authors and VideoLAN | ||
| * Copyright © 2018 Videolabs |
There was a problem hiding this comment.
I think you can remove the Videolabs copyright ;)
Sources/VLCSettingsController.m
Outdated
|
|
||
| [actionSheet setActionWithClosure:^(id item) { | ||
| [self.settingsStore setObject:item forKey:specifier.key]; | ||
| [self.settingsStore synchronize]; |
There was a problem hiding this comment.
Doesn't the self here lead to a retain cycle?
| @objc init(specifier: IASKSpecifier, settingsReader: IASKSettingsReader, settingsStore: IASKSettingsStore) { | ||
| self.specifier = specifier | ||
| self.settingsReader = settingsReader | ||
| self.settingsStore = settingsStore |
There was a problem hiding this comment.
shouldn't there be a super.init() ?
a0d4510 to
332f986
Compare
| let title: UILabel = { | ||
| let title = UILabel() | ||
| title.font = UIFont.systemFont(ofSize: 13) | ||
| title.font = UIFont.boldSystemFont(ofSize: 13) |
There was a problem hiding this comment.
Is this change according to Figma?
| name.textColor = PresentationTheme.current.colors.cellTextColor | ||
| name.font = UIFont.systemFont(ofSize: 15) | ||
| name.translatesAutoresizingMaskIntoConstraints = false | ||
| name.setContentHuggingPriority(.defaultLow, for: .horizontal) |
There was a problem hiding this comment.
Do we need to set ContentHuggingPriority ?
There was a problem hiding this comment.
This is to extend the name label all the way to the right so the checkmark can be at the rightmost edge. It can be moved to the subclass if it's breaking things.
| } | ||
|
|
||
| private func setupViews() { | ||
| func setupViews() { |
There was a problem hiding this comment.
I don't think this method should be internal.
There was a problem hiding this comment.
can I ask you why?? It's currently being overriden by VLCSettingsActionSheetCell
There was a problem hiding this comment.
I believe that it would be quite wrong to let other classes have the possibility to initialize the properties of VLCActionSheetCell.
I'm not saying that VLCActionSheetCell is perfect but I think classes should try to stay "self-contained".
For example, I think this would be nicer:
class TestCell: VLCActionSheetCell {
override init(frame: CGRect) {
super.init(frame: frame) // super.setupViews() is called in the super.init()
setupViews()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
private func setupViews() {
stackView.removeArrangedSubview(icon)
stackView.addArrangedSubview(//something\\)
}
}
Also, I'm sorry if I don't make any sense 😅
There was a problem hiding this comment.
Gotcha! And it totally makes sense :D
| @objc init(settingsReader: IASKSettingsReader, settingsStore: IASKSettingsStore) { | ||
| super.init() | ||
| self.settingsReader = settingsReader | ||
| self.settingsStore = settingsStore |
There was a problem hiding this comment.
Shouldn't the properties be initialized before calling super.init()? Therefore not needing to implicitly unwrap the properties on top?
There was a problem hiding this comment.
ah good catch. completely missed this :D
332f986 to
843a2fe
Compare
|
Just tested it with Chromecast and nothing seems to be broken @carolanitz
|
843a2fe to
64450d8
Compare
64450d8 to
73b6147
Compare
|
🔔 ping! |
|
|
||
| func actionSheet(collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { | ||
| guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: VLCSettingsSheetCell.identifier, for: indexPath) as? VLCSettingsSheetCell else { | ||
| fatalError("VLCSettingsSpecifierManager: VLCActionSheetDataSource: Unable to dequeue reusable cell") |
There was a problem hiding this comment.
doesn't dequeueReusableCell return nil when there is no cell to reuse ? and shouldn't in that case a new Cell be created instead of having a fatalError ?
|
@mkchoi212 looks fine to me just that one question regarding dequeueReusableCell :) |
73b6147 to
57fccfe
Compare
|
🔔 ping :D |
|
sorry this time I saw something else instead of having fatalerrors which litterally crash the app we should probably return rather empty arrays and just have assertionfailures. The only time you should use fatalerror is when you corrupt data or get into an unrecoverable appstate where only a restart would be the solution. Other options are errormessages to the user |
|
|
||
| func actionSheet(collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { | ||
| guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: VLCSettingsSheetCell.identifier, for: indexPath) as? VLCSettingsSheetCell else { | ||
| return UICollectionViewCell() |
There was a problem hiding this comment.
might make sense to still have an assertionfailure here because this should only happen when someone forgot to register the cellidentifier and the cellclass right ?
|
merged with 0bcf87a and following |

Checklist
bundle exec fastlane testfrom the root directory to see all new and existing tests passbundle exec fastlane lintto ensure the code style is validDescription
Must be rebased after the settings PR is merged
Instead of pushing a new view to adjust the settings, VLCActionSheet is used.