Skip to content

Instantly share code, notes, and snippets.

View satishVekariya's full-sized avatar

Satish satishVekariya

View GitHub Profile
@satishVekariya
satishVekariya / ColoredToggle.swift
Last active May 10, 2023 07:45
A custom toggle style
import SwiftUI
/// Custom toggle style
///
/// Reference:
/// - https://www.bigmountainstudio.com/community/public/posts/11825-swiftui-togglestyle-customizing-the-toggle
struct ColoredToggleStyle: ToggleStyle {
let labelFont = Font.system(size: 14, weight: .regular)
let labelColor = Color.secondaryMain
let onColor = Color.semanticsSuccessMain
@satishVekariya
satishVekariya / ChatCollectionViewFlowLayout.swift
Created November 19, 2019 11:26 — forked from jochenschoellig/ChatCollectionViewFlowLayout.swift
A subclass of UICollectionViewFlowLayout to get chat behavior without turning collection view upside-down. This layout is written in Swift 3 and absolutely usable with RxSwift and RxDataSources because UI is completely separated from any logic or binding.
import UIKit
class ChatCollectionViewFlowLayout: UICollectionViewFlowLayout {
private var topMostVisibleItem = Int.max
private var bottomMostVisibleItem = -Int.max
private var offset: CGFloat = 0.0
private var visibleAttributes: [UICollectionViewLayoutAttributes]?