Skip to content

Commit

Permalink
feat(layer-dialog): DialogLayer支持全屏模式
Browse files Browse the repository at this point in the history
DialogLayer支持全屏模式,可以通过setFitInsets方法打开。

Closes #13
  • Loading branch information
goweii committed Jun 17, 2023
1 parent fbc718d commit 3be6a77
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ fun <T : DialogLayer> T.avoidStatusBar(enable: Boolean) = this.apply {
this.setAvoidStatusBar(enable)
}

fun <T : DialogLayer> T.fitInsets(fitInsets: Boolean) = this.apply {
this.setFitInsets(fitInsets)
}

fun <T : DialogLayer> T.gravity(gravity: Int) = this.apply {
this.setGravity(gravity)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ protected View onCreateChild(@NonNull LayoutInflater inflater, @NonNull ViewGrou
return container;
}

@NonNull
@Nullable
protected View onCreateBackground(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
if (getConfig().mBackgroundView != null) {
ViewGroup backgroundParent = (ViewGroup) getConfig().mBackgroundView.getParent();
Expand Down Expand Up @@ -346,7 +346,9 @@ protected FrameLayout.LayoutParams generateContentDefaultLayoutParams() {

@Override
protected void fitDecorInsets(@NonNull Rect insets) {
Utils.setViewPadding(getViewHolder().getContentWrapper(), insets);
if (getConfig().mFitInsets) {
Utils.setViewPadding(getViewHolder().getContentWrapper(), insets);
}
if (getConfig().mAvoidStatusBar) {
int paddingTop = getViewHolder().getContentWrapper().getPaddingTop();
int statusBarHeight = Utils.getStatusBarHeightIfVisible(getActivity());
Expand Down Expand Up @@ -618,6 +620,17 @@ public DialogLayer setBackgroundColorRes(@ColorRes int colorRes) {
return this;
}

/**
* 设置是否避开页面内边距
*
* @param fitInsets 设置是否避开页面内边距
*/
@NonNull
public DialogLayer setFitInsets(boolean fitInsets) {
getConfig().mFitInsets = fitInsets;
return this;
}

/**
* 设置避开状态栏
*
Expand Down Expand Up @@ -845,6 +858,7 @@ protected static class Config extends DecorLayer.Config {

protected boolean mCancelableOnTouchOutside = true;

protected boolean mFitInsets = true;
protected boolean mAvoidStatusBar = false;

protected int mGravity = Gravity.NO_GRAVITY;
Expand Down

0 comments on commit 3be6a77

Please sign in to comment.