Skip to content

Instantly share code, notes, and snippets.

View jasdev's full-sized avatar

Jasdev Singh jasdev

View GitHub Profile
@marcpalmer
marcpalmer / CombineExportProgressSample.swift
Last active April 10, 2023 02:09
Pulling down a video asset from Photos and exporting it, with progress and cancellation with Combine
/// Get the payload of a video asset and export it to a local temp file.
/// The resulting publsher will emit values until completed or cancelled. The `Double` is the progress,
/// which is a combination of the download progress and the export progress, so it will range from 0 to 1 but the
/// last export part is probably a lot quicker than the download part.
///
/// Calling cancel() on the publisher will cancel both the image request and the export as appropriate
func exportAVAsset(forPHAsset phAsset: PHAsset) -> (AnyPublisher<(URL?, Double), MediaError>) {
let avAssetOptions = PHVideoRequestOptions()
avAssetOptions.isNetworkAccessAllowed = true
avAssetOptions.deliveryMode = .highQualityFormat
@truizlop
truizlop / CircleWave.swift
Created September 29, 2020 15:43
Circle wave animation
import SwiftUI
struct CircleWave: Shape {
let N = 360
let SPEED: Double = 1 / 1000.0
let SHIFT: Double = 2 * Double.pi / 3
let FREQUENCY: Double = 8
var factor: Double
var colorIndex: Double
@mobilinked
mobilinked / gist:9b6086b3760bcf1e5432932dad0813c0
Last active February 9, 2024 13:03
SwiftUI - prevent auto dismiss the sheet by drag down
//
// Created by https://quickplan.app on 2020/11/8.
//
import SwiftUI
/// Control if allow to dismiss the sheet by the user actions
/// - Drag down on the sheet on iPhone and iPad
/// - Tap outside the sheet on iPad
/// No impact to dismiss programatically (by calling "presentationMode.wrappedValue.dismiss()")
//
// ContentView.swift
//
//
// Created by Bernstein, Joel on 7/4/20.
//
import SwiftUI
struct ElementModel: Identifiable
@stammy
stammy / TipsView.swift
Created July 4, 2020 17:24
SwiftUI MicroAnimation example
//
// TipsView.swift
// Stonks
//
// Created by Paul Stamatiou on 7/3/20.
//
import SwiftUI
import PlaygroundSupport
import SwiftUI
import PlaygroundSupport
// constants
let cardWidth: CGFloat = 343
let cardHeight: CGFloat = 212
let spacing = 36
let animation = Animation.spring()
let cardColors = [
Color(UIColor.systemRed),
@mergesort
mergesort / AnimationDemo.swift
Last active December 18, 2023 02:34
A SwiftUI prototype animation for adding/removing players from a game
import SwiftUI
let colors = [
Color.pink,
Color.blue,
Color.green,
Color.orange,
Color.purple,
Color.black,
]
//
// Spinner.swift
// spinner
//
// Created by Soroush Khanlou on 5/29/20.
// Copyright © 2020 Soroush Khanlou. All rights reserved.
//
import SwiftUI
@joshdholtz
joshdholtz / Fastfile
Created May 28, 2020 15:57
fastlane - Get TestFlight Feedback
lane :connect_feedback do
fastlane_require 'spaceship'
Spaceship::Tunes.login
Spaceship::Tunes.select_team
# Gets app
app = Spaceship::ConnectAPI::App.find(ENV["TEST_APP_BUNDLE"])
# Gets feedback for an app (default includes screenshots and tester info)
@xtabbas
xtabbas / SnapCarousel.swift
Created May 10, 2020 18:13
A carousel that snap items in place build on top of SwiftUI
//
// SnapCarousel.swift
// prototype5
//
// Created by xtabbas on 5/7/20.
// Copyright © 2020 xtadevs. All rights reserved.
//
import SwiftUI