Commit 88cbd54a by Javier Heisekce

Se colapsa los contactos

parent 92cc2d0f
ContactsApp.xcodeproj/xcuserdata/user.xcuserdatad/xcdebugger/
......@@ -12,6 +12,7 @@
CE3351F3241A65D400BA57CA /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CE3351F1241A65D400BA57CA /* Main.storyboard */; };
CE3351F5241A65D500BA57CA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CE3351F4241A65D500BA57CA /* Assets.xcassets */; };
CE3351F8241A65D500BA57CA /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CE3351F6241A65D500BA57CA /* LaunchScreen.storyboard */; };
CEC259D8241FAC79005237F5 /* File.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEC259D7241FAC79005237F5 /* File.swift */; };
CEC9A37F241BFBD000F024EE /* ContactsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEC9A37E241BFBD000F024EE /* ContactsViewController.swift */; };
CEC9A381241C096D00F024EE /* SingleContactViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEC9A380241C096D00F024EE /* SingleContactViewController.swift */; };
/* End PBXBuildFile section */
......@@ -24,6 +25,7 @@
CE3351F4241A65D500BA57CA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
CE3351F7241A65D500BA57CA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
CE3351F9241A65D500BA57CA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
CEC259D7241FAC79005237F5 /* File.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = File.swift; sourceTree = "<group>"; };
CEC9A37E241BFBD000F024EE /* ContactsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactsViewController.swift; sourceTree = "<group>"; };
CEC9A380241C096D00F024EE /* SingleContactViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SingleContactViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
......@@ -66,6 +68,7 @@
CE3351F9241A65D500BA57CA /* Info.plist */,
CEC9A37E241BFBD000F024EE /* ContactsViewController.swift */,
CEC9A380241C096D00F024EE /* SingleContactViewController.swift */,
CEC259D7241FAC79005237F5 /* File.swift */,
);
path = ContactsApp;
sourceTree = "<group>";
......@@ -141,6 +144,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
CEC259D8241FAC79005237F5 /* File.swift in Sources */,
CE3351EC241A65D400BA57CA /* AppDelegate.swift in Sources */,
CEC9A37F241BFBD000F024EE /* ContactsViewController.swift in Sources */,
CE3351EE241A65D400BA57CA /* SceneDelegate.swift in Sources */,
......
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
uuid = "FAEBA8FF-01C0-4AC4-9E9A-FC8BDE9B6CFE"
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "DD77F967-46EF-4823-80DE-1DB5A3A787F1"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "ContactsApp/SingleContactViewController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "26"
endingLineNumber = "26"
landmarkName = "viewDidLoad()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "ECE5C42C-6FA2-494C-BD01-61ED62BE071C"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "ContactsApp/SingleContactViewController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "24"
endingLineNumber = "24"
landmarkName = "viewDidLoad()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
......@@ -14,6 +14,7 @@ class ContactsViewController: UIViewController {
@IBOutlet weak var contactsTable: UITableView!
var contacts = [CNContact]()
var contactsBackup = [CNContact]()
let contactStore = CNContactStore()
override func viewDidLoad() {
......@@ -24,9 +25,8 @@ class ContactsViewController: UIViewController {
func importContacts() {
let keys = [CNContactFormatter.descriptorForRequiredKeys(for: .fullName)]
//obtengo
let request = CNContactFetchRequest(keysToFetch: keys)
let keys = [CNContactFormatter.descriptorForRequiredKeys(for: .fullName), CNContactEmailAddressesKey, CNContactPhoneNumbersKey, CNContactImageDataKey, CNContactImageDataAvailableKey] as [Any]
let request = CNContactFetchRequest( keysToFetch: keys as! [CNKeyDescriptor])
request.sortOrder = CNContactSortOrder.givenName
do {
try self.contactStore.enumerateContacts(with: request) {
......@@ -66,5 +66,31 @@ extension ContactsViewController: UITableViewDelegate, UITableViewDataSource {
performSegue(withIdentifier: "gotocontact", sender: selectedContact)
}
func tableView(_ tableView: UITableView, estimatedHeightForHeaderInSection section: Int) -> CGFloat {
return 40
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let button = UIButton(type: .system)
button.setTitle("Λ", for: .normal)
button.setTitleColor(.black, for: .normal)
button.titleLabel?.font = UIFont.boldSystemFont(ofSize: 15)
button.backgroundColor = .systemGray4
button.addTarget(self, action: #selector(closeSection), for: .touchUpInside)
return button//ʌΛ
}
@objc func closeSection() {
contactsBackup = contacts
let section = 0
var indexPaths = [IndexPath]()
for row in contacts.indices {
let indexPath = IndexPath(row: row, section: section)
indexPaths.append(indexPath)
}
contacts.removeAll()
contactsTable.reloadData()
}
}
//
// File.swift
// ContactsApp
//
// Created by User on 3/16/20.
// Copyright © 2020 jheisecke. All rights reserved.
//
import Foundation
class Contacts {
}
......@@ -21,7 +21,7 @@ class SingleContactViewController: UIViewController {
if let contact = selectedContact{
title = "\(contact.givenName) \(contact.familyName)"
contactFullname.text = "\(contact.givenName) \(contact.familyName)"
phoneNumber.text = contact.phoneNumbers.description
//phoneNumber.text = CNLabeledValue.localizedStringForLabel(contact.phoneNumbers)
if contact.imageDataAvailable {
if let image = contact.imageData {
......
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