Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
App16
iOS
Commits
d11fa925
Commit
d11fa925
authored
Mar 25, 2020
by
Grigor Aghabalyan
⚽
Browse files
Feat: create form api
parent
4422bb18
Changes
14
Hide whitespace changes
Inline
Side-by-side
App16.xcodeproj/project.pbxproj
View file @
d11fa925
...
...
@@ -39,6 +39,9 @@
C5D691B5242AD290004268C3
/* QrViewController.xib in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
C5D691B3242AD290004268C3
/* QrViewController.xib */
;
};
C5D691B8242AD62A004268C3
/* FormListCell.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
C5D691B6242AD62A004268C3
/* FormListCell.swift */
;
};
C5D691B9242AD62A004268C3
/* FormListCell.xib in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
C5D691B7242AD62A004268C3
/* FormListCell.xib */
;
};
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 */
;
};
DFF30959C2696CFA212F54E4
/* Pods_App16.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
AC947C811CE3C096F8981C77
/* Pods_App16.framework */
;
};
/* End PBXBuildFile section */
...
...
@@ -80,6 +83,9 @@
C5D691B3242AD290004268C3
/* QrViewController.xib */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file.xib
;
path
=
QrViewController.xib
;
sourceTree
=
"<group>"
;
};
C5D691B6242AD62A004268C3
/* FormListCell.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
FormListCell.swift
;
sourceTree
=
"<group>"
;
};
C5D691B7242AD62A004268C3
/* FormListCell.xib */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file.xib
;
path
=
FormListCell.xib
;
sourceTree
=
"<group>"
;
};
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>"
;
};
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
...
...
@@ -189,6 +195,7 @@
C5D6916A242AA44D004268C3
/* Services */
=
{
isa
=
PBXGroup
;
children
=
(
C5D691BD242AE510004268C3
/* FormCreateService.swift */
,
);
path
=
Services
;
sourceTree
=
"<group>"
;
...
...
@@ -196,6 +203,7 @@
C5D6916B242AA457004268C3
/* Models */
=
{
isa
=
PBXGroup
;
children
=
(
C5D691BA242AE1D1004268C3
/* Form */
,
);
path
=
Models
;
sourceTree
=
"<group>"
;
...
...
@@ -313,6 +321,15 @@
path
=
Qr
;
sourceTree
=
"<group>"
;
};
C5D691BA242AE1D1004268C3
/* Form */
=
{
isa
=
PBXGroup
;
children
=
(
C5D691BB242AE1F8004268C3
/* FormCreateRequestForm.swift */
,
C5D691BF242AE5E2004268C3
/* FormCreateResponse.swift */
,
);
path
=
Form
;
sourceTree
=
"<group>"
;
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
...
...
@@ -439,6 +456,7 @@
C5D691AF242AC607004268C3
/* WelcomeViewController.swift in Sources */
,
C5D691A4242AAF13004268C3
/* Extensions.swift in Sources */
,
C5D69179242AA58F004268C3
/* BaseResponse.swift in Sources */
,
C5D691C0242AE5E2004268C3
/* FormCreateResponse.swift in Sources */
,
C5D69199242AAD3F004268C3
/* FormCreateViewController.swift in Sources */
,
C5D6917F242AA5D9004268C3
/* CheckBaseHelper.swift in Sources */
,
C5D6914E242AA091004268C3
/* AppDelegate.swift in Sources */
,
...
...
@@ -446,12 +464,14 @@
C5D69173242AA539004268C3
/* BaseService.swift in Sources */
,
C5D691A1242AAE12004268C3
/* MainViewController.swift in Sources */
,
C5D69194242AAD00004268C3
/* SingleFormViewController.swift in Sources */
,
C5D691BE242AE510004268C3
/* FormCreateService.swift in Sources */
,
C5D69170242AA4E9004268C3
/* Config.swift in Sources */
,
C5D6916E242AA4D2004268C3
/* Settings.swift in Sources */
,
C5D691B4242AD290004268C3
/* QrViewController.swift in Sources */
,
C5D691AB242AC17D004268C3
/* UIView+Extensions.swift in Sources */
,
C5D69177242AA573004268C3
/* ValidationError.swift in Sources */
,
C5D6917D242AA5BE004268C3
/* UserDefaultsHelper.swift in Sources */
,
C5D691BC242AE1F8004268C3
/* FormCreateRequestForm.swift in Sources */
,
C5D69150242AA091004268C3
/* SceneDelegate.swift in Sources */
,
C5D6917B242AA5AA004268C3
/* DateFormat.swift in Sources */
,
C5D69181242AA5EB004268C3
/* AlertControllerHelper.swift in Sources */
,
...
...
App16/AppDelegate.swift
View file @
d11fa925
...
...
@@ -20,6 +20,17 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
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
)
}
let
token
=
tokenParts
.
joined
()
print
(
token
)
UserDefaultsHelper
.
set
(
alias
:
.
deviceToken
,
value
:
token
)
}
// MARK: UISceneSession Lifecycle
@available
(
iOS
13.0
,
*
)
...
...
App16/Base.lproj/LaunchScreen.storyboard
View file @
d11fa925
...
...
@@ -17,18 +17,17 @@
<autoresizingMask
key=
"autoresizingMask"
widthSizable=
"YES"
heightSizable=
"YES"
/>
<subviews>
<imageView
clipsSubviews=
"YES"
userInteractionEnabled=
"NO"
contentMode=
"scaleAspectFit"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
image=
"logo_white"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"ANO-op-Dzy"
>
<rect
key=
"frame"
x=
"13
1
"
y=
"37
2
"
width=
"153"
height=
"153"
/>
<rect
key=
"frame"
x=
"13
0.5
"
y=
"37
1.5
"
width=
"153"
height=
"153"
/>
<constraints>
<constraint
firstAttribute=
"width"
secondItem=
"ANO-op-Dzy"
secondAttribute=
"height"
multiplier=
"1:1"
id=
"xUg-v4-NyX"
/>
<constraint
firstAttribute=
"width"
constant=
"153"
id=
"Okv-ME-ODP"
/>
<constraint
firstAttribute=
"height"
constant=
"153"
id=
"aE8-EW-fZh"
/>
</constraints>
</imageView>
</subviews>
<color
key=
"backgroundColor"
red=
"0.023529411764705882"
green=
"0.47058823529411764"
blue=
"0.094117647058823528"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"sRGB"
/>
<constraints>
<constraint
firstItem=
"6Tk-OE-BBY"
firstAttribute=
"trailing"
secondItem=
"ANO-op-Dzy"
secondAttribute=
"trailing"
constant=
"130"
id=
"4vw-Gr-xRO"
/>
<constraint
firstItem=
"ANO-op-Dzy"
firstAttribute=
"leading"
secondItem=
"6Tk-OE-BBY"
secondAttribute=
"leading"
constant=
"131"
id=
"5gr-ki-WAp"
/>
<constraint
firstItem=
"6Tk-OE-BBY"
firstAttribute=
"bottom"
secondItem=
"ANO-op-Dzy"
secondAttribute=
"bottom"
constant=
"337"
id=
"eMG-vX-zti"
/>
<constraint
firstItem=
"ANO-op-Dzy"
firstAttribute=
"top"
secondItem=
"6Tk-OE-BBY"
secondAttribute=
"top"
constant=
"328"
id=
"hjX-rl-mVj"
/>
<constraint
firstItem=
"ANO-op-Dzy"
firstAttribute=
"centerX"
secondItem=
"Ze5-6b-2t3"
secondAttribute=
"centerX"
id=
"2Xh-GW-ZCh"
/>
<constraint
firstItem=
"ANO-op-Dzy"
firstAttribute=
"centerY"
secondItem=
"Ze5-6b-2t3"
secondAttribute=
"centerY"
id=
"ne8-Os-bum"
/>
</constraints>
<viewLayoutGuide
key=
"safeArea"
id=
"6Tk-OE-BBY"
/>
</view>
...
...
App16/Base.lproj/Main.storyboard
View file @
d11fa925
<?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
"
>
<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=
"
6Nj-Zc-Htr
"
>
<device
id=
"retina6_1"
orientation=
"portrait"
appearance=
"light"
/>
<dependencies>
<deployment
identifier=
"iOS"
/>
<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"
/>
...
...
@@ -14,32 +15,48 @@
<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"
/>
<subviews>
<imageView
clipsSubviews=
"YES"
userInteractionEnabled=
"NO"
contentMode=
"scaleAspectFit"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
image=
"logo_white"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"nNR-lN-GxL"
>
<rect
key=
"frame"
x=
"130.5"
y=
"371.5"
width=
"153"
height=
"153"
/>
<constraints>
<constraint
firstAttribute=
"height"
constant=
"153"
id=
"TLy-To-oCm"
/>
<constraint
firstAttribute=
"width"
constant=
"153"
id=
"Uaf-Vf-Wd7"
/>
</constraints>
</imageView>
</subviews>
<color
key=
"backgroundColor"
red=
"0.023529411764705882"
green=
"0.47058823529411764"
blue=
"0.094117647058823528"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"sRGB"
/>
<constraints>
<constraint
firstItem=
"nNR-lN-GxL"
firstAttribute=
"centerX"
secondItem=
"8bC-Xf-vdC"
secondAttribute=
"centerX"
id=
"BTD-IC-AwP"
/>
<constraint
firstItem=
"nNR-lN-GxL"
firstAttribute=
"centerY"
secondItem=
"8bC-Xf-vdC"
secondAttribute=
"centerY"
id=
"Fff-HG-BCP"
/>
</constraints>
<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=
"1
047.826086956521
7"
y=
"134.59821428571428"
/>
<point
key=
"canvasLocation"
x=
"1
957.971014492753
7"
y=
"134.59821428571428"
/>
</scene>
<!--Navigation Controller-->
<scene
sceneID=
"
nWW-W9-vx4
"
>
<scene
sceneID=
"
F4d-du-g5W
"
>
<objects>
<navigationController
automaticallyAdjustsScrollViewInsets=
"NO"
id=
"
guI-71-aGH
"
sceneMemberID=
"viewController"
>
<navigationController
automaticallyAdjustsScrollViewInsets=
"NO"
id=
"
6Nj-Zc-Htr
"
sceneMemberID=
"viewController"
>
<toolbarItems/>
<navigationBar
key=
"navigationBar"
contentMode=
"scaleToFill"
insetsLayoutMarginsFromSafeArea=
"NO"
id=
"
TeA-vN-4M2
"
>
<navigationBar
key=
"navigationBar"
contentMode=
"scaleToFill"
insetsLayoutMarginsFromSafeArea=
"NO"
id=
"
o6o-e7-Hbn
"
>
<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=
"x
xJ-tu-BMh
"
/>
<segue
destination=
"BYZ-38-t0r"
kind=
"relationship"
relationship=
"rootViewController"
id=
"x
oW-DU-jGI
"
/>
</connections>
</navigationController>
<placeholder
placeholderIdentifier=
"IBFirstResponder"
id=
"
TJx-tg-VTe
"
userLabel=
"First Responder"
customClass=
"UIResponder"
sceneMemberID=
"firstResponder"
/>
<placeholder
placeholderIdentifier=
"IBFirstResponder"
id=
"
Wfm-27-OH7
"
userLabel=
"First Responder"
customClass=
"UIResponder"
sceneMemberID=
"firstResponder"
/>
</objects>
<point
key=
"canvasLocation"
x=
"1
37.6811594202898
7"
y=
"134.59821428571428"
/>
<point
key=
"canvasLocation"
x=
"1
047.826086956521
7"
y=
"134.59821428571428"
/>
</scene>
</scenes>
<resources>
<image
name=
"logo_white"
width=
"153"
height=
"153"
/>
</resources>
</document>
App16/Config/Config.swift
View file @
d11fa925
...
...
@@ -12,7 +12,7 @@ struct Config {
static
let
ENVIRONMENT
=
"DEV"
static
let
HOST_NAME
=
"app16.x-tech.am"
static
let
BASE_URL
=
"https://"
+
Config
.
HOST_NAME
+
"api/"
+
API_VERSION
static
let
BASE_URL
=
"https://"
+
Config
.
HOST_NAME
+
"
/
api/"
+
API_VERSION
static
let
API_TOKEN
=
""
static
let
API_VERSION
=
"v1"
static
let
API_FORMAT
=
"json"
...
...
App16/Helpers/UserDefaultsHelper.swift
View file @
d11fa925
...
...
@@ -11,7 +11,10 @@ import UIKit
enum
UDAliases
:
String
{
case
AuthToken
=
"auth_token"
case
logined
case
firstName
case
lstName
case
middleName
case
deviceToken
}
class
UserDefaultsHelper
{
...
...
App16/Models/Form/FormCreateRequestForm.swift
0 → 100644
View file @
d11fa925
//
// FormCreateRequestForm.swift
// App16
//
// Created by Grigor Aghabalyan on 3/25/20.
// Copyright © 2020 X-TECH. All rights reserved.
//
import
Foundation
import
ObjectMapper
class
FormCreateRequestForm
:
Mappable
{
var
deviceToken
:
String
?
var
firstName
:
String
?
var
lastName
:
String
?
var
middleName
:
String
?
var
outAddress
:
String
?
var
outLatitude
:
Double
?
var
outLongitude
:
Double
?
var
outDatetime
:
String
?
var
visitingAddressAndName
:
String
?
var
visitingLatitude
:
Double
?
var
visitingLongitude
:
Double
?
var
visitingReason
:
String
?
var
plannedReturnDatetime
:
String
?
required
init
?(
map
:
Map
)
{
}
init
(
deviceToken
:
String
?,
firstName
:
String
?,
lastName
:
String
?,
middleName
:
String
?,
outAddress
:
String
?,
outLatitude
:
Double
?,
outLongitude
:
Double
?,
outDatetime
:
String
?,
visitingAddressAndName
:
String
?,
visitingLatitude
:
Double
?,
visitingLongitude
:
Double
?,
visitingReason
:
String
?,
plannedReturnDatetime
:
String
?)
{
self
.
deviceToken
=
deviceToken
self
.
firstName
=
firstName
self
.
lastName
=
lastName
self
.
middleName
=
middleName
self
.
outAddress
=
outAddress
self
.
outLatitude
=
outLatitude
self
.
outLongitude
=
outLongitude
self
.
outDatetime
=
outDatetime
self
.
visitingAddressAndName
=
visitingAddressAndName
self
.
visitingLatitude
=
visitingLatitude
self
.
visitingLongitude
=
visitingLongitude
self
.
visitingReason
=
visitingReason
self
.
plannedReturnDatetime
=
plannedReturnDatetime
}
func
mapping
(
map
:
Map
)
{
deviceToken
<-
map
[
"device_token"
]
firstName
<-
map
[
"first_name"
]
lastName
<-
map
[
"last_name"
]
middleName
<-
map
[
"middle_name"
]
outAddress
<-
map
[
"out_address"
]
outLatitude
<-
map
[
"out_latitude"
]
outLongitude
<-
map
[
"out_longitude"
]
outDatetime
<-
map
[
"out_datetime"
]
visitingAddressAndName
<-
map
[
"visiting_address_and_name"
]
visitingLatitude
<-
map
[
"visiting_latitude"
]
visitingLongitude
<-
map
[
"visiting_longitude"
]
visitingReason
<-
map
[
"visiting_reason"
]
plannedReturnDatetime
<-
map
[
"planned_return_datetime"
]
}
}
App16/Models/Form/FormCreateResponse.swift
0 → 100644
View file @
d11fa925
//
// FormCreateResponse.swift
// App16
//
// Created by Grigor Aghabalyan on 3/25/20.
// Copyright © 2020 X-TECH. All rights reserved.
//
import
ObjectMapper
class
FormCreateResponse
:
Mappable
{
var
deviceToken
:
String
?
var
firstName
:
String
?
var
lastName
:
String
?
var
middleName
:
String
?
var
outAddress
:
String
?
var
outLatitude
:
Double
?
var
outLongitude
:
Double
?
var
outDatetime
:
String
?
var
visitingAddressAndName
:
String
?
var
visitingLatitude
:
Double
?
var
visitingLongitude
:
Double
?
var
visitingReason
:
String
?
var
plannedReturnDatetime
:
String
?
required
init
?(
map
:
Map
)
{
}
init
()
{
}
func
mapping
(
map
:
Map
)
{
deviceToken
<-
map
[
"device_token"
]
firstName
<-
map
[
"first_name"
]
lastName
<-
map
[
"last_name"
]
middleName
<-
map
[
"middle_name"
]
outAddress
<-
map
[
"out_address"
]
outLatitude
<-
map
[
"out_latitude"
]
outLongitude
<-
map
[
"out_longitude"
]
outDatetime
<-
map
[
"out_datetime"
]
visitingAddressAndName
<-
map
[
"visiting_address_and_name"
]
visitingLatitude
<-
map
[
"visiting_latitude"
]
visitingLongitude
<-
map
[
"visiting_longitude"
]
visitingReason
<-
map
[
"visiting_reason"
]
plannedReturnDatetime
<-
map
[
"planned_return_datetime"
]
}
}
enum
FormCreateResponseData
<
FormCreateResponse
>
{
case
success
(
result
:
FormCreateResponse
)
case
base
(
response
:
BaseResponse
)
case
conflict
case
isOffline
}
App16/Services/FormCreateService.swift
0 → 100644
View file @
d11fa925
//
// FormCreateService.swift
// App16
//
// Created by Grigor Aghabalyan on 3/25/20.
// Copyright © 2020 X-TECH. All rights reserved.
//
import
ObjectMapper
import
AlamofireObjectMapper
import
Alamofire
import
ObjectMapper
import
AlamofireObjectMapper
import
Alamofire
class
FormCreateService
{
static
let
shered
=
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")
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
))
}
}
}
}
App16/Views/Form/Create/FormCreateViewController.swift
View file @
d11fa925
...
...
@@ -21,6 +21,7 @@ class FormCreateViewController: UIViewController {
UITextField
!
@IBOutlet
weak
var
createButton
:
UIButton
!
@IBOutlet
weak
var
activityIndicator
:
UIActivityIndicatorView
!
// MARK: - LifeCycle
override
func
viewDidLoad
()
{
...
...
@@ -37,7 +38,7 @@ class FormCreateViewController: UIViewController {
let
alertController
=
AlertControllerHelper
.
showAlert
(
title
:
nil
,
message
:
"Խնդում ենք լրացրեք բոլոր դաշտերը"
)
self
.
present
(
alertController
,
animated
:
true
,
completion
:
nil
)
}
else
{
openQrView
()
createForm
()
}
}
...
...
@@ -46,4 +47,47 @@ class FormCreateViewController: UIViewController {
let
controller
=
QrViewController
()
changeRoot
(
UINavigationController
(
rootViewController
:
controller
))
}
private
func
createForm
()
{
activityIndicator
.
isHidden
=
false
activityIndicator
.
startAnimating
()
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
form
=
FormCreateRequestForm
(
deviceToken
:
deviceToken
,
firstName
:
firstName
,
lastName
:
lastName
,
middleName
:
middleName
,
outAddress
:
outAddressTextFiled
.
text
,
outLatitude
:
nil
,
outLongitude
:
nil
,
outDatetime
:
outDateTimeTextFiled
.
text
,
visitingAddressAndName
:
destinationAddressTextField
.
text
,
visitingLatitude
:
nil
,
visitingLongitude
:
nil
,
visitingReason
:
destinationTypeTextField
.
text
,
plannedReturnDatetime
:
planneDateTimeTextField
.
text
)
FormCreateService
.
shered
.
createForm
(
data
:
form
)
{
(
weaterResponseData
)
in
switch
weaterResponseData
{
case
.
base
(
response
:
let
baseResposne
):
self
.
activityIndicator
.
stopAnimating
()
CheckBaseHelper
.
checkBaseResponse
(
baseResposne
,
viewController
:
self
)
case
.
success
(
let
resultsData
):
self
.
activityIndicator
.
stopAnimating
()
print
(
resultsData
)
self
.
openQrView
()
case
.
isOffline
:
self
.
activityIndicator
.
stopAnimating
()
return
case
.
conflict
:
self
.
activityIndicator
.
stopAnimating
()
return
}
}
}
}
App16/Views/Form/Create/FormCreateViewController.xib
View file @
d11fa925
...
...
@@ -10,6 +10,7 @@
<objects>
<placeholder
placeholderIdentifier=
"IBFilesOwner"
id=
"-1"
userLabel=
"File's Owner"
customClass=
"FormCreateViewController"
customModule=
"App16"
customModuleProvider=
"target"
>
<connections>
<outlet
property=
"activityIndicator"
destination=
"AyJ-6A-jyJ"
id=
"JAO-M0-NOK"
/>
<outlet
property=
"createButton"
destination=
"NyF-FR-xam"
id=
"UmO-AP-uuM"
/>
<outlet
property=
"destinationAddressTextField"
destination=
"rPL-7I-ofi"
id=
"TjC-eL-miv"
/>
<outlet
property=
"destinationTypeTextField"
destination=
"4aW-Ax-Ff0"
id=
"e4d-zH-y4m"
/>
...
...
@@ -292,11 +293,16 @@
<constraint
firstItem=
"Kwt-kc-N2e"
firstAttribute=
"leading"
secondItem=
"9XT-9B-ssX"
secondAttribute=
"leading"
id=
"zKM-S9-Uad"
/>
</constraints>
</scrollView>
<activityIndicatorView
hidden=
"YES"
opaque=
"NO"
contentMode=
"scaleToFill"
horizontalHuggingPriority=
"750"
verticalHuggingPriority=
"750"
hidesWhenStopped=
"YES"
style=
"medium"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"AyJ-6A-jyJ"
>
<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=
"9XT-9B-ssX"
firstAttribute=
"trailing"
secondItem=
"fnl-2z-Ty3"
secondAttribute=
"trailing"
id=
"5wS-Yt-kTM"
/>
<constraint
firstItem=
"AyJ-6A-jyJ"
firstAttribute=
"centerX"
secondItem=
"i5M-Pr-FkT"
secondAttribute=
"centerX"
id=
"RoB-IV-UgI"
/>
<constraint
firstItem=
"9XT-9B-ssX"
firstAttribute=
"leading"
secondItem=
"i5M-Pr-FkT"
secondAttribute=
"leading"
id=
"YtC-LG-tZZ"
/>
<constraint
firstItem=
"AyJ-6A-jyJ"
firstAttribute=
"centerY"
secondItem=
"i5M-Pr-FkT"
secondAttribute=
"centerY"
id=
"aa1-uE-r7f"
/>
<constraint
firstAttribute=
"bottom"
secondItem=
"9XT-9B-ssX"
secondAttribute=
"bottom"
id=
"tVT-nu-c8g"
/>
<constraint
firstItem=
"9XT-9B-ssX"
firstAttribute=
"top"
secondItem=
"i5M-Pr-FkT"
secondAttribute=
"top"
id=
"yFY-yg-gKn"
/>
</constraints>
...
...
App16/Views/Login/LoginViewController.swift
View file @
d11fa925
...
...
@@ -36,6 +36,13 @@ class LoginViewController: UIViewController {
changeRoot
(
UINavigationController
(
rootViewController
:
controller
))
}
private
func
setDatUserDef
()
{
UserDefaultsHelper
.
set
(
alias
:
.
firstName
,
value
:
firstNameTextField
.
text
)
UserDefaultsHelper
.
set
(
alias
:
.
lstName
,
value
:
lastNameTextFiled
.
text
)
UserDefaultsHelper
.
set
(
alias
:
.
middleName
,
value
:
middleNameTextField
.
text
)
}
// MARK: - Actions
@IBAction
func
nextButtonAction
(
_
sender
:
Any
)
{
...
...
@@ -46,7 +53,10 @@ class LoginViewController: UIViewController {
let
alertController
=
AlertControllerHelper
.
showAlert
(
title
:
nil
,
message
:
"Խնդում ենք լրացրեք բոլոր դաշտերը"
)
self
.
present
(
alertController
,
animated
:
true
,
completion
:
nil
)
}
else
{
setDatUserDef
()
openWelcomeController
()
}
}
}
App16/Views/Main/MainViewController.swift
View file @
d11fa925
...
...
@@ -29,4 +29,5 @@ class MainViewController: UIViewController {
let
controller
=
FormCreateViewController
()
changeRoot
(
UINavigationController
(
rootViewController
:
controller
))
}
}
App16/Views/Welcome/WelcomeViewController.swift
View file @
d11fa925
...
...
@@ -20,6 +20,11 @@ class WelcomeViewController: UIViewController {
super
.
viewDidLoad
()
setRightBarButton
()
let
firstName
=
UserDefaultsHelper
.
getString
(
for
:
.
firstName
)
let
lastName
=
UserDefaultsHelper
.
getString
(
for
:
.
lstName
)
nameLabel
.
text
=
(
firstName
??
"-"
)
+
" "
+
(
lastName
??
"-"
)
}
private
func
setRightBarButton
()
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment