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

Merge branch 'master' into dev

parents 593a6961 a2e815cd
......@@ -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>
......
......@@ -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>
......@@ -23,12 +24,17 @@
<rect key="frame" x="0.0" y="52" width="414" height="844"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
</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"/>
<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"/>
<constraint firstItem="5tF-n7-YKL" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="PZ1-5Q-16f"/>
<constraint firstItem="HZb-fy-7lq" firstAttribute="top" secondItem="fnl-2z-Ty3" secondAttribute="top" constant="8" id="dLk-Zr-Bbk"/>
</constraints>
<viewLayoutGuide key="safeArea" id="fnl-2z-Ty3"/>
......
......@@ -40,6 +40,7 @@
</view>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Անուն" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="YHD-ah-neD">
<rect key="frame" x="25" y="10" width="284" height="29"/>
<color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<textInputTraits key="textInputTraits"/>
</textField>
......@@ -73,6 +74,7 @@
</view>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Ազգանուն" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="hzo-dL-cmW">
<rect key="frame" x="25" y="10" width="284" height="29"/>
<color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<textInputTraits key="textInputTraits"/>
</textField>
......@@ -106,6 +108,7 @@
</view>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Հայրանուն" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="gwp-uV-LBg">
<rect key="frame" x="25" y="10" width="284" height="29"/>
<color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<textInputTraits key="textInputTraits"/>
</textField>
......@@ -154,7 +157,7 @@
</constraints>
</imageView>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="0Fv-DJ-48Q" secondAttribute="trailing" constant="40" id="4iV-DE-utu"/>
<constraint firstAttribute="bottom" secondItem="XbI-AN-w8C" secondAttribute="bottom" constant="40" id="6dP-Mi-eOM"/>
......
......@@ -15,6 +15,7 @@ class MainViewController: UIViewController {
super.viewDidLoad()
retriveCurentForm()
self.navigationController?.navigationBar.isHidden = true
}
private func openLoginViewController() {
......
......@@ -49,7 +49,7 @@ class QrViewController: UIViewController {
private func openCreateFormView() {
let controller = FormCreateViewController()
controller.isCreateMode = false
controller.formViewType = .viewFromQr
self.navigationController?.navigationBar.topItem?.title = " "
self.navigationController?.pushViewController(controller, animated: true)
}
......
......@@ -46,7 +46,8 @@ class WelcomeViewController: UIViewController {
@IBAction func createButtonAction(_ sender: UIButton) {
let controller = FormCreateViewController()
controller.isCreateMode = true
controller.formViewType = .creta
self.navigationController?.navigationBar.topItem?.title = " "
self.navigationController?.pushViewController(controller, animated: true)
}
......
......@@ -22,19 +22,19 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Բարի գալուստ" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="tpq-Rn-PFH">
<rect key="frame" x="25" y="187" width="364" height="27"/>
<rect key="frame" x="25" y="236" width="364" height="27"/>
<fontDescription key="fontDescription" type="system" pointSize="22"/>
<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="Անուն Ազգանուն" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="RJu-c4-bw8">
<rect key="frame" x="25" y="222" width="364" height="27"/>
<rect key="frame" x="25" y="271" width="364" height="27"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="22"/>
<nil key="textColor"/>
<color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Jmm-GA-Npp">
<rect key="frame" x="40" y="351" width="334" height="50"/>
<rect key="frame" x="40" y="378" width="334" height="50"/>
<color key="backgroundColor" red="0.0" green="0.53725490200000003" blue="0.15686274510000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="ofI-nA-vgf"/>
......@@ -53,7 +53,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="xKX-74-m44">
<rect key="frame" x="40" y="423" width="334" height="50"/>
<rect key="frame" x="40" y="450" width="334" height="50"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="SD9-Jp-OMB"/>
......@@ -77,15 +77,24 @@
<action selector="historyButtonAction:" destination="-1" eventType="touchUpInside" id="gYU-zc-tGC"/>
</connections>
</button>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="logo_green" translatesAutoresizingMaskIntoConstraints="NO" id="39T-Am-QrN">
<rect key="frame" x="171" y="84" width="72" height="72"/>
<constraints>
<constraint firstAttribute="width" constant="72" id="hr6-Z1-HDD"/>
<constraint firstAttribute="height" constant="72" id="rX4-P5-bJs"/>
</constraints>
</imageView>
</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="tpq-Rn-PFH" firstAttribute="top" secondItem="fnl-2z-Ty3" secondAttribute="top" constant="143" id="0zG-8Y-1ak"/>
<constraint firstItem="xKX-74-m44" firstAttribute="leading" secondItem="fnl-2z-Ty3" secondAttribute="leading" constant="40" id="1EZ-9p-hsc"/>
<constraint firstItem="fnl-2z-Ty3" firstAttribute="trailing" secondItem="RJu-c4-bw8" secondAttribute="trailing" constant="25" id="Cng-7l-xT0"/>
<constraint firstItem="tpq-Rn-PFH" firstAttribute="top" secondItem="39T-Am-QrN" secondAttribute="bottom" constant="80" id="Lzl-WV-3JE"/>
<constraint firstItem="tpq-Rn-PFH" firstAttribute="leading" secondItem="fnl-2z-Ty3" secondAttribute="leading" constant="25" id="NGj-74-yUC"/>
<constraint firstItem="fnl-2z-Ty3" firstAttribute="trailing" secondItem="xKX-74-m44" secondAttribute="trailing" constant="40" id="UNL-Wy-Tsw"/>
<constraint firstItem="Jmm-GA-Npp" firstAttribute="top" secondItem="RJu-c4-bw8" secondAttribute="bottom" constant="102" id="XqL-Wa-gsg"/>
<constraint firstItem="39T-Am-QrN" firstAttribute="top" secondItem="fnl-2z-Ty3" secondAttribute="top" constant="40" id="XXY-rv-lx0"/>
<constraint firstItem="Jmm-GA-Npp" firstAttribute="top" secondItem="RJu-c4-bw8" secondAttribute="bottom" constant="80" id="XqL-Wa-gsg"/>
<constraint firstItem="39T-Am-QrN" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="f0p-e1-dlb"/>
<constraint firstItem="Jmm-GA-Npp" firstAttribute="leading" secondItem="fnl-2z-Ty3" secondAttribute="leading" constant="40" id="fgw-Q6-lpD"/>
<constraint firstItem="fnl-2z-Ty3" firstAttribute="trailing" secondItem="Jmm-GA-Npp" secondAttribute="trailing" constant="40" id="ga8-9n-BNj"/>
<constraint firstItem="RJu-c4-bw8" firstAttribute="top" secondItem="tpq-Rn-PFH" secondAttribute="bottom" constant="8" id="moi-cn-Z7J"/>
......@@ -97,4 +106,7 @@
<point key="canvasLocation" x="139" y="131"/>
</view>
</objects>
<resources>
<image name="logo_green" width="73" height="73"/>
</resources>
</document>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment