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
/// This is how often we will get device motion updates | |
/// 0.03 is more than often enough and is about the rate that the video frame changes! | |
motionManager.deviceMotionUpdateInterval = 0.03 | |
motionManager.startDeviceMotionUpdates(to: .main) { | |
[weak self] (data, error) in | |
guard let data = data, error == nil else { | |
return | |
} |
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
override func viewDidLayoutSubviews() { | |
super.viewDidLayoutSubviews() | |
/// viewDidLoad() is often too early to get the first initial attitude, so we use viewDidLayoutSubviews() instead | |
if let currentAttitude = motionManager.deviceMotion?.attitude { | |
/// we populate initialAttitude with the current attitude | |
initialAttitude = currentAttitude | |
} | |
} |
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 updateHighlightOrientations(attitude: CMAttitude) { | |
/// initialAttitude is an optional that points to the reference frame that the device started at | |
/// we set this when the device lays out it's subviews on the first launch | |
if let initAttitude = initialAttitude { | |
/// We can now translate the current attitude to the reference frame | |
attitude.multiply(byInverseOf: initAttitude) | |
/// Roll is the movement of the phone left and right, Pitch is forwards and backwards | |
let rollValue = attitude.roll.radiansToDegrees |
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
// | |
// ** iCimulator.swift ** | |
// | |
// MIT License | |
// | |
// Copyright (c) 2019 YuigaWada | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy |
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 Alamofire | |
let heroku_token = "4d6e1611-9b1a-4bdd-948c-1ea25dfb4178" | |
func load_all_apps(completion: @escaping ([Any]) -> ()) { | |
var json_apps_list: [Any] = [] | |
print("APP") | |
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 scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { | |
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. | |
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene. | |
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). | |
guard let _ = (scene as? UIWindowScene) else { return } | |
/// ↓ ADD THIS ↓ | |
if let rootWindow = window { | |
let iPhoneXSize = CGSize(width: 375, height: 812) /// if you're running this on an iPhone X, delete this line... | |
//let iPhone8Size = CGSize(width: 375, height: 667) /// ...and uncomment this line |
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 application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | |
// Override point for customization after application launch. | |
/// ↓ ADD THIS ↓ | |
if let rootWindow = window { | |
let iPhoneXSize = CGSize(width: 375, height: 812) /// if you're running this on an iPhone X, delete this line... | |
//let iPhone8Size = CGSize(width: 375, height: 667) /// ...and uncomment this line | |
Projector.display(rootWindow: rootWindow, testingSize: iPhoneXSize) | |
} |
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 Projector { | |
static func display(rootWindow: UIWindow, testingSize: CGSize) { | |
/// the size of the device that you're running your app on | |
let myDeviceSize = UIScreen.main.bounds.size | |
let myDeviceAspectRatio = myDeviceSize.width / myDeviceSize.height | |
let testingDeviceAspectRatio = testingSize.width / testingSize.height |
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
enum DeviceType { | |
//MARK: - iPhones | |
/** | |
iPhone 5, iPhone 5S, iPhone 5C, iPhone SE 1st gen | |
*/ | |
case iPhoneSE1 | |
/** | |
iPhone 6, iPhone 6S, iPhone 7, iPhone 8, iPhone SE 2nd gen |
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
let screenSize = DeviceType.iPhone11.getSize() | |
Projector.display(rootWindow: rootWindow, testingSize: screenSize) |