Commit cf2d80e4 authored by Grigor Aghabalyan's avatar Grigor Aghabalyan
Browse files

Feat: add Date picek

parent d11fa925
......@@ -42,6 +42,10 @@
C5D691BC242AE1F8004268C3 /* FormCreateRequestForm.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5D691BB242AE1F8004268C3 /* FormCreateRequestForm.swift */; };
C5D691BE242AE510004268C3 /* FormCreateService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5D691BD242AE510004268C3 /* FormCreateService.swift */; };
C5D691C0242AE5E2004268C3 /* FormCreateResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5D691BF242AE5E2004268C3 /* FormCreateResponse.swift */; };
C5D691C2242AF07F004268C3 /* CurrentFormService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5D691C1242AF07F004268C3 /* CurrentFormService.swift */; };
C5D691C4242AF0B1004268C3 /* CurentFormRequestForm.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5D691C3242AF0B1004268C3 /* CurentFormRequestForm.swift */; };
C5D691D0242AFEB0004268C3 /* DatePickerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5D691CE242AFEB0004268C3 /* DatePickerViewController.swift */; };
C5D691D1242AFEB0004268C3 /* DatePickerViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = C5D691CF242AFEB0004268C3 /* DatePickerViewController.xib */; };
DFF30959C2696CFA212F54E4 /* Pods_App16.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AC947C811CE3C096F8981C77 /* Pods_App16.framework */; };
/* End PBXBuildFile section */
......@@ -86,6 +90,10 @@
C5D691BB242AE1F8004268C3 /* FormCreateRequestForm.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormCreateRequestForm.swift; sourceTree = "<group>"; };
C5D691BD242AE510004268C3 /* FormCreateService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormCreateService.swift; sourceTree = "<group>"; };
C5D691BF242AE5E2004268C3 /* FormCreateResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormCreateResponse.swift; sourceTree = "<group>"; };
C5D691C1242AF07F004268C3 /* CurrentFormService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurrentFormService.swift; sourceTree = "<group>"; };
C5D691C3242AF0B1004268C3 /* CurentFormRequestForm.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurentFormRequestForm.swift; sourceTree = "<group>"; };
C5D691CE242AFEB0004268C3 /* DatePickerViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatePickerViewController.swift; sourceTree = "<group>"; };
C5D691CF242AFEB0004268C3 /* DatePickerViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = DatePickerViewController.xib; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -196,6 +204,7 @@
isa = PBXGroup;
children = (
C5D691BD242AE510004268C3 /* FormCreateService.swift */,
C5D691C1242AF07F004268C3 /* CurrentFormService.swift */,
);
path = Services;
sourceTree = "<group>";
......@@ -211,6 +220,7 @@
C5D6916C242AA460004268C3 /* Views */ = {
isa = PBXGroup;
children = (
C5D691CD242AFEB0004268C3 /* DatePicker */,
C5D691B1242AD26C004268C3 /* Qr */,
C5D6919B242AADBD004268C3 /* Main */,
C5D691AC242AC5F3004268C3 /* Welcome */,
......@@ -326,10 +336,20 @@
children = (
C5D691BB242AE1F8004268C3 /* FormCreateRequestForm.swift */,
C5D691BF242AE5E2004268C3 /* FormCreateResponse.swift */,
C5D691C3242AF0B1004268C3 /* CurentFormRequestForm.swift */,
);
path = Form;
sourceTree = "<group>";
};
C5D691CD242AFEB0004268C3 /* DatePicker */ = {
isa = PBXGroup;
children = (
C5D691CE242AFEB0004268C3 /* DatePickerViewController.swift */,
C5D691CF242AFEB0004268C3 /* DatePickerViewController.xib */,
);
path = DatePicker;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
......@@ -395,6 +415,7 @@
C5D6915A242AA094004268C3 /* LaunchScreen.storyboard in Resources */,
C5D6919A242AAD3F004268C3 /* FormCreateViewController.xib in Resources */,
C5D691B5242AD290004268C3 /* QrViewController.xib in Resources */,
C5D691D1242AFEB0004268C3 /* DatePickerViewController.xib in Resources */,
C5D69190242AAC86004268C3 /* FormListViewController.xib in Resources */,
C5D691B0242AC607004268C3 /* WelcomeViewController.xib in Resources */,
C5D69157242AA094004268C3 /* Assets.xcassets in Resources */,
......@@ -465,7 +486,10 @@
C5D691A1242AAE12004268C3 /* MainViewController.swift in Sources */,
C5D69194242AAD00004268C3 /* SingleFormViewController.swift in Sources */,
C5D691BE242AE510004268C3 /* FormCreateService.swift in Sources */,
C5D691C2242AF07F004268C3 /* CurrentFormService.swift in Sources */,
C5D69170242AA4E9004268C3 /* Config.swift in Sources */,
C5D691C4242AF0B1004268C3 /* CurentFormRequestForm.swift in Sources */,
C5D691D0242AFEB0004268C3 /* DatePickerViewController.swift in Sources */,
C5D6916E242AA4D2004268C3 /* Settings.swift in Sources */,
C5D691B4242AD290004268C3 /* QrViewController.swift in Sources */,
C5D691AB242AC17D004268C3 /* UIView+Extensions.swift in Sources */,
......
......@@ -8,6 +8,7 @@
import UIKit
import IQKeyboardManagerSwift
import UserNotifications
@UIApplicationMain
......@@ -18,19 +19,38 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
IQKeyboardManager.shared.enable = true
UNUserNotificationCenter.current().delegate = self
//Notifications
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(
options: authOptions,
completionHandler: {_, _ in })
} else {
let settings: UIUserNotificationSettings =
UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
application.registerUserNotificationSettings(settings)
}
UIApplication.shared.registerForRemoteNotifications()
application.registerForRemoteNotifications()
return true
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
print("APNs token retrieved: \(deviceToken)")
let tokenParts = deviceToken.map { data -> String in
return String(format: "%02.2hhx", data)
}
let token = tokenParts.joined()
print(token)
UserDefaultsHelper.set(alias: .deviceToken, value: token)
}
print("APNs token retrieved: \(deviceToken)")
let tokenParts = deviceToken.map { data -> String in
return String(format: "%02.2hhx", data)
}
let token = tokenParts.joined()
print(token)
UserDefaultsHelper.set(alias: .deviceToken, value: token)
}
// MARK: UISceneSession Lifecycle
@available(iOS 13.0, *)
......@@ -50,3 +70,24 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}
// [START ios_10_message_handling]
@available(iOS 10, *)
extension AppDelegate : UNUserNotificationCenterDelegate {
// Receive displayed notifications for iOS 10 devices.
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
// let userInfo = notification.request.content.userInfo
// if let messageID = userInfo[gcmMessageIDKey] {
// print("Message ID: \(messageID)")
// }
// Print full message.
// print(userInfo)
// Change this to your preferred presentation option
completionHandler([])
}
}
......@@ -15,3 +15,12 @@ func getController<T: UIViewController>() -> T {
func changeRoot(_ controller: UIViewController) {
UIApplication.shared.keyWindow?.rootViewController = controller
}
extension Date {
func toString( dateFormat format : String ) -> String {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = format
return dateFormatter.string(from: self)
}
}
......@@ -17,7 +17,7 @@ class CheckBaseHelper {
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)
let alert = AlertControllerHelper.showAlert(title: "Սխալ", message: nil)
viewController.present(alert, animated: true, completion: nil)
case .unauthorized:
let alert = AlertControllerHelper.showAlert(title: "Invalid credentials", message: nil)
......
......@@ -9,6 +9,7 @@
import Foundation
enum DateFormat: String {
case ShortDate = "MM/dd/yyyy"
case LongDate = "MMMM dd, yyyy"
case EventClientDate = "dd MMMM yyyy"
......
//
// CurentFormRequestForm.swift
// App16
//
// Created by Grigor Aghabalyan on 3/25/20.
// Copyright © 2020 X-TECH. All rights reserved.
//
import Foundation
import ObjectMapper
class CurentFormRequestForm: Mappable {
var deviceToken: String?
required init?(map: Map) { }
init(deviceToken: String?) {
self.deviceToken = deviceToken
}
func mapping(map: Map) {
deviceToken <- map["device_token"]
}
}
//
// CurrentFormService.swift
// App16
//
// Created by Grigor Aghabalyan on 3/25/20.
// Copyright © 2020 X-TECH. All rights reserved.
//
import ObjectMapper
import AlamofireObjectMapper
import Alamofire
class CurrentFormService {
static let shered = CurrentFormService()
func retrive(data: CurentFormRequestForm, completion: @escaping ((FormCreateResponseData<FormCreateResponse>) -> Void)) {
BaseService.shared.get(endpoint: "/applications/current", parameters: data.toJSON(), for: .unsecure)
.responseString { (response) in
//print(response.result.value ?? "result value is nil")
if let responseHttp = response.response, let value = response.result.value {
if let baseResponse = BaseService.shared.checkBaseResponse(responseHttp, value) {
return completion(.base(response: baseResponse))
}
} else {
return completion(.isOffline)
}
switch response.response?.statusCode ?? 400 {
case 200:
if let value = response.result.value, let data = Mapper<FormCreateResponse>().map(JSONString: value) {
return completion(.success(result: data))
}
return completion(.base(response: .unexpectedError(error: ResponseUnexpectedError.mappingFailed)))
default:
return completion(.base(response: .badRequest))
}
}
}
}
......@@ -21,7 +21,7 @@ class FormCreateService {
func createForm(data: FormCreateRequestForm, completion: @escaping ((FormCreateResponseData<FormCreateResponse>) -> Void)) {
BaseService.shared.post(endpoint: "/applications", object: data.toJSON(), for: .unsecure)
.responseString { (response) in
//print(response.result.value ?? "result value is nil")
print(response.result.value ?? "result value is nil")
if let responseHttp = response.response, let value = response.result.value {
if let baseResponse = BaseService.shared.checkBaseResponse(responseHttp, value) {
return completion(.base(response: baseResponse))
......@@ -30,7 +30,7 @@ class FormCreateService {
return completion(.isOffline)
}
switch response.response?.statusCode ?? 400 {
case 200:
case 200...201:
if let value = response.result.value, let data = Mapper<FormCreateResponse>().map(JSONString: value) {
return completion(.success(result: data))
}
......
//
// DatePickerViewController.swift
// Yan
//
// Created by Grigor Aghabalyan on 2/26/20.
// Copyright © 2020 X-TECH. All rights reserved.
//
import UIKit
class DatePickerViewController: UIViewController {
// MARK: - IBOutlets
@IBOutlet weak var okButton: UIButton!
@IBOutlet weak var datePickerView: UIDatePicker!
// MARK: - RxVariables
var selectedDate: String?
private var callback: ((String?) -> ())?
// MARK: - LifeCycle
override func viewDidLoad() {
super.viewDidLoad()
datePickerView.addTarget(self, action: #selector(dateChanged(_:)), for: .valueChanged)
datePickerView.datePickerMode = .time
datePickerView.locale = Locale(identifier: "hy")
}
func getData(callback: @escaping (String?) -> ()) {
self.callback = callback
}
private func dismisView() {
self.dismiss(animated: true, completion: nil)
}
@objc func dateChanged(_ sender: UIDatePicker) {
let components = Calendar.current.dateComponents([.hour, .minute], from: sender.date)
if let hour = components.hour, let minute = components.minute {
selectedDate = String(format: "%02d:%02d", hour, minute)
}
}
@IBAction func okButtonAction(_ sender: UIButton) {
self.dismisView()
callback?(selectedDate)
}
}
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15705" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<customFonts key="customFonts">
<array key="SegoePro-Regular.ttf">
<string>SegoePro</string>
</array>
</customFonts>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="DatePickerViewController" customModule="App16" customModuleProvider="target">
<connections>
<outlet property="datePickerView" destination="Vlm-81-gMY" id="rAO-iD-Ddh"/>
<outlet property="okButton" destination="42S-LP-YBO" id="6C1-Z8-uju"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="AlP-zS-889">
<rect key="frame" x="0.0" y="680" width="414" height="216"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</view>
<datePicker contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" datePickerMode="dateAndTime" minuteInterval="1" translatesAutoresizingMaskIntoConstraints="NO" id="Vlm-81-gMY">
<rect key="frame" x="0.0" y="680" width="414" height="216"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</datePicker>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="wup-MC-w7E">
<rect key="frame" x="0.0" y="640" width="414" height="40"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="42S-LP-YBO">
<rect key="frame" x="374" y="5.5" width="40" height="29"/>
<constraints>
<constraint firstAttribute="width" constant="40" id="Mv9-ir-cmT"/>
</constraints>
<fontDescription key="fontDescription" name="SegoePro" family="Segoe Pro" pointSize="14"/>
<state key="normal" title="OK">
<color key="titleColor" name="pushedButton"/>
</state>
<connections>
<action selector="okButtonAction:" destination="-1" eventType="touchUpInside" id="uaB-gF-59p"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" name="mainBackground"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="JRD-7R-lKy"/>
<constraint firstAttribute="trailing" secondItem="42S-LP-YBO" secondAttribute="trailing" id="Pmg-3M-cNk"/>
<constraint firstItem="42S-LP-YBO" firstAttribute="centerY" secondItem="wup-MC-w7E" secondAttribute="centerY" id="bSK-wy-qgE"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="AlP-zS-889" firstAttribute="height" secondItem="Vlm-81-gMY" secondAttribute="height" id="26N-UT-cqK"/>
<constraint firstItem="Vlm-81-gMY" firstAttribute="leading" secondItem="fnl-2z-Ty3" secondAttribute="leading" id="6pS-By-OLO"/>
<constraint firstAttribute="bottom" secondItem="AlP-zS-889" secondAttribute="bottom" id="8ia-rd-X60"/>
<constraint firstItem="wup-MC-w7E" firstAttribute="trailing" secondItem="fnl-2z-Ty3" secondAttribute="trailing" id="EJN-Qz-bYy"/>
<constraint firstItem="wup-MC-w7E" firstAttribute="leading" secondItem="fnl-2z-Ty3" secondAttribute="leading" id="REu-Th-JwF"/>
<constraint firstItem="AlP-zS-889" firstAttribute="leading" secondItem="fnl-2z-Ty3" secondAttribute="leading" id="c11-rF-0ug"/>
<constraint firstItem="Vlm-81-gMY" firstAttribute="top" secondItem="wup-MC-w7E" secondAttribute="bottom" id="iXh-Qb-mCh"/>
<constraint firstItem="Vlm-81-gMY" firstAttribute="trailing" secondItem="fnl-2z-Ty3" secondAttribute="trailing" id="pMy-pd-ffn"/>
<constraint firstAttribute="bottom" secondItem="Vlm-81-gMY" secondAttribute="bottom" id="zPK-we-oZB"/>
<constraint firstItem="AlP-zS-889" firstAttribute="trailing" secondItem="fnl-2z-Ty3" secondAttribute="trailing" id="zf5-Ey-a13"/>
</constraints>
<viewLayoutGuide key="safeArea" id="fnl-2z-Ty3"/>
<point key="canvasLocation" x="137.68115942028987" y="126.5625"/>
</view>
</objects>
<resources>
<namedColor name="mainBackground">
<color red="0.97647058823529409" green="0.97647058823529409" blue="0.97647058823529409" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="pushedButton">
<color red="0.21568627450980393" green="0.5490196078431373" blue="0.88235294117647056" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
</resources>
</document>
......@@ -22,12 +22,35 @@ class FormCreateViewController: UIViewController {
@IBOutlet weak var createButton: UIButton!
@IBOutlet weak var activityIndicator: UIActivityIndicatorView!
// MARK: - LifeCycle
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func outDateButtonAction(_ sender: UIButton) {
let vc = DatePickerViewController()
vc.modalPresentationStyle = .overFullScreen
vc.modalTransitionStyle = .crossDissolve
vc.getData { [weak self] (date) in
self?.outDateTimeTextFiled.text = date
}
self.present(vc, animated: false, completion: nil)
}
@IBAction func planneDateTimeButtonAction(_ sender: UIButton) {
let vc = DatePickerViewController()
vc.modalPresentationStyle = .overFullScreen
vc.modalTransitionStyle = .crossDissolve
vc.getData { [weak self] (date) in
self?.planneDateTimeTextField.text = date
}
self.present(vc, animated: false, completion: nil)
}
@IBAction func createButtonAction(_ sender: UIButton) {
......@@ -56,21 +79,22 @@ class FormCreateViewController: UIViewController {
let firstName = UserDefaultsHelper.getString(for: .firstName)
let lastName = UserDefaultsHelper.getString(for: .lstName)
let middleName = UserDefaultsHelper.getString(for: .middleName)
let deviceToken = UserDefaultsHelper.getString(for: .deviceToken)
let deviceId = UIDevice.current.identifierForVendor?.uuidString
let date = Date().toString(dateFormat: DateFormat.StandartDate.rawValue)
let form = FormCreateRequestForm(deviceToken: deviceToken,
let form = FormCreateRequestForm(deviceToken: deviceId,
firstName: firstName,
lastName: lastName,
middleName: middleName,
outAddress: outAddressTextFiled.text,
outLatitude: nil,
outLongitude: nil,
outDatetime: outDateTimeTextFiled.text,
outDatetime: outDateTimeTextFiled.text != nil ? date + " " + outDateTimeTextFiled.text! : nil,
visitingAddressAndName: destinationAddressTextField.text,
visitingLatitude: nil,
visitingLongitude: nil,
visitingReason: destinationTypeTextField.text,
plannedReturnDatetime: planneDateTimeTextField.text)
plannedReturnDatetime: planneDateTimeTextField.text != nil ? date + " " + planneDateTimeTextField.text! : nil)
FormCreateService.shered.createForm(data: form) { (weaterResponseData) in
switch weaterResponseData {
......
......@@ -14,8 +14,7 @@ class MainViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
openLoginViewController()
retriveCurentForm()
}
private func openLoginViewController() {
......@@ -24,10 +23,41 @@ class MainViewController: UIViewController {
changeRoot(controller)
}
private func openFormCreateController() {
private func openQRController() {
let controller = QrViewController()
changeRoot(UINavigationController(rootViewController: controller))
}
private func openWelcomeController() {
let controller = FormCreateViewController()
let controller = WelcomeViewController()
changeRoot(UINavigationController(rootViewController: controller))
}
private func retriveCurentForm() {
let form = CurentFormRequestForm(deviceToken: UIDevice.current.identifierForVendor?.uuidString)
CurrentFormService.shered.retrive(data: form) { (weaterResponseData) in
switch weaterResponseData {
case .base(response: let baseResposne):
if UserDefaultsHelper.getString(for: .lstName) == nil {
self.openLoginViewController()
}else {
self.openWelcomeController()
}
CheckBaseHelper.checkBaseResponse(baseResposne, viewController: self)
case .success(_):
self.openQRController()
case .isOffline:
//self.activityIndicator.stopAnimating()
return
case .conflict:
//self.activityIndicator.stopAnimating()
return
}
}
}
}
......@@ -14,11 +14,19 @@ class QrViewController: UIViewController {
@IBOutlet weak var qrImageView: UIImageView!
@IBOutlet weak var fomrButton: UIButton!
@IBOutlet weak var finishButton: UIButton!
@IBOutlet weak var activityIndicator: UIActivityIndicatorView!
// MARK: - LifeCycle
override func viewDidLoad() {
super.viewDidLoad()
if let teviceId = UIDevice.current.identifierForVendor?.uuidString {
activityIndicator.isHidden = false
activityIndicator.startAnimating()
let url = "https://app16.x-tech.am/api/v1/applications/qr_code?device_token=\(teviceId)"
setImage(url, imageView: qrImageView)
}
}
// MARK: - Actions
......@@ -43,4 +51,19 @@ class QrViewController: UIViewController {
let controller = FormCreateViewController()
self.navigationController?.pushViewController(controller, animated: true)
}
private func setImage(_ imageURL: String, imageView: UIImageView) {
if let imageURL = URL(string: imageURL) {
imageView.af_setImage(withURL: imageURL,
placeholderImage: nil,
filter: nil,
progress: nil,
progressQueue: .main,
imageTransition: .crossDissolve(0.1),
runImageTransitionIfCached: true) { (response) in
self.activityIndicator.stopAnimating()
}
}
}
}
......@@ -10,6 +10,7 @@
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="QrViewController" customModule="App16" customModuleProvider="target">
<connections>
<outlet property="activityIndicator" destination="ahX-zy-qBz" id="AZ6-3u-nDS"/>
<outlet property="finishButton" destination="pPZ-K4-2Kg" id="7HX-fh-rYR"/>
<outlet property="fomrButton" destination="72Y-zH-s26" id="JJK-Uk-0Hu"/>