@@ -53,26 +53,34 @@ export class SnackBar extends SnackBarBase {
53
53
attachView = attachView [ '_modal' ] ;
54
54
}
55
55
const page = ( attachView instanceof Page ? attachView : attachView . page ) ;
56
- let nView = ( page . nativeViewProtected as android . view . View ) . getParent ( ) . getParent ( ) as any ;
56
+ let nView = ( page . nativeViewProtected as android . view . View ) . getParent ( ) ;
57
+ if ( page . hasActionBar ) {
58
+ nView = nView . getParent ( ) ;
59
+ }
57
60
let nCoordinatorLayout : androidx . coordinatorlayout . widget . CoordinatorLayout = ( page as any ) . nCoordinatorLayout ;
58
61
if ( ! nCoordinatorLayout && ! ( nView instanceof androidx . coordinatorlayout . widget . CoordinatorLayout ) && nView instanceof android . view . ViewGroup ) {
59
62
nCoordinatorLayout = new androidx . coordinatorlayout . widget . CoordinatorLayout ( attachView . _context ) ;
60
63
61
64
if ( options . view ) {
62
65
const nAttachedView = options . view . nativeViewProtected as android . view . View ;
63
66
const params = new android . widget . FrameLayout . LayoutParams ( nAttachedView . getWidth ( ) , nAttachedView . getHeight ( ) ) ;
64
- params . topMargin = Utils . layout . toDevicePixels ( options . view . getLocationRelativeTo ( page ) . y ) ;
67
+ const myArray = ( Array ) . create ( 'int' , 2 ) ;
68
+ nView . getLocationOnScreen ( myArray ) ;
69
+ const otherArray = ( Array ) . create ( 'int' , 2 ) ;
70
+ options . view . nativeViewProtected . getLocationOnScreen ( otherArray ) ;
71
+
72
+ params . topMargin = otherArray [ 1 ] - myArray [ 1 ] ;
65
73
( nView as any ) . addView ( nCoordinatorLayout , params ) ;
66
74
} else {
67
75
( nView as any ) . addView ( nCoordinatorLayout , new android . view . ViewGroup . LayoutParams ( android . view . ViewGroup . LayoutParams . MATCH_PARENT , android . view . ViewGroup . LayoutParams . MATCH_PARENT ) ) ;
68
76
}
69
77
70
78
nView = nCoordinatorLayout ;
71
79
}
72
- this . _snackbar = com . google . android . material . snackbar . Snackbar . make ( nView , options . message , options . hideDelay ) ;
80
+ this . _snackbar = com . google . android . material . snackbar . Snackbar . make ( nView as any , options . message , options . hideDelay ) ;
73
81
74
- this . _snackbar . setText ( options . message ) ;
75
- this . _snackbar . setDuration ( options . hideDelay ) ;
82
+ // this._snackbar.setText(options.message);
83
+ // this._snackbar.setDuration(options.hideDelay);
76
84
77
85
// set text color of the TextView in the Android SnackBar
78
86
if ( options . textColor && Color . isValid ( options . textColor ) ) {
@@ -159,7 +167,9 @@ export class SnackBar extends SnackBarBase {
159
167
}
160
168
} ,
161
169
162
- onShown ( snackbar : com . google . android . material . snackbar . Snackbar ) { } ,
170
+ onShown ( snackbar : com . google . android . material . snackbar . Snackbar ) {
171
+
172
+ } ,
163
173
} ) ;
164
174
cb . setListener ( callbackListener ) ;
165
175
( cb as any ) . nListener = callbackListener ; // handles the resolve of the promise
0 commit comments