Skip to content

Commit 348d80f

Browse files
committed
Demo table view
1 parent b87e667 commit 348d80f

File tree

7 files changed

+106
-53
lines changed

7 files changed

+106
-53
lines changed

ReusableDataSource.xcodeproj/project.pbxproj

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
F68F11B1209CFF7300BADC8D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F68F11AF209CFF7300BADC8D /* Main.storyboard */; };
2424
F68F11B3209CFF7400BADC8D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F68F11B2209CFF7400BADC8D /* Assets.xcassets */; };
2525
F68F11B6209CFF7400BADC8D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F68F11B4209CFF7400BADC8D /* LaunchScreen.storyboard */; };
26+
F68F11CC209CFFC900BADC8D /* ImageTextTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F68F11CA209CFFC900BADC8D /* ImageTextTableViewCell.swift */; };
27+
F68F11CD209CFFC900BADC8D /* TextTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F68F11CB209CFFC900BADC8D /* TextTableViewCell.swift */; };
28+
F68F11CE209D052B00BADC8D /* ReusableDataSource.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F68F1173209CE0F600BADC8D /* ReusableDataSource.framework */; };
29+
F68F11CF209D052B00BADC8D /* ReusableDataSource.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = F68F1173209CE0F600BADC8D /* ReusableDataSource.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
2630
/* End PBXBuildFile section */
2731

2832
/* Begin PBXContainerItemProxy section */
@@ -40,8 +44,29 @@
4044
remoteGlobalIDString = F68F11A8209CFF7300BADC8D;
4145
remoteInfo = ReusableDataSourceDemo;
4246
};
47+
F68F11D0209D052B00BADC8D /* PBXContainerItemProxy */ = {
48+
isa = PBXContainerItemProxy;
49+
containerPortal = F68F116A209CE0F600BADC8D /* Project object */;
50+
proxyType = 1;
51+
remoteGlobalIDString = F68F1172209CE0F600BADC8D;
52+
remoteInfo = ReusableDataSource;
53+
};
4354
/* End PBXContainerItemProxy section */
4455

56+
/* Begin PBXCopyFilesBuildPhase section */
57+
F68F11D2209D052B00BADC8D /* Embed Frameworks */ = {
58+
isa = PBXCopyFilesBuildPhase;
59+
buildActionMask = 2147483647;
60+
dstPath = "";
61+
dstSubfolderSpec = 10;
62+
files = (
63+
F68F11CF209D052B00BADC8D /* ReusableDataSource.framework in Embed Frameworks */,
64+
);
65+
name = "Embed Frameworks";
66+
runOnlyForDeploymentPostprocessing = 0;
67+
};
68+
/* End PBXCopyFilesBuildPhase section */
69+
4570
/* Begin PBXFileReference section */
4671
F68F1173209CE0F600BADC8D /* ReusableDataSource.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ReusableDataSource.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4772
F68F1176209CE0F600BADC8D /* ReusableDataSource.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ReusableDataSource.h; sourceTree = "<group>"; };
@@ -66,6 +91,8 @@
6691
F68F11B7209CFF7400BADC8D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
6792
F68F11BC209CFF7400BADC8D /* ReusableDataSourceDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ReusableDataSourceDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
6893
F68F11C2209CFF7500BADC8D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
94+
F68F11CA209CFFC900BADC8D /* ImageTextTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageTextTableViewCell.swift; sourceTree = "<group>"; };
95+
F68F11CB209CFFC900BADC8D /* TextTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextTableViewCell.swift; sourceTree = "<group>"; };
6996
/* End PBXFileReference section */
7097

