Skip to content

Conversation

@danbee
Copy link
Owner

@danbee danbee commented Mar 30, 2020

Simulator Screen Shot - iPhone 11 Pro - 2020-04-03 at 11 47 51
Simulator Screen Shot - iPhone 11 Pro - 2020-04-03 at 11 49 29
Simulator Screen Shot - iPhone 11 Pro - 2020-04-03 at 11 49 40

@danbee danbee force-pushed the add-ios-album-list branch from 60b344a to 23e5860 Compare April 3, 2020 03:02
Copy link
Contributor

@sharplet sharplet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! This is very cool 👍

guard let imageData = imageResult.image.pngData()
else { return }

let _ = RawImageDataProvider(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does instantiating and then discarding the RawImageDataProvider do?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely nothing. This was left over from some of the Mac code I copypasta'd

}

override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
setAppearance()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, to see if the trait collection change is related to dark mode or something else, you can use hasDifferentColorAppearance(comparedTo: previousTraitCollection).

NotificationCenter.default.addObserver(self, selector: #selector(didConnect), name: .didConnect, object: nil)

title = "Albums"
navigationController?.navigationBar.prefersLargeTitles = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW if you're using a storyboard, it should be possible to set both of these properties directly in the storyboard file.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took me a while to find!

albumMetadata.text = "\(album.artist) · \(album.date)"

var layoutSize = UIView.layoutFittingExpandedSize
layoutSize.width = UIScreen.main.bounds.width
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, a good place to work out the layout width is in viewWillLayoutSubviews() or viewDidLayoutSubviews(). Moving this code there and using view.bounds.width instead of UIScreen.main.bounds.width will make this more robust to things like orientation changes or size changes on iPad.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved it here because it was updating the layout often and I was noticing some jankyness with the calculation (the sizes of things would jump about). Now I've figured this it out I can probably move it back.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something I also usually do here is to cache the previous width, so the layout only needs to be recalculated if the width has changed.


extension CGColor {
static let albumBorderColorLight = CGColor.init(srgbRed: 0, green: 0, blue: 0, alpha: 0.15)
static let albumBorderColorDark = CGColor.init(srgbRed: 255, green: 255, blue: 255, alpha: 0.15)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about defining these colours in an asset catalog so you can reuse them across platforms without dropping down to Core Graphics?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't even aware that I could do that!

//
// override func collectionView(_ collectionView: UICollectionView, indexPathForIndexTitle title: String, at index: Int) -> IndexPath {
// return IndexPath(index: 0)
// }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this commented code be removed?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be for now. I was originally leaving it in as a reminder of the methods I need to implement to get the index thing working.

@danbee danbee force-pushed the add-ios-album-list branch from eeadba8 to 39f1c4f Compare July 10, 2020 18:33
@danbee danbee force-pushed the add-ios-album-list branch from 39f1c4f to 88ec059 Compare February 14, 2021 14:13
Base automatically changed from master to main March 13, 2021 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants