feat:Manage Demo Project
This commit is contained in:
@@ -7,9 +7,11 @@
|
||||
//
|
||||
|
||||
#import "AppDelegate.h"
|
||||
#import "ViewController.h"
|
||||
|
||||
@interface AppDelegate ()
|
||||
|
||||
@property(nonatomic, strong) UIViewController *rootVC;
|
||||
@property(nonatomic, strong) UINavigationController *navigationController;
|
||||
@end
|
||||
|
||||
@implementation AppDelegate
|
||||
@@ -17,6 +19,14 @@ @implementation AppDelegate
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||
// Override point for customization after application launch.
|
||||
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||
self.rootVC = [[ViewController alloc] init];
|
||||
|
||||
self.window.rootViewController = self.rootVC;
|
||||
self.navigationController = [[UINavigationController
|
||||
alloc] initWithRootViewController:self.rootVC];
|
||||
[self.window addSubview:self.navigationController.view];
|
||||
[self.window makeKeyAndVisible];
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
12
iOS/Example/Example/DemoVC.h
Normal file
12
iOS/Example/Example/DemoVC.h
Normal file
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// 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 DemoVC : UIViewController
|
||||
- (instancetype)initWithPath:(NSString *)filePath;
|
||||
@end
|
45
iOS/Example/Example/DemoVC.m
Normal file
45
iOS/Example/Example/DemoVC.m
Normal file
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// Created by pengfei.zhou on 2019/11/19.
|
||||
// Copyright (c) 2019 pengfei.zhou. All rights reserved.
|
||||
//
|
||||
|
||||
#import "DemoVC.h"
|
||||
#import "DoricContext.h"
|
||||
#import "DoricLayouts.h"
|
||||
#import "DoricExtensions.h"
|
||||
#import "DoricRootNode.h"
|
||||
#import "DoricLocalServer.h"
|
||||
|
||||
@interface DemoVC ()
|
||||
@property(nonatomic, copy) NSString *filePath;
|
||||
@property(nonatomic, strong) DoricContext *doricContext;
|
||||
//@property(nonatomic, strong) DoricLocalServer *localServer;
|
||||
@end
|
||||
|
||||
@implementation DemoVC
|
||||
- (instancetype)initWithPath:(NSString *)filePath {
|
||||
if (self = [self init]) {
|
||||
_filePath = filePath;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
NSString *jsContent = [NSString stringWithContentsOfFile:self.filePath encoding:NSUTF8StringEncoding error:nil];
|
||||
self.doricContext = [[DoricContext alloc] initWithScript:jsContent source:self.filePath];
|
||||
[self.doricContext.rootNode setupRootView:[[DoricStackView new] also:^(DoricStackView *it) {
|
||||
it.backgroundColor = [UIColor whiteColor];
|
||||
it.layoutConfig = [[DoricLayoutConfig alloc]
|
||||
initWithWidth:DoricLayoutAtMost
|
||||
height:DoricLayoutAtMost
|
||||
margin:DoricMarginMake(0, 88, 0, 0)
|
||||
];
|
||||
[self.view addSubview:it];
|
||||
}]];
|
||||
[self.doricContext initContextWithWidth:self.view.width height:self.view.height];
|
||||
// [self.doricContext.driver connectDevKit:@"ws://192.168.11.38:7777"];
|
||||
// self.localServer = [[DoricLocalServer alloc] init];
|
||||
// [self.localServer startWithPort:8910];
|
||||
}
|
||||
|
||||
@end
|
@@ -7,38 +7,53 @@
|
||||
//
|
||||
|
||||
#import "ViewController.h"
|
||||
#import "UIView+Doric.h"
|
||||
#import "DoricUtil.h"
|
||||
#import "DoricContext.h"
|
||||
#import "DoricNativePlugin.h"
|
||||
#import "DoricRootNode.h"
|
||||
#import "DoricLocalServer.h"
|
||||
#import "DoricLayouts.h"
|
||||
#import "DoricExtensions.h"
|
||||
#import "Doric.h"
|
||||
#import "DemoVC.h"
|
||||
|
||||
@interface ViewController ()
|
||||
@property(nonatomic, strong) DoricContext *doricContext;
|
||||
@property(nonatomic, strong) DoricLocalServer *localServer;
|
||||
@interface ViewController () <UITableViewDelegate, UITableViewDataSource>
|
||||
@property(nonatomic, copy) NSArray <NSString *> *demoFilePaths;
|
||||
@end
|
||||
|
||||
@implementation ViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"ScrollerDemo" ofType:@"js"];
|
||||
NSString *jsContent = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
|
||||
self.doricContext = [[DoricContext alloc] initWithScript:jsContent source:@"test.js"];
|
||||
[self.doricContext.rootNode setupRootView:[[DoricStackView new] also:^(DoricStackView *it) {
|
||||
it.layoutConfig = [[DoricLayoutConfig alloc] initWithWidth:DoricLayoutAtMost height:DoricLayoutAtMost];
|
||||
[self.view addSubview:it];
|
||||
NSString *path = [[NSBundle mainBundle] bundlePath];
|
||||
NSString *demoPath = [path stringByAppendingPathComponent:@"demo"];
|
||||
NSFileManager *mgr = [NSFileManager defaultManager];
|
||||
self.demoFilePaths = [[mgr subpathsAtPath:demoPath] filter:^BOOL(NSString *obj) {
|
||||
return ![obj containsString:@".map"];
|
||||
}];
|
||||
[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;
|
||||
}]];
|
||||
[self.doricContext initContextWithWidth:self.view.width height:self.view.height];
|
||||
[self.doricContext.driver connectDevKit:@"ws://192.168.11.38:7777"];
|
||||
self.localServer = [[DoricLocalServer alloc] init];
|
||||
[self.localServer startWithPort:8910];
|
||||
NSLog(@"00112233");
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
return self.demoFilePaths.count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
NSString *path = self.demoFilePaths[(NSUInteger) indexPath.row];
|
||||
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
|
||||
if (cell == nil) {
|
||||
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cellID"];
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
}
|
||||
cell.textLabel.text = path;
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
NSString *path = [[NSBundle mainBundle] bundlePath];
|
||||
NSString *demoPath = [path stringByAppendingPathComponent:@"demo"];
|
||||
NSString *fullPath = [demoPath stringByAppendingPathComponent:self.demoFilePaths[(NSUInteger) indexPath.row]];
|
||||
DemoVC *demoVC = [[DemoVC alloc] initWithPath:fullPath];
|
||||
[self.navigationController pushViewController:demoVC animated:NO];
|
||||
}
|
||||
|
||||
@end
|
||||
|
1
iOS/Example/Example/demo
Symbolic link
1
iOS/Example/Example/demo
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../demo/bundle/src/
|
Reference in New Issue
Block a user