AppDelegate.swift 3.63 KB
Newer Older
Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
1
2
3
4
5
6
7
8
//
//  AppDelegate.swift
//  App16
//
//  Created by Grigor Aghabalyan on 3/25/20.
//  Copyright © 2020 X-TECH. All rights reserved.
//

Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
9

Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
10
import UIKit
Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
11
import IQKeyboardManagerSwift
Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
12
import UserNotifications
Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
13
14
15

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
16
17
18
    var window: UIWindow?
    
    func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
19
        
Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
20
        UINavigationBar.appearance().barTintColor = UIColor(red: 0/255, green: 137/255, blue: 40/255, alpha: 1)
Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
21
        UINavigationBar.appearance().titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
22
23
24
25
        UINavigationBar.appearance().tintColor = .white
        
        UINavigationBar.appearance().isTranslucent = false
        
Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
26
27
28
29
30
31
32
33
34
35
36
37
        if #available(iOS 13.0, *) {
            // In iOS 13 setup is done in SceneDelegate
        } else {
            let window = UIWindow(frame: UIScreen.main.bounds)
            self.window = window
            
            let mainstoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
            let newViewcontroller:UIViewController = mainstoryboard.instantiateViewController(withIdentifier: "MainViewController") as! MainViewController
            window.rootViewController = newViewcontroller
        }
        
        IQKeyboardManager.shared.enable = true
Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
38
        setDefaultLanguage()
Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
39
40
        return true
    }
Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
41
    
Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
42
43
44
45
46
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        if #available(iOS 13.0, *) {
            // In iOS 13 setup is done in SceneDelegate
        } else {
            self.window?.makeKeyAndVisible()
Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
47
        }
Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
48
49
        
        return true
Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
50
    }
Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
    
    func applicationWillResignActive(_ application: UIApplication) {
        // Not called under iOS 13 - See SceneDelegate sceneWillResignActive
    }
    
    func applicationDidEnterBackground(_ application: UIApplication) {
        // Not called under iOS 13 - See SceneDelegate sceneDidEnterBackground
    }
    
    func applicationWillEnterForeground(_ application: UIApplication) {
        // Not called under iOS 13 - See SceneDelegate sceneWillEnterForeground
    }
    
    func applicationDidBecomeActive(_ application: UIApplication) {
        // Not called under iOS 13 - See SceneDelegate sceneDidBecomeActive
    }
    
Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
68
    // MARK: UISceneSession Lifecycle
Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
69
    
Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
70
71
72
73
74
75
    @available(iOS 13.0, *)
    func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
        // Called when a new scene session is being created.
        // Use this method to select a configuration to create the new scene with.
        return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
    }
Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
76
    
Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
77
78
79
80
81
82
    @available(iOS 13.0, *)
    func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
        // Called when the user discards a scene session.
        // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
        // Use this method to release any resources that were specific to the discarded scenes, as they will not return.
    }
Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
83
84
85
86
87
88
89
90
    
    private func setDefaultLanguage() {
        
        if UserDefaultsHelper.getString(for: .locale) == nil {
            
            Settings.changeLanguage(Settings.Languages.Armenian.rawValue, langauge: "Հայերեն")
        }
    }
Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
91
}