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
6524daa8
Commit
6524daa8
authored
May 13, 2020
by
Julio Hermosa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
primera entrega
parent
57491b63
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
69 additions
and
23 deletions
+69
-23
ayudapy.xcworkspace/xcuserdata/roshka.xcuserdatad/UserInterfaceState.xcuserstate
+0
-0
ayudapy/Base.lproj/Main.storyboard
+0
-0
ayudapy/CoreData/CoreDataManager.swift
+9
-0
ayudapy/CoreData/Favorites.xcdatamodeld/favoriteRequests.xcdatamodel/contents
+3
-1
ayudapy/Entity+CoreDataProperties.swift
+1
-0
ayudapy/Static/Format.swift
+1
-1
ayudapy/ViewControllers/MapViewController.swift
+0
-1
ayudapy/ViewControllers/MyPendingsTableViewCell.swift
+13
-1
ayudapy/ViewControllers/PendingsViewController.swift
+34
-7
ayudapy/ViewControllers/RequestViewController.swift
+8
-12
No files found.
ayudapy.xcworkspace/xcuserdata/roshka.xcuserdatad/UserInterfaceState.xcuserstate
View file @
6524daa8
No preview for this file type
ayudapy/Base.lproj/Main.storyboard
View file @
6524daa8
This diff is collapsed.
Click to expand it.
ayudapy/CoreData/CoreDataManager.swift
View file @
6524daa8
...
...
@@ -42,6 +42,15 @@ class CoreDataManager {
print
(
"error al guardar
\(
error
)
"
)
}
}
func
deleteFavorites
(
id
:
Int
,
array
:
[
Entity
]){
let
context
=
container
.
viewContext
for
i
in
0
..<
array
.
count
{
if
array
[
i
]
.
id
==
Int64
(
id
){
context
.
delete
(
array
[
i
])
}
}
}
func
fetchFavorites
()
->
[
Entity
]{
let
fetchRequest
:
NSFetchRequest
<
Entity
>
=
Entity
.
fetchRequest
()
do
{
...
...
ayudapy/CoreData/Favorites.xcdatamodeld/favoriteRequests.xcdatamodel/contents
View file @
6524daa8
...
...
@@ -6,9 +6,10 @@
<attribute
name=
"id"
attributeType=
"Integer 64"
defaultValueString=
"0"
usesScalarValueType=
"YES"
/>
<attribute
name=
"message"
optional=
"YES"
attributeType=
"String"
/>
<attribute
name=
"name"
optional=
"YES"
attributeType=
"String"
/>
<attribute
name=
"phoneNumber"
optional=
"YES"
attributeType=
"String"
/>
<attribute
name=
"title"
optional=
"YES"
attributeType=
"String"
/>
</entity>
<elements>
<element
name=
"Entity"
positionX=
"-54"
positionY=
"-9"
width=
"128"
height=
"1
33
"
/>
<element
name=
"Entity"
positionX=
"-54"
positionY=
"-9"
width=
"128"
height=
"1
48
"
/>
</elements>
</model>
\ No newline at end of file
ayudapy/Entity+CoreDataProperties.swift
View file @
6524daa8
...
...
@@ -22,5 +22,6 @@ extension Entity {
@NSManaged
public
var
date
:
Date
?
@NSManaged
public
var
address
:
String
?
@NSManaged
public
var
title
:
String
?
@NSManaged
public
var
phoneNumber
:
String
?
}
ayudapy/Static/Format.swift
View file @
6524daa8
...
...
@@ -56,7 +56,7 @@ extension String{
returnValue
=
String
(
subStr
)
case
.
hour
:
let
start
=
date
.
index
(
date
.
startIndex
,
offsetBy
:
1
0
)
let
start
=
date
.
index
(
date
.
startIndex
,
offsetBy
:
1
1
)
let
end
=
date
.
index
(
date
.
startIndex
,
offsetBy
:
16
)
let
range
=
start
..<
end
let
subStr
=
date
[
range
]
...
...
ayudapy/ViewControllers/MapViewController.swift
View file @
6524daa8
...
...
@@ -149,7 +149,6 @@ class MapViewController: UIViewController {
marker
.
map
=
self
.
mapView
marker
.
iconView
=
markerView
//marker.icon = markerImage
marker
.
title
=
"
\(
features
[
i
]
.
properties
.
pk
)
"
}
})
...
...
ayudapy/ViewControllers/MyPendingsTableViewCell.swift
View file @
6524daa8
...
...
@@ -10,17 +10,29 @@ import UIKit
class
MyPendingsTableViewCell
:
UITableViewCell
{
var
id
=
Int
()
let
format
=
Format
.
init
()
let
manager
=
CoreDataManager
()
@IBOutlet
weak
var
dayLabel
:
UILabel
!
@IBOutlet
weak
var
monthLabel
:
UILabel
!
@IBOutlet
weak
var
titleLabel
:
UILabel
!
@IBOutlet
weak
var
detailLabel
:
UILabel
!
let
format
=
Format
.
init
()
@IBOutlet
weak
var
deleteButton
:
UIButton
!
@IBAction
func
deleteRow
(
_
sender
:
Any
)
{
let
array
=
manager
.
fetchFavorites
()
print
(
id
)
manager
.
deleteFavorites
(
id
:
id
,
array
:
array
)
}
override
func
awakeFromNib
()
{
super
.
awakeFromNib
()
dayLabel
.
textColor
=
format
.
subTitleTextColor
monthLabel
.
textColor
=
format
.
titleTextColor
}
override
func
setSelected
(
_
selected
:
Bool
,
animated
:
Bool
)
{
...
...
ayudapy/ViewControllers/PendingsViewController.swift
View file @
6524daa8
...
...
@@ -9,10 +9,20 @@
import
UIKit
import
CoreData
struct
MyPendings
{
var
id
:
Int
var
title
:
String
?
var
message
:
String
?
var
date
:
String
var
address
:
String
?
var
contactNumber
:
String
?
var
contactName
:
String
?
}
class
PendingsViewController
:
UIViewController
{
let
manager
=
CoreDataManager
()
var
favorites
=
[(
Int64
,
String
,
String
)
]()
var
myPendings
=
[
MyPendings
]()
let
format
=
Format
.
init
()
@IBOutlet
weak
var
tableView
:
UITableView
!
...
...
@@ -20,11 +30,10 @@ class PendingsViewController: UIViewController {
override
func
viewWillAppear
(
_
animated
:
Bool
)
{
super
.
viewWillAppear
(
animated
)
let
array
=
manager
.
fetchFavorites
()
for
i
in
0
..<
manager
.
fetchFavorites
()
.
count
{
favorites
.
append
((
Int64
(
array
[
i
]
.
id
),
array
[
i
]
.
message
!
,
"
\(
array
[
i
]
.
date
!
)
"
))
//print(array[i].id, array[i].name!, array[i].date!)
myPendings
.
append
(
MyPendings
(
id
:
Int
(
array
[
i
]
.
id
),
title
:
array
[
i
]
.
title
,
message
:
array
[
i
]
.
message
,
date
:
"
\(
array
[
i
]
.
date
!
)
"
,
address
:
array
[
i
]
.
address
,
contactNumber
:
array
[
i
]
.
name
,
contactName
:
array
[
i
]
.
phoneNumber
))
}
//print(favorites)
}
override
func
viewDidLoad
()
{
...
...
@@ -42,17 +51,35 @@ extension PendingsViewController: UITableViewDelegate, UITableViewDataSource{
func
tableView
(
_
tableView
:
UITableView
,
cellForRowAt
indexPath
:
IndexPath
)
->
UITableViewCell
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"cell"
,
for
:
indexPath
)
as!
MyPendingsTableViewCell
let
date
=
favorites
[
indexPath
.
row
]
.
2
let
date
=
myPendings
[
indexPath
.
row
]
.
date
let
month
=
date
.
getDatePart
(
dateUnit
:
.
month
)
let
monthString
=
month
.
getMonthShortString
()
let
day
=
date
.
getDatePart
(
dateUnit
:
.
day
)
cell
.
titleLabel
.
text
=
"
\(
favorites
[
indexPath
.
row
]
.
1
)
"
cell
.
detailLabel
.
text
=
"
\(
favorites
[
indexPath
.
row
]
.
2
)
"
var
detailLabel
:
String
=
""
cell
.
titleLabel
.
text
=
myPendings
[
indexPath
.
row
]
.
title
cell
.
titleLabel
.
textColor
=
format
.
subTitleTextColor
cell
.
titleLabel
.
font
=
format
.
subTitleFontStyle
if
let
address
=
myPendings
[
indexPath
.
row
]
.
address
{
detailLabel
=
address
}
if
let
contactName
=
myPendings
[
indexPath
.
row
]
.
contactName
{
detailLabel
=
detailLabel
+
"
\n\(
contactName
)
"
}
if
let
contactNumber
=
myPendings
[
indexPath
.
row
]
.
contactNumber
{
detailLabel
=
detailLabel
+
"
\n\(
contactNumber
)
"
}
cell
.
detailLabel
.
text
=
detailLabel
cell
.
detailLabel
.
font
=
format
.
bodyFontStyle
cell
.
dayLabel
.
text
=
day
cell
.
monthLabel
.
text
=
monthString
let
id
=
myPendings
[
indexPath
.
row
]
.
id
cell
.
id
=
id
return
cell
}
func
tableView
(
_
tableView
:
UITableView
,
viewForHeaderInSection
section
:
Int
)
->
UIView
?
{
let
headerLabel
=
UILabel
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
100
,
height
:
50
))
headerLabel
.
text
=
"Mis Pendientes"
...
...
ayudapy/ViewControllers/RequestViewController.swift
View file @
6524daa8
...
...
@@ -24,8 +24,6 @@ class RequestViewController: UIViewController {
var
isFavorite
=
Bool
()
var
checked
=
Bool
()
var
favorites
=
[
Int
]()
// private let appDelegate = UIApplication.shared.delegate as! AppDelegate
// private let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
private
let
manager
=
CoreDataManager
()
...
...
@@ -52,8 +50,12 @@ class RequestViewController: UIViewController {
}
func
showRequestInformation
(){
let
day
=
date
.
getDatePart
(
dateUnit
:
.
day
)
let
month
=
(
date
.
getDatePart
(
dateUnit
:
.
month
))
.
getMonthInSpanish
()
let
year
=
date
.
getDatePart
(
dateUnit
:
.
year
)
let
hour
=
date
.
getDatePart
(
dateUnit
:
.
hour
)
let
dateLabel
=
UILabel
()
dateLabel
.
text
=
"Publicado el
:
\(
date
)
"
dateLabel
.
text
=
"Publicado el
\(
day
)
de
\(
month
)
de
\(
year
)
a las
\(
hour
)
"
dateLabel
.
font
=
format
.
dateFontStyle
dateLabel
.
textColor
=
format
.
dateTextColor
let
titleLbl
=
UILabel
()
...
...
@@ -81,17 +83,11 @@ class RequestViewController: UIViewController {
addressLabel
.
text
=
"
\(
address
)
"
addressLabel
.
lineBreakMode
=
.
byWordWrapping
addressLabel
.
numberOfLines
=
.
max
// let cityLabel = UILabel()
// cityLabel.text = city
let
howToGetButton
=
UIButton
()
//(frame: CGRect(x: 0, y: 0, width: view.frame.width * 0.9, height: 20))
let
howToGetButton
=
UIButton
()
howToGetButton
.
backgroundColor
=
format
.
subTitleTextColor
howToGetButton
.
layer
.
cornerRadius
=
10
// let howToGetLabel = UILabel()
// howToGetLabel.text = "Como LLegar"
// howToGetLabel.font = format.subTitleFontStyle
// howToGetLabel.textColor = .white
// howToGetLabel.textAlignment = .center
// howToGetButton.addSubview(howToGetLabel)
howToGetButton
.
setTitle
(
"Como llegar"
,
for
:
.
normal
)
howToGetButton
.
titleLabel
?
.
font
=
format
.
subTitleFontStyle
let
contactLabel
=
UILabel
()
...
...
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