2024-07-04 19:48:15 +05:30
|
|
|
//
|
|
|
|
|
// GamesWebViewVC.swift
|
|
|
|
|
// WOKA
|
|
|
|
|
//
|
|
|
|
|
// Created by MacBook Pro on 04/07/24.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
|
import WebKit
|
|
|
|
|
|
|
|
|
|
class GamesWebViewVC: UIViewController {
|
|
|
|
|
|
|
|
|
|
var url : String?
|
|
|
|
|
var orientation : ScreenOrientation?
|
|
|
|
|
|
|
|
|
|
@IBOutlet weak var webView: WKWebView!
|
|
|
|
|
|
|
|
|
|
override func viewDidLoad() {
|
|
|
|
|
super.viewDidLoad()
|
|
|
|
|
|
|
|
|
|
if let orientation, orientation == .landscape{
|
2024-08-01 00:08:56 +05:30
|
|
|
appDelegate.deviceOrientation = .landscapeRight
|
|
|
|
|
let value = UIInterfaceOrientation.landscapeRight.rawValue
|
|
|
|
|
UIDevice.current.setValue(value, forKey: "orientation")
|
2024-07-04 19:48:15 +05:30
|
|
|
rotateToLandsScapeDevice()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
guard let url else{return}
|
|
|
|
|
|
|
|
|
|
let authUrl = url + "?tk=" + AuthFunc.shareInstance.getAccessToken()
|
|
|
|
|
|
|
|
|
|
let link = URL(string: authUrl)!
|
|
|
|
|
let request = URLRequest(url: link)
|
|
|
|
|
webView.load(request)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func rotateToLandsScapeDevice(){
|
2024-08-01 00:08:56 +05:30
|
|
|
// let appDelegate = UIApplication.shared.delegate as! AppDelegate
|
|
|
|
|
// appDelegate.myOrientation = .landscapeRight
|
|
|
|
|
// if #available(iOS 16.0, *) {
|
|
|
|
|
// let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene
|
|
|
|
|
// windowScene?.requestGeometryUpdate(.iOS(interfaceOrientations: UIInterfaceOrientationMask.landscapeRight))
|
|
|
|
|
// } else {
|
|
|
|
|
// UIDevice.current.setValue(UIInterfaceOrientationMask.landscapeRight.rawValue, forKey: "orientation")
|
|
|
|
|
// }
|
|
|
|
|
// UIView.setAnimationsEnabled(true)
|
2024-07-04 19:48:15 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func rotateToPotraitScapeDevice(){
|
|
|
|
|
|
2024-08-01 00:08:56 +05:30
|
|
|
// let appDelegate = UIApplication.shared.delegate as! AppDelegate
|
|
|
|
|
// appDelegate.myOrientation = .portrait
|
|
|
|
|
// if #available(iOS 16.0, *) {
|
|
|
|
|
// let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene
|
|
|
|
|
// windowScene?.requestGeometryUpdate(.iOS(interfaceOrientations: UIInterfaceOrientationMask.portrait))
|
|
|
|
|
// } else {
|
|
|
|
|
// UIDevice.current.setValue(UIInterfaceOrientationMask.landscapeRight.rawValue, forKey: "orientation")
|
|
|
|
|
// }
|
|
|
|
|
//// UIDevice.current.setValue(UIInterfaceOrientation.portrait.rawValue, forKey: "orientation")
|
|
|
|
|
// UIView.setAnimationsEnabled(true)
|
2024-07-04 19:48:15 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@IBAction func backBtnTapped(_ sender: UIButton) {
|
|
|
|
|
let sb = UIStoryboard(name: K.StoryBoard.customAlerts, bundle: nil)
|
|
|
|
|
let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.CustomAlerts.yesNoAlertVC) as! YesNoAlertVC
|
|
|
|
|
vcPush.mainTitleText = "Warning"
|
|
|
|
|
vcPush.contentLabel = "Clicking \"OK\" will exit you from the game. Are you sure you want to proceed?"
|
|
|
|
|
vcPush.yesBtnText = "OK"
|
|
|
|
|
vcPush.noBtnText = "Cancel"
|
|
|
|
|
vcPush.onDoneBlock = { mode in
|
|
|
|
|
switch mode{
|
|
|
|
|
case .yes:
|
2024-08-01 00:08:56 +05:30
|
|
|
appDelegate.deviceOrientation = .portrait
|
|
|
|
|
|
|
|
|
|
let value = UIInterfaceOrientation.portrait.rawValue
|
|
|
|
|
UIDevice.current.setValue(value, forKey: "orientation")
|
|
|
|
|
UIViewController.attemptRotationToDeviceOrientation()
|
|
|
|
|
// Timer.scheduledTimer(withTimeInterval: 1, repeats: false) { _ in
|
|
|
|
|
// self.dismiss(animated: true)
|
|
|
|
|
// }
|
2024-07-04 19:48:15 +05:30
|
|
|
case .no:
|
|
|
|
|
print("no")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
vcPush.modalPresentationStyle = .overCurrentContext
|
|
|
|
|
vcPush.modalTransitionStyle = .crossDissolve
|
|
|
|
|
self.present(vcPush, animated: true)
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-01 00:08:56 +05:30
|
|
|
// MARK: - Handle Screen Transition
|
|
|
|
|
|
|
|
|
|
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
|
|
|
|
|
super.viewWillTransition(to: size, with: coordinator)
|
|
|
|
|
|
|
|
|
|
coordinator.animate(alongsideTransition: nil) { _ in
|
|
|
|
|
self.checkOrientation()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private func checkOrientation() {
|
|
|
|
|
let isPortrait = UIScreen.main.bounds.size.width < UIScreen.main.bounds.size.height
|
|
|
|
|
if isPortrait {
|
|
|
|
|
print("Device is in portrait mode")
|
|
|
|
|
Timer.scheduledTimer(withTimeInterval: 0.4, repeats: false) { _ in
|
|
|
|
|
self.dismiss(animated: true)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
print("Device is in landscape mode")
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-07-04 19:48:15 +05:30
|
|
|
}
|