This file contains 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 UIKit | |
protocol InnerCollectionViewCell: UICollectionViewCell { | |
associatedtype Item: Hashable | |
func configure(with item: Item, index: Int) | |
} | |
extension UICollectionViewFlowLayout { | |
func rect(at index: Int) -> CGRect { | |
CGRect( |
This file contains 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 UIKit | |
class InfiniteCell: UICollectionViewCell, UICollectionViewDataSource, UICollectionViewDelegate { | |
private var total: Int { additionalItemCount + items.count } | |
private var additionalItemCount: Int = 0 | |
private let threshold: Int = 3 // will need to be based on orientation and screen size to perform correctly | |
private var items: [UIColor] = [] | |
private let itemSize: CGSize = .init(width: 150, height: 150) | |
private var itemsWidth: CGFloat { CGFloat(items.count) * itemSize.width } | |
private lazy var flowLayout = UICollectionViewFlowLayout() |
This file contains 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 Tab: Equatable, Identifiable { | |
var id: UUID = UUID() | |
var color: Color | |
} | |
struct OffsetKey: PreferenceKey { | |
static var defaultValue: CGFloat = 0 |
This file contains 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 ContentView: View { | |
@State var offset: CGFloat = 190 | |
@State var endOffset: CGFloat = 190 | |
@State var items: [Int] = [ | |
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19 | |
] | |
var itemSpacing: CGFloat = 10 |
This file contains 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 | |
extension View { | |
func sticky(in coordinateSpace: CoordinateSpace) -> some View { | |
modifier(StickyViewModifier(coordinateSpace: coordinateSpace)) | |
} | |
} | |
private struct StickyViewModifier: ViewModifier { | |
let coordinateSpace: CoordinateSpace |
This file contains 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 | |
enum Behaviour { | |
case pinnedBelow | |
case normal | |
case pinnedAbove | |
} | |
struct NonStickyView<Content: View>: View { | |
let id: String |
This file contains 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 | |
enum Constants { | |
static let backgroundHeight: CGFloat = 500 | |
static let headerHeight: CGFloat = 150 | |
static let contentHeight: CGFloat = 350 | |
} | |
struct ColoredView: View { | |
let color: Color |
This file contains 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 | |
enum Constants { | |
static let heroHeight: CGFloat = 500 | |
static let menuHeight: CGFloat = 150 | |
} | |
struct LargeHeaderView: View { | |
let color: Color |
This file contains 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 UIKit | |
enum Style { | |
static let backgroundColor = UIColor.black | |
static let spacing = CGFloat(8) | |
static let filterStackHeight = CGFloat(34) | |
static let filterHeaderHeight = (filterStackHeight * 2) + (spacing * 3) | |
} | |
class ViewController: UIViewController { |
This file contains 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 Foundation | |
var injectedLines = """ | |
@Injected | |
private var someSharedValue: SharedValue.Type | |
@Injected | |
private var someUnregisteredValue: UnregisteredValue | |
#if os(tvOS) | |
@Injected |
NewerOlder