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
3a2fb802
Commit
3a2fb802
authored
Mar 29, 2020
by
Grigor Aghabalyan
⚽
Browse files
Feat: add SingleView form
parent
ac56c2a8
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
App16.xcodeproj/project.pbxproj
View file @
3a2fb802
...
...
@@ -15,6 +15,8 @@
C5356A3D242FC9F900EFD310
/* Language.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
C5356A3C242FC9F900EFD310
/* Language.swift */
;
};
C5356A41242FCB4700EFD310
/* LanguageCell.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
C5356A3F242FCB4600EFD310
/* LanguageCell.swift */
;
};
C5356A42242FCB4700EFD310
/* LanguageCell.xib in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
C5356A40242FCB4600EFD310
/* LanguageCell.xib */
;
};
C54206282430AC53001D858F
/* SingleFormViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
C54206262430AC53001D858F
/* SingleFormViewController.swift */
;
};
C54206292430AC53001D858F
/* SingleFormViewController.xib in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
C54206272430AC53001D858F
/* SingleFormViewController.xib */
;
};
C5D2A725242B077100825031
/* FormsService.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
C5D2A724242B077100825031
/* FormsService.swift */
;
};
C5D2A727242B0A2300825031
/* FormsResponse.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
C5D2A726242B0A2300825031
/* FormsResponse.swift */
;
};
C5D2A729242B12F200825031
/* FormResponse.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
C5D2A728242B12F200825031
/* FormResponse.swift */
;
};
...
...
@@ -77,6 +79,8 @@
C5356A3C242FC9F900EFD310
/* Language.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Language.swift
;
sourceTree
=
"<group>"
;
};
C5356A3F242FCB4600EFD310
/* LanguageCell.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
LanguageCell.swift
;
sourceTree
=
"<group>"
;
};
C5356A40242FCB4600EFD310
/* LanguageCell.xib */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file.xib
;
path
=
LanguageCell.xib
;
sourceTree
=
"<group>"
;
};
C54206262430AC53001D858F
/* SingleFormViewController.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
SingleFormViewController.swift
;
sourceTree
=
"<group>"
;
};
C54206272430AC53001D858F
/* SingleFormViewController.xib */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file.xib
;
path
=
SingleFormViewController.xib
;
sourceTree
=
"<group>"
;
};
C5D2A724242B077100825031
/* FormsService.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
FormsService.swift
;
sourceTree
=
"<group>"
;
};
C5D2A726242B0A2300825031
/* FormsResponse.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
FormsResponse.swift
;
sourceTree
=
"<group>"
;
};
C5D2A728242B12F200825031
/* FormResponse.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
FormResponse.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -196,6 +200,15 @@
path
=
Cells
;
sourceTree
=
"<group>"
;
};
C54206252430AC28001D858F
/* Single */
=
{
isa
=
PBXGroup
;
children
=
(
C54206262430AC53001D858F
/* SingleFormViewController.swift */
,
C54206272430AC53001D858F
/* SingleFormViewController.xib */
,
);
path
=
Single
;
sourceTree
=
"<group>"
;
};
C5D69141242AA091004268C3
=
{
isa
=
PBXGroup
;
children
=
(
...
...
@@ -328,6 +341,7 @@
C5D69187242AAC05004268C3
/* Form */
=
{
isa
=
PBXGroup
;
children
=
(
C54206252430AC28001D858F
/* Single */
,
C5D69196242AAD2C004268C3
/* Create */
,
C5D6918C242AAC73004268C3
/* FormList */
,
);
...
...
@@ -490,6 +504,7 @@
C5D691D1242AFEB0004268C3
/* DatePickerViewController.xib in Resources */
,
C5D69190242AAC86004268C3
/* FormListViewController.xib in Resources */
,
C5356A35242FBAF800EFD310
/* SettingsViewController.xib in Resources */
,
C54206292430AC53001D858F
/* SingleFormViewController.xib in Resources */
,
C5D691B0242AC607004268C3
/* WelcomeViewController.xib in Resources */
,
C5D69157242AA094004268C3
/* Assets.xcassets in Resources */
,
C5D69155242AA091004268C3
/* Main.storyboard in Resources */
,
...
...
@@ -552,6 +567,7 @@
C5D69179242AA58F004268C3
/* BaseResponse.swift in Sources */
,
C5D691C0242AE5E2004268C3
/* FormCreateResponse.swift in Sources */
,
C5D69199242AAD3F004268C3
/* FormCreateViewController.swift in Sources */
,
C54206282430AC53001D858F
/* SingleFormViewController.swift in Sources */
,
C5D6917F242AA5D9004268C3
/* CheckBaseHelper.swift in Sources */
,
C5356A34242FBAF800EFD310
/* SettingsViewController.swift in Sources */
,
C5356A39242FC1F900EFD310
/* LanguageViewController.swift in Sources */
,
...
...
@@ -742,7 +758,7 @@
buildSettings
=
{
ASSETCATALOG_COMPILER_APPICON_NAME
=
AppIcon
;
CODE_SIGN_STYLE
=
Automatic
;
CURRENT_PROJECT_VERSION
=
1
0
;
CURRENT_PROJECT_VERSION
=
1
1
;
DEVELOPMENT_TEAM
=
JY829SQQAV
;
INFOPLIST_FILE
=
App16/Info.plist
;
IPHONEOS_DEPLOYMENT_TARGET
=
12.0
;
...
...
@@ -764,7 +780,7 @@
buildSettings
=
{
ASSETCATALOG_COMPILER_APPICON_NAME
=
AppIcon
;
CODE_SIGN_STYLE
=
Automatic
;
CURRENT_PROJECT_VERSION
=
1
0
;
CURRENT_PROJECT_VERSION
=
1
1
;
DEVELOPMENT_TEAM
=
JY829SQQAV
;
INFOPLIST_FILE
=
App16/Info.plist
;
IPHONEOS_DEPLOYMENT_TARGET
=
12.0
;
...
...
App16/Resources/en.lproj/Localizable.strings
View file @
3a2fb802
...
...
@@ -6,6 +6,8 @@
Copyright © 2020 X-TECH. All rights reserved.
*/
"OK" = "Ok";
"FIRST_NAME" = "Fist name";
"LAST_NAME" = "Last name";
"MIDDLE_NAME" = "Middle name";
...
...
@@ -30,3 +32,5 @@
"LANGUAGE" = "Language";
"LANGUAGES" = "Languages";
"CANCEL" = "Cancel";
"Please fill in all fields" = "Please fill in all fields";
App16/Resources/hy.lproj/Localizable.strings
View file @
3a2fb802
...
...
@@ -6,6 +6,8 @@
Copyright © 2020 X-TECH. All rights reserved.
*/
"OK" = "Լավ";
"FIRST_NAME" = "Անուն";
"LAST_NAME" = "Ազգանուն";
"MIDDLE_NAME" = "հայրանուն";
...
...
@@ -30,3 +32,5 @@
"LANGUAGE" = "Լեզու";
"LANGUAGES" = "Լեզուներ";
"CANCEL" = "Չեղարկել";
"Please fill in all fields" = "Խնդում ենք լրացրեք բոլոր դաշտերը";
App16/Resources/ru.lproj/Localizable.strings
View file @
3a2fb802
...
...
@@ -6,6 +6,8 @@
Copyright © 2020 X-TECH. All rights reserved.
*/
"OK" = "Ok";
"FIRST_NAME" = "Имя";
"LAST_NAME" = "Фамилия";
"MIDDLE_NAME" = "Отчество";
...
...
@@ -30,3 +32,5 @@
"LANGUAGE" = "Язык";
"LANGUAGES" = "Языки";
"CANCEL" = "Отменить";
"Please fill in all fields" = "Пожалуйста, заполните все поля";
App16/Views/Form/Create/FormCreateViewController.swift
View file @
3a2fb802
...
...
@@ -50,34 +50,17 @@ class FormCreateViewController: UIViewController {
super
.
viewDidLoad
()
setUI
()
switch
formViewType
{
case
.
creta
:
createButton
.
isHidden
=
false
self
.
title
=
"CREATE_FORM"
.
localized
()
curentDate
.
text
=
date
case
.
viewFromList
:
self
.
title
=
"FORM"
.
localized
()
createButton
.
isHidden
=
true
setData
(
response
:
data
)
case
.
viewFromQr
:
self
.
title
=
"FORM"
.
localized
()
createButton
.
isHidden
=
true
retriveCurentForm
()
}
}
private
func
setUI
()
{
if
let
firstName
=
UserDefaultsHelper
.
getString
(
for
:
.
firstName
),
let
lastName
=
UserDefaultsHelper
.
getString
(
for
:
.
lstName
),
let
middleName
=
UserDefaultsHelper
.
getString
(
for
:
.
middleName
)
{
nameLabel
.
text
=
"
\(
firstName
)
\(
lastName
)
\(
middleName
)
"
}
}
private
func
setUI
()
{
self
.
title
=
"CREATE_FORM"
.
localized
()
createButton
.
setTitle
(
"CREATE"
.
localized
(),
for
:
.
normal
)
outDateTimeTextLabel
.
text
=
"OUT_ADDRESS"
.
localized
()
outAddressTextLabel
.
text
=
"OUT_DATETIME"
.
localized
()
...
...
@@ -117,7 +100,7 @@ class FormCreateViewController: UIViewController {
||
outAddressTextFiled
.
text
==
""
||
destinationAddressTextField
.
text
==
""
||
planneDateTimeTextField
.
text
==
""
{
let
alertController
=
AlertControllerHelper
.
showAlert
(
title
:
nil
,
message
:
"
Խնդում ենք լրացրեք բոլոր դաշտերը"
)
let
alertController
=
AlertControllerHelper
.
showAlert
(
title
:
nil
,
message
:
"
Please fill in all fields"
.
localized
()
)
self
.
present
(
alertController
,
animated
:
true
,
completion
:
nil
)
}
else
{
createForm
()
...
...
@@ -173,58 +156,4 @@ class FormCreateViewController: UIViewController {
}
}
}
private
func
retriveCurentForm
()
{
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
.
data
)
}
case
.
isOffline
:
self
.
activityIndicator
.
stopAnimating
()
return
case
.
conflict
:
self
.
activityIndicator
.
stopAnimating
()
return
}
}
}
private
func
setData
(
response
:
FormResponse
?)
{
destinationAddressTextField
.
isUserInteractionEnabled
=
false
planneDateTimeTextField
.
isUserInteractionEnabled
=
false
destinationTypeTextField
.
isUserInteractionEnabled
=
false
destinationAddressTextField
.
isUserInteractionEnabled
=
false
outDateButtonAction
.
isUserInteractionEnabled
=
false
planneDateTimeButton
.
isUserInteractionEnabled
=
false
outAddressTextFiled
.
isUserInteractionEnabled
=
false
outDateTimeTextFiled
.
isUserInteractionEnabled
=
false
planneDateTimeTextField
.
isUserInteractionEnabled
=
false
outDateTimeTextFiled
.
text
=
response
?
.
outDatetime
outAddressTextFiled
.
text
=
response
?
.
outAddress
destinationAddressTextField
.
text
=
response
?
.
visitingAddressAndName
planneDateTimeTextField
.
text
=
response
?
.
plannedReturnDatetime
destinationTypeTextField
.
text
=
response
?
.
visitingReason
curentDate
.
text
=
response
?
.
createdAt
}
}
App16/Views/Form/FormList/FormListViewController.swift
View file @
3a2fb802
...
...
@@ -96,9 +96,8 @@ extension FormListViewController: UITableViewDelegate {
private
func
openCreateFormView
(
index
:
Int
)
{
let
controller
=
FormCreateViewController
()
controller
.
formViewType
=
.
viewFromList
controller
.
data
=
dataSource
[
index
]
let
controller
=
SingleFormViewController
()
controller
.
formData
=
dataSource
[
index
]
self
.
navigationController
?
.
navigationBar
.
topItem
?
.
title
=
" "
self
.
navigationController
?
.
pushViewController
(
controller
,
animated
:
true
)
}
...
...
App16/Views/Form/Single/SingleFormViewController.swift
0 → 100644
View file @
3a2fb802
//
// SingleFormViewController.swift
// App16
//
// Created by Grigor Aghabalyan on 3/29/20.
// Copyright © 2020 X-TECH. All rights reserved.
//
import
UIKit
class
SingleFormViewController
:
UIViewController
{
// MARK: - IBOutlets
@IBOutlet
weak
var
fistNameTextLabel
:
UILabel
!
@IBOutlet
weak
var
lastNameTextLabel
:
UILabel
!
@IBOutlet
weak
var
meddleNameTextLabel
:
UILabel
!
@IBOutlet
weak
var
outDateTimeTextLabel
:
UILabel
!
@IBOutlet
weak
var
outAddressTextLabel
:
UILabel
!
@IBOutlet
weak
var
destinationAddressTextLabel
:
UILabel
!
@IBOutlet
weak
var
planneDateTimeTextLabel
:
UILabel
!
@IBOutlet
weak
var
destinationTypeTextLabel
:
UILabel
!
@IBOutlet
weak
var
fistNameLabel
:
UILabel
!
@IBOutlet
weak
var
lastNameLabel
:
UILabel
!
@IBOutlet
weak
var
meddleNameLabel
:
UILabel
!
@IBOutlet
weak
var
outDateTimeLabel
:
UILabel
!
@IBOutlet
weak
var
outAddressLabel
:
UILabel
!
@IBOutlet
weak
var
destinationAddressLabel
:
UILabel
!
@IBOutlet
weak
var
planneDateTimeLabel
:
UILabel
!
@IBOutlet
weak
var
destinationTypeLabel
:
UILabel
!
@IBOutlet
weak
var
curentDateLabel
:
UILabel
!
@IBOutlet
weak
var
activityIndicator
:
UIActivityIndicatorView
!
// MARK: - Variables
var
formData
:
FormResponse
?
// MARK: - LifeCycle
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
setUI
()
if
let
data
=
formData
{
setData
(
response
:
data
)
}
else
{
retriveCurentForm
()
}
}
private
func
setUI
()
{
self
.
title
=
"FORM"
.
localized
()
fistNameLabel
.
text
=
"FIRST_NAME"
.
localized
()
lastNameLabel
.
text
=
"LAST_NAME"
.
localized
()
meddleNameLabel
.
text
=
"MEDDLE_NAME"
.
localized
()
outDateTimeTextLabel
.
text
=
"OUT_ADDRESS"
.
localized
()
outAddressTextLabel
.
text
=
"OUT_DATETIME"
.
localized
()
destinationAddressTextLabel
.
text
=
"Address of the place of visit/Title"
.
localized
()
planneDateTimeTextLabel
.
text
=
"Estimated Return Time"
.
localized
()
destinationTypeTextLabel
.
text
=
"Purpose of the visit"
.
localized
()
}
private
func
setData
(
response
:
FormResponse
?)
{
fistNameLabel
.
text
=
response
?
.
firstName
lastNameLabel
.
text
=
response
?
.
lastName
meddleNameLabel
.
text
=
response
?
.
middleName
outDateTimeLabel
.
text
=
response
?
.
outDatetime
outAddressLabel
.
text
=
response
?
.
outAddress
destinationAddressLabel
.
text
=
response
?
.
visitingAddressAndName
planneDateTimeLabel
.
text
=
response
?
.
plannedReturnDatetime
destinationTypeLabel
.
text
=
response
?
.
visitingReason
curentDateLabel
.
text
=
response
?
.
createdAt
}
private
func
retriveCurentForm
()
{
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
.
data
)
}
case
.
isOffline
:
self
.
activityIndicator
.
stopAnimating
()
return
case
.
conflict
:
self
.
activityIndicator
.
stopAnimating
()
return
}
}
}
}
App16/Views/Form/Single/SingleFormViewController.xib
0 → 100644
View file @
3a2fb802
This diff is collapsed.
Click to expand it.
App16/Views/Qr/QrViewController.swift
View file @
3a2fb802
...
...
@@ -17,18 +17,16 @@ class QrViewController: UIViewController {
@IBOutlet
weak
var
finishButton
:
UIButton
!
@IBOutlet
weak
var
activityIndicator
:
UIActivityIndicatorView
!
// MARK: - Variables
let
downloader
=
ImageDownloader
()
var
urlRequest
:
URLRequest
?
// MARK: - LifeCycle
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
downloaderQR
()
setUI
()
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
)
}
}
private
func
setUI
()
{
...
...
@@ -37,14 +35,29 @@ class QrViewController: UIViewController {
finishButton
.
setTitle
(
"FINISH"
.
localized
(),
for
:
.
normal
)
}
private
func
downloaderQR
()
{
self
.
activityIndicator
.
isHidden
=
false
self
.
activityIndicator
.
startAnimating
()
if
let
teviceId
=
UIDevice
.
current
.
identifierForVendor
?
.
uuidString
{
urlRequest
=
URLRequest
(
url
:
URL
(
string
:
"https://app16.x-tech.am/api/v1/applications/qr_code?device_token=
\(
teviceId
)
"
)
!
)
downloader
.
download
(
urlRequest
!
)
{
response
in
if
case
.
success
(
let
image
)
=
response
.
result
{
print
(
image
)
self
.
qrImageView
.
image
=
image
self
.
activityIndicator
.
stopAnimating
()
}
}
}
}
// MARK: - Actions
@IBAction
func
formButtonAction
(
_
sender
:
UIButton
)
{
openCreateFormView
()
}
@IBAction
func
finshButtonAction
(
_
sender
:
UIButton
)
{
retriveCurentForm
()
finishCurentForm
()
}
private
func
openWelcomeView
()
{
...
...
@@ -55,8 +68,8 @@ class QrViewController: UIViewController {
private
func
openCreateFormView
()
{
let
controller
=
FormCreate
ViewController
()
controller
.
formViewType
=
.
viewFromQr
let
controller
=
SingleForm
ViewController
()
self
.
navigationController
?
.
navigationBar
.
topItem
?
.
title
=
" "
self
.
navigationController
?
.
pushViewController
(
controller
,
animated
:
true
)
}
...
...
@@ -76,20 +89,21 @@ class QrViewController: UIViewController {
}
}
private
func
retriveCurentForm
()
{
// MARK: - Request
private
func
finishCurentForm
()
{
let
form
=
CurentFormRequestForm
(
deviceToken
:
UIDevice
.
current
.
identifierForVendor
?
.
uuidString
)
FormFinishService
.
shered
.
finishForm
(
data
:
form
)
{
(
responseData
)
in
switch
responseData
{
case
.
base
(
response
:
let
baseResposne
):
switch
responseData
{
case
.
base
(
response
:
let
baseResposne
):
CheckBaseHelper
.
checkBaseResponse
(
baseResposne
,
viewController
:
self
)
case
.
success
(
_
):
case
.
success
(
_
):
self
.
openWelcomeView
()
case
.
isOffline
:
case
.
isOffline
:
return
case
.
conflict
:
return
case
.
conflict
:
return
}
}
}
}
}
}
}
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