Skip to content

Commit b4eb75c

Browse files
authored
Fix sample app
1 parent 9021d54 commit b4eb75c

12 files changed

Lines changed: 461 additions & 134 deletions

File tree

Example/Cloudinary.xcodeproj/project.pbxproj

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@
133133
B64ED21D2B8C933B00BE653E /* ConditionalProduct.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B64ED1BC2B8C933A00BE653E /* ConditionalProduct.storyboard */; };
134134
B64ED21E2B8C933B00BE653E /* Base.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B64ED1BE2B8C933A00BE653E /* Base.storyboard */; };
135135
B64ED21F2B8C933B00BE653E /* ImageWidget.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B64ED1C02B8C933A00BE653E /* ImageWidget.storyboard */; };
136-
B64ED2202B8C933B00BE653E /* UploadWidget.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B64ED1C12B8C933A00BE653E /* UploadWidget.storyboard */; };
137136
B64ED2212B8C933B00BE653E /* Widgets.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B64ED1C22B8C933A00BE653E /* Widgets.storyboard */; };
138137
B64ED2222B8C933B00BE653E /* InnerUploadFrame.xib in Resources */ = {isa = PBXBuildFile; fileRef = B64ED1C42B8C933A00BE653E /* InnerUploadFrame.xib */; };
139138
B64ED2232B8C933B00BE653E /* Upload.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B64ED1C52B8C933A00BE653E /* Upload.storyboard */; };
@@ -157,6 +156,7 @@
157156
B64ED2352B8C933B00BE653E /* FirebaseEventsHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = B64ED1DF2B8C933B00BE653E /* FirebaseEventsHandler.swift */; };
158157
B64ED2362B8C933B00BE653E /* EventObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = B64ED1E02B8C933B00BE653E /* EventObject.swift */; };
159158
B64ED2372B8C933B00BE653E /* EventsProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = B64ED1E12B8C933B00BE653E /* EventsProvider.swift */; };
159+
B64F0DDD2BC6541000B94590 /* UploadWidget.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B64F0DDC2BC6541000B94590 /* UploadWidget.storyboard */; };
160160
B67476152B8CA0D2006ED6C2 /* IntegrateAIViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B67476142B8CA0D2006ED6C2 /* IntegrateAIViewController.swift */; };
161161
B67476172B8CA0EF006ED6C2 /* IntegrateAI.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B67476162B8CA0EF006ED6C2 /* IntegrateAI.storyboard */; };
162162
B694AAF32B308C3C00075041 /* VideoEventsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B694AAF22B308C3C00075041 /* VideoEventsTests.swift */; };
@@ -362,7 +362,6 @@
362362
B64ED19F2B8C933A00BE653E /* WidgetsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WidgetsViewController.swift; sourceTree = "<group>"; };
363363
B64ED1A02B8C933A00BE653E /* ImageWidgetViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageWidgetViewController.swift; sourceTree = "<group>"; };
364364
B64ED1A12B8C933A00BE653E /* UploadWidgetViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UploadWidgetViewController.swift; sourceTree = "<group>"; };
365-
B64ED1A22B8C933A00BE653E /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = ../../../Sample/Cloudinary_Sample_App/Cloudinary_Sample_App/Info.plist; sourceTree = "<group>"; };
366365
B64ED1A52B8C933A00BE653E /* Toolbar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Toolbar.swift; sourceTree = "<group>"; };
367366
B64ED1A62B8C933A00BE653E /* Toolbar.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = Toolbar.xib; sourceTree = "<group>"; };
368367
B64ED1A82B8C933A00BE653E /* ToolbarItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ToolbarItem.swift; sourceTree = "<group>"; };
@@ -381,7 +380,6 @@
381380
B64ED1BC2B8C933A00BE653E /* ConditionalProduct.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = ConditionalProduct.storyboard; sourceTree = "<group>"; };
382381
B64ED1BE2B8C933A00BE653E /* Base.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Base.storyboard; sourceTree = "<group>"; };
383382
B64ED1C02B8C933A00BE653E /* ImageWidget.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = ImageWidget.storyboard; sourceTree = "<group>"; };
384-
B64ED1C12B8C933A00BE653E /* UploadWidget.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = UploadWidget.storyboard; sourceTree = "<group>"; };
385383
B64ED1C22B8C933A00BE653E /* Widgets.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Widgets.storyboard; sourceTree = "<group>"; };
386384
B64ED1C42B8C933A00BE653E /* InnerUploadFrame.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = InnerUploadFrame.xib; sourceTree = "<group>"; };
387385
B64ED1C52B8C933A00BE653E /* Upload.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Upload.storyboard; sourceTree = "<group>"; };
@@ -405,6 +403,8 @@
405403
B64ED1DF2B8C933B00BE653E /* FirebaseEventsHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FirebaseEventsHandler.swift; sourceTree = "<group>"; };
406404
B64ED1E02B8C933B00BE653E /* EventObject.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EventObject.swift; sourceTree = "<group>"; };
407405
B64ED1E12B8C933B00BE653E /* EventsProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EventsProvider.swift; sourceTree = "<group>"; };
406+
B64F0DDA2BC6506700B94590 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
407+
B64F0DDC2BC6541000B94590 /* UploadWidget.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = UploadWidget.storyboard; sourceTree = "<group>"; };
408408
B67476142B8CA0D2006ED6C2 /* IntegrateAIViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IntegrateAIViewController.swift; sourceTree = "<group>"; };
409409
B67476162B8CA0EF006ED6C2 /* IntegrateAI.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = IntegrateAI.storyboard; sourceTree = "<group>"; };
410410
B694AAF22B308C3C00075041 /* VideoEventsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoEventsTests.swift; sourceTree = "<group>"; };
@@ -841,8 +841,7 @@
841841
B64ED1D72B8C933B00BE653E /* Extensions */,
842842
B64ED1642B8C933900BE653E /* GoogleService-Info.plist */,
843843
B64ED1DA2B8C933B00BE653E /* Helpers */,
844-
B64ED1A22B8C933A00BE653E /* Info.plist */,
845-
B64ED1652B8C933900BE653E /* Resources */,
844+
B64F0DDA2BC6506700B94590 /* Info.plist */,
846845
B64ED1D92B8C933B00BE653E /* SceneDelegate.swift */,
847846
B64ED1D42B8C933A00BE653E /* Utils */,
848847
B64ED1AF2B8C933A00BE653E /* Views */,
@@ -891,13 +890,6 @@
891890
name = "Podspec Metadata";
892891
sourceTree = "<group>";
893892
};
894-
B64ED1652B8C933900BE653E /* Resources */ = {
895-
isa = PBXGroup;
896-
children = (
897-
);
898-
path = Resources;
899-
sourceTree = "<group>";
900-
};
901893
B64ED1692B8C933A00BE653E /* Controllers */ = {
902894
isa = PBXGroup;
903895
children = (
@@ -1203,8 +1195,8 @@
12031195
isa = PBXGroup;
12041196
children = (
12051197
B64ED1C02B8C933A00BE653E /* ImageWidget.storyboard */,
1206-
B64ED1C12B8C933A00BE653E /* UploadWidget.storyboard */,
12071198
B64ED1C22B8C933A00BE653E /* Widgets.storyboard */,
1199+
B64F0DDC2BC6541000B94590 /* UploadWidget.storyboard */,
12081200
);
12091201
path = Widgets;
12101202
sourceTree = "<group>";
@@ -1641,7 +1633,6 @@
16411633
B67476172B8CA0EF006ED6C2 /* IntegrateAI.storyboard in Resources */,
16421634
D73DBB0B258BA0570002E7E5 /* dog.mov in Resources */,
16431635
B64ED2222B8C933B00BE653E /* InnerUploadFrame.xib in Resources */,
1644-
B64ED2202B8C933B00BE653E /* UploadWidget.storyboard in Resources */,
16451636
D73DBB0A258BA0550002E7E5 /* dog2.mp4 in Resources */,
16461637
B64ED21D2B8C933B00BE653E /* ConditionalProduct.storyboard in Resources */,
16471638
B64ED2002B8C933B00BE653E /* video_links.plist in Resources */,
@@ -1663,6 +1654,7 @@
16631654
B64ED2172B8C933B00BE653E /* VideoSocialOverlays.storyboard in Resources */,
16641655
B64ED2212B8C933B00BE653E /* Widgets.storyboard in Resources */,
16651656
B64ED2162B8C933B00BE653E /* VideoFeed.storyboard in Resources */,
1657+
B64F0DDD2BC6541000B94590 /* UploadWidget.storyboard in Resources */,
16661658
B64ED2242B8C933B00BE653E /* UploadNoCloud.storyboard in Resources */,
16671659
B64ED2182B8C933B00BE653E /* Video.storyboard in Resources */,
16681660
B64ED2232B8C933B00BE653E /* Upload.storyboard in Resources */,

Example/Cloudinary/Controllers/Base/BaseViewController.swift

Lines changed: 60 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ class BaseViewController: UIViewController {
1515
var type: BaseControllerType!
1616
var innerIndex: Int = 0
1717

18+
var currentController: UIViewController!
19+
1820
override func viewWillAppear(_ animated: Bool) {
1921
super.viewWillAppear(animated)
2022
setTitle()
@@ -59,63 +61,63 @@ class BaseViewController: UIViewController {
5961
}
6062

6163
private func setController() {
62-
switch type {
63-
case .Optimization:
64-
let currentController = UIStoryboard(name: "Optimization", bundle: nil).instantiateViewController(identifier: "OptimizationViewController") as! OptimizationViewController
65-
currentController.view.frame = vwContainer.bounds
66-
currentController.type = .Optimization
67-
addChild(currentController)
68-
vwContainer.addSubview(currentController.view)
69-
currentController.didMove(toParent: self)
70-
case .Transform:
71-
let currentController = UIStoryboard(name: "Transform", bundle: nil).instantiateViewController(identifier: "TransformViewController") as! TransformViewController
72-
currentController.innerIndex = innerIndex
73-
currentController.view.frame = vwContainer.bounds
74-
addChild(currentController)
75-
vwContainer.addSubview(currentController.view)
76-
currentController.didMove(toParent: self)
77-
case .UseCases:
78-
let currentController = UIStoryboard(name: "UseCases", bundle: nil).instantiateViewController(identifier: "UseCasesViewController") as! UseCasesViewController
79-
currentController.view.frame = vwContainer.bounds
80-
currentController.innerIndex = innerIndex
81-
addChild(currentController)
82-
vwContainer.addSubview(currentController.view)
83-
currentController.didMove(toParent: self)
84-
case .Upload:
85-
let currentController = (UIStoryboard(name: "UploadChoice", bundle: nil).instantiateViewController(identifier: "UploadChoiceController") as! UploadChoiceController)
86-
currentController.view.frame = vwContainer.bounds
87-
currentController.type = .Upload
88-
addChild(currentController)
89-
vwContainer.addSubview(currentController.view)
90-
currentController.didMove(toParent: self)
91-
case .UploadLarge:
92-
let currentController = (UIStoryboard(name: "UploadChoice", bundle: nil).instantiateViewController(identifier: "UploadChoiceController") as! UploadChoiceController)
93-
currentController.view.frame = vwContainer.bounds
94-
currentController.type = .UploadLarge
95-
addChild(currentController)
96-
vwContainer.addSubview(currentController.view)
97-
currentController.didMove(toParent: self)
98-
case .FetchUpload:
99-
let currentController = UIStoryboard(name: "Optimization", bundle: nil).instantiateViewController(identifier: "OptimizationViewController") as! OptimizationViewController
100-
currentController.view.frame = vwContainer.bounds
101-
currentController.publicId = "https://upload.wikimedia.org/wikipedia/commons/thumb/0/08/Leonardo_da_Vinci_%281452-1519%29_-_The_Last_Supper_%281495-1498%29.jpg/1600px-Leonardo_da_Vinci_%281452-1519%29_-_The_Last_Supper_%281495-1498%29.jpg?20150402075721"
102-
currentController.type = .FetchUpload
103-
addChild(currentController)
104-
vwContainer.addSubview(currentController.view)
105-
currentController.didMove(toParent: self)
106-
case .UploadWidget:
107-
let currentController = UIStoryboard(name: "UploadWidget", bundle: nil).instantiateViewController(identifier: "UploadWidgetViewController")
108-
currentController.view.frame = vwContainer.bounds
109-
addChild(currentController)
110-
vwContainer.addSubview(currentController.view)
111-
currentController.didMove(toParent: self)
112-
case .ImageWidget:
113-
let currentController = UIStoryboard(name: "ImageWidget", bundle: nil).instantiateViewController(identifier: "ImageWidgetViewController")
114-
currentController.view.frame = vwContainer.bounds
115-
addChild(currentController)
116-
vwContainer.addSubview(currentController.view)
117-
currentController.didMove(toParent: self)
118-
break
64+
switch type {
65+
case .Optimization:
66+
currentController = UIStoryboard(name: "Optimization", bundle: nil).instantiateViewController(identifier: "OptimizationViewController") as! OptimizationViewController
67+
currentController.view.frame = vwContainer.bounds
68+
(currentController as! OptimizationViewController).type = .Optimization
69+
addChild(currentController)
70+
vwContainer.addSubview(currentController.view)
71+
currentController.didMove(toParent: self)
72+
case .Transform:
73+
currentController = UIStoryboard(name: "Transform", bundle: nil).instantiateViewController(identifier: "TransformViewController") as! TransformViewController
74+
(currentController as! TransformViewController).innerIndex = innerIndex
75+
currentController.view.frame = vwContainer.bounds
76+
addChild(currentController)
77+
vwContainer.addSubview(currentController.view)
78+
currentController.didMove(toParent: self)
79+
case .UseCases:
80+
currentController = UIStoryboard(name: "UseCases", bundle: nil).instantiateViewController(identifier: "UseCasesViewController") as! UseCasesViewController
81+
currentController.view.frame = vwContainer.bounds
82+
(currentController as! UseCasesViewController).innerIndex = innerIndex
83+
addChild(currentController)
84+
vwContainer.addSubview(currentController.view)
85+
currentController.didMove(toParent: self)
86+
case .Upload:
87+
currentController = (UIStoryboard(name: "UploadChoice", bundle: nil).instantiateViewController(identifier: "UploadChoiceController") as! UploadChoiceController)
88+
currentController.view.frame = vwContainer.bounds
89+
(currentController as! UploadChoiceController).type = .Upload
90+
addChild(currentController)
91+
vwContainer.addSubview(currentController.view)
92+
currentController.didMove(toParent: self)
93+
case .UploadLarge:
94+
currentController = (UIStoryboard(name: "UploadChoice", bundle: nil).instantiateViewController(identifier: "UploadChoiceController") as! UploadChoiceController)
95+
currentController.view.frame = vwContainer.bounds
96+
(currentController as! UploadChoiceController).type = .UploadLarge
97+
addChild(currentController)
98+
vwContainer.addSubview(currentController.view)
99+
currentController.didMove(toParent: self)
100+
case .FetchUpload:
101+
currentController = UIStoryboard(name: "Optimization", bundle: nil).instantiateViewController(identifier: "OptimizationViewController") as! OptimizationViewController
102+
currentController.view.frame = vwContainer.bounds
103+
(currentController as! OptimizationViewController).publicId = "https://upload.wikimedia.org/wikipedia/commons/thumb/0/08/Leonardo_da_Vinci_%281452-1519%29_-_The_Last_Supper_%281495-1498%29.jpg/1600px-Leonardo_da_Vinci_%281452-1519%29_-_The_Last_Supper_%281495-1498%29.jpg?20150402075721"
104+
(currentController as! OptimizationViewController).type = .FetchUpload
105+
addChild(currentController)
106+
vwContainer.addSubview(currentController.view)
107+
currentController.didMove(toParent: self)
108+
case .UploadWidget:
109+
if (currentController == nil || (currentController as? UploadWidgetViewController == nil)) {
110+
currentController = UIStoryboard(name: "UploadWidget", bundle: nil).instantiateViewController(identifier: "UploadWidgetViewController")
111+
currentController.view.frame = vwContainer.bounds
112+
addChild(currentController)
113+
vwContainer.addSubview(currentController.view)
114+
currentController.didMove(toParent: self)
115+
}
116+
case .ImageWidget:
117+
currentController = UIStoryboard(name: "ImageWidget", bundle: nil).instantiateViewController(identifier: "ImageWidgetViewController")
118+
currentController.view.frame = vwContainer.bounds
119+
addChild(currentController)
120+
vwContainer.addSubview(currentController.view)
119121
case .none:
120122
break
121123
}
@@ -139,6 +141,7 @@ enum BaseControllerType {
139141
public enum UploadViewType {
140142
case Upload
141143
case UploadLarge
144+
case UploadWidget
142145
}
143146

144147
public enum OptimizationViewType {

0 commit comments

Comments
 (0)