Skip to content

Commit 09263ae

Browse files
authored
Merge pull request #2 from jgonfer/1.0.0
1.0.0 -> master
2 parents 1f02568 + 81a17e1 commit 09263ae

File tree

85 files changed

+825
-132
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+825
-132
lines changed

touch 3d/touch 3d.xcodeproj/project.pbxproj

+35-15
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@
88

99
/* Begin PBXBuildFile section */
1010
1D63DBA71E320AE8008143EF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D63DBA61E320AE8008143EF /* AppDelegate.swift */; };
11-
1D63DBA91E320AE8008143EF /* FirstViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D63DBA81E320AE8008143EF /* FirstViewController.swift */; };
12-
1D63DBAB1E320AE8008143EF /* SecondViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D63DBAA1E320AE8008143EF /* SecondViewController.swift */; };
11+
1D63DBA91E320AE8008143EF /* AnimalsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D63DBA81E320AE8008143EF /* AnimalsViewController.swift */; };
1312
1D63DBAE1E320AE8008143EF /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1D63DBAC1E320AE8008143EF /* Main.storyboard */; };
1413
1D63DBB01E320AE8008143EF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1D63DBAF1E320AE8008143EF /* Assets.xcassets */; };
1514
1D63DBB31E320AE8008143EF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1D63DBB11E320AE8008143EF /* LaunchScreen.storyboard */; };
1615
1D63DBBE1E320AE8008143EF /* touch_3dTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D63DBBD1E320AE8008143EF /* touch_3dTests.swift */; };
1716
1D63DBC91E320AE8008143EF /* touch_3dUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D63DBC81E320AE8008143EF /* touch_3dUITests.swift */; };
17+
1DB771FE1E32305F00AAF862 /* ItemViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1DB771FD1E32305F00AAF862 /* ItemViewController.swift */; };
18+
1DB772001E324FBD00AAF862 /* RelaxViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1DB771FF1E324FBD00AAF862 /* RelaxViewController.swift */; };
19+
1DB772021E32556400AAF862 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 1DB772011E32556400AAF862 /* InfoPlist.strings */; };
20+
1DFB04E81E321C7400810FF4 /* Item.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1DFB04E71E321C7400810FF4 /* Item.swift */; };
1821
/* End PBXBuildFile section */
1922

2023
/* Begin PBXContainerItemProxy section */
@@ -35,10 +38,9 @@
3538
/* End PBXContainerItemProxy section */
3639

3740
/* Begin PBXFileReference section */
38-
1D63DBA31E320AE8008143EF /* touch 3d.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "touch 3d.app"; sourceTree = BUILT_PRODUCTS_DIR; };
41+
1D63DBA31E320AE8008143EF /* 3D Touch.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "3D Touch.app"; sourceTree = BUILT_PRODUCTS_DIR; };
3942
1D63DBA61E320AE8008143EF /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
40-
1D63DBA81E320AE8008143EF /* FirstViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FirstViewController.swift; sourceTree = "<group>"; };
41-
1D63DBAA1E320AE8008143EF /* SecondViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecondViewController.swift; sourceTree = "<group>"; };
43+
1D63DBA81E320AE8008143EF /* AnimalsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnimalsViewController.swift; sourceTree = "<group>"; };
4244
1D63DBAD1E320AE8008143EF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
4345
1D63DBAF1E320AE8008143EF /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
4446
1D63DBB21E320AE8008143EF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
@@ -49,6 +51,10 @@
4951
1D63DBC41E320AE8008143EF /* touch 3dUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "touch 3dUITests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
5052
1D63DBC81E320AE8008143EF /* touch_3dUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = touch_3dUITests.swift; sourceTree = "<group>"; };
5153
1D63DBCA1E320AE8008143EF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
54+
1DB771FD1E32305F00AAF862 /* ItemViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ItemViewController.swift; sourceTree = "<group>"; };
55+
1DB771FF1E324FBD00AAF862 /* RelaxViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RelaxViewController.swift; sourceTree = "<group>"; };
56+
1DB772011E32556400AAF862 /* InfoPlist.strings */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; path = InfoPlist.strings; sourceTree = "<group>"; };
57+
1DFB04E71E321C7400810FF4 /* Item.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Item.swift; sourceTree = "<group>"; };
5258
/* End PBXFileReference section */
5359

5460
/* Begin PBXFrameworksBuildPhase section */
@@ -89,7 +95,7 @@
8995
1D63DBA41E320AE8008143EF /* Products */ = {
9096
isa = PBXGroup;
9197
children = (
92-
1D63DBA31E320AE8008143EF /* touch 3d.app */,
98+
1D63DBA31E320AE8008143EF /* 3D Touch.app */,
9399
1D63DBB91E320AE8008143EF /* touch 3dTests.xctest */,
94100
1D63DBC41E320AE8008143EF /* touch 3dUITests.xctest */,
95101
);
@@ -100,11 +106,14 @@
100106
isa = PBXGroup;
101107
children = (
102108
1D63DBA61E320AE8008143EF /* AppDelegate.swift */,
103-
1D63DBA81E320AE8008143EF /* FirstViewController.swift */,
104-
1D63DBAA1E320AE8008143EF /* SecondViewController.swift */,
109+
1D63DBA81E320AE8008143EF /* AnimalsViewController.swift */,
110+
1DB771FD1E32305F00AAF862 /* ItemViewController.swift */,
111+
1DFB04E71E321C7400810FF4 /* Item.swift */,
112+
1DB771FF1E324FBD00AAF862 /* RelaxViewController.swift */,
105113
1D63DBAC1E320AE8008143EF /* Main.storyboard */,
106114
1D63DBAF1E320AE8008143EF /* Assets.xcassets */,
107115
1D63DBB11E320AE8008143EF /* LaunchScreen.storyboard */,
116+
1DB772011E32556400AAF862 /* InfoPlist.strings */,
108117
1D63DBB41E320AE8008143EF /* Info.plist */,
109118
);
110119
path = "touch 3d";
@@ -145,7 +154,7 @@
145154
);
146155
name = "touch 3d";
147156
productName = "touch 3d";
148-
productReference = 1D63DBA31E320AE8008143EF /* touch 3d.app */;
157+
productReference = 1D63DBA31E320AE8008143EF /* 3D Touch.app */;
149158
productType = "com.apple.product-type.application";
150159
};
151160
1D63DBB81E320AE8008143EF /* touch 3dTests */ = {
@@ -196,6 +205,7 @@
196205
TargetAttributes = {
197206
1D63DBA21E320AE8008143EF = {
198207
CreatedOnToolsVersion = 8.2.1;
208+
DevelopmentTeam = C2NJ6URQ6C;
199209
ProvisioningStyle = Automatic;
200210
};
201211
1D63DBB81E320AE8008143EF = {
@@ -236,6 +246,7 @@
236246
buildActionMask = 2147483647;
237247
files = (
238248
1D63DBB31E320AE8008143EF /* LaunchScreen.storyboard in Resources */,
249+
1DB772021E32556400AAF862 /* InfoPlist.strings in Resources */,
239250
1D63DBB01E320AE8008143EF /* Assets.xcassets in Resources */,
240251
1D63DBAE1E320AE8008143EF /* Main.storyboard in Resources */,
241252
);
@@ -262,9 +273,11 @@
262273
isa = PBXSourcesBuildPhase;
263274
buildActionMask = 2147483647;
264275
files = (
265-
1D63DBAB1E320AE8008143EF /* SecondViewController.swift in Sources */,
276+
1DB772001E324FBD00AAF862 /* RelaxViewController.swift in Sources */,
277+
1DFB04E81E321C7400810FF4 /* Item.swift in Sources */,
278+
1DB771FE1E32305F00AAF862 /* ItemViewController.swift in Sources */,
266279
1D63DBA71E320AE8008143EF /* AppDelegate.swift in Sources */,
267-
1D63DBA91E320AE8008143EF /* FirstViewController.swift in Sources */,
280+
1D63DBA91E320AE8008143EF /* AnimalsViewController.swift in Sources */,
268281
);
269282
runOnlyForDeploymentPostprocessing = 0;
270283
};
@@ -416,10 +429,12 @@
416429
isa = XCBuildConfiguration;
417430
buildSettings = {
418431
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
432+
DEVELOPMENT_TEAM = C2NJ6URQ6C;
419433
INFOPLIST_FILE = "touch 3d/Info.plist";
434+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
420435
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
421-
PRODUCT_BUNDLE_IDENTIFIER = "com.jgonfer.touch-3d";
422-
PRODUCT_NAME = "$(TARGET_NAME)";
436+
PRODUCT_BUNDLE_IDENTIFIER = "com.netquest.touch-3d";
437+
PRODUCT_NAME = "3D Touch";
423438
SWIFT_VERSION = 3.0;
424439
};
425440
name = Debug;
@@ -428,10 +443,12 @@
428443
isa = XCBuildConfiguration;
429444
buildSettings = {
430445
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
446+
DEVELOPMENT_TEAM = C2NJ6URQ6C;
431447
INFOPLIST_FILE = "touch 3d/Info.plist";
448+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
432449
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
433-
PRODUCT_BUNDLE_IDENTIFIER = "com.jgonfer.touch-3d";
434-
PRODUCT_NAME = "$(TARGET_NAME)";
450+
PRODUCT_BUNDLE_IDENTIFIER = "com.netquest.touch-3d";
451+
PRODUCT_NAME = "3D Touch";
435452
SWIFT_VERSION = 3.0;
436453
};
437454
name = Release;
@@ -509,6 +526,7 @@
509526
1D63DBCF1E320AE8008143EF /* Release */,
510527
);
511528
defaultConfigurationIsVisible = 0;
529+
defaultConfigurationName = Release;
512530
};
513531
1D63DBD01E320AE8008143EF /* Build configuration list for PBXNativeTarget "touch 3dTests" */ = {
514532
isa = XCConfigurationList;
@@ -517,6 +535,7 @@
517535
1D63DBD21E320AE8008143EF /* Release */,
518536
);
519537
defaultConfigurationIsVisible = 0;
538+
defaultConfigurationName = Release;
520539
};
521540
1D63DBD31E320AE8008143EF /* Build configuration list for PBXNativeTarget "touch 3dUITests" */ = {
522541
isa = XCConfigurationList;
@@ -525,6 +544,7 @@
525544
1D63DBD51E320AE8008143EF /* Release */,
526545
);
527546
defaultConfigurationIsVisible = 0;
547+
defaultConfigurationName = Release;
528548
};
529549
/* End XCConfigurationList section */
530550
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
//
2+
// AnimalsViewController.swift
3+
// touch 3d
4+
//
5+
// Created by jgonzalez on 20/1/17.
6+
// Copyright © 2017 jgonfer. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
enum ItemType {
12+
case animal, mountain
13+
}
14+
15+
class AnimalsViewController: UIViewController {
16+
@IBOutlet weak var tableView: UITableView!
17+
18+
let type: ItemType = .animal
19+
let cellHeight: CGFloat = 75.0
20+
let footerHeight: CGFloat = 55.0
21+
let cellIdentifier = "cell"
22+
let segueIdentifier = "showAnimalDetail"
23+
var animals: [Item]?
24+
var selectedIndex: IndexPath?
25+
26+
override func viewDidLoad() {
27+
super.viewDidLoad()
28+
29+
setupView()
30+
}
31+
32+
override func didReceiveMemoryWarning() {
33+
super.didReceiveMemoryWarning()
34+
}
35+
36+
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
37+
if segue.identifier == segueIdentifier {
38+
guard let vc = segue.destination as? ItemViewController, let selectedIndex = self.selectedIndex, let animals = self.animals else {
39+
return
40+
}
41+
vc.item = animals[selectedIndex.row]
42+
}
43+
}
44+
45+
func openAnimalFor(shortcutIdentifier: ShortcutIdentifier) -> Bool {
46+
switch shortcutIdentifier {
47+
case .OpenFox:
48+
selectedIndex = IndexPath(row: 1, section: 0)
49+
performSegue(withIdentifier: segueIdentifier, sender: nil)
50+
case .OpenRandomAnimal:
51+
guard let animals = self.animals else {
52+
return false
53+
}
54+
let randomNumber = Int(arc4random_uniform(UInt32(animals.count)))
55+
selectedIndex = IndexPath(row: randomNumber, section: 0)
56+
performSegue(withIdentifier: segueIdentifier, sender: nil)
57+
default:
58+
return false
59+
}
60+
return true
61+
}
62+
63+
private func setupView() {
64+
title = "Animals"
65+
66+
animals = [Item]()
67+
animals?.append(Item(name: "Cat", image: "cat", url: nil, type: type))
68+
animals?.append(Item(name: "Fox", image: "fox", url: nil, type: type))
69+
animals?.append(Item(name: "Rabbit", image: "rabbit", url: nil, type: type))
70+
animals?.append(Item(name: "Bear", image: "bear", url: nil, type: type))
71+
}
72+
}
73+
74+
extension AnimalsViewController: UITableViewDelegate, UITableViewDataSource {
75+
func numberOfSections(in tableView: UITableView) -> Int {
76+
return 1
77+
}
78+
79+
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
80+
guard let _ = animals else {
81+
return 0
82+
}
83+
return animals!.count
84+
}
85+
86+
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
87+
return cellHeight
88+
}
89+
90+
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
91+
return footerHeight
92+
}
93+
94+
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
95+
let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier) ?? UITableViewCell(style: .default, reuseIdentifier: cellIdentifier)
96+
97+
let animal = animals![indexPath.row]
98+
cell.textLabel?.text = animal.name
99+
100+
if let image = animal.image {
101+
cell.imageView?.image = UIImage(named: image)
102+
} else if let image = animal.image {
103+
let url = URL(string: image)
104+
let data = try? Data(contentsOf: url!)
105+
cell.imageView?.image = UIImage(data: data!)
106+
}
107+
108+
return cell
109+
}
110+
111+
func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? {
112+
return "Designed by Freepik: http://www.freepik.com/"
113+
}
114+
115+
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
116+
tableView.deselectRow(at: indexPath, animated: true)
117+
selectedIndex = indexPath
118+
performSegue(withIdentifier: segueIdentifier, sender: nil)
119+
}
120+
}
121+

touch 3d/touch 3d/AppDelegate.swift

+53-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@
88

99
import UIKit
1010

11+
enum ShortcutIdentifier: String {
12+
case OpenAnimals
13+
case OpenFox
14+
case OpenRandomAnimal
15+
case OpenRelax
16+
17+
init?(identifier: String) {
18+
guard let shortIdentifier = identifier.components(separatedBy: ".").last else {
19+
return nil
20+
}
21+
self.init(rawValue: shortIdentifier)
22+
}
23+
}
24+
1125
@UIApplicationMain
1226
class AppDelegate: UIResponder, UIApplicationDelegate {
1327

@@ -41,6 +55,44 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
4155
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
4256
}
4357

44-
58+
59+
// MARK: Shortcut Handler Methods
60+
61+
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
62+
completionHandler(shouldPerformActionFor(shortcutItem: shortcutItem))
63+
}
64+
65+
private func shouldPerformActionFor(shortcutItem: UIApplicationShortcutItem) -> Bool {
66+
let shortcutType = shortcutItem.type
67+
guard let shortcutIdentifier = ShortcutIdentifier(identifier: shortcutType) else {
68+
return false
69+
}
70+
return selectTabBarItemFor(shortcutIdentifier: shortcutIdentifier)
71+
}
72+
73+
private func selectTabBarItemFor(shortcutIdentifier: ShortcutIdentifier) -> Bool {
74+
guard let myTabBar = self.window?.rootViewController as? UITabBarController else {
75+
return false
76+
}
77+
78+
switch shortcutIdentifier {
79+
case .OpenAnimals:
80+
myTabBar.selectedIndex = 0
81+
return true
82+
case .OpenRelax:
83+
myTabBar.selectedIndex = 1
84+
return true
85+
case .OpenFox, .OpenRandomAnimal:
86+
myTabBar.selectedIndex = 0
87+
guard let nvc = myTabBar.selectedViewController as? UINavigationController else {
88+
return false
89+
}
90+
guard let vc = nvc.viewControllers.first as? AnimalsViewController else {
91+
return false
92+
}
93+
nvc.popToRootViewController(animated: false)
94+
return vc.openAnimalFor(shortcutIdentifier: shortcutIdentifier)
95+
}
96+
}
4597
}
4698

0 commit comments

Comments
 (0)