Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit aa15af8

Browse filesBrowse files
committed
fix(android): custom animation android.style for showModal
1 parent a91cd15 commit aa15af8
Copy full SHA for aa15af8

File tree

Expand file treeCollapse file tree

4 files changed

+31
-24
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+31
-24
lines changed

‎packages/core/ui/core/view-base/index.d.ts

Copy file name to clipboardExpand all lines: packages/core/ui/core/view-base/index.d.ts
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ export interface ShowModalOptions {
9696
* For possible values see https://developer.android.com/reference/android/view/WindowManager.LayoutParams#softInputMode
9797
*/
9898
windowSoftInputMode?: number;
99+
/**
100+
* An optional parameter specifying the style of the dialog window
101+
*/
102+
style?: number;
99103
};
100104
/**
101105
* An optional parameter specifying whether the modal view can be dismissed when not in full-screen mode.

‎packages/core/ui/core/view-base/index.ts

Copy file name to clipboardExpand all lines: packages/core/ui/core/view-base/index.ts
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ export interface ShowModalOptions {
106106
*/
107107
windowSoftInputMode?: number;
108108

109+
/**
110+
* An optional parameter specifying the style of the dialog window.
111+
*/
112+
style?: number;
113+
109114
/**
110115
* An optional parameter to force show the modal from background. If used then you dont get android state save mechanism
111116
* if not used then the modal showing is delayed until the app is in foreground again

‎packages/core/ui/core/view/index.android.ts

Copy file name to clipboardExpand all lines: packages/core/ui/core/view/index.android.ts
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ interface DialogOptions {
6969
animated: boolean;
7070
stretched: boolean;
7171
cancelable: boolean;
72-
windowSoftInputMode: number;
72+
windowSoftInputMode?: number;
73+
style?: number;
7374
shownCallback: () => void;
7475
dismissCallback: () => void;
7576
}
@@ -168,6 +169,7 @@ function initializeDialogFragment() {
168169
public showImmediatelyFromBackground: boolean;
169170
private _fullscreen: boolean;
170171
private _windowSoftInputMode: number;
172+
private _animationStyle: number;
171173
private _animated: boolean;
172174
private _stretched: boolean;
173175
private _cancelable: boolean;
@@ -203,6 +205,7 @@ function initializeDialogFragment() {
203205
this._dismissCallback = options.dismissCallback;
204206
this._shownCallback = options.shownCallback;
205207
this._windowSoftInputMode = options.windowSoftInputMode;
208+
this._animationStyle = options.style;
206209
this.setStyle(androidx.fragment.app.DialogFragment.STYLE_NO_TITLE, 0);
207210

208211
let theme = this.getTheme();
@@ -226,8 +229,9 @@ function initializeDialogFragment() {
226229

227230
// set the modal window animation
228231
// https://github.com/NativeScript/NativeScript/issues/5989
232+
console.log('setWindowAnimations', this._animationStyle, styleAnimationDialog);
229233
if (this._animated) {
230-
dialog.getWindow().setWindowAnimations(styleAnimationDialog);
234+
dialog.getWindow().setWindowAnimations(this._animationStyle ?? styleAnimationDialog);
231235
}
232236

233237
dialog.setCanceledOnTouchOutside(this._cancelable);
@@ -267,7 +271,8 @@ function initializeDialogFragment() {
267271
const window = this.getDialog().getWindow();
268272
const length = android.view.ViewGroup.LayoutParams.MATCH_PARENT;
269273
// set the animations to use on showing and hiding the dialog
270-
window.setWindowAnimations(16973826); //android.R.style.Animation_Dialog
274+
// window.setWindowAnimations(16973826); //android.R.style.Animation_Dialog
275+
window.setWindowAnimations(this._animationStyle ?? 16973826 /* android.R.style.Animation_Dialog */);
271276
window.setLayout(length, length);
272277
// This removes the default backgroundDrawable so there are no margins.
273278
window.setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(android.graphics.Color.WHITE));
@@ -742,19 +747,14 @@ export class View extends ViewCommon {
742747
df.setArguments(args);
743748

744749
const cancelable = options.cancelable !== undefined ? !!options.cancelable : true;
745-
let windowSoftInputMode: number;
746-
747-
if (options.android) {
748-
windowSoftInputMode = (<any>options).android.windowSoftInputMode;
749-
}
750750

751751
const dialogOptions: DialogOptions = {
752752
owner: this,
753753
fullscreen: !!options.fullscreen,
754754
animated: !!options.animated,
755755
stretched: !!options.stretched,
756756
cancelable: cancelable,
757-
windowSoftInputMode: windowSoftInputMode,
757+
...(options?.android || {}),
758758
shownCallback: () => this._raiseShownModallyEvent(),
759759
dismissCallback: () => this.closeModal(),
760760
};

‎packages/core/ui/transition/page-transition.android.ts

Copy file name to clipboardExpand all lines: packages/core/ui/transition/page-transition.android.ts
+13-15Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -284,21 +284,19 @@ export class PageTransition extends Transition {
284284
}
285285
}
286286
onTransitionEnd(entry) {
287-
if (__ANDROID__) {
288-
// as we use hide on fragments instead of remove
289-
// we need to reset setTransitionName after transition end
290-
// otherwise it will break next transitions using the same transitionName
291-
const fromPage = entry?.resolvedPage;
292-
const { presenting } = SharedTransition.getSharedElements(fromPage, null);
293-
presenting.forEach((v) => {
294-
setTransitionName(v, null);
295-
// androidx.transition.ChangeTransform does not restore setTransitionAlpha
296-
// which makes the view invisible.
297-
// can be a problem when the transition view on the return animation is not the same as enter
298-
// one example is RecyclerView to ViewPager transition
299-
(v.nativeViewProtected as android.view.View).setTransitionAlpha(1);
300-
});
301-
}
287+
// as we use hide on fragments instead of remove
288+
// we need to reset setTransitionName after transition end
289+
// otherwise it will break next transitions using the same transitionName
290+
const fromPage = entry?.resolvedPage;
291+
const { presenting } = SharedTransition.getSharedElements(fromPage, null);
292+
presenting.forEach((v) => {
293+
setTransitionName(v, null);
294+
// androidx.transition.ChangeTransform does not restore setTransitionAlpha
295+
// which makes the view invisible.
296+
// can be a problem when the transition view on the return animation is not the same as enter
297+
// one example is RecyclerView to ViewPager transition
298+
(v.nativeViewProtected as android.view.View).setTransitionAlpha(1);
299+
});
302300
}
303301
}
304302

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.