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 ChatCollectionViewFlowLayout: UICollectionViewFlowLayout { | |
private var topMostVisibleItem = Int.max | |
private var bottomMostVisibleItem = -Int.max | |
private var offset: CGFloat = 0.0 | |
private var visibleAttributes: [UICollectionViewLayoutAttributes]? |
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 | |
/// 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 |
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
// | |
// LastAtBottomVStack.swift | |
// | |
// | |
// Created by Satish Vekariya on 21/04/2023. | |
// | |
import SwiftUI | |
// MARK: - LastAtBottomVStack |
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 Combine | |
import Foundation | |
// MARK: - Polling | |
/// A thread safe polling(repeat task over given time) handler object | |
public actor Polling { | |
public typealias TaskItem = () async -> Void | |
public typealias PollingTask = Task<Void, Never> | |
typealias PollingSubject = CurrentValueSubject<Int, Never> |
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
fileprivate struct KeyboardToolBar: ViewModifier { | |
let focusableIds: [String] | |
@State private var activeId: String? = nil | |
func body(content: Content) -> some View { | |
content | |
.toolbar { | |
ToolbarItemGroup(placement: .keyboard) { | |
if focusableIds.count > 1 { | |
Button { |
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 Swinject /// https://github.com/Swinject/Swinject.git | |
import Foundation | |
@propertyWrapper | |
public struct Inject<Dependency> { | |
public let wrappedValue: Dependency | |
public init(resolver: Resolver = AppAssembler.shared.resolver) { | |
wrappedValue = resolver.resolve(Dependency.self)! | |
} |
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 | |
/// The CarouselLayoutGenerator struct provides a convenient way to generate a UICollectionViewCompositionalLayout with a carousel-style layout. | |
/// This layout is suitable for creating horizontally scrolling carousels of items, commonly used in applications to showcase a series of items or images. | |
/// | |
/// Example: | |
/// ``` | |
/// +----------------------------+ | |
/// | ______________________ ____|_________________ ______________________ | |
/// | | | | | | | | |
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
// | |
// CollectionViewRepresentable.swift | |
// | |
// | |
// Created by Satish Vekariya on 12/11/2023. | |
// | |
import SwiftUI | |
import UIKit |
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 | |
import AVKit | |
public struct VideoPlayerView<Overlay: View>: View { | |
let overlay: Overlay | |
let player: AVPlayer | |
@State private var isShowOverlay = true | |
public init(_ player: AVPlayer, overlay: () -> (Overlay)) { | |
self.player = player |
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
struct UShape: Shape { | |
var radius: CGFloat = 8 | |
var inset: CGFloat = 5/2 | |
func path(in rect: CGRect) -> Path { | |
var path = Path() | |
let rect = rect.inset(by: .init(top: 0, left: inset, bottom: inset, right: inset)) | |
let width = rect.maxX | |
let height = rect.maxY | |
OlderNewer