Skip to content

Instantly share code, notes, and snippets.

@KazaiMazai
KazaiMazai / EnvironmentVars.stencil
Last active June 13, 2023 13:42
Scripts for managing env vars in Xcode and CI. Here is an article with detailed description: https://kazaimazai.com/secret-env-vars-xcode-ci
//swiftlint:disable all
struct EnvironmentVars {
/// Generated using 'EnvironmentVars.stencil' template
static let secretNumberOne = "{{ argument.SECRET_ONE }}"
static let secretNumberTwo = "{{ argument.SECRET_TWO }}"
}
@KazaiMazai
KazaiMazai / CollectionView.swift
Last active November 11, 2024 02:27
Better SwiftUI wrapper for UICollectionView
import SwiftUI
extension CollectionView {
typealias UIKitCollectionView = CollectionViewWithDataSource<SectionIdentifierType, ItemIdentifierType>
typealias DataSource = UICollectionViewDiffableDataSource<SectionIdentifierType, ItemIdentifierType>
typealias Snapshot = NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>
typealias UpdateCompletion = () -> Void
}
struct CollectionView<SectionIdentifierType, ItemIdentifierType>
@KazaiMazai
KazaiMazai / CollectionView.swift
Last active August 19, 2024 10:03
SwiftUI wrapper for UICollectionView
import UIKit
import SwiftUI
public protocol SectionProtocol: Hashable {
associatedtype Item: Hashable
var items: [Item] { get }
}
extension CollectionView {
@KazaiMazai
KazaiMazai / HorizontalAlignment.swift
Last active April 2, 2023 07:01
Custom Segmented Picker with SwiftUI
extension HorizontalAlignment {
private enum CenterAlignmentID: AlignmentID {
static func defaultValue(in dimension: ViewDimensions) -> CGFloat {
return dimension[HorizontalAlignment.center]
}
}
static var horizontalCenterAlignment: HorizontalAlignment {
HorizontalAlignment(CenterAlignmentID.self)