Skip to content

Commit 3be6a77

Browse files
committed
feat(layer-dialog): DialogLayer支持全屏模式
DialogLayer支持全屏模式,可以通过setFitInsets方法打开。 Closes #13
1 parent fbc718d commit 3be6a77

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

layer-dialog-ktx/src/main/java/per/goweii/layer/dialog/ktx/DialogLayer.kt

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ fun <T : DialogLayer> T.avoidStatusBar(enable: Boolean) = this.apply {
3636
this.setAvoidStatusBar(enable)
3737
}
3838

39+
fun <T : DialogLayer> T.fitInsets(fitInsets: Boolean) = this.apply {
40+
this.setFitInsets(fitInsets)
41+
}
42+
3943
fun <T : DialogLayer> T.gravity(gravity: Int) = this.apply {
4044
this.setGravity(gravity)
4145
}

layer-dialog/src/main/java/per/goweii/layer/dialog/DialogLayer.java

+16-2
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ protected View onCreateChild(@NonNull LayoutInflater inflater, @NonNull ViewGrou
160160
return container;
161161
}
162162

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

347347
@Override
348348
protected void fitDecorInsets(@NonNull Rect insets) {
349-
Utils.setViewPadding(getViewHolder().getContentWrapper(), insets);
349+
if (getConfig().mFitInsets) {
350+
Utils.setViewPadding(getViewHolder().getContentWrapper(), insets);
351+
}
350352
if (getConfig().mAvoidStatusBar) {
351353
int paddingTop = getViewHolder().getContentWrapper().getPaddingTop();
352354
int statusBarHeight = Utils.getStatusBarHeightIfVisible(getActivity());
@@ -618,6 +620,17 @@ public DialogLayer setBackgroundColorRes(@ColorRes int colorRes) {
618620
return this;
619621
}
620622

623+
/**
624+
* 设置是否避开页面内边距
625+
*
626+
* @param fitInsets 设置是否避开页面内边距
627+
*/
628+
@NonNull
629+
public DialogLayer setFitInsets(boolean fitInsets) {
630+
getConfig().mFitInsets = fitInsets;
631+
return this;
632+
}
633+
621634
/**
622635
* 设置避开状态栏
623636
*
@@ -845,6 +858,7 @@ protected static class Config extends DecorLayer.Config {
845858

846859
protected boolean mCancelableOnTouchOutside = true;
847860

861+
protected boolean mFitInsets = true;
848862
protected boolean mAvoidStatusBar = false;
849863

850864
protected int mGravity = Gravity.NO_GRAVITY;

0 commit comments

Comments
 (0)