7198
/* Begin PBXFrameworksBuildPhase section */
@@ -88,6 +115,7 @@
88115
isa = PBXFrameworksBuildPhase;
89116
buildActionMask = 2147483647;
90117
files = (
118+
F68F11CE209D052B00BADC8D /* ReusableDataSource.framework in Frameworks */,
91119
);
92120
runOnlyForDeploymentPostprocessing = 0;
93121
};
@@ -192,6 +220,7 @@
192220
F68F11AA209CFF7300BADC8D /* ReusableDataSourceDemo */ = {
193221
isa = PBXGroup;
194222
children = (
223+
F68F11C9209CFFC900BADC8D /* Cells */,
195224
F68F11AB209CFF7300BADC8D /* AppDelegate.swift */,
196225
F68F11AD209CFF7300BADC8D /* ViewController.swift */,
197226
F68F11AF209CFF7300BADC8D /* Main.storyboard */,
@@ -210,6 +239,15 @@
210239
path = ReusableDataSourceDemoTests;
211240
sourceTree = "<group>";
212241
};
242+
F68F11C9209CFFC900BADC8D /* Cells */ = {
243+
isa = PBXGroup;
244+
children = (
245+
F68F11CA209CFFC900BADC8D /* ImageTextTableViewCell.swift */,
246+
F68F11CB209CFFC900BADC8D /* TextTableViewCell.swift */,
247+
);
248+
path = Cells;
249+
sourceTree = "<group>";
250+
};
213251
/* End PBXGroup section */
214252

215253
/* Begin PBXHeadersBuildPhase section */
@@ -268,10 +306,12 @@
268306
F68F11A5209CFF7300BADC8D /* Sources */,
269307
F68F11A6209CFF7300BADC8D /* Frameworks */,
270308
F68F11A7209CFF7300BADC8D /* Resources */,
309+
F68F11D2209D052B00BADC8D /* Embed Frameworks */,
271310
);
272311
buildRules = (
273312
);
274313
dependencies = (
314+
F68F11D1209D052B00BADC8D /* PBXTargetDependency */,
275315
);
276316
name = ReusableDataSourceDemo;
277317
productName = ReusableDataSourceDemo;
@@ -421,7 +461,9 @@
421461
isa = PBXSourcesBuildPhase;
422462
buildActionMask = 2147483647;
423463
files = (
464+
F68F11CD209CFFC900BADC8D /* TextTableViewCell.swift in Sources */,
424465
F68F11AE209CFF7300BADC8D /* ViewController.swift in Sources */,
466+
F68F11CC209CFFC900BADC8D /* ImageTextTableViewCell.swift in Sources */,
425467
F68F11AC209CFF7300BADC8D /* AppDelegate.swift in Sources */,
426468
);
427469
runOnlyForDeploymentPostprocessing = 0;
@@ -446,6 +488,11 @@
446488
target = F68F11A8209CFF7300BADC8D /* ReusableDataSourceDemo */;
447489
targetProxy = F68F11BD209CFF7500BADC8D /* PBXContainerItemProxy */;
448490
};
491+
F68F11D1209D052B00BADC8D /* PBXTargetDependency */ = {
492+
isa = PBXTargetDependency;
493+
target = F68F1172209CE0F600BADC8D /* ReusableDataSource */;
494+
targetProxy = F68F11D0209D052B00BADC8D /* PBXContainerItemProxy */;
495+
};
449496
/* End PBXTargetDependency section */
450497

