iOS: add doric panel list
This commit is contained in:
parent
598634e0dc
commit
1f567cb928
@ -11,6 +11,7 @@
|
||||
1BCA4753C9D35032A0288028 /* libPods-ExampleUITests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FD2D6CCC8DCDABA7F86EAE7C /* libPods-ExampleUITests.a */; };
|
||||
52F56220E3A039DD5E3EA3B2 /* libPods-Example.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4650C6577493F533466F084B /* libPods-Example.a */; };
|
||||
8BCADA7C23CD5B65005EEF96 /* NavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BCADA7B23CD5B64005EEF96 /* NavigationController.m */; };
|
||||
8BE3A340287C098100D399FA /* DoricPanelListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BE3A33E287C098000D399FA /* DoricPanelListViewController.m */; };
|
||||
D751D4B065D8D4FA6594B5EE /* DemoVC.m in Sources */ = {isa = PBXBuildFile; fileRef = D751D19E97EF4EDD7588FEBE /* DemoVC.m */; };
|
||||
D751DDB012BAF476A252CD93 /* DemoLibrary.m in Sources */ = {isa = PBXBuildFile; fileRef = D751D2175D09F2C10691FB81 /* DemoLibrary.m */; };
|
||||
E2334AF022E9D2060098A085 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = E2334AEF22E9D2060098A085 /* AppDelegate.m */; };
|
||||
@ -51,6 +52,8 @@
|
||||
8A68295410FE7498FAFBB726 /* libPods-ExampleTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ExampleTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
8BCADA7A23CD5B5F005EEF96 /* NavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NavigationController.h; sourceTree = "<group>"; };
|
||||
8BCADA7B23CD5B64005EEF96 /* NavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NavigationController.m; sourceTree = "<group>"; };
|
||||
8BE3A33E287C098000D399FA /* DoricPanelListViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DoricPanelListViewController.m; sourceTree = "<group>"; };
|
||||
8BE3A33F287C098100D399FA /* DoricPanelListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DoricPanelListViewController.h; sourceTree = "<group>"; };
|
||||
B93423722F2E06DC238CDD18 /* Pods-ExampleUITests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ExampleUITests.release.xcconfig"; path = "Pods/Target Support Files/Pods-ExampleUITests/Pods-ExampleUITests.release.xcconfig"; sourceTree = "<group>"; };
|
||||
B93D4DB00FD244178B7CE7C4 /* Pods-ExampleTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ExampleTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-ExampleTests/Pods-ExampleTests.release.xcconfig"; sourceTree = "<group>"; };
|
||||
D751D19E97EF4EDD7588FEBE /* DemoVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DemoVC.m; sourceTree = "<group>"; };
|
||||
@ -170,6 +173,8 @@
|
||||
E2334AFC22E9D2070098A085 /* Info.plist */,
|
||||
E2334AF922E9D2070098A085 /* LaunchScreen.storyboard */,
|
||||
E2334AFD22E9D2070098A085 /* main.m */,
|
||||
8BE3A33F287C098100D399FA /* DoricPanelListViewController.h */,
|
||||
8BE3A33E287C098000D399FA /* DoricPanelListViewController.m */,
|
||||
D751D19E97EF4EDD7588FEBE /* DemoVC.m */,
|
||||
D751DDEC114E037231257E64 /* DemoVC.h */,
|
||||
D751D2175D09F2C10691FB81 /* DemoLibrary.m */,
|
||||
@ -439,6 +444,7 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
8BE3A340287C098100D399FA /* DoricPanelListViewController.m in Sources */,
|
||||
E2334AF322E9D2060098A085 /* ViewController.m in Sources */,
|
||||
E2334AFE22E9D2070098A085 /* main.m in Sources */,
|
||||
E2334AF022E9D2060098A085 /* AppDelegate.m in Sources */,
|
||||
|
11
doric-iOS/Example/Example/DoricPanelListViewController.h
Normal file
11
doric-iOS/Example/Example/DoricPanelListViewController.h
Normal file
@ -0,0 +1,11 @@
|
||||
//
|
||||
// Created by pengfei.zhou on 2019/11/19.
|
||||
// Copyright (c) 2019 pengfei.zhou. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
|
||||
@interface DoricPanelListViewController : UIViewController
|
||||
@end
|
102
doric-iOS/Example/Example/DoricPanelListViewController.m
Normal file
102
doric-iOS/Example/Example/DoricPanelListViewController.m
Normal file
@ -0,0 +1,102 @@
|
||||
//
|
||||
// Created by pengfei.zhou on 2019/11/19.
|
||||
// Copyright (c) 2019 pengfei.zhou. All rights reserved.
|
||||
//
|
||||
#import <DoricCore/Doric.h>
|
||||
|
||||
#import "DoricPanelListViewController.h"
|
||||
#import "DoricSingleton.h"
|
||||
|
||||
@interface DoricPanelListViewController () <UITableViewDelegate, UITableViewDataSource>
|
||||
@property(nonatomic, copy) NSArray <NSString *> *demoFilePaths;
|
||||
@property(nonatomic, strong) NSMutableDictionary *doricViewControllers;
|
||||
@end
|
||||
|
||||
@implementation DoricPanelListViewController
|
||||
|
||||
- (instancetype)init {
|
||||
if (self = [super init]) {
|
||||
_doricViewControllers = [NSMutableDictionary new];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated {
|
||||
[super viewDidAppear:animated];
|
||||
[self.view addSubview:[[UITableView new] also:^(UITableView *it) {
|
||||
it.width = self.view.width;
|
||||
it.height = self.view.height;
|
||||
it.left = it.top = 0;
|
||||
it.dataSource = self;
|
||||
it.delegate = self;
|
||||
}]];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
self.title = @"Doric Panel List";
|
||||
[self.navigationController.navigationBar setBackgroundImage:UIImageWithColor(UIColor.whiteColor) forBarMetrics:UIBarMetricsDefault];
|
||||
NSString *path = [[NSBundle mainBundle] bundlePath];
|
||||
NSString *demoPath = [path stringByAppendingPathComponent:@"src"];
|
||||
NSFileManager *mgr = [NSFileManager defaultManager];
|
||||
self.demoFilePaths = [[mgr subpathsAtPath:demoPath] filter:^BOOL(NSString *obj) {
|
||||
return ![obj containsString:@".map"] && ![obj containsString:@"es5."];
|
||||
}];
|
||||
NSMutableArray <NSString *> *tmp = [self.demoFilePaths mutableCopy];
|
||||
NSStringCompareOptions comparisonOptions = NSCaseInsensitiveSearch | NSNumericSearch | NSWidthInsensitiveSearch | NSForcedOrderingSearch;
|
||||
[tmp sortUsingComparator:^NSComparisonResult(NSString *obj1, NSString *obj2) {
|
||||
NSRange range = NSMakeRange(0, obj1.length);
|
||||
return [obj1 compare:obj2 options:comparisonOptions range:range];
|
||||
}];
|
||||
self.demoFilePaths = tmp;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
return self.demoFilePaths.count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
NSString *cellId = [@(indexPath.row) stringValue];
|
||||
|
||||
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
|
||||
if (cell == nil) {
|
||||
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
cell.textLabel.hidden = YES;
|
||||
|
||||
NSString *file = self.demoFilePaths[(NSUInteger) indexPath.row];
|
||||
DoricViewController *doricViewController = [[DoricViewController alloc]
|
||||
initWithSource:[NSString stringWithFormat:@"assets://src/%@", file]
|
||||
alias:@"__dev__"
|
||||
extra:nil
|
||||
];
|
||||
|
||||
[self addChildViewController:doricViewController];
|
||||
[cell.contentView addSubview:doricViewController.view];
|
||||
|
||||
doricViewController.view.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
NSLayoutConstraint *leading = [NSLayoutConstraint constraintWithItem:doricViewController.view attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:cell.contentView attribute:NSLayoutAttributeLeading multiplier:1.0 constant:0.0];
|
||||
NSLayoutConstraint *trailing = [NSLayoutConstraint constraintWithItem:doricViewController.view attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:cell.contentView attribute:NSLayoutAttributeTrailing multiplier:1.0 constant:0.0];
|
||||
NSLayoutConstraint *top = [NSLayoutConstraint constraintWithItem:doricViewController.view attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:cell.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0.0];
|
||||
NSLayoutConstraint *bottom = [NSLayoutConstraint constraintWithItem:doricViewController.view attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:cell.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0.0];
|
||||
|
||||
[cell.contentView addConstraint:leading];
|
||||
[cell.contentView addConstraint:trailing];
|
||||
[cell.contentView addConstraint:top];
|
||||
[cell.contentView addConstraint:bottom];
|
||||
|
||||
[doricViewController didMoveToParentViewController:self];
|
||||
[doricViewController.view layoutIfNeeded];
|
||||
} else {
|
||||
//TODO at here to handle data bind
|
||||
}
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
return 300;
|
||||
}
|
||||
|
||||
@end
|
@ -7,12 +7,11 @@
|
||||
//
|
||||
|
||||
#import <DoricCore/Doric.h>
|
||||
|
||||
#import <DoricDevkit/DoricDev.h>
|
||||
|
||||
#import "ViewController.h"
|
||||
|
||||
#import "DemoLibrary.h"
|
||||
#import "DoricPanelListViewController.h""
|
||||
|
||||
@interface ViewController () <UITableViewDelegate, UITableViewDataSource>
|
||||
@property(nonatomic, copy) NSArray <NSString *> *demoFilePaths;
|
||||
@ -38,6 +37,7 @@ - (void)viewDidLoad {
|
||||
return [obj1 compare:obj2 options:comparisonOptions range:range];
|
||||
}];
|
||||
[tmp insertObject:@"Dev Kit" atIndex:0];
|
||||
[tmp insertObject:@"Doric Panel List" atIndex:1];
|
||||
self.demoFilePaths = tmp;
|
||||
|
||||
[Doric registerLibrary:[DemoLibrary new]];
|
||||
@ -84,6 +84,19 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
|
||||
[[DoricDev instance] openDevMode:self];
|
||||
return;
|
||||
}
|
||||
if (indexPath.row == 1) {
|
||||
DoricPanelListViewController *panelListViewController = [DoricPanelListViewController new];
|
||||
|
||||
UIViewController *viewController = [UIApplication sharedApplication].delegate.window.rootViewController;
|
||||
UINavigationController *navigationController;
|
||||
if ([viewController isKindOfClass:[UINavigationController class]]) {
|
||||
navigationController = (UINavigationController *) viewController;
|
||||
} else {
|
||||
navigationController = viewController.navigationController;
|
||||
}
|
||||
[navigationController pushViewController:panelListViewController animated:NO];
|
||||
return;
|
||||
}
|
||||
NSString *file = self.demoFilePaths[(NSUInteger) indexPath.row];
|
||||
DoricViewController *doricViewController = [[DoricViewController alloc]
|
||||
initWithSource:[NSString stringWithFormat:@"assets://src/%@", file]
|
||||
|
Reference in New Issue
Block a user