This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import UIKit | |
class CollectionViewExample: UIViewController { | |
//... | |
// MARK: Data | |
struct Item: MyCollectionViewCell.Content { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import UIKit | |
class MyCollectionViewCell: UICollectionViewCell { | |
static var reuseIdentifier = "MyCollectionViewCell" | |
typealias Content = Card.Content | |
private(set) var host: UIHostingController<Card>? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
protocol CardContent { | |
var imageName: String { get } | |
var title: String { get } | |
var description: String { get } | |
} | |
struct Card: View { | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//... | |
extension CollectionViewExample: UICollectionViewDataSource { | |
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { | |
return 9 | |
} | |
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { | |
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MyCollectionViewCell.reuseIdentifier, for: indexPath) as? MyCollectionViewCell else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import UIKit | |
class MyCollectionViewCell: UICollectionViewCell { | |
lazy var host: UIHostingController = { | |
return UIHostingController(rootView: Card()) | |
}() | |
//... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import UIKit | |
class CollectionViewExample: UIViewController { | |
lazy var collectionView: UICollectionView = { | |
let layout = UICollectionViewFlowLayout() | |
layout.scrollDirection = .horizontal | |
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout) | |
collectionView.backgroundColor = UIColor(named: "Light") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import UIKit | |
class MyCollectionViewCell: UICollectionViewCell { | |
static var reuseIdentifier = "MyCollectionViewCell" | |
lazy var host: UIHostingController = { | |
return UIHostingController(rootView: Card()) | |
}() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct Card: View { | |
var body: some View { | |
VStack(alignment: .leading, spacing: 8) { | |
Image("condos") | |
.resizable() | |
.clipShape(RoundedRectangle(cornerRadius: 4)) | |
Text("Condo with awesome views of downtown") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
/// Common aspect ratios | |
public enum AspectRatio: CGFloat { | |
case square = 1 | |
case threeToFour = 0.75 | |
case fourToThree = 1.75 | |
} | |
/// Fit an image to a certain aspect ratio while maintaining its aspect ratio |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Project | Object | Fix | |
---|---|---|---|
UIToolkit | UIToolkit (class) | Rename class to UIToolkitConfiguration | |
TripBoards | TripBoards (protocol) | Rename TripBoards to TripBoardManager |