Commit 92cc2d0f by Javier Heisekce

Initial commit

parent c7f78d33
......@@ -9,21 +9,23 @@
/* Begin PBXBuildFile section */
CE3351EC241A65D400BA57CA /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE3351EB241A65D400BA57CA /* AppDelegate.swift */; };
CE3351EE241A65D400BA57CA /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE3351ED241A65D400BA57CA /* SceneDelegate.swift */; };
CE3351F0241A65D400BA57CA /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE3351EF241A65D400BA57CA /* ViewController.swift */; };
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 */; };
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 */
/* Begin PBXFileReference section */
CE3351E8241A65D400BA57CA /* ContactsApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ContactsApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
CE3351EB241A65D400BA57CA /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
CE3351ED241A65D400BA57CA /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
CE3351EF241A65D400BA57CA /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
CE3351F2241A65D400BA57CA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
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>"; };
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 */
/* Begin PBXFrameworksBuildPhase section */
......@@ -58,11 +60,12 @@
children = (
CE3351EB241A65D400BA57CA /* AppDelegate.swift */,
CE3351ED241A65D400BA57CA /* SceneDelegate.swift */,
CE3351EF241A65D400BA57CA /* ViewController.swift */,
CE3351F1241A65D400BA57CA /* Main.storyboard */,
CE3351F4241A65D500BA57CA /* Assets.xcassets */,
CE3351F6241A65D500BA57CA /* LaunchScreen.storyboard */,
CE3351F9241A65D500BA57CA /* Info.plist */,
CEC9A37E241BFBD000F024EE /* ContactsViewController.swift */,
CEC9A380241C096D00F024EE /* SingleContactViewController.swift */,
);
path = ContactsApp;
sourceTree = "<group>";
......@@ -138,9 +141,10 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
CE3351F0241A65D400BA57CA /* ViewController.swift in Sources */,
CE3351EC241A65D400BA57CA /* AppDelegate.swift in Sources */,
CEC9A37F241BFBD000F024EE /* ContactsViewController.swift in Sources */,
CE3351EE241A65D400BA57CA /* SceneDelegate.swift in Sources */,
CEC9A381241C096D00F024EE /* SingleContactViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
<?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>
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<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="PED-ba-Jdi">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<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"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<!--Contacts View Controller-->
<scene sceneID="0f3-9z-OKM">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<viewController id="l7R-c3-U8p" customClass="ContactsViewController" customModule="ContactsApp" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ulw-yq-gCd">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="dBj-cU-Ugw">
<rect key="frame" x="0.0" y="44" width="375" height="623"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="contactName" id="QkB-8k-kbX">
<rect key="frame" x="0.0" y="28" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="QkB-8k-kbX" id="AMU-de-w3M">
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="l7R-c3-U8p" id="EZI-Xr-mrx"/>
<outlet property="delegate" destination="l7R-c3-U8p" id="pgD-yj-lEC"/>
</connections>
</tableView>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints>
<constraint firstItem="ig1-pz-8Nn" firstAttribute="trailing" secondItem="dBj-cU-Ugw" secondAttribute="trailing" id="HCT-3z-lWu"/>
<constraint firstItem="dBj-cU-Ugw" firstAttribute="top" secondItem="ig1-pz-8Nn" secondAttribute="top" id="NqI-Ku-x9S"/>
<constraint firstItem="dBj-cU-Ugw" firstAttribute="leading" secondItem="ig1-pz-8Nn" secondAttribute="leading" id="ecL-bI-50d"/>
<constraint firstItem="ig1-pz-8Nn" firstAttribute="bottom" secondItem="dBj-cU-Ugw" secondAttribute="bottom" id="ydk-Ee-Ybk"/>
</constraints>
<viewLayoutGuide key="safeArea" id="ig1-pz-8Nn"/>
</view>
<navigationItem key="navigationItem" id="U0h-dc-vbE"/>
<connections>
<outlet property="contactsTable" destination="dBj-cU-Ugw" id="8YS-LO-fy0"/>
<segue destination="i2T-MY-6qf" kind="show" identifier="gotocontact" id="1Ts-QM-UT7"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="On8-yo-4E7" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1414.4927536231885" y="63.616071428571423"/>
</scene>
<!--Single Contact View Controller-->
<scene sceneID="wAp-rN-Dr5">
<objects>
<viewController id="i2T-MY-6qf" customClass="SingleContactViewController" customModule="ContactsApp" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="T9g-Qz-Xx3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="SSh-qK-Te0">
<rect key="frame" x="16" y="73" width="100" height="100"/>
<constraints>
<constraint firstAttribute="height" constant="100" id="GFa-s9-VDx"/>
<constraint firstAttribute="width" constant="100" id="zm3-wz-QlG"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="KATE FODSFUBSDIFUBSD" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1Kw-mC-GdR">
<rect key="frame" x="124" y="70" width="236.5" height="24"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleTitle3"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6Eu-n5-bWt">
<rect key="frame" x="124" y="113" width="48" height="24"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleTitle3"/>
<color key="textColor" systemColor="systemBlueColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints>
<constraint firstItem="6Eu-n5-bWt" firstAttribute="leading" secondItem="SSh-qK-Te0" secondAttribute="trailing" constant="8" id="KY6-oD-zqi"/>
<constraint firstItem="1Kw-mC-GdR" firstAttribute="leading" secondItem="SSh-qK-Te0" secondAttribute="trailing" constant="8" id="Ogd-VN-JDE"/>
<constraint firstItem="1Kw-mC-GdR" firstAttribute="top" secondItem="YV1-WY-lTn" secondAttribute="top" constant="26" id="YZK-KY-6DD"/>
<constraint firstItem="6Eu-n5-bWt" firstAttribute="top" secondItem="1Kw-mC-GdR" secondAttribute="bottom" constant="19" id="YuN-VJ-nj8"/>
<constraint firstItem="SSh-qK-Te0" firstAttribute="top" secondItem="1Kw-mC-GdR" secondAttribute="bottom" constant="-21" id="a1j-Kp-lBQ"/>
<constraint firstItem="SSh-qK-Te0" firstAttribute="leading" secondItem="T9g-Qz-Xx3" secondAttribute="leadingMargin" id="z7n-CK-Jte"/>
</constraints>
<viewLayoutGuide key="safeArea" id="YV1-WY-lTn"/>
</view>
<navigationItem key="navigationItem" id="y8U-qe-KjJ"/>
<connections>
<outlet property="contactFullname" destination="1Kw-mC-GdR" id="p01-Rh-EGg"/>
<outlet property="phoneNumber" destination="6Eu-n5-bWt" id="T4T-Ts-Lbq"/>
<outlet property="profilePic" destination="SSh-qK-Te0" id="raT-yr-aQm"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="VkC-Sb-eq8" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2400.8000000000002" y="62.518740629685162"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="aHL-eE-Wng">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="PED-ba-Jdi" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="hnS-P6-VYu">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="l7R-c3-U8p" kind="relationship" relationship="rootViewController" id="zXy-Oq-gZP"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="yeS-Ra-Ow0" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="505.79710144927537" y="63.616071428571423"/>
</scene>
</scenes>
</document>
//
// ContactsViewController.swift
// ContactsApp
//
// Created by User on 3/13/20.
// Copyright © 2020 jheisecke. All rights reserved.
//
import UIKit
import ContactsUI
class ContactsViewController: UIViewController {
@IBOutlet weak var contactsTable: UITableView!
var contacts = [CNContact]()
let contactStore = CNContactStore()
override func viewDidLoad() {
super.viewDidLoad()
importContacts()
contactsTable.tableFooterView = UIView(frame: .zero)
}
func importContacts() {
let keys = [CNContactFormatter.descriptorForRequiredKeys(for: .fullName)]
//obtengo
let request = CNContactFetchRequest(keysToFetch: keys)
request.sortOrder = CNContactSortOrder.givenName
do {
try self.contactStore.enumerateContacts(with: request) {
(contact, stop) in
// Array containing all unified contacts from everywhere
self.contacts.append(contact)
}
}
catch {
print("unable to fetch contacts")
}
print(contacts)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let singleContactVC = segue.destination as? SingleContactViewController {
if let selectedCnt = sender as? CNContact {
singleContactVC.selectedContact = selectedCnt
}
}
}
}
extension ContactsViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return contacts.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "contactName")!
cell.textLabel?.text = "\(contacts[indexPath.row].givenName) \(contacts[indexPath.row].familyName)"
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let selectedContact = contacts[indexPath.row]
performSegue(withIdentifier: "gotocontact", sender: selectedContact)
}
}
......@@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSContactsUsageDescription</key>
<string>Voy a spamear a tus contactos</string>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
......
//
// SingleContactViewController.swift
// ContactsApp
//
// Created by User on 3/13/20.
// Copyright © 2020 jheisecke. All rights reserved.
//
import UIKit
import ContactsUI
class SingleContactViewController: UIViewController {
@IBOutlet weak var contactFullname: UILabel!
var selectedContact : CNContact?
@IBOutlet weak var profilePic: UIImageView!
@IBOutlet weak var phoneNumber: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
if let contact = selectedContact{
title = "\(contact.givenName) \(contact.familyName)"
contactFullname.text = "\(contact.givenName) \(contact.familyName)"
phoneNumber.text = contact.phoneNumbers.description
if contact.imageDataAvailable {
if let image = contact.imageData {
if let imageData = UIImage(data: image){
profilePic.image = imageData
}
}
}
}
}
}
//
// ViewController.swift
// ContactsApp
//
// Created by User on 3/12/20.
// Copyright © 2020 jheisecke. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
}
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