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 | |
struct PagerManager<Content: View>: View { | |
let pageCount: Int | |
@Binding var currentIndex: Int | |
let content: Content | |
//Set the initial values for the variables | |
init(pageCount: Int, currentIndex: Binding<Int>, @ViewBuilder content: () -> Content) { | |
self.pageCount = pageCount |
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 ContentView: View { | |
@State private var currentPage = 0 | |
var body: some View { | |
//Pager Manager | |
VStack{ | |
PagerManager(pageCount: 2, currentIndex: $currentPage) { | |
Text("First page") | |
Text("Second page") |
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 UIKit | |
struct PageViewController: UIViewControllerRepresentable { | |
var controllers: [UIViewController] | |
@Binding var currentPage: Int | |
func makeCoordinator() -> Coordinator { | |
Coordinator(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
/** | |
* MacEditorTextView | |
* Copyright (c) Thiago Holanda 2020-2021 | |
* https://twitter.com/tholanda | |
* | |
* MIT license | |
*/ | |
import Combine | |
import SwiftUI |
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 Foundation | |
import PlaygroundSupport | |
PlaygroundPage.current.needsIndefiniteExecution = true | |
let credential = URLCredential(user: “[email protected]”, password: “password”, persistence: URLCredential.Persistence.forSession) | |
let protectionSpace = URLProtectionSpace(host: "example.com", port: 443, protocol: "https", realm: "Restricted", authenticationMethod: NSURLAuthenticationMethodHTTPBasic) | |
URLCredentialStorage.shared.setDefaultCredential(credential, for: protectionSpace) | |
let config = URLSessionConfiguration.default |
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
extension CGPath { | |
func apply(action: @escaping (CGPathElement)->()) { | |
var action = action | |
apply(info: &action) { | |
let action = $0!.bindMemory(to: ((CGPathElement)->()).self, capacity: 1).pointee | |
action($1.pointee) | |
} | |
} | |
} |
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 | |
import Photos | |
extension PHPhotoLibrary { | |
// MARK: - PHPhotoLibrary+SaveImage | |
// MARK: - Public | |
func savePhoto(image:UIImage, albumName:String, completion:((PHAsset?)->())? = nil) { | |
func save() { |
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
func copyDatabaseIfNeeded() { | |
// Move database file from bundle to documents folder | |
let fileManager = FileManager.default | |
let documentsUrl = fileManager.urls(for: .documentDirectory, | |
in: .userDomainMask) | |
guard documentsUrl.count != 0 else { | |
return // Could not find documents URL |
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 CustomActivity: UIActivity { | |
override class var activityCategory: UIActivityCategory { | |
return .action | |
} | |
override var activityType: UIActivityType? { | |
guard let bundleId = Bundle.main.bundleIdentifier else {return nil} |
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 | |
import PlaygroundSupport | |
PlaygroundPage.current.needsIndefiniteExecution = true | |
let url = URL(string: "http://ip.jsontest.com/")! | |
let session = URLSession.shared() | |
let q = session.dataTask(with: url) { data, response, error in | |
do { |
NewerOlder