Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/api/hippy-react/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,9 @@ import icon from './qb_icon_new.png';
| placeholder | 如果没有任何文字输入,会显示此字符串。 | `string` | `Android、iOS、hippy-react-web、Web-Renderer、Voltron` |
| placeholderTextColor | 占位字符串显示的文字颜色。(也可设置为 Style 属性)`最低支持版本2.13.4` | [`color`](api/style/color.md) | `Android、iOS、Web-Renderer、Voltron` |
| returnKeyType | 指定软键盘的回车键显示的样式。(其中部分样式仅`multiline=false`时有效) | `enum (done, go, next, search, send)` | `Android、iOS、Web-Renderer、Voltron` |
| blurOnSubmit | 指定当 `TextInput` 组件为多行时,按下回车键是否自动失去焦点。`default: false` | `boolean` | `iOS` |
| autoCorrect | 指定 `TextInput` 组件输入的文字是否自动修正。`default: false` | `boolean` | `iOS` |
| clearTextOnFocus | 指定当 `TextInput` 组件为多行时,是否在获取焦点时清除文字。`default: false` | `boolean` | `iOS` |
| value | 指定 `TextInput` 组件的值。 | `string` | `Android、iOS、hippy-react-web、Web-Renderer、Voltron` |
| autoFocus | 组件渲染时自动获得焦点。 | `boolean` | `Android、iOS、hippy-react-web、Web-Renderer、Voltron` |
| breakStrategy* | 设置Android API 23及以上系统的文本折行策略。`default: simple` | `enum(simple, high_quality, balanced)` | `Android(版本 2.14.2以上)` |
Expand Down
3 changes: 3 additions & 0 deletions docs/api/hippy-vue/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,9 @@
| placeholder | 如果没有任何文字输入,会显示此字符串。 | `string` | `Android、iOS、Web-Renderer、Voltron、Ohos` |
| placeholder-text-color | 占位字符串显示的文字颜色。(也可设置为 Style 属性) `最低支持版本2.13.4` | [`color`](api/style/color.md) | `Android、iOS、Web-Renderer、Voltron、Ohos` |
| returnKeyType | 指定软键盘的回车键显示的样式。(其中部分样式仅对单行文本组件有效) | `enum(done, go, next, search, send)` | `Android、iOS、Web-Renderer`、Ohos |
| blurOnSubmit | 指定当 `input` 组件为多行时,按下回车键是否自动失去焦点。`default: false` | `boolean` | `iOS` |
| autoCorrect | 指定 `input` 组件输入的文字是否自动修正。`default: false` | `boolean` | `iOS` |
| clearTextOnFocus | 指定当 `input` 组件为多行时,是否在获取焦点时清除文字。`default: false` | `boolean` | `iOS` |
| value | 指定 `input` 组件的值。 | `string` | `Android、iOS、Web-Renderer、Voltron` |
| break-strategy* | 设置Android API 23及以上系统的文本换行策略。`default: simple` | `enum(simple, high_quality, balanced)` | `Android(版本 2.14.2以上)` |

Expand Down
87 changes: 38 additions & 49 deletions framework/examples/ios-demo/HippyDemo/HippyDemoViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
@import hippy;


@interface HippyDemoViewController () <HippyMethodInterceptorProtocol, HippyBridgeDelegate, HippyRootViewDelegate> {
@interface HippyDemoViewController () <HippyBridgeDelegate, HippyRootViewDelegate> {
HippyBridge *_hippyBridge;
HippyRootView *_hippyRootView;
BOOL _fromCache;
Expand Down Expand Up @@ -90,6 +90,7 @@ - (void)runHippyCache {
[self.contentAreaView addSubview:_hippyRootView];
}


#pragma mark - Hippy Setup

- (void)registerLogFunction {
Expand All @@ -100,15 +101,24 @@ - (void)registerLogFunction {
// this is a demo imp, output to console:
HippyDefaultLogFunction(level, source, fileName, lineNumber, message);
});

HippySetFatalHandler(^(NSError * _Nonnull error) {
// do error report or something else...
// fatal error will also output by HippySetLogFunction above.
NSLog(@"Hippy Fatal Error occurred! msg:%@", error.description);
});
}

- (void)runHippyDemo {
// Necessary configuration:
// `moduleName` corresponds to the Hippy App name on the JS side
NSString *moduleName = @"Demo";

// Set launch options for hippy bridge
HippyLaunchOptions *launchOptions = [HippyLaunchOptions new];
launchOptions.debugMode = _debugMode;
launchOptions.useHermesEngine = _useHermesEngine;

// Prepare initial properties for js side
NSDictionary *initialProperties = @{ @"isSimulator": @(TARGET_OS_SIMULATOR) };

Expand Down Expand Up @@ -148,14 +158,36 @@ - (void)runHippyDemo {
rootView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
[self.contentAreaView addSubview:rootView];
_hippyRootView = rootView;


// Optional configs:
bridge.methodInterceptor = self; // see HippyMethodInterceptorProtocol
}


#pragma mark - Helpers
#pragma mark - HippyBridgeDelegate

- (BOOL)shouldStartInspector:(HippyBridge *)bridge {
return bridge.debugMode;
}

- (NSURL *)inspectorSourceURLForBridge:(HippyBridge *)bridge {
// You can customize to any url.
// By default, we resolve the devtools address from the debug url passed to the bridge.
return bridge.debugURL;
}

- (CGFloat)fontSizeMultiplierForHippy:(HippyBridge *)bridge {
// This is a demo implementation, you can customize it.
// The default value is 1.0.
// The font size multiplier is used to scale the font size of the text in the Hippy view.
// For example, if you set it to 2.0, the font size will be twice as large as the default size.
return 1.0;
}


#pragma mark - HippyRootViewDelegate

// Some imp of HippyRootViewDelegate methods, optional...


#pragma mark - Others

- (NSString *)currentJSBundleDir {
NSString *dir = nil;
Expand Down Expand Up @@ -211,47 +243,4 @@ - (UIInterfaceOrientationMask)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAllButUpsideDown;
}


#pragma mark - HippyBridgeDelegate

- (BOOL)shouldStartInspector:(HippyBridge *)bridge {
return bridge.debugMode;
}

- (NSURL *)inspectorSourceURLForBridge:(HippyBridge *)bridge {
// You can customize to any url.
// By default, we resolve the devtools address from the debug url passed to the bridge.
return bridge.debugURL;
}

- (CGFloat)fontSizeMultiplierForHippy:(HippyBridge *)bridge {
// This is a demo implementation, you can customize it.
// The default value is 1.0.
// The font size multiplier is used to scale the font size of the text in the Hippy view.
// For example, if you set it to 2.0, the font size will be twice as large as the default size.
return 1.0;
}


#pragma mark - Optional - HippyMethodInterceptorProtocol

- (BOOL)shouldInvokeWithModuleName:(NSString *)moduleName
methodName:(NSString *)methodName
arguments:(NSArray<id<HippyBridgeArgument>> *)arguments
argumentsValues:(NSArray *)argumentsValue
containCallback:(BOOL)containCallback {
HippyAssert(moduleName, @"module name must not be null");
HippyAssert(methodName, @"method name must not be null");
return YES;
}

- (BOOL)shouldCallbackBeInvokedWithModuleName:(NSString *)moduleName
methodName:(NSString *)methodName
callbackId:(NSNumber *)cbId
arguments:(id)arguments {
HippyAssert(moduleName, @"module name must not be null");
HippyAssert(methodName, @"method name must not be null");
return YES;
}

@end
4 changes: 2 additions & 2 deletions xcodeinitscript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ios_tool_chain_path=${root_dir}/buildconfig/cmake/ios.toolchain.cmake
#devtools project
cd ./devtools/devtools-integration/ios
rm -rf ./DevtoolsBackend
cmake ./CMakeLists.txt -B ./DevtoolsBackend -G Xcode -DMODULE_TOOLS=YES -DCMAKE_TOOLCHAIN_FILE=${ios_tool_chain_path} -DPLATFORM=OS64COMBINED -DENABLE_ARC=YES -DDEPLOYMENT_TARGET=11.0 -DENABLE_INSPECTOR=YES -DCMAKE_POLICY_VERSION_MINIMUM=3.5
cmake ./CMakeLists.txt -B ./DevtoolsBackend -G Xcode -DMODULE_TOOLS=YES -DCMAKE_TOOLCHAIN_FILE=${ios_tool_chain_path} -DPLATFORM=OS64COMBINED -DENABLE_ARC=YES -DDEPLOYMENT_TARGET=12.0 -DENABLE_INSPECTOR=YES -DCMAKE_POLICY_VERSION_MINIMUM=3.5
echo -e "\033[33m devtools cmake build end\033[0m"

#layout project - use taitank by deault
Expand All @@ -39,6 +39,6 @@ layout_engine="Taitank"
if [[ ${1} ]]; then
layout_engine=${1}
fi
cmake ./CMakeLists.txt -B ./dom_project -G Xcode -DMODULE_TOOLS=YES -DCMAKE_TOOLCHAIN_FILE=${ios_tool_chain_path} -DPLATFORM=OS64COMBINED -DDEPLOYMENT_TARGET=11.0 -DLAYOUT_ENGINE=${layout_engine}
cmake ./CMakeLists.txt -B ./dom_project -G Xcode -DMODULE_TOOLS=YES -DCMAKE_TOOLCHAIN_FILE=${ios_tool_chain_path} -DPLATFORM=OS64COMBINED -DDEPLOYMENT_TARGET=12.0 -DLAYOUT_ENGINE=${layout_engine}
echo -e "\033[33m dom cmake build end\033[0m"

Loading