Skip to content

Instantly share code, notes, and snippets.

View SwiftLogic's full-sized avatar
Flowing

OhSass from Swift Skool SwiftLogic

Flowing
View GitHub Profile
//
// HostingCell.swift
// theathletic-ios
//
// Created by .
// Copyright © 2021 The Athletic. All rights reserved.
//
import SwiftUI
import UIKit
@dabodamjan
dabodamjan / MailComposeViewController.swift
Last active April 24, 2024 07:31
Sending a contact us email on iOS 14 (can be also used with SwiftUI)
//
// Feel free to use this code in your project.
// Inspired by SO answer https://stackoverflow.com/a/65743126
// Uses DeviceKit as a dependency https://github.com/devicekit/DeviceKit
//
import Foundation
import MessageUI
import DeviceKit
@romiroma
romiroma / Tappable-SwiftUI.swift
Created October 31, 2020 06:06
Tappable Text in SwiftUI
import Foundation
import SwiftUI
struct TappableColoredText: View {
enum Component {
case text(String)
case tappable(String, () -> Void)
}
let components: [Component]
@clarkeben
clarkeben / UIKit-Animations.swift
Last active April 25, 2024 15:17
A list of simple yet effective animation extensions for UIKit
import UIKit
//MARK: - UIButton Animations
extension UIButton {
// Contract and retract animation
func contractRetractBtn(duration: Double) {
let contraction = CASpringAnimation(keyPath: "transform.scale")
contraction.duration = duration
contraction.fromValue = 0.96
import Foundation
extension Character {
var isEmoji: Bool {
return unicodeScalars.allSatisfy { $0.properties.isEmoji }
}
}
func recentlyUsedEmoji() -> [Character]? {
#if os(iOS)
@vakhidbetrakhmadov
vakhidbetrakhmadov / AVAsset+util.swift
Last active April 28, 2025 08:57
Cropping video track to a specified crop rectangle.
import Foundation
import AVFoundation
extension AVAsset {
func cropVideoTrack(at index: Int, cropRect: CGRect, outputURL: URL, completion: @escaping (Result<Void, Swift.Error>) -> Void) {
enum Orientation {
case up, down, right, left
//
// CameraController.swift
//
import AVFoundation
import Photos
import UIKit
class CameraController: UIViewController {
enum Camera {
@saurav12994
saurav12994 / index.js
Created July 31, 2018 05:42
Delete Folder in Firebase cloud storage using Cloud Function
I hava a folder inside CustomerDocuments in Firebase cloud storage name xyz which contains many types of file like .pdf,.txt,.png etc.
function deletefromstorage(quoteiddelete)
{
//quoteiddelete contains folder name in CustomerDocuments which we want to delete.
const Storage = require('@google-cloud/storage');
const storage = new Storage();
const srcBucketName = 'abc.apot.com';

If .DS_Store was never added to your git repository, simply add it to your .gitignore file.

If you don't have one, create a file called

.gitignore

In your the root directory of your app and simply write

@ccabanero
ccabanero / Sample iOS Unit Tests: Working with a ViewController that presents a UIAlertController
Last active September 4, 2022 20:17
Sample iOS Unit Tests: Working with a ViewController that presents a UIAlertController
func testControllerShowsAlertIfUserLogsInWithEmptyUsernameAndPasswordTextField() {
// mock of LoginViewController
class MockLoginViewController: LoginViewController {
var presentViewControllerTarget: UIViewController?
override func presentViewController(viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)?) {
presentViewControllerTarget = viewControllerToPresent
}
}