451498
/* Begin PBXVariantGroup section */
@@ -681,6 +728,7 @@
681728
F68F11C4209CFF7500BADC8D /* Debug */ = {
682729
isa = XCBuildConfiguration;
683730
buildSettings = {
731+
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
684732
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
685733
CODE_SIGN_STYLE = Automatic;
686734
DEVELOPMENT_TEAM = MDX989Y6D8;
@@ -699,6 +747,7 @@
699747
F68F11C5209CFF7500BADC8D /* Release */ = {
700748
isa = XCBuildConfiguration;
701749
buildSettings = {
750+
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
702751
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
703752
CODE_SIGN_STYLE = Automatic;
704753
DEVELOPMENT_TEAM = MDX989Y6D8;
Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,17 @@
1-
//
2-
// AppDelegate.swift
3-
// ReusableDataSourceDemo
4-
//
5-
// Created by Ivan Rep on 04/05/2018.
6-
// Copyright © 2018 Rep. All rights reserved.
7-
//
8-
91
import UIKit
102

113
@UIApplicationMain
124
class AppDelegate: UIResponder, UIApplicationDelegate {
135

14-
var window: UIWindow?
15-
16-
17-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
18-
// Override point for customization after application launch.
19-
return true
20-
}
6+
var window: UIWindow? = UIWindow()
217

22-
func applicationWillResignActive(_ application: UIApplication) {
23-
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
24-
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
25-
}
8+
func application(
9+
_ application: UIApplication,
10+
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
2611

27-
func applicationDidEnterBackground(_ application: UIApplication) {
28-
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
29-
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
30-
}
12+
window?.rootViewController = ViewController(style: .grouped)
13+
window?.makeKeyAndVisible()
3114

32-
func applicationWillEnterForeground(_ application: UIApplication) {
33-
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
34-
}
35-
36-
func applicationDidBecomeActive(_ application: UIApplication) {
37-
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
38-
}
39-
40-
func applicationWillTerminate(_ application: UIApplication) {
41-
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
15+
return true
4216
}
43-
44-
4517
}
46-
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"filename" : "if_filter_383135.pdf"
6+
}
7+
],
8+
"info" : {
9+
"version" : 1,
10+
"author" : "xcode"
11+
}
12+
}
Binary file not shown.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import ReusableDataSource
2+
import UIKit
3+
4+
struct ImageTextTableViewCellViewModel {
5+
let textViewModel: String
6+
let imageViewModel: UIImage
7+
}
8+
9+
class ImageTextTableViewCell: UITableViewCell, ReusableViewModelPresenter {
10+
func present(viewModel: ImageTextTableViewCellViewModel) {
11+
textLabel?.text = viewModel.textViewModel
12+
imageView?.image = viewModel.imageViewModel
13+
}
14+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import ReusableDataSource
2+
import UIKit
3+
4+
struct TextTableViewCellViewModel {
5+
let textViewModel: String
6+
}
7+
8+
class TextTableViewCell: UITableViewCell, ReusableViewModelPresenter {
9+
public func present(viewModel: TextTableViewCellViewModel) {
10+
textLabel?.text = viewModel.textViewModel
11+
}
12+
}
Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
1-
//
2-
// ViewController.swift
3-
// ReusableDataSourceDemo
4-
//
5-
// Created by Ivan Rep on 04/05/2018.
6-
// Copyright © 2018 Rep. All rights reserved.
7-
//
8-
1+
import ReusableDataSource
92
import UIKit
103

11-
class ViewController: UIViewController {
4+
class ViewController: UITableViewController {
5+
let dataSource = ReusableTableViewDataSource()
6+
7+
lazy var reusableViewModels = [
8+
ReusableViewModel<TextTableViewCell>(viewModel: TextTableViewCellViewModel(textViewModel: "Cell 1")).anyPresentable,
9+
ReusableViewModel<TextTableViewCell>(viewModel: TextTableViewCellViewModel(textViewModel: "Cell 2")).anyPresentable,
10+
ReusableViewModel<ImageTextTableViewCell>(viewModel: ImageTextTableViewCellViewModel(textViewModel: "Cell 3", imageViewModel: #imageLiteral(resourceName: "filter"))).anyPresentable,
11+
ReusableViewModel<TextTableViewCell>(viewModel: TextTableViewCellViewModel(textViewModel: "Cell 2")).anyPresentable
12+
]
1213

1314
override func viewDidLoad() {
1415
super.viewDidLoad()
15-
// Do any additional setup after loading the view, typically from a nib.
16-
}
1716

18-
override func didReceiveMemoryWarning() {
19-
super.didReceiveMemoryWarning()
20-
// Dispose of any resources that can be recreated.
17+
tableView.dataSource = dataSource
18+
dataSource.present(presentableViewModels: reusableViewModels, on: tableView)
2119
}
22-
23-
2420
}
25-

0 commit comments

Comments
 (0)