Commit 8845f56f authored by Grigor Aghabalyan's avatar Grigor Aghabalyan
Browse files

Merge branch 'dev' into 'master'

Dev

See merge request !1
parents dbe085c0 d56554a3
......@@ -646,6 +646,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = JY829SQQAV;
INFOPLIST_FILE = App16/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
......@@ -656,7 +657,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "am.x-tech.App16";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = 1;
};
name = Debug;
};
......@@ -666,6 +667,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = JY829SQQAV;
INFOPLIST_FILE = App16/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
......@@ -676,7 +678,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "am.x-tech.App16";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = 1;
};
name = Release;
};
......
......@@ -6,88 +6,78 @@
// Copyright © 2020 X-TECH. All rights reserved.
//
import UIKit
import IQKeyboardManagerSwift
import UserNotifications
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
var window: UIWindow?
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
IQKeyboardManager.shared.enable = true
UINavigationBar.appearance().barTintColor = UIColor(red: 0/255, green: 137/255, blue: 40/255, alpha: 1)
UINavigationBar.appearance().titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
UINavigationBar.appearance().tintColor = .white
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 })
UINavigationBar.appearance().isTranslucent = false
if #available(iOS 13.0, *) {
// In iOS 13 setup is done in SceneDelegate
} else {
let settings: UIUserNotificationSettings =
UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
application.registerUserNotificationSettings(settings)
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
}
UIApplication.shared.registerForRemoteNotifications()
application.registerForRemoteNotifications()
IQKeyboardManager.shared.enable = true
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)
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()
}
let token = tokenParts.joined()
print(token)
UserDefaultsHelper.set(alias: .deviceToken, value: token)
return true
}
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
}
// 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.
}
}
// [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([])
}
}
......@@ -11,7 +11,7 @@
<!--Main View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="MainViewController" customModule="App16" customModuleProvider="target" sceneMemberID="viewController">
<viewController storyboardIdentifier="MainViewController" 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"/>
......
......@@ -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: "Սխալ", message: nil)
let alert = AlertControllerHelper.showAlert(title: error.title, message: error.invalidParams.first?.messages?.first)
viewController.present(alert, animated: true, completion: nil)
case .unauthorized:
let alert = AlertControllerHelper.showAlert(title: "Invalid credentials", message: nil)
......
......@@ -17,7 +17,7 @@
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIApplicationSceneManifest</key>
......
......@@ -10,10 +10,11 @@ import Foundation
import ObjectMapper
class ValidationError: Mappable {
var type: String = ""
var title: String = ""
var detail: String = ""
var invalidParams: [InvalidParam] = []
var invalidParams: [ValidationErrorFields] = []
required init?(map: Map) {
......@@ -21,9 +22,26 @@ class ValidationError: Mappable {
func mapping(map: Map) {
type <- map["type"]
title <- map["title"]
title <- map["error.message"]
detail <- map["detail"]
invalidParams <- map["invalidParams"]
invalidParams <- map["error.fields"]
}
}
class ValidationErrorFields: Mappable {
var key: String?
var messages: [String]?
required init?(map: Map) {
}
func mapping(map: Map) {
key <- map["key"]
messages <- map["messages"]
}
}
......
......@@ -12,13 +12,11 @@ import UIKit
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
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 }
}
func sceneDidDisconnect(_ scene: UIScene) {
......@@ -48,7 +46,4 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
// Use this method to save data, release shared resources, and store enough scene-specific state information
// to restore the scene back to its current state.
}
}
......@@ -15,7 +15,7 @@ class DatePickerViewController: UIViewController {
@IBOutlet weak var datePickerView: UIDatePicker!
// MARK: - RxVariables
var selectedDate: String?
var selectedDate = Date().toString(dateFormat: DateFormat.HoursAndSeconds.rawValue)
private var callback: ((String?) -> ())?
......@@ -27,7 +27,7 @@ class DatePickerViewController: UIViewController {
datePickerView.datePickerMode = .time
datePickerView.locale = Locale(identifier: "hy")
datePickerView.setValue(UIColor.black, forKeyPath: "textColor")
}
func getData(callback: @escaping (String?) -> ()) {
......@@ -46,7 +46,9 @@ class DatePickerViewController: UIViewController {
selectedDate = String(format: "%02d:%02d", hour, minute)
}
}
@IBAction func okButtonAction(_ sender: UIButton) {
self.dismisView()
callback?(selectedDate)
}
......
......@@ -28,7 +28,7 @@
<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"/>
<color key="backgroundColor" red="0.99999600649999998" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</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"/>
......
......@@ -6,41 +6,63 @@
// Copyright © 2020 X-TECH. All rights reserved.
//
enum FormViewType {
case viewFromList
case viewFromQr
case creta
}
import UIKit
import IQKeyboardManagerSwift
class FormCreateViewController: UIViewController {
// MARK: - IBOutlets
@IBOutlet weak var curentDate: UILabel!
@IBOutlet weak var outDateTimeTextFiled: UITextField!
@IBOutlet weak var outAddressTextFiled: UITextField!
@IBOutlet weak var destinationAddressTextField: UITextField!
@IBOutlet weak var planneDateTimeTextField: UITextField!
@IBOutlet weak var destinationTypeTextField:
UITextField!
@IBOutlet weak var destinationTypeTextField: UITextField!
@IBOutlet weak var createButton: UIButton!
@IBOutlet weak var activityIndicator: UIActivityIndicatorView!
@IBOutlet weak var outDateButtonAction: UIButton!
@IBOutlet weak var planneDateTimeButton: UIButton!
var isCreateMode = false
// MARK: - Variables
var data: FormResponse!
var formViewType: FormViewType = .creta
// MARK: - LifeCycle
override func viewDidLoad() {
super.viewDidLoad()
if isCreateMode {
switch formViewType {
case .creta:
createButton.isHidden = false
self.title = "Ավելացնել ձևաթուղթ"
}else {
self.title = "Ստեղծել ձևաթուղթ"
case .viewFromList:
self.title = "Ձևաթուղթ"
createButton.isHidden = true
setData(response: data)
case .viewFromQr:
self.title = "Ձևաթուղթ"
createButton.isHidden = true
retriveCurentForm()
}
let date = Date().toString(dateFormat: DateFormat.StandartDate.rawValue)
curentDate.text = date
}
// MARK: - Actions
@IBAction func outDateButtonAction(_ sender: UIButton) {
let vc = DatePickerViewController()
......@@ -129,31 +151,37 @@ class FormCreateViewController: UIViewController {
}
private func retriveCurentForm() {
let form = CurentFormRequestForm(deviceToken: UIDevice.current.identifierForVendor?.uuidString)
CurrentFormService.shered.retrive(data: form) { (responseData) in
switch responseData {
case .base(response: let baseResposne):
CheckBaseHelper.checkBaseResponse(baseResposne, viewController: self)
case .success(let response):
activityIndicator.isHidden = false
activityIndicator.startAnimating()
let form = CurentFormRequestForm(deviceToken: UIDevice.current.identifierForVendor?.uuidString)
CurrentFormService.shered.retrive(data: form) { (responseData) in
switch responseData {
case .base(response: let baseResposne):
self.activityIndicator.stopAnimating()
CheckBaseHelper.checkBaseResponse(baseResposne, viewController: self)
case .success(let response):
self.activityIndicator.stopAnimating()
DispatchQueue.main.async {
self.setData(response: response)
self.setData(response: response.data )
}
case .isOffline:
case .isOffline:
return
case .conflict:
self.activityIndicator.stopAnimating()
return
case .conflict:
return
}
}
}
self.activityIndicator.stopAnimating()
return
}
}
}
private func setData(response: FormCreateResponse) {
private func setData(response: FormResponse?) {
destinationAddressTextField.isUserInteractionEnabled = false
planneDateTimeTextField.isUserInteractionEnabled = false
......@@ -162,15 +190,16 @@ class FormCreateViewController: UIViewController {
outDateButtonAction.isUserInteractionEnabled = false
planneDateTimeButton.isUserInteractionEnabled = false
outAddressTextFiled.isUserInteractionEnabled = false
outDateTimeTextFiled.isUserInteractionEnabled = false
planneDateTimeTextField.isUserInteractionEnabled = false
outDateTimeTextFiled.text = response.data?.outDatetime
outAddressTextFiled.text = response.data?.outAddress
outDateTimeTextFiled.text = response?.outDatetime
outAddressTextFiled.text = response?.outAddress
destinationAddressTextField.text = response.data?.visitingAddressAndName
planneDateTimeTextField.text = response.data?.plannedReturnDatetime
destinationTypeTextField.text = response.data?.visitingReason
destinationAddressTextField.text = response?.visitingAddressAndName
planneDateTimeTextField.text = response?.plannedReturnDatetime
destinationTypeTextField.text = response?.visitingReason
}
}
......@@ -23,31 +23,31 @@
<label opaque="NO" userInteractionEnabled="NO" alpha="0.41999999999999998" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="25.03.20" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="oeh-Ou-ekY">
<rect key="frame" x="28" y="8" width="333" height="18"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<nil key="textColor"/>
<color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Ելքի ժամ։" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="wnZ-Nm-n2v">
<rect key="frame" x="8" y="29" width="84" height="20"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="16"/>
<nil key="textColor"/>
<color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" text="16։00 AM" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="tda-Za-9BL">
<rect key="frame" x="96" y="29" width="265" height="20"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<nil key="textColor"/>
<color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Վերադարձի ժամ։" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="0kk-CH-aEy">
<rect key="frame" x="8" y="57" width="153" height="20"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="16"/>
<nil key="textColor"/>
<color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" text="16։00 AM" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="pem-jd-5mO">
<rect key="frame" x="169" y="57" width="192" height="20"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<nil key="textColor"/>
<color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
</subviews>
......@@ -78,6 +78,7 @@
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="5OJ-Lh-Jnc" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="16" id="Dif-PR-mhb"/>
<constraint firstAttribute="trailing" secondItem="5OJ-Lh-Jnc" secondAttribute="trailing" constant="16" id="Q2J-46-mfn"/>
......
......@@ -12,6 +12,7 @@ class FormListViewController: UIViewController {
// MARK: - IBOutlet
@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var activityIndicator: UIActivityIndicatorView!
// MARK: - Varibales
private let formListCell = "FormListCell"
......@@ -25,6 +26,7 @@ class FormListViewController: UIViewController {
tableView.dataSource = self
registerCelll()
self.title = "Պատմություն"
if let deviceId = UIDevice.current.identifierForVendor?.uuidString {
retriveCurentForm(deviceToken: deviceId)
......@@ -40,23 +42,27 @@ class FormListViewController: UIViewController {
private func retriveCurentForm(deviceToken: String) {
activityIndicator.isHidden = false
activityIndicator.startAnimating()
let form = CurentFormRequestForm(deviceToken: UIDevice.current.identifierForVendor?.uuidString)
FormsService.shered.retriveForms(data: form) { (responseData) in
switch responseData {
case .base(response: let baseResposne):
self.activityIndicator.stopAnimating()
CheckBaseHelper.checkBaseResponse(baseResposne, viewController: self)
case .success(let response):
self.activityIndicator.stopAnimating()
self.dataSource = response.data ?? []
DispatchQueue.main.async {
self.tableView.reloadData()
}
case .isOffline:
//self.activityIndicator.stopAnimating()
self.activityIndicator.stopAnimating()
return
case .conflict:
//self.activityIndicator.stopAnimating()
self.activityIndicator.stopAnimating()
return
}
}
......@@ -85,15 +91,14 @@ extension FormListViewController: UITableViewDataSource {
extension FormListViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
openCreateFormView()
print(indexPath.row)
openCreateFormView(index: indexPath.row)
}
private func openCreateFormView() {
private func openCreateFormView(index: Int) {
let controller = FormCreateViewController()
controller.isCreateMode = false
controller.formViewType = .viewFromList
controller.data = dataSource[index]
self.navigationController?.navigationBar.topItem?.title = " "
self.navigationController?.pushViewController(controller, animated: true)
}
......
......@@ -10,6 +10,7 @@
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="FormListViewController" customModule="App16" customModuleProvider="target">
<connections>
<outlet property="activityIndicator" destination="5tF-n7-YKL" id="jRm-bP-GRh"/>
<outlet property="tableView" destination="HZb-fy-7lq" id="4bl-6f-doL"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
</connections>
......@@ -21,14 +22,19 @@
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="none" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="HZb-fy-7lq">
<rect key="frame" x="0.0" y="52" width="414" height="844"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<color key="backgroundColor" red="0.99999600649999998" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</tableView>
<activityIndicatorView hidden="YES" opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" hidesWhenStopped="YES" style="medium" translatesAutoresizingMaskIntoConstraints="NO" id="5tF-n7-YKL">
<rect key="frame" x="197" y="438" width="20" height="20"/>
</activityIndicatorView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="HZb-fy-7lq" firstAttribute="leading" secondItem="fnl-2z-Ty3" secondAttribute="leading" id="2Ot-Go-5dk"/>
<constraint firstItem="HZb-fy-7lq" firstAttribute="trailing" secondItem="fnl-2z-Ty3" secondAttribute="trailing" id="JJa-S3-A8H"/>
<constraint firstItem="5tF-n7-YKL" firstAttribute="centerY" secondItem="i5M-Pr-FkT" secondAttribute="centerY" id="JRh-dp-FPF"/>
<constraint firstAttribute="bottom" secondItem="HZb-fy-7lq" secondAttribute="bottom" id="Ma1-TH-OLm"/>