Skip to content

Instantly share code, notes, and snippets.

View satishVekariya's full-sized avatar

Satish satishVekariya

View GitHub Profile
@satishVekariya
satishVekariya / UnknownProgressIndicator.swift
Created August 16, 2024 18:40
Unknown progress indicator view
struct UnknownProgressIndicator: View {
var size: CGFloat = 100
var primaryColor = Color(red: 1.0, green: 0.5, blue: 0.4)
var bgColor = Color(red: 0.155, green: 0.041, blue: 0.3)
var animationCycleTime: CGFloat = 3.5
@State private var rotation: CGFloat = 90
var body: some View {
Circle()
@satishVekariya
satishVekariya / List+StretchyBackground.swift
Last active May 31, 2024 22:08
These modifiers are designed to observe changes in the view's bounds and provide a stretchy background effect for a list.
import SwiftUI
/// These modifiers are designed to observe changes in the view's bounds and provide a stretchy background effect for a list.
///
/// Source: https://gist.github.com/satishVekariya/c52477b6acafdf200606335e39a37382
public extension View {
/// List/View bound change observer
///
/// Mostly you need to use this on List cell
///
@satishVekariya
satishVekariya / UShape.swift
Last active February 11, 2024 13:48
SwiftUI draw "U" shape
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
@satishVekariya
satishVekariya / VideoPlayerView.swift
Last active November 24, 2023 18:59
AvPlayer wrapper for SwiftUI
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
@satishVekariya
satishVekariya / CollectionViewRepresentable.swift
Last active November 13, 2023 14:39
A SwiftUI wrapper of UICollectionView that manages an ordered collection of data items and presents them using customizable layouts.
//
// CollectionViewRepresentable.swift
//
//
// Created by Satish Vekariya on 12/11/2023.
//
import SwiftUI
import UIKit
@satishVekariya
satishVekariya / CarouselLayoutGenerator.swift
Created November 10, 2023 20:32
The CarouselLayoutGenerator struct provides a convenient way to generate a UICollectionViewCompositionalLayout with a carousel-style layout.
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:
/// ```
/// +----------------------------+
/// | ______________________ ____|_________________ ______________________
/// | | | | | | | |
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)!
}
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 {
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>
//
// LastAtBottomVStack.swift
//
//
// Created by Satish Vekariya on 21/04/2023.
//
import SwiftUI
// MARK: - LastAtBottomVStack