Commit 77264b45 authored by Grigor Aghabalyan's avatar Grigor Aghabalyan
Browse files

First commit

parents
# Created by https://www.gitignore.io/api/xcode,carthage,cocoapods
# Edit at https://www.gitignore.io/?templates=xcode,carthage,cocoapods
.idea
.DS_Store
### Carthage ###
# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts
Carthage/Build
### CocoaPods ###
## CocoaPods GitIgnore Template
# CocoaPods - Only use to conserve bandwidth / Save time on Pushing
# - Also handy if you have a large number of dependant pods
# - AS PER https://guides.cocoapods.org/using/using-cocoapods.html NEVER IGNORE THE LOCK FILE
Pods/
### Xcode ###
# Xcode
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## User settings
xcuserdata/
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
*.xcscmblueprint
*.xccheckout
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
build/
DerivedData/
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
## Xcode Patch
*.xcodeproj/*
!*.xcodeproj/project.pbxproj
!*.xcodeproj/xcshareddata/
!*.xcworkspace/contents.xcworkspacedata
/*.gcno
### Xcode Patch ###
**/xcshareddata/WorkspaceSettings.xcsettings
# End of https://www.gitignore.io/api/xcode,carthage,cocoapods
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:App16.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
//
// AppDelegate.swift
// App16
//
// Created by Grigor Aghabalyan on 3/25/20.
// Copyright © 2020 X-TECH. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
// MARK: UISceneSession Lifecycle
@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)
}
@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.
}
}
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15705" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="guI-71-aGH">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Main View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="MainViewController" customModule="App16" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
<navigationItem key="navigationItem" id="2ZQ-E5-2sE"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1047.8260869565217" y="134.59821428571428"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="nWW-W9-vx4">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="guI-71-aGH" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="TeA-vN-4M2">
<rect key="frame" x="0.0" y="44" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="BYZ-38-t0r" kind="relationship" relationship="rootViewController" id="xxJ-tu-BMh"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="TJx-tg-VTe" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="137.68115942028987" y="134.59821428571428"/>
</scene>
</scenes>
</document>
//
// Config.swift
// App16
//
// Created by Grigor Aghabalyan on 3/25/20.
// Copyright © 2020 X-TECH. All rights reserved.
//
import Foundation
struct Config {
static let ENVIRONMENT = "DEV"
static let HOST_NAME = "openweathermap.org"
static let BASE_URL = "https://api." + Config.HOST_NAME + "/data/2.5"
static let API_TOKEN = ""
static let API_VERSION = "v1"
static let API_FORMAT = "json"
static let DEBUG = true
}
//
// Extensions.swift
// App16
//
// Created by Grigor Aghabalyan on 3/25/20.
// Copyright © 2020 X-TECH. All rights reserved.
//
import UIKit
func getController<T: UIViewController>() -> T {
return T(nibName: String(describing: T.self), bundle: nil)
}
func changeRoot(_ controller: UIViewController) {
UIApplication.shared.keyWindow?.rootViewController = controller
}
//
// AlertControllerHelper.swift
// App16
//
// Created by Grigor Aghabalyan on 3/25/20.
// Copyright © 2020 X-TECH. All rights reserved.
//
import Foundation
import UIKit
class AlertControllerHelper {
class func showAlert(title: String?, message: String?) -> UIAlertController {
let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertController.Style.alert)
let okBt = UIAlertAction(title: "OK", style: UIAlertAction.Style.default) { (result : UIAlertAction) -> Void in}
alert.addAction(okBt)
return alert
}
}
//
// CheckBaseHelper.swift
// App16
//
// Created by Grigor Aghabalyan on 3/25/20.
// Copyright © 2020 X-TECH. All rights reserved.
//
import Foundation
import UIKit
class CheckBaseHelper {
static func checkBaseResponse(_ baseResponse: BaseResponse, viewController: UIViewController) {
switch baseResponse {
case .badRequest:
let alert = AlertControllerHelper.showAlert(title: "Bed request", message: nil)
viewController.present(alert, animated: true, completion: nil)
case .validationProblem(error: let error):
let alert = AlertControllerHelper.showAlert(title: error.detail, message: nil)
viewController.present(alert, animated: true, completion: nil)
case .unauthorized:
let alert = AlertControllerHelper.showAlert(title: "Invalid credentials", message: nil)
viewController.present(alert, animated: true, completion: nil)
case .serviceOffline:
let alert = AlertControllerHelper.showAlert(title: "Service is Offline", message: nil)
viewController.present(alert, animated: true, completion: nil)
case .notFound:
let alert = AlertControllerHelper.showAlert(title: "Bad credentials", message: nil)
viewController.present(alert, animated: true, completion: nil)
case .unexpectedError(error: let error):
let alert = AlertControllerHelper.showAlert(title: error.message, message: nil)
viewController.present(alert, animated: true, completion: nil)
}
}
}
//
// DateFormat.swift
// App16
//
// Created by Grigor Aghabalyan on 3/25/20.
// Copyright © 2020 X-TECH. All rights reserved.
//
import Foundation
enum DateFormat: String {
case ShortDate = "MM/dd/yyyy"
case LongDate = "MMMM dd, yyyy"
case EventClientDate = "dd MMMM yyyy"
case ShortTime = "HH.mm"
case ShortDataRevers = "dd/MM/yy"
case HoursAndSeconds = "HH:mm"
case StandartDate = "yyyy-MM-dd"
case specific = "d MMM yyyy"
case day = "d"
case hour = "h"
case month = "M"
}
enum DateFormatterFormats: String {
case long = "yyyy-MM-dd'T'HH:mm:ss.SSS"
case middle = "yyyy-MM-dd'T'HH:mm:ss"
case short = "yyyy-MM-dd"
}
class DateFormattingHelper {
static private let formatter = DateFormatter()
static let formatterForParse = { (_ format: DateFormatterFormats ) -> DateFormatter in
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = format.rawValue
return dateFormatter
}
static func stringFrom(date: Date?, format: DateFormat) -> String {
guard let date = date else {
return ""
}
formatter.dateFormat = format.rawValue
return formatter.string(from: date)
}
static func dateFrom(string: String, format: DateFormat) -> Date {
formatter.dateFormat = format.rawValue
return formatter.date(from: string) ?? Date()
}
}
//
// UserDefaultsHelper.swift
// App16
//
// Created by Grigor Aghabalyan on 3/25/20.
// Copyright © 2020 X-TECH. All rights reserved.
//
import UIKit
enum UDAliases: String {
case AuthToken = "auth_token"
case logined
}
class UserDefaultsHelper {
static func isNil(_ alias: UDAliases) -> Bool {
return UserDefaults.standard.string(forKey: alias.rawValue) == nil
}
static func getString(for alias: UDAliases) -> String? {
return UserDefaults.standard.string(forKey: alias.rawValue)
}
static func get(alias: UDAliases) -> Any? {
return UserDefaults.standard.string(forKey: alias.rawValue)
}
static func boolFor(alias: UDAliases) -> Bool? {
return UserDefaults.standard.bool(forKey: alias.rawValue)
}
static func set(alias: UDAliases, value: String) {
UserDefaults.standard.set(value, forKey: alias.rawValue)
}
static func set(alias: UDAliases, value: Any?) {
UserDefaults.standard.set(value, forKey: alias.rawValue)
}
static func remove(alias: UDAliases) {
UserDefaults.standard.removeObject(forKey: alias.rawValue)
}
static func remove(aliases: UDAliases...) {
aliases.forEach { (alias) in
UserDefaults.standard.removeObject(forKey: alias.rawValue)
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
<key>UISceneStoryboardFile</key>
<string>Main</string>
</dict>
</array>
</dict>
</dict>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
//
// BaseResponse.swift
// App16
//
// Created by Grigor Aghabalyan on 3/25/20.
// Copyright © 2020 X-TECH. All rights reserved.
//
import Foundation
enum BaseResponse {
case serviceOffline
/* http status code 400 */
case badRequest
/* http status code 401 */
case unauthorized
/* http status code 404 */
case notFound
/* http status code 422 */
case validationProblem(error: ValidationError)
/* http status code 500 */
case unexpectedError(error: ResponseUnexpectedError)
}
//
// BaseService.swift
// App16