Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ayudapy
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Julio Hermosa
ayudapy
Commits
9d76d329
Commit
9d76d329
authored
May 19, 2020
by
Julio Hermosa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Se ordena y documenta el código
parent
f2c90045
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
74 additions
and
83 deletions
+74
-83
ayudapy.xcworkspace/xcuserdata/roshka.xcuserdatad/UserInterfaceState.xcuserstate
+0
-0
ayudapy/Base.lproj/Main.storyboard
+2
-2
ayudapy/CoreData/CoreDataManager.swift
+10
-0
ayudapy/Info.plist
+2
-4
ayudapy/Static/Format.swift
+6
-6
ayudapy/ViewControllers/MapViewController.swift
+21
-37
ayudapy/ViewControllers/PendingsViewController.swift
+9
-6
ayudapy/ViewControllers/RequestViewController.swift
+24
-28
No files found.
ayudapy.xcworkspace/xcuserdata/roshka.xcuserdatad/UserInterfaceState.xcuserstate
View file @
9d76d329
No preview for this file type
ayudapy/Base.lproj/Main.storyboard
View file @
9d76d329
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
<!--Request View Controller-->
<!--Request View Controller-->
<scene
sceneID=
"MGi-Q6-5W5"
>
<scene
sceneID=
"MGi-Q6-5W5"
>
<objects>
<objects>
<viewController
storyboardIdentifier=
"
pedido
sVC"
id=
"efO-tm-e7g"
customClass=
"RequestViewController"
customModule=
"ayudapy"
customModuleProvider=
"target"
sceneMemberID=
"viewController"
>
<viewController
storyboardIdentifier=
"
request
sVC"
id=
"efO-tm-e7g"
customClass=
"RequestViewController"
customModule=
"ayudapy"
customModuleProvider=
"target"
sceneMemberID=
"viewController"
>
<view
key=
"view"
contentMode=
"scaleToFill"
id=
"2Bp-lZ-T6S"
>
<view
key=
"view"
contentMode=
"scaleToFill"
id=
"2Bp-lZ-T6S"
>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"414"
height=
"896"
/>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"414"
height=
"896"
/>
<autoresizingMask
key=
"autoresizingMask"
widthSizable=
"YES"
heightSizable=
"YES"
/>
<autoresizingMask
key=
"autoresizingMask"
widthSizable=
"YES"
heightSizable=
"YES"
/>
...
@@ -41,7 +41,7 @@
...
@@ -41,7 +41,7 @@
<!--Pendings View Controller-->
<!--Pendings View Controller-->
<scene
sceneID=
"1wO-Og-nyO"
>
<scene
sceneID=
"1wO-Og-nyO"
>
<objects>
<objects>
<viewController
storyboardIdentifier=
"pendi
ente
sVC"
id=
"Ncc-gI-9dq"
customClass=
"PendingsViewController"
customModule=
"ayudapy"
customModuleProvider=
"target"
sceneMemberID=
"viewController"
>
<viewController
storyboardIdentifier=
"pendi
ng
sVC"
id=
"Ncc-gI-9dq"
customClass=
"PendingsViewController"
customModule=
"ayudapy"
customModuleProvider=
"target"
sceneMemberID=
"viewController"
>
<view
key=
"view"
contentMode=
"scaleToFill"
id=
"s2s-eb-0xG"
>
<view
key=
"view"
contentMode=
"scaleToFill"
id=
"s2s-eb-0xG"
>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"414"
height=
"896"
/>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"414"
height=
"896"
/>
<autoresizingMask
key=
"autoresizingMask"
widthSizable=
"YES"
heightSizable=
"YES"
/>
<autoresizingMask
key=
"autoresizingMask"
widthSizable=
"YES"
heightSizable=
"YES"
/>
...
...
ayudapy/CoreData/CoreDataManager.swift
View file @
9d76d329
...
@@ -69,6 +69,16 @@ class CoreDataManager {
...
@@ -69,6 +69,16 @@ class CoreDataManager {
}
}
return
[]
return
[]
}
}
func
checkData
(
id
:
Int
,
entityList
:
[
Entity
])
->
Bool
{
let
array
=
entityList
var
bool
=
false
for
i
in
0
..<
array
.
count
{
if
array
[
i
]
.
id
==
Int64
(
id
){
bool
=
true
}
}
return
bool
}
// func saveInCheckedList(id: Int, latitude: Double, longitude: Double, completion: @escaping()-> Void){
// func saveInCheckedList(id: Int, latitude: Double, longitude: Double, completion: @escaping()-> Void){
// let context = container.viewContext
// let context = container.viewContext
...
...
ayudapy/Info.plist
View file @
9d76d329
...
@@ -20,6 +20,8 @@
...
@@ -20,6 +20,8 @@
<
string
>
1
<
/string
>
<
string
>
1
<
/string
>
<
k
e
y
>
LSRequiresIPhoneOS
<
/k
e
y
>
<
k
e
y
>
LSRequiresIPhoneOS
<
/k
e
y
>
<
tru
e
/
>
<
tru
e
/
>
<
k
e
y
>
NSLocationWhenInUseUsageDescription
<
/k
e
y
>
<
string
><
/string
>
<
k
e
y
>
UIApplicationSceneManifest
<
/k
e
y
>
<
k
e
y
>
UIApplicationSceneManifest
<
/k
e
y
>
<
d
i
c
t
>
<
d
i
c
t
>
<
k
e
y
>
UIApplicationSupportsMultipleScenes
<
/k
e
y
>
<
k
e
y
>
UIApplicationSupportsMultipleScenes
<
/k
e
y
>
...
@@ -50,11 +52,7 @@
...
@@ -50,11 +52,7 @@
<
k
e
y
>
UISupportedInterfaceOrientations
<
/k
e
y
>
<
k
e
y
>
UISupportedInterfaceOrientations
<
/k
e
y
>
<
a
rr
a
y
>
<
a
rr
a
y
>
<
string
>
UIInterfaceOrientationPortrait
<
/string
>
<
string
>
UIInterfaceOrientationPortrait
<
/string
>
<
string
>
UIInterfaceOrientationLandscapeLeft
<
/string
>
<
string
>
UIInterfaceOrientationLandscapeRight
<
/string
>
<
/
a
rr
a
y
>
<
/
a
rr
a
y
>
<
k
e
y
>
NSLocationWhenInUseUsageDescription
<
/k
e
y
>
<
string
><
/string
>
<
k
e
y
>
UISupportedInterfaceOrientations
~
ipad
<
/k
e
y
>
<
k
e
y
>
UISupportedInterfaceOrientations
~
ipad
<
/k
e
y
>
<
a
rr
a
y
>
<
a
rr
a
y
>
<
string
>
UIInterfaceOrientationPortrait
<
/string
>
<
string
>
UIInterfaceOrientationPortrait
<
/string
>
...
...
ayudapy/Static/Format.swift
View file @
9d76d329
...
@@ -129,12 +129,12 @@ extension String{
...
@@ -129,12 +129,12 @@ extension String{
}
}
return
month
return
month
}
}
func
convertURL
()
->
String
{
//
func convertURL()->String{
var
newURL
=
self
//
var newURL = self
let
subStr
:
Substring
=
"_th"
//
let subStr:Substring = "_th"
//
return
newURL
//
return newURL
}
//
}
}
}
ayudapy/ViewControllers/MapViewController.swift
View file @
9d76d329
...
@@ -54,7 +54,7 @@ class MapViewController: UIViewController {
...
@@ -54,7 +54,7 @@ class MapViewController: UIViewController {
infoLabel
.
font
=
UIFont
.
systemFont
(
ofSize
:
8
)
infoLabel
.
font
=
UIFont
.
systemFont
(
ofSize
:
8
)
infoLabel
.
textColor
=
format
.
footerTextColor
infoLabel
.
textColor
=
format
.
footerTextColor
infoButton
.
setImage
(
UIImage
(
named
:
"infoButton"
),
for
:
.
normal
)
infoButton
.
setImage
(
UIImage
(
named
:
"infoButton"
),
for
:
.
normal
)
infoButton
.
addTarget
(
self
,
action
:
#selector(
goToInfo
)
,
for
:
.
touchUpInside
)
infoButton
.
addTarget
(
self
,
action
:
#selector(
goToInfo
VC
)
,
for
:
.
touchUpInside
)
footerView
.
addSubview
(
infoLabel
)
footerView
.
addSubview
(
infoLabel
)
footerView
.
addSubview
(
infoButton
)
footerView
.
addSubview
(
infoButton
)
...
@@ -83,7 +83,7 @@ class MapViewController: UIViewController {
...
@@ -83,7 +83,7 @@ class MapViewController: UIViewController {
pendingLabel
.
font
=
UIFont
.
systemFont
(
ofSize
:
8
)
pendingLabel
.
font
=
UIFont
.
systemFont
(
ofSize
:
8
)
pendingLabel
.
textAlignment
=
.
center
pendingLabel
.
textAlignment
=
.
center
pendingButton
.
setImage
(
UIImage
(
named
:
"pendientesButton"
),
for
:
.
normal
)
pendingButton
.
setImage
(
UIImage
(
named
:
"pendientesButton"
),
for
:
.
normal
)
pendingButton
.
addTarget
(
self
,
action
:
#selector(
goToPendi
entes
)
,
for
:
.
touchUpInside
)
pendingButton
.
addTarget
(
self
,
action
:
#selector(
goToPendi
ngsVC
)
,
for
:
.
touchUpInside
)
footerView
.
addSubview
(
pendingLabel
)
footerView
.
addSubview
(
pendingLabel
)
...
@@ -114,7 +114,7 @@ class MapViewController: UIViewController {
...
@@ -114,7 +114,7 @@ class MapViewController: UIViewController {
let
position
=
CLLocationCoordinate2D
(
latitude
:
lat
,
longitude
:
long
)
let
position
=
CLLocationCoordinate2D
(
latitude
:
lat
,
longitude
:
long
)
let
markerView
=
UIView
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
30
,
height
:
35
))
let
markerView
=
UIView
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
30
,
height
:
35
))
let
markerButton
=
UIButton
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
30
,
height
:
35
))
let
markerButton
=
UIButton
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
30
,
height
:
35
))
if
self
.
isFavorite
(
id
:
self
.
id
)
{
if
self
.
manager
.
checkData
(
id
:
self
.
id
,
entityList
:
self
.
favorites
)
{
markerButton
.
setImage
(
UIImage
(
named
:
"pinFavGMAPS"
),
for
:
.
normal
)
markerButton
.
setImage
(
UIImage
(
named
:
"pinFavGMAPS"
),
for
:
.
normal
)
}
}
else
{
else
{
...
@@ -148,28 +148,10 @@ class MapViewController: UIViewController {
...
@@ -148,28 +148,10 @@ class MapViewController: UIViewController {
mapView
.
isHidden
=
true
mapView
.
isHidden
=
true
}
}
//Verificamos si el marcador corresponde a un favorito
func
isFavorite
(
id
:
Int
)
->
Bool
{
var
bool
=
Bool
()
if
favorites
.
count
>
0
{
for
i
in
0
..<
favorites
.
count
{
if
favorites
[
i
]
.
id
==
Int64
(
id
)
{
bool
=
true
}
else
{
bool
=
false
}
}
}
else
{
bool
=
false
}
return
bool
}
//Mostramos en el mapa los marcadores de los pedidos guardados en mis pendientes y/o marcados como listo
//Mostramos en el mapa los marcadores de los pedidos guardados en mis pendientes y/o marcados como listo
func
showFavoritesOrCheckedIcons
(){
func
showFavoritesOrCheckedIcons
(){
let
named
=
"pinFavGMAPS"
let
named
=
"pinFavGMAPS"
favorites
=
manager
.
fetchFavorites
()
for
i
in
0
..<
favorites
.
count
{
for
i
in
0
..<
favorites
.
count
{
let
markerView
=
UIView
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
30
,
height
:
35
))
let
markerView
=
UIView
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
30
,
height
:
35
))
let
markerButton
=
UIButton
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
30
,
height
:
35
))
let
markerButton
=
UIButton
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
30
,
height
:
35
))
...
@@ -184,7 +166,7 @@ class MapViewController: UIViewController {
...
@@ -184,7 +166,7 @@ class MapViewController: UIViewController {
}
}
//Selectors
//Selectors
@objc
func
goToInfo
(){
@objc
func
goToInfo
VC
(){
let
infoVC
=
self
.
storyboard
?
.
instantiateViewController
(
withIdentifier
:
"infoVC"
)
as!
InfoViewController
let
infoVC
=
self
.
storyboard
?
.
instantiateViewController
(
withIdentifier
:
"infoVC"
)
as!
InfoViewController
show
(
infoVC
,
sender
:
nil
)
show
(
infoVC
,
sender
:
nil
)
}
}
...
@@ -193,28 +175,30 @@ class MapViewController: UIViewController {
...
@@ -193,28 +175,30 @@ class MapViewController: UIViewController {
UIApplication
.
shared
.
open
(
url
as
URL
)
UIApplication
.
shared
.
open
(
url
as
URL
)
}
}
}
}
@objc
func
goToPendientes
(){
@objc
func
goToPendingsVC
(){
let
pendientesVC
=
self
.
storyboard
?
.
instantiateViewController
(
withIdentifier
:
"pendientesVC"
)
as!
PendingsViewController
let
pendingsVC
=
self
.
storyboard
?
.
instantiateViewController
(
withIdentifier
:
"pendingsVC"
)
as!
PendingsViewController
show
(
pendientesVC
,
sender
:
nil
)
pendingsVC
.
currentLatitude
=
(
currentLocation
?
.
coordinate
.
latitude
)
!
pendingsVC
.
currentLongitude
=
(
currentLocation
?
.
coordinate
.
longitude
)
!
show
(
pendingsVC
,
sender
:
nil
)
}
}
@objc
func
goToRequestV
iewController
(
pk
:
Int
){
@objc
func
goToRequestV
C
(
pk
:
Int
){
let
pedidosVC
=
self
.
storyboard
?
.
instantiateViewController
(
withIdentifier
:
"pedido
sVC"
)
as!
RequestViewController
let
requestsVC
=
self
.
storyboard
?
.
instantiateViewController
(
withIdentifier
:
"request
sVC"
)
as!
RequestViewController
pedido
sVC
.
id
=
id
request
sVC
.
id
=
id
pedido
sVC
.
currentLatitude
=
(
currentLocation
?
.
coordinate
.
latitude
)
!
request
sVC
.
currentLatitude
=
(
currentLocation
?
.
coordinate
.
latitude
)
!
pedido
sVC
.
currentLongitude
=
(
currentLocation
?
.
coordinate
.
longitude
)
!
request
sVC
.
currentLongitude
=
(
currentLocation
?
.
coordinate
.
longitude
)
!
if
isFavorite
(
id
:
id
){
if
manager
.
checkData
(
id
:
id
,
entityList
:
favorites
){
pedido
sVC
.
isFavorite
=
true
request
sVC
.
isFavorite
=
true
print
(
"El pedido
\(
id
)
es favorito"
)
print
(
"El pedido
\(
id
)
es favorito"
)
}
}
pedidosVC
.
helpRequest
()
requestsVC
.
helpRequest
()
//show(pedidosVC, sender: nil)
isModalInPresentation
=
true
isModalInPresentation
=
true
present
(
pedido
sVC
,
animated
:
true
,
completion
:
nil
)
present
(
request
sVC
,
animated
:
true
,
completion
:
nil
)
}
}
override
func
viewWillAppear
(
_
animated
:
Bool
)
{
override
func
viewWillAppear
(
_
animated
:
Bool
)
{
super
.
viewWillAppear
(
true
)
super
.
viewWillAppear
(
true
)
favorites
=
manager
.
fetchFavorites
()
favorites
=
manager
.
fetchFavorites
()
print
(
"Estos son los favoritos
\(
favorites
)
"
)
helpRequest
()
helpRequest
()
}
}
...
@@ -271,7 +255,7 @@ extension MapViewController: CLLocationManagerDelegate, GMSMapViewDelegate {
...
@@ -271,7 +255,7 @@ extension MapViewController: CLLocationManagerDelegate, GMSMapViewDelegate {
func
mapView
(
_
mapView
:
GMSMapView
,
didTap
marker
:
GMSMarker
)
->
Bool
{
func
mapView
(
_
mapView
:
GMSMapView
,
didTap
marker
:
GMSMarker
)
->
Bool
{
id
=
Int
(
marker
.
title
!
)
!
id
=
Int
(
marker
.
title
!
)
!
goToRequestV
iewController
(
pk
:
id
)
goToRequestV
C
(
pk
:
id
)
return
true
return
true
}
}
func
mapView
(
_
mapView
:
GMSMapView
,
willMove
gesture
:
Bool
)
{
func
mapView
(
_
mapView
:
GMSMapView
,
willMove
gesture
:
Bool
)
{
...
...
ayudapy/ViewControllers/PendingsViewController.swift
View file @
9d76d329
...
@@ -13,20 +13,23 @@ class PendingsViewController: UIViewController {
...
@@ -13,20 +13,23 @@ class PendingsViewController: UIViewController {
let
manager
=
CoreDataManager
()
let
manager
=
CoreDataManager
()
var
favorites
=
[
Entity
]()
var
favorites
=
[
Entity
]()
let
format
=
Format
.
init
()
let
format
=
Format
.
init
()
var
currentLatitude
=
Double
()
var
currentLongitude
=
Double
()
@IBOutlet
weak
var
tableView
:
UITableView
!
@IBOutlet
weak
var
tableView
:
UITableView
!
func
goToRequestViewController
(
pk
:
Int
){
func
goToRequestViewController
(
pk
:
Int
){
let
pedidosVC
=
self
.
storyboard
?
.
instantiateViewController
(
withIdentifier
:
"pedidosVC"
)
as!
RequestViewController
let
requestsVC
=
self
.
storyboard
?
.
instantiateViewController
(
withIdentifier
:
"requestsVC"
)
as!
RequestViewController
pedidosVC
.
id
=
pk
requestsVC
.
id
=
pk
requestsVC
.
currentLatitude
=
currentLatitude
requestsVC
.
currentLongitude
=
currentLongitude
if
isFavorite
(
id
:
pk
){
if
isFavorite
(
id
:
pk
){
pedido
sVC
.
isFavorite
=
true
request
sVC
.
isFavorite
=
true
}
}
print
(
"ID del pedido:
\(
pk
)
"
)
print
(
"ID del pedido:
\(
pk
)
"
)
pedido
sVC
.
helpRequest
()
request
sVC
.
helpRequest
()
//show(pedidosVC, sender: nil)
//show(pedidosVC, sender: nil)
present
(
pedido
sVC
,
animated
:
true
,
completion
:
nil
)
present
(
request
sVC
,
animated
:
true
,
completion
:
nil
)
}
}
func
isFavorite
(
id
:
Int
)
->
Bool
{
func
isFavorite
(
id
:
Int
)
->
Bool
{
var
bool
=
Bool
()
var
bool
=
Bool
()
...
...
ayudapy/ViewControllers/RequestViewController.swift
View file @
9d76d329
...
@@ -36,12 +36,12 @@ class RequestViewController: UIViewController {
...
@@ -36,12 +36,12 @@ class RequestViewController: UIViewController {
let
checkImage
=
UIImage
(
named
:
"iconListoUnchecked"
)
let
checkImage
=
UIImage
(
named
:
"iconListoUnchecked"
)
let
checkLabel
=
UILabel
()
let
checkLabel
=
UILabel
()
//solicitud api segun nro de pedido de ayuda "pk"
func
helpRequest
(){
func
helpRequest
(){
let
url
=
"https://ayudapy.org/api/v1/helprequests/"
let
url
=
"https://ayudapy.org/api/v1/helprequests/"
HTTPClient
.
request
(
endpoint
:
url
+
"
\(
id
)
"
,
onSuccess
:
{
(
response
:
Request
?)
in
HTTPClient
.
request
(
endpoint
:
url
+
"
\(
id
)
"
,
onSuccess
:
{
(
response
:
Request
?)
in
if
let
requestInformation
=
response
{
if
let
requestInformation
=
response
{
print
(
"Estos son los datos
\(
requestInformation
)
"
)
print
(
"Estos son los datos
:
\(
requestInformation
)
"
)
self
.
name
=
response
!.
name
self
.
name
=
response
!.
name
self
.
message
=
response
!.
message
self
.
message
=
response
!.
message
self
.
hRequestTitle
=
response
!.
title
self
.
hRequestTitle
=
response
!.
title
...
@@ -52,7 +52,6 @@ class RequestViewController: UIViewController {
...
@@ -52,7 +52,6 @@ class RequestViewController: UIViewController {
self
.
imageUrl
=
response
!.
picture
self
.
imageUrl
=
response
!.
picture
self
.
longitude
=
response
!.
location
.
coordinates
[
0
]
self
.
longitude
=
response
!.
location
.
coordinates
[
0
]
self
.
latitude
=
response
!.
location
.
coordinates
[
1
]
self
.
latitude
=
response
!.
location
.
coordinates
[
1
]
self
.
isFavorite
=
self
.
isFavoriteCheck
()
self
.
showRequestInformation
()
self
.
showRequestInformation
()
}
}
else
{
else
{
...
@@ -62,7 +61,9 @@ class RequestViewController: UIViewController {
...
@@ -62,7 +61,9 @@ class RequestViewController: UIViewController {
})
})
}
}
//Muestra la información recibida en pantalla
func
showRequestInformation
(){
func
showRequestInformation
(){
//fecha (se convierte el string de la fecha completa a otro con la unidad de tiempo seleccionada
let
day
=
date
.
getDatePart
(
dateUnit
:
.
day
)
let
day
=
date
.
getDatePart
(
dateUnit
:
.
day
)
let
month
=
(
date
.
getDatePart
(
dateUnit
:
.
month
))
.
getMonthInSpanish
()
let
month
=
(
date
.
getDatePart
(
dateUnit
:
.
month
))
.
getMonthInSpanish
()
let
year
=
date
.
getDatePart
(
dateUnit
:
.
year
)
let
year
=
date
.
getDatePart
(
dateUnit
:
.
year
)
...
@@ -71,22 +72,28 @@ class RequestViewController: UIViewController {
...
@@ -71,22 +72,28 @@ class RequestViewController: UIViewController {
dateLabel
.
text
=
"Publicado el
\(
day
)
de
\(
month
)
de
\(
year
)
a las
\(
hour
)
"
dateLabel
.
text
=
"Publicado el
\(
day
)
de
\(
month
)
de
\(
year
)
a las
\(
hour
)
"
dateLabel
.
font
=
format
.
dateFontStyle
dateLabel
.
font
=
format
.
dateFontStyle
dateLabel
.
textColor
=
format
.
dateTextColor
dateLabel
.
textColor
=
format
.
dateTextColor
//titulo del pedido
let
titleLbl
=
UILabel
()
let
titleLbl
=
UILabel
()
titleLbl
.
text
=
"
\(
hRequestTitle
)
"
titleLbl
.
text
=
"
\(
hRequestTitle
)
"
titleLbl
.
font
=
format
.
titleFontStyle
titleLbl
.
font
=
format
.
titleFontStyle
titleLbl
.
textColor
=
format
.
titleTextColor
titleLbl
.
textColor
=
format
.
titleTextColor
//detalle del pedido
let
messageLabel
=
UILabel
()
let
messageLabel
=
UILabel
()
messageLabel
.
text
=
"
\(
message
)
"
messageLabel
.
text
=
"
\(
message
)
"
messageLabel
.
font
=
format
.
bodyFontStyle
messageLabel
.
font
=
format
.
bodyFontStyle
messageLabel
.
numberOfLines
=
.
max
messageLabel
.
numberOfLines
=
.
max
messageLabel
.
lineBreakMode
=
.
byWordWrapping
messageLabel
.
lineBreakMode
=
.
byWordWrapping
messageLabel
.
sizeToFit
()
messageLabel
.
sizeToFit
()
//Para mostrar la imagen en caso de que el campo no sea nulo
let
imageView
=
UIImageView
()
let
imageView
=
UIImageView
()
if
imageUrl
!=
nil
{
if
imageUrl
!=
nil
{
imageView
.
layer
.
frame
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
100
,
height
:
100
)
imageView
.
layer
.
frame
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
100
,
height
:
100
)
imageView
.
kf
.
indicatorType
=
.
activity
imageView
.
kf
.
indicatorType
=
.
activity
imageView
.
kf
.
setImage
(
with
:
URL
(
string
:
imageUrl
!
))
imageView
.
kf
.
setImage
(
with
:
URL
(
string
:
imageUrl
!
))
}
}
//Se agrupan las vistas en la cabecera
let
headerStackView
=
UIStackView
(
arrangedSubviews
:
[
dateLabel
,
titleLbl
,
messageLabel
])
let
headerStackView
=
UIStackView
(
arrangedSubviews
:
[
dateLabel
,
titleLbl
,
messageLabel
])
headerStackView
.
axis
=
.
vertical
headerStackView
.
axis
=
.
vertical
headerStackView
.
spacing
=
5
headerStackView
.
spacing
=
5
...
@@ -128,17 +135,18 @@ class RequestViewController: UIViewController {
...
@@ -128,17 +135,18 @@ class RequestViewController: UIViewController {
contactInformationStackView
.
axis
=
.
vertical
contactInformationStackView
.
axis
=
.
vertical
contactInformationStackView
.
spacing
=
5
contactInformationStackView
.
spacing
=
5
//Se muestra el botón y la etiqueta de marcar como listo
//checkButton.frame.size = CGSize(width: 80, height: 80)
checkLabel
.
text
=
"Marcar como listo"
checkLabel
.
text
=
"Marcar como listo"
checkLabel
.
font
=
format
.
bodyFontStyle
checkLabel
.
font
=
format
.
bodyFontStyle
checkLabel
.
textAlignment
=
.
center
checkLabel
.
textAlignment
=
.
center
checkButton
.
setImage
(
checkImage
,
for
:
.
normal
)
let
checkStackView
=
UIStackView
(
arrangedSubviews
:
[
checkButton
,
checkLabel
])
let
checkStackView
=
UIStackView
(
arrangedSubviews
:
[
checkButton
,
checkLabel
])
checkStackView
.
axis
=
.
vertical
checkStackView
.
axis
=
.
vertical
checkStackView
.
distribution
=
.
fillEqually
checkStackView
.
distribution
=
.
fillEqually
checkStackView
.
spacing
=
0
checkStackView
.
spacing
=
0
//se muestra el botón y etiqueta para Agregar a pendientes
isFavoriteButton
.
frame
.
size
=
CGSize
(
width
:
80
,
height
:
80
)
isFavoriteButton
.
frame
.
size
=
CGSize
(
width
:
80
,
height
:
80
)
if
isFavorite
{
if
isFavorite
{
isFavoriteButton
.
setImage
(
UIImage
(
named
:
"iconPendientesChecked"
),
for
:
.
normal
)
isFavoriteButton
.
setImage
(
UIImage
(
named
:
"iconPendientesChecked"
),
for
:
.
normal
)
...
@@ -149,7 +157,6 @@ class RequestViewController: UIViewController {
...
@@ -149,7 +157,6 @@ class RequestViewController: UIViewController {
isFavoriteButton
.
addTarget
(
self
,
action
:
#selector(
addOrRemoveFavorite(sender: )
)
,
for
:
.
touchUpInside
)
isFavoriteButton
.
addTarget
(
self
,
action
:
#selector(
addOrRemoveFavorite(sender: )
)
,
for
:
.
touchUpInside
)
isFavoriteLabel
.
text
=
"Agregar a mis Pendientes"
isFavoriteLabel
.
text
=
"Agregar a mis Pendientes"
}
}
isFavoriteLabel
.
font
=
format
.
bodyFontStyle
isFavoriteLabel
.
font
=
format
.
bodyFontStyle
isFavoriteLabel
.
numberOfLines
=
2
isFavoriteLabel
.
numberOfLines
=
2
isFavoriteLabel
.
textAlignment
=
.
center
isFavoriteLabel
.
textAlignment
=
.
center
...
@@ -157,39 +164,22 @@ class RequestViewController: UIViewController {
...
@@ -157,39 +164,22 @@ class RequestViewController: UIViewController {
isFavoriteStackView
.
axis
=
.
vertical
isFavoriteStackView
.
axis
=
.
vertical
isFavoriteStackView
.
distribution
=
.
fillEqually
isFavoriteStackView
.
distribution
=
.
fillEqually
isFavoriteStackView
.
spacing
=
0
isFavoriteStackView
.
spacing
=
0
checkButton
.
setImage
(
checkImage
,
for
:
.
normal
)
let
footerStackView
=
UIStackView
(
arrangedSubviews
:
[
isFavoriteStackView
,
checkStackView
])
let
footerStackView
=
UIStackView
(
arrangedSubviews
:
[
isFavoriteStackView
,
checkStackView
])
footerStackView
.
axis
=
.
horizontal
footerStackView
.
axis
=
.
horizontal
footerStackView
.
distribution
=
.
fillEqually
footerStackView
.
distribution
=
.
fillEqually
footerStackView
.
heightAnchor
.
constraint
(
equalToConstant
:
100
)
.
isActive
=
true
footerStackView
.
heightAnchor
.
constraint
(
equalToConstant
:
80
)
.
isActive
=
true
//viewHeightAnchor += Int(isFavoriteStackView.frame.height)
//viewHeightAnchor += 30
//Se agregan las vistas en un stack view vertical para que se vean ordenadamente, adaptando a la pantalla del dispositivo
let
stackView
=
UIStackView
(
arrangedSubviews
:
[
headerStackView
,
addressStackView
,
contactInformationStackView
,
footerStackView
])
let
stackView
=
UIStackView
(
arrangedSubviews
:
[
headerStackView
,
addressStackView
,
contactInformationStackView
,
footerStackView
])
stackView
.
axis
=
.
vertical
stackView
.
axis
=
.
vertical
stackView
.
distribution
=
.
equalSpacing
stackView
.
distribution
=
.
equalSpacing
stackView
.
spacing
=
10
stackView
.
spacing
=
10
stackView
.
layer
.
frame
=
CGRect
(
x
:
20
,
y
:
20
,
width
:
view
.
frame
.
width
*
0.9
,
height
:
view
.
frame
.
height
*
0.9
)
stackView
.
layer
.
frame
=
CGRect
(
x
:
20
,
y
:
20
,
width
:
view
.
frame
.
width
-
20
,
height
:
view
.
frame
.
height
*
0.9
)
view
.
addSubview
(
stackView
)
view
.
addSubview
(
stackView
)
}
}
func
isFavoriteCheck
()
->
Bool
{
var
bool
=
false
for
i
in
0
..<
favorites
.
count
{
if
favorites
[
i
]
.
id
==
Int64
(
id
)
{
bool
=
true
}
else
{
bool
=
false
}
}
return
bool
}
func
isReadyCheck
()
->
Bool
{
func
isReadyCheck
()
->
Bool
{
return
false
return
false
}
}
...
@@ -200,6 +190,7 @@ class RequestViewController: UIViewController {
...
@@ -200,6 +190,7 @@ class RequestViewController: UIViewController {
self
.
isFavorite
=
false
self
.
isFavorite
=
false
sender
.
setImage
(
UIImage
(
named
:
"iconPendientesUnchecked"
),
for
:
.
normal
)
sender
.
setImage
(
UIImage
(
named
:
"iconPendientesUnchecked"
),
for
:
.
normal
)
self
.
isFavoriteLabel
.
text
=
"Agregar a mis Pendientes"
self
.
isFavoriteLabel
.
text
=
"Agregar a mis Pendientes"
reloadInputViews
()
}
else
}
else
{
{
manager
.
saveFavorites
(
id
:
id
,
name
:
name
,
date
:
date
,
address
:
address
,
message
:
message
,
title
:
hRequestTitle
,
phoneNumber
:
phoneNumber
,
latitude
:
latitude
,
longitude
:
longitude
)
{
[
weak
self
]
in
manager
.
saveFavorites
(
id
:
id
,
name
:
name
,
date
:
date
,
address
:
address
,
message
:
message
,
title
:
hRequestTitle
,
phoneNumber
:
phoneNumber
,
latitude
:
latitude
,
longitude
:
longitude
)
{
[
weak
self
]
in
...
@@ -209,10 +200,10 @@ class RequestViewController: UIViewController {
...
@@ -209,10 +200,10 @@ class RequestViewController: UIViewController {
self
.
isFavorite
=
true
self
.
isFavorite
=
true
sender
.
setImage
(
UIImage
(
named
:
"iconPendientesChecked"
),
for
:
.
normal
)
sender
.
setImage
(
UIImage
(
named
:
"iconPendientesChecked"
),
for
:
.
normal
)
self
.
isFavoriteLabel
.
text
=
"Quitar de mis Pendientes"
self
.
isFavoriteLabel
.
text
=
"Quitar de mis Pendientes"
reloadInputViews
()
}
}
}
}
@objc
func
openGoogleMapsLink
(){
@objc
func
openGoogleMapsLink
(){
//https://www.google.com/maps/dir/-25.2860598,-57.6162619/-25.287641,-57.611509/
if
let
url
=
NSURL
(
string
:
"https://www.google.com/maps/dir/
\(
currentLatitude
)
,
\(
currentLongitude
)
/
\(
latitude
)
,
\(
longitude
)
"
){
if
let
url
=
NSURL
(
string
:
"https://www.google.com/maps/dir/
\(
currentLatitude
)
,
\(
currentLongitude
)
/
\(
latitude
)
,
\(
longitude
)
"
){
UIApplication
.
shared
.
open
(
url
as
URL
)
UIApplication
.
shared
.
open
(
url
as
URL
)
}
}
...
@@ -251,6 +242,11 @@ class RequestViewController: UIViewController {
...
@@ -251,6 +242,11 @@ class RequestViewController: UIViewController {
self
.
present
(
alert
,
animated
:
true
)
self
.
present
(
alert
,
animated
:
true
)
}
}
override
func
viewWillAppear
(
_
animated
:
Bool
)
{
favorites
=
manager
.
fetchFavorites
()
isFavorite
=
manager
.
checkData
(
id
:
id
,
entityList
:
favorites
)
}
override
func
viewDidLoad
()
{
override
func
viewDidLoad
()
{
}
}
...
...
Write
Preview
Markdown
is supported
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