Skip to content

Instantly share code, notes, and snippets.

View mspvirajpatel's full-sized avatar
🏠
Working from home

Virajkumar Patel mspvirajpatel

🏠
Working from home
View GitHub Profile
public struct LoginUserData {
public var userId: String? = ""
public var userName: String? = ""
public var email: String? = ""
public var gender: Int = 0
public var birthday: String? = ""
public var about: String? = ""
public var photoUrl: String? = ""
public var idToken: String? = ""
public var accessToken: String? = ""
import Foundation
import AuthenticationServices
@available(iOS 13.0, *)
open class AppleSignInManager: NSObject {
static let shared: AppleSignInManager = AppleSignInManager()
var userData: LoginUserData? = nil
var isShareImageVideo: Bool = false
@mspvirajpatel
mspvirajpatel / RecordAudio.swift
Created August 7, 2019 09:01 — forked from hotpaw2/RecordAudio.swift
Swift Audio Recording class. Reads buffers of input samples from the microphone using the iOS RemoteIO Audio Unit API
//
// RecordAudio.swift
//
// This is a Swift class (updated for Swift 5)
// that uses the iOS RemoteIO Audio Unit
// to record audio input samples,
// (should be instantiated as a singleton object.)
//
// Created by Ronald Nicholson on 10/21/16.
// Copyright © 2017,2019 HotPaw Productions. All rights reserved.
@mspvirajpatel
mspvirajpatel / RPScreenWriter.swift
Created June 10, 2019 06:25
ScreenWriter With ReplayKit
import Foundation
import AVFoundation
import ReplayKit
class RPScreenWriter {
// Write video
var videoOutputURL: URL
var videoWriter: AVAssetWriter?
var videoInput: AVAssetWriterInput?
// Write audio
// Media is a video
let videoUrl = "Your URL FILE" as! NSURL
let asset = AVAsset(url: videoUrl as URL)
let first: CMTimeRange = CMTimeRange.init(start: kCMTimeZero, duration: CMTime.init(seconds: 2, preferredTimescale: asset.duration.timescale))
let firstScael: CMTime = CMTimeMakeWithSeconds((Float64(2) * Float64(5)), asset.duration.timescale)
let second: CMTimeRange = CMTimeRange.init(start: CMTime.init(seconds: 5, preferredTimescale: asset.duration.timescale), duration: CMTime.init(seconds: 5, preferredTimescale: asset.duration.timescale))
let secondScael: CMTime = CMTimeMakeWithSeconds((Float64(5) / Float64(5.0)), asset.duration.timescale)
extension UIImage {
enum CompressImageErrors: Error {
case invalidExSize
case sizeImpossibleToReach
}
func compressImage(_ expectedSizeKb: Int, completion : (UIImage,CGFloat) -> Void ) throws {
@mspvirajpatel
mspvirajpatel / IBInspectable.Swift
Created February 21, 2018 10:01
How to create an IBInspectable of type enum
enum StatusShape:Int {
case Rectangle
case Triangle
case Circle
}
// Programmatically: use the enum
var shape:StatusShape = .Rectangle
// IB: use the adapter
@mspvirajpatel
mspvirajpatel / ViewController.swift
Created February 19, 2018 03:59
Animate text change in UILabel (Label Fade Animation)
class ViewController: UIViewController {
@IBOutlet weak var label: UILabel!
var count = 0
@IBAction func doAction(_ sender: UIButton) {
// This will fade:
label.fadeTransition(0.4)
count += 1
label.text = "\(count)"
@mspvirajpatel
mspvirajpatel / APIManager.h
Last active September 22, 2017 09:33
API Call Manager Class Objective C
#import <Foundation/Foundation.h>
typedef NS_OPTIONS(NSInteger, APITask){
Login = 0,
Register = 1
};
@interface APIManager : NSObject
func uploadGoogleURL(imageName: String,contents : String,parentsFolderId : String?) {
self.showProgressHUD(viewController: self, title: "uploadImage".localize(), subtitle: "")
let metadata = GTLRDrive_File.init()
metadata.name = imageName
if parentsFolderId != nil
{
let folderId: String = parentsFolderId!
metadata.parents = [folderId]
}