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 CGFloat { | |
var dp: CGFloat { | |
var finalSize = (self / 375) * UIScreen.main.bounds.width | |
if UIScreen.main.bounds.width <= 320 { // For iPhone 5S | |
finalSize = self * 0.95 | |
} | |
return finalSize | |
} | |
} |
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
var mediaJSON = { "categories" : [ { "name" : "Movies", | |
"videos" : [ | |
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org", | |
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ], | |
"subtitle" : "By Blender Foundation", | |
"thumb" : "images/BigBuckBunny.jpg", | |
"title" : "Big Buck Bunny" | |
}, | |
{ "description" : "The first Blender Open Movie from 2006", | |
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ], |
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 query(address: String) -> String { | |
let url = URL(string: address) | |
let semaphore = DispatchSemaphore(value: 0) | |
var result: String = "" | |
let task = URLSession.shared.dataTask(with: url!) {(data, response, error) in | |
result = String(data: data!, encoding: String.Encoding.utf8)! | |
semaphore.signal() | |
} |
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
// | |
// NotificationScheduler.swift | |
// LocationNotifier | |
// | |
import UIKit | |
import UserNotifications | |
protocol NotificationSchedulerDelegate: UNUserNotificationCenterDelegate { |
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
// | |
// PieChart.swift | |
// NokiaGame | |
// | |
// Created by Prafulla Singh on 13/9/20. | |
// Copyright © 2020 Prafulla Singh. All rights reserved. | |
// | |
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 | |
public extension Int { | |
public var int32Value: Int32 { return Int32(self) } | |
public var int64Value: Int64 { return Int64(self) } | |
public var uintValue: UInt { return UInt(self) } | |
public var doubleValue: Double { return Double(self) } | |
public var floatValue: CGFloat { return CGFloat(self) } | |
public var float64Value: Float64 { return Float64(self) } | |
public var numberValue: NSNumber { return NSNumber(integerLiteral: 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
// | |
// UIView+Extension.swift | |
// | |
// Created by Bishal Ghimire on 4/30/16. | |
// Copyright © 2016 Bishal Ghimire. All rights reserved. | |
// | |
import UIKit | |
// |
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
// Example: view.round([.TopLeft, .TopRight], radius: 15) | |
extension UIView { | |
/** | |
Rounds the given set of corners to the specified radius | |
- parameter corners: Corners to round | |
- parameter radius: Radius to round to | |
*/ | |
func round(corners: UIRectCorner, radius: CGFloat) { |
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 evaluateJavaScript(to webView: WKWebView) { | |
let p = "var y = document.getElementsByTagName(\"P\"); var i; for (i = 0; i < y.length; i++) {y[i].style.fontSize = \"500%\";}" | |
webView.evaluateJavaScript(p) {(result, error) in | |
guard error == nil else { | |
print(error!) | |
return | |
} | |
print(String(describing: result)) | |
} |
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
// | |
// ImagePicker.swift | |
// UIImagePicker | |
// | |
// Created by M Usman on 08/11/2019. | |
// Copyright © 2019 M Usman. All rights reserved. | |
// | |
import SwiftUI | |
import Combine |
NewerOlder