Skip to content

Commit

Permalink
添加 forceTransparentDialogWindow 配置项
Browse files Browse the repository at this point in the history
  • Loading branch information
listenzz committed Apr 13, 2022
1 parent 62f68f5 commit 80dfb65
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ static GlobalStyle getGlobalStyle() {

boolean extendedLayoutIncludesTopBar;

boolean forceTransparentDialogWindow;

Garden(@NonNull HybridFragment fragment, Style style) {
// 构造 garden 实例时,Toolbar 还没有被创建

Expand All @@ -81,6 +83,8 @@ static GlobalStyle getGlobalStyle() {
if (!TextUtils.isEmpty(screenColor)) {
style.setScreenBackgroundColor(Color.parseColor(screenColor));
}

this.forceTransparentDialogWindow = options.getBoolean("forceTransparentDialogWindow");

applyOptions(options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.os.Bundle;
import android.view.View;
import android.view.Window;

import androidx.annotation.CallSuper;
import androidx.annotation.NonNull;
Expand Down Expand Up @@ -90,6 +91,11 @@ protected void onCustomStyle(@NonNull Style style) {
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
garden.configureToolbar();
if (getShowsDialog() && garden.forceTransparentDialogWindow) {
Window window = getWindow();
assert window != null;
window.setDimAmount(0);
}
}

public Garden getGarden() {
Expand Down
2 changes: 2 additions & 0 deletions ios/HybridNavigation/HBDGarden.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

// ------

@property(nonatomic, assign) BOOL forceTransparentDialogWindow;

- (instancetype)initWithViewController:(HBDViewController *)vc;

- (void)setLeftBarButtonItem:(NSDictionary *)item;
Expand Down
6 changes: 6 additions & 0 deletions ios/HybridNavigation/ViewController/HBDModalViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,12 @@ - (void)hbd_showViewController:(UIViewController *)vc requestCode:(NSInteger)req

HBDModalViewController *modalViewController = [[HBDModalViewController alloc] init];
modalViewController.contentViewController = vc;
if ([vc isKindOfClass:[HBDViewController class]]) {
HBDViewController *hbdvc = (HBDViewController *)vc;
if (hbdvc.garden.forceTransparentDialogWindow) {
modalViewController.dimmingView.backgroundColor = UIColor.clearColor;
}
}
[modalViewController showWithAnimated:animated completion:completion];
}

Expand Down
2 changes: 1 addition & 1 deletion ios/HybridNavigation/ViewController/HBDViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ - (instancetype)initWithModuleName:(NSString *)moduleName props:(NSDictionary *)
_options = options;
_props = props;
_garden = [[HBDGarden alloc] initWithViewController:self];

_garden.forceTransparentDialogWindow = [options[@"forceTransparentDialogWindow"] boolValue];
[self applyNavigationBarOptions:options];
[self applyTabBarOptions:options];
}
Expand Down
1 change: 1 addition & 0 deletions src/typing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export interface NavigationOption {

export interface NavigationItem extends NavigationOption {
screenBackgroundColor?: Color // 当前页面背景
forceTransparentDialogWindow?: boolean // 当页面是 Dialog 时,是否强制背景透明
topBarHidden?: boolean // 是否隐藏 TopBar
extendedLayoutIncludesTopBar?: boolean // 页面内容是否延伸到 TopBar 底下,通常用于需要动态改变 `topBarAlpha` 的场合
swipeBackEnabled?: boolean // 是否可以通过右滑返回。如果 `backInteractive` 设置为 false, 那么该值无效。Android 下,只有开启了侧滑返回功能,该值才会生效。
Expand Down

0 comments on commit 80dfb65

Please sign in to comment.