Merge branch 'feature/scrollview' into 'master'
Feature/scrollview See merge request !14
This commit is contained in:
commit
ec5d9783a8
@ -19,7 +19,9 @@
|
|||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name=".DemoActivity">
|
<activity
|
||||||
|
android:name=".DemoActivity"
|
||||||
|
android:theme="@style/Theme.Design.Light.NoActionBar">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ package pub.doric.demo;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.Window;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
@ -9,9 +9,8 @@
|
|||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
AAAF5D5802FC6E7E4F481F5D /* libPods-ExampleTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 942158E9B500A4C975FD37F3 /* libPods-ExampleTests.a */; };
|
AAAF5D5802FC6E7E4F481F5D /* libPods-ExampleTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 942158E9B500A4C975FD37F3 /* libPods-ExampleTests.a */; };
|
||||||
B1AF6AE00A9B4675290F5947 /* libPods-ExampleUITests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 64B9242B26FEC4AEC20FF43D /* libPods-ExampleUITests.a */; };
|
B1AF6AE00A9B4675290F5947 /* libPods-ExampleUITests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 64B9242B26FEC4AEC20FF43D /* libPods-ExampleUITests.a */; };
|
||||||
|
D751D4B065D8D4FA6594B5EE /* DemoVC.m in Sources */ = {isa = PBXBuildFile; fileRef = D751D19E97EF4EDD7588FEBE /* DemoVC.m */; };
|
||||||
D9E087DE6FF1DB083B30D9E7 /* libPods-Example.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C043B7BA79339ABA1CF46881 /* libPods-Example.a */; };
|
D9E087DE6FF1DB083B30D9E7 /* libPods-Example.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C043B7BA79339ABA1CF46881 /* libPods-Example.a */; };
|
||||||
E21DC9D42302870000660C5C /* Snake.js in Resources */ = {isa = PBXBuildFile; fileRef = E21DC9D22302865E00660C5C /* Snake.js */; };
|
|
||||||
E21DC9D52302870000660C5C /* Counter.js in Resources */ = {isa = PBXBuildFile; fileRef = E21DC9D32302865E00660C5C /* Counter.js */; };
|
|
||||||
E2334AF022E9D2060098A085 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = E2334AEF22E9D2060098A085 /* AppDelegate.m */; };
|
E2334AF022E9D2060098A085 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = E2334AEF22E9D2060098A085 /* AppDelegate.m */; };
|
||||||
E2334AF322E9D2060098A085 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E2334AF222E9D2060098A085 /* ViewController.m */; };
|
E2334AF322E9D2060098A085 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E2334AF222E9D2060098A085 /* ViewController.m */; };
|
||||||
E2334AF622E9D2060098A085 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E2334AF422E9D2060098A085 /* Main.storyboard */; };
|
E2334AF622E9D2060098A085 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E2334AF422E9D2060098A085 /* Main.storyboard */; };
|
||||||
@ -20,8 +19,7 @@
|
|||||||
E2334AFE22E9D2070098A085 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = E2334AFD22E9D2070098A085 /* main.m */; };
|
E2334AFE22E9D2070098A085 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = E2334AFD22E9D2070098A085 /* main.m */; };
|
||||||
E2334B0822E9D2070098A085 /* ExampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E2334B0722E9D2070098A085 /* ExampleTests.m */; };
|
E2334B0822E9D2070098A085 /* ExampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E2334B0722E9D2070098A085 /* ExampleTests.m */; };
|
||||||
E2334B1322E9D2070098A085 /* ExampleUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = E2334B1222E9D2070098A085 /* ExampleUITests.m */; };
|
E2334B1322E9D2070098A085 /* ExampleUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = E2334B1222E9D2070098A085 /* ExampleUITests.m */; };
|
||||||
E2BF7BF7237E8E9F001B0EDC /* ListDemo.js in Resources */ = {isa = PBXBuildFile; fileRef = E2BF7BF6237E8E9F001B0EDC /* ListDemo.js */; };
|
E2F4481723839AC500073C7F /* demo in Resources */ = {isa = PBXBuildFile; fileRef = E2F4481623839AC500073C7F /* demo */; };
|
||||||
E2F447F42383924B00073C7F /* ScrollerDemo.js in Resources */ = {isa = PBXBuildFile; fileRef = E2F447F32383924B00073C7F /* ScrollerDemo.js */; };
|
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXContainerItemProxy section */
|
/* Begin PBXContainerItemProxy section */
|
||||||
@ -51,8 +49,8 @@
|
|||||||
942158E9B500A4C975FD37F3 /* libPods-ExampleTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ExampleTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
942158E9B500A4C975FD37F3 /* libPods-ExampleTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ExampleTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
A5AE090AE3815360EC768C8D /* Pods-Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-Example/Pods-Example.release.xcconfig"; sourceTree = "<group>"; };
|
A5AE090AE3815360EC768C8D /* Pods-Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-Example/Pods-Example.release.xcconfig"; sourceTree = "<group>"; };
|
||||||
C043B7BA79339ABA1CF46881 /* libPods-Example.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Example.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
C043B7BA79339ABA1CF46881 /* libPods-Example.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Example.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
E21DC9D22302865E00660C5C /* Snake.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = Snake.js; sourceTree = "<group>"; };
|
D751D19E97EF4EDD7588FEBE /* DemoVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DemoVC.m; sourceTree = "<group>"; };
|
||||||
E21DC9D32302865E00660C5C /* Counter.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = Counter.js; sourceTree = "<group>"; };
|
D751DDEC114E037231257E64 /* DemoVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DemoVC.h; sourceTree = "<group>"; };
|
||||||
E2334AEB22E9D2060098A085 /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
E2334AEB22E9D2060098A085 /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
E2334AEE22E9D2060098A085 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
|
E2334AEE22E9D2060098A085 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
|
||||||
E2334AEF22E9D2060098A085 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
|
E2334AEF22E9D2060098A085 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
|
||||||
@ -69,8 +67,7 @@
|
|||||||
E2334B0E22E9D2070098A085 /* ExampleUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ExampleUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
E2334B0E22E9D2070098A085 /* ExampleUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ExampleUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
E2334B1222E9D2070098A085 /* ExampleUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ExampleUITests.m; sourceTree = "<group>"; };
|
E2334B1222E9D2070098A085 /* ExampleUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ExampleUITests.m; sourceTree = "<group>"; };
|
||||||
E2334B1422E9D2070098A085 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
E2334B1422E9D2070098A085 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
E2BF7BF6237E8E9F001B0EDC /* ListDemo.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = ListDemo.js; sourceTree = "<group>"; };
|
E2F4481623839AC500073C7F /* demo */ = {isa = PBXFileReference; lastKnownFileType = folder; path = demo; sourceTree = "<group>"; };
|
||||||
E2F447F32383924B00073C7F /* ScrollerDemo.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = ScrollerDemo.js; sourceTree = "<group>"; };
|
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
@ -124,22 +121,9 @@
|
|||||||
name = Frameworks;
|
name = Frameworks;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
E21DC9D12302865E00660C5C /* src */ = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
E2F447F32383924B00073C7F /* ScrollerDemo.js */,
|
|
||||||
E2BF7BF6237E8E9F001B0EDC /* ListDemo.js */,
|
|
||||||
E21DC9D22302865E00660C5C /* Snake.js */,
|
|
||||||
E21DC9D32302865E00660C5C /* Counter.js */,
|
|
||||||
);
|
|
||||||
name = src;
|
|
||||||
path = ../../demo/bundle/src;
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
E2334AE222E9D2060098A085 = {
|
E2334AE222E9D2060098A085 = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
E21DC9D12302865E00660C5C /* src */,
|
|
||||||
E2334AED22E9D2060098A085 /* Example */,
|
E2334AED22E9D2060098A085 /* Example */,
|
||||||
E2334B0622E9D2070098A085 /* ExampleTests */,
|
E2334B0622E9D2070098A085 /* ExampleTests */,
|
||||||
E2334B1122E9D2070098A085 /* ExampleUITests */,
|
E2334B1122E9D2070098A085 /* ExampleUITests */,
|
||||||
@ -162,6 +146,7 @@
|
|||||||
E2334AED22E9D2060098A085 /* Example */ = {
|
E2334AED22E9D2060098A085 /* Example */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
E2F4481623839AC500073C7F /* demo */,
|
||||||
E2334AEE22E9D2060098A085 /* AppDelegate.h */,
|
E2334AEE22E9D2060098A085 /* AppDelegate.h */,
|
||||||
E2334AEF22E9D2060098A085 /* AppDelegate.m */,
|
E2334AEF22E9D2060098A085 /* AppDelegate.m */,
|
||||||
E2334AF122E9D2060098A085 /* ViewController.h */,
|
E2334AF122E9D2060098A085 /* ViewController.h */,
|
||||||
@ -171,6 +156,8 @@
|
|||||||
E2334AF922E9D2070098A085 /* LaunchScreen.storyboard */,
|
E2334AF922E9D2070098A085 /* LaunchScreen.storyboard */,
|
||||||
E2334AFC22E9D2070098A085 /* Info.plist */,
|
E2334AFC22E9D2070098A085 /* Info.plist */,
|
||||||
E2334AFD22E9D2070098A085 /* main.m */,
|
E2334AFD22E9D2070098A085 /* main.m */,
|
||||||
|
D751D19E97EF4EDD7588FEBE /* DemoVC.m */,
|
||||||
|
D751DDEC114E037231257E64 /* DemoVC.h */,
|
||||||
);
|
);
|
||||||
path = Example;
|
path = Example;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -301,11 +288,8 @@
|
|||||||
isa = PBXResourcesBuildPhase;
|
isa = PBXResourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
E2F447F42383924B00073C7F /* ScrollerDemo.js in Resources */,
|
|
||||||
E2BF7BF7237E8E9F001B0EDC /* ListDemo.js in Resources */,
|
|
||||||
E21DC9D42302870000660C5C /* Snake.js in Resources */,
|
|
||||||
E21DC9D52302870000660C5C /* Counter.js in Resources */,
|
|
||||||
E2334AFB22E9D2070098A085 /* LaunchScreen.storyboard in Resources */,
|
E2334AFB22E9D2070098A085 /* LaunchScreen.storyboard in Resources */,
|
||||||
|
E2F4481723839AC500073C7F /* demo in Resources */,
|
||||||
E2334AF822E9D2070098A085 /* Assets.xcassets in Resources */,
|
E2334AF822E9D2070098A085 /* Assets.xcassets in Resources */,
|
||||||
E2334AF622E9D2060098A085 /* Main.storyboard in Resources */,
|
E2334AF622E9D2060098A085 /* Main.storyboard in Resources */,
|
||||||
);
|
);
|
||||||
@ -439,6 +423,7 @@
|
|||||||
E2334AF322E9D2060098A085 /* ViewController.m in Sources */,
|
E2334AF322E9D2060098A085 /* ViewController.m in Sources */,
|
||||||
E2334AFE22E9D2070098A085 /* main.m in Sources */,
|
E2334AFE22E9D2070098A085 /* main.m in Sources */,
|
||||||
E2334AF022E9D2060098A085 /* AppDelegate.m in Sources */,
|
E2334AF022E9D2060098A085 /* AppDelegate.m in Sources */,
|
||||||
|
D751D4B065D8D4FA6594B5EE /* DemoVC.m in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
@ -7,9 +7,11 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import "AppDelegate.h"
|
#import "AppDelegate.h"
|
||||||
|
#import "ViewController.h"
|
||||||
|
|
||||||
@interface AppDelegate ()
|
@interface AppDelegate ()
|
||||||
|
@property(nonatomic, strong) UIViewController *rootVC;
|
||||||
|
@property(nonatomic, strong) UINavigationController *navigationController;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation AppDelegate
|
@implementation AppDelegate
|
||||||
@ -17,6 +19,14 @@ @implementation AppDelegate
|
|||||||
|
|
||||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||||
// Override point for customization after application launch.
|
// 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;
|
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
|
50
iOS/Example/Example/DemoVC.m
Normal file
50
iOS/Example/Example/DemoVC.m
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
//
|
||||||
|
// 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 {
|
||||||
|
self.title = self.filePath;
|
||||||
|
NSString *path = [[NSBundle mainBundle] bundlePath];
|
||||||
|
NSString *demoPath = [path stringByAppendingPathComponent:@"demo"];
|
||||||
|
NSString *fullPath = [demoPath stringByAppendingPathComponent:self.filePath];
|
||||||
|
NSString *jsContent = [NSString stringWithContentsOfFile:fullPath 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)
|
||||||
|
];
|
||||||
|
it.top = 88;
|
||||||
|
[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,51 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import "ViewController.h"
|
#import "ViewController.h"
|
||||||
#import "UIView+Doric.h"
|
#import "Doric.h"
|
||||||
#import "DoricUtil.h"
|
#import "DemoVC.h"
|
||||||
#import "DoricContext.h"
|
|
||||||
#import "DoricNativePlugin.h"
|
|
||||||
#import "DoricRootNode.h"
|
|
||||||
#import "DoricLocalServer.h"
|
|
||||||
#import "DoricLayouts.h"
|
|
||||||
#import "DoricExtensions.h"
|
|
||||||
|
|
||||||
@interface ViewController ()
|
@interface ViewController () <UITableViewDelegate, UITableViewDataSource>
|
||||||
@property(nonatomic, strong) DoricContext *doricContext;
|
@property(nonatomic, copy) NSArray <NSString *> *demoFilePaths;
|
||||||
@property(nonatomic, strong) DoricLocalServer *localServer;
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation ViewController
|
@implementation ViewController
|
||||||
|
|
||||||
- (void)viewDidLoad {
|
- (void)viewDidLoad {
|
||||||
[super viewDidLoad];
|
[super viewDidLoad];
|
||||||
|
self.title = @"Doric Demo";
|
||||||
NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"ScrollerDemo" ofType:@"js"];
|
NSString *path = [[NSBundle mainBundle] bundlePath];
|
||||||
NSString *jsContent = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
|
NSString *demoPath = [path stringByAppendingPathComponent:@"demo"];
|
||||||
self.doricContext = [[DoricContext alloc] initWithScript:jsContent source:@"test.js"];
|
NSFileManager *mgr = [NSFileManager defaultManager];
|
||||||
[self.doricContext.rootNode setupRootView:[[DoricStackView new] also:^(DoricStackView *it) {
|
self.demoFilePaths = [[mgr subpathsAtPath:demoPath] filter:^BOOL(NSString *obj) {
|
||||||
it.layoutConfig = [[DoricLayoutConfig alloc] initWithWidth:DoricLayoutAtMost height:DoricLayoutAtMost];
|
return ![obj containsString:@".map"];
|
||||||
[self.view addSubview:it];
|
}];
|
||||||
|
[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 {
|
||||||
|
DemoVC *demoVC = [[DemoVC alloc] initWithPath:self.demoFilePaths[(NSUInteger) indexPath.row]];
|
||||||
|
[self.navigationController pushViewController:demoVC animated:NO];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
1
iOS/Example/Example/demo
Symbolic link
1
iOS/Example/Example/demo
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../../demo/bundle/src/
|
21
iOS/Pod/Classes/Doric.h
Normal file
21
iOS/Pod/Classes/Doric.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2019] [Doric.Pub]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
#import "DoricContext.h"
|
||||||
|
#import "DoricLayouts.h"
|
||||||
|
#import "DoricExtensions.h"
|
||||||
|
#import "DoricViewNode.h"
|
||||||
|
#import "DoricRootNode.h"
|
||||||
|
#import "UIView+Doric.h"
|
@ -92,6 +92,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
|
|||||||
DoricListItemNode *node = cell.doricListItemNode;
|
DoricListItemNode *node = cell.doricListItemNode;
|
||||||
node.viewId = model[@"id"];
|
node.viewId = model[@"id"];
|
||||||
[node blend:props];
|
[node blend:props];
|
||||||
|
[node.view setNeedsLayout];
|
||||||
CGSize size = [node.view sizeThatFits:CGSizeMake(cell.width, cell.height)];
|
CGSize size = [node.view sizeThatFits:CGSizeMake(cell.width, cell.height)];
|
||||||
[self callItem:position height:size.height];
|
[self callItem:position height:size.height];
|
||||||
return cell;
|
return cell;
|
||||||
|
@ -27,3 +27,21 @@
|
|||||||
|
|
||||||
- (void)let:(void (^)(id it))block;
|
- (void)let:(void (^)(id it))block;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@interface NSArray <ObjectType> (Doric)
|
||||||
|
- (void)forEachIndexed:(void (NS_NOESCAPE ^)(ObjectType obj, NSUInteger idx))block;
|
||||||
|
|
||||||
|
- (NSArray *)mapIndexed:(id (NS_NOESCAPE ^)(ObjectType obj, NSUInteger idx))block;
|
||||||
|
|
||||||
|
- (NSArray *)flatMapIndexed:(NSArray *(NS_NOESCAPE ^)(ObjectType obj, NSUInteger idx))block;
|
||||||
|
|
||||||
|
- (NSArray *)filterIndexed:(BOOL (NS_NOESCAPE ^)(ObjectType obj, NSUInteger idx))block;
|
||||||
|
|
||||||
|
- (void)forEach:(void (NS_NOESCAPE ^)(ObjectType obj))block;
|
||||||
|
|
||||||
|
- (NSArray *)map:(id (NS_NOESCAPE ^)(ObjectType obj))block;
|
||||||
|
|
||||||
|
- (NSArray *)flatMap:(NSArray *(NS_NOESCAPE ^)(ObjectType obj))block;
|
||||||
|
|
||||||
|
- (NSArray <ObjectType> *)filter:(BOOL (NS_NOESCAPE ^)(ObjectType obj))block;
|
||||||
|
@end
|
@ -33,3 +33,70 @@ - (void)let:(void (^)(id it))block {
|
|||||||
block(self);
|
block(self);
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@implementation NSArray (Doric)
|
||||||
|
- (void)forEachIndexed:(void (NS_NOESCAPE ^)(id obj, NSUInteger idx))block {
|
||||||
|
[self enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
||||||
|
block(obj, idx);
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSArray *)mapIndexed:(id (NS_NOESCAPE ^)(id obj, NSUInteger idx))block {
|
||||||
|
NSMutableArray *temp = [NSMutableArray new];
|
||||||
|
[self enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
||||||
|
[temp addObject:block(obj, idx)];
|
||||||
|
}];
|
||||||
|
return [temp copy];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSArray *)flatMapIndexed:(NSArray *(NS_NOESCAPE ^)(id obj, NSUInteger idx))block {
|
||||||
|
NSMutableArray *temp = [NSMutableArray new];
|
||||||
|
[self enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
||||||
|
[temp addObjectsFromArray:block(obj, idx)];
|
||||||
|
}];
|
||||||
|
return [temp copy];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSArray *)filterIndexed:(BOOL (NS_NOESCAPE ^)(id obj, NSUInteger idx))block {
|
||||||
|
NSMutableArray *temp = [NSMutableArray new];
|
||||||
|
[self enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
||||||
|
if (block(obj, idx)) {
|
||||||
|
[temp addObject:obj];
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
return [temp copy];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)forEach:(void (NS_NOESCAPE ^)(id obj))block {
|
||||||
|
for (id obj in self) {
|
||||||
|
block(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSArray *)map:(id (NS_NOESCAPE ^)(id obj))block {
|
||||||
|
NSMutableArray *temp = [NSMutableArray new];
|
||||||
|
for (id obj in self) {
|
||||||
|
[temp addObject:block(obj)];
|
||||||
|
}
|
||||||
|
return [temp copy];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSArray *)flatMap:(NSArray *(NS_NOESCAPE ^)(id obj))block {
|
||||||
|
NSMutableArray *temp = [NSMutableArray new];
|
||||||
|
for (id obj in self) {
|
||||||
|
[temp addObjectsFromArray:block(obj)];
|
||||||
|
}
|
||||||
|
return [temp copy];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSArray *)filter:(BOOL (NS_NOESCAPE ^)(id obj))block {
|
||||||
|
NSMutableArray *temp = [NSMutableArray new];
|
||||||
|
for (id obj in self) {
|
||||||
|
if (block(obj)) {
|
||||||
|
[temp addObject:obj];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [temp copy];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
Reference in New Issue
Block a user