@@ -13,6 +13,14 @@ public enum CardPosition
1313 Center
1414 }
1515
16+ public enum EdgePosition
17+ {
18+ Left ,
19+ Right ,
20+ Top ,
21+ Bottom
22+ }
23+
1624 /// <summary>
1725 /// Card page. Based on custom transitions
1826 /// </summary>
@@ -103,12 +111,6 @@ public CardPage()
103111
104112 _layout . Children . Add ( _contentView , ( ) => this . LayerPosition ) ;
105113
106- if ( _platformHelper . ControlAnimatesItself )
107- {
108- _shadowLayer . TranslationY = _platformHelper . GetScreenSize ( ) . Height - ( CardPadding . Top ) ;
109- _contentView . TranslationY = _platformHelper . GetScreenSize ( ) . Height - ( CardPadding . Top ) ;
110- }
111-
112114 // Add tap
113115 _overlay . GestureRecognizers . Add ( new TapGestureRecognizer
114116 {
@@ -251,6 +253,51 @@ public CardPosition Position
251253 }
252254 }
253255
256+ private EdgePosition _edge = EdgePosition . Bottom ;
257+ public EdgePosition Edge
258+ {
259+ get { return _edge ; }
260+ set
261+ {
262+ if ( _edge == value ) return ;
263+ _edge = value ;
264+
265+ if ( _platformHelper . ControlAnimatesItself )
266+ {
267+ switch ( Edge )
268+ {
269+ case EdgePosition . Top :
270+ _shadowLayer . TranslationX = 0 ;
271+ _contentView . TranslationX = 0 ;
272+ _shadowLayer . TranslationY = 0 - _platformHelper . GetScreenSize ( ) . Height + ( CardPadding . Bottom ) ;
273+ _contentView . TranslationY = 0 - _platformHelper . GetScreenSize ( ) . Height + ( CardPadding . Bottom ) ;
274+ break ;
275+ case EdgePosition . Bottom :
276+ _shadowLayer . TranslationX = 0 ;
277+ _contentView . TranslationX = 0 ;
278+ _shadowLayer . TranslationY = _platformHelper . GetScreenSize ( ) . Height - ( CardPadding . Top ) ;
279+ _contentView . TranslationY = _platformHelper . GetScreenSize ( ) . Height - ( CardPadding . Top ) ;
280+ break ;
281+ case EdgePosition . Left :
282+ _shadowLayer . TranslationX = 0 - _platformHelper . GetScreenSize ( ) . Width + ( CardPadding . Right ) ;
283+ _contentView . TranslationX = 0 - _platformHelper . GetScreenSize ( ) . Width + ( CardPadding . Right ) ;
284+ _shadowLayer . TranslationY = 0 ;
285+ _contentView . TranslationY = 0 ;
286+ break ;
287+ case EdgePosition . Right :
288+ _shadowLayer . TranslationX = _platformHelper . GetScreenSize ( ) . Width - ( CardPadding . Left ) ;
289+ _contentView . TranslationX = _platformHelper . GetScreenSize ( ) . Width - ( CardPadding . Left ) ;
290+ _shadowLayer . TranslationY = 0 ;
291+ _contentView . TranslationY = 0 ;
292+ break ;
293+ default :
294+ throw new ArgumentException ( nameof ( Position ) ) ;
295+ }
296+ }
297+
298+ }
299+ }
300+
254301 private Thickness _cardPadding ;
255302 public Thickness CardPadding
256303 {
@@ -292,18 +339,32 @@ public virtual Task ShowAsync()
292339 public virtual async Task CloseAsync ( )
293340 {
294341 if ( _platformHelper . ControlAnimatesItself ) {
342+ var tasks = new Task [ 3 ] ;
343+ switch ( Edge )
344+ {
345+ case EdgePosition . Top :
346+ tasks [ 0 ] = _shadowLayer . TranslateTo ( 0.0 , 0 - _platformHelper . GetScreenSize ( ) . Height + ( CardPadding . Bottom ) , 250 , Easing . CubicInOut ) ;
347+ tasks [ 1 ] = _contentView . TranslateTo ( 0.0 , 0 - _platformHelper . GetScreenSize ( ) . Height + ( CardPadding . Bottom ) , 250 , Easing . CubicInOut ) ;
348+ break ;
349+ case EdgePosition . Bottom :
350+ tasks [ 0 ] = _shadowLayer . TranslateTo ( 0.0 , _platformHelper . GetScreenSize ( ) . Height - ( CardPadding . Top ) , 250 , Easing . CubicInOut ) ;
351+ tasks [ 1 ] = _contentView . TranslateTo ( 0.0 , _platformHelper . GetScreenSize ( ) . Height - ( CardPadding . Top ) , 250 , Easing . CubicInOut ) ;
352+ break ;
353+ case EdgePosition . Left :
354+ tasks [ 0 ] = _shadowLayer . TranslateTo ( 0 - _platformHelper . GetScreenSize ( ) . Width + ( CardPadding . Right ) , 0.0 , 250 , Easing . CubicInOut ) ;
355+ tasks [ 1 ] = _contentView . TranslateTo ( 0 - _platformHelper . GetScreenSize ( ) . Width + ( CardPadding . Right ) , 0.0 , 250 , Easing . CubicInOut ) ;
356+ break ;
357+ case EdgePosition . Right :
358+ tasks [ 0 ] = _shadowLayer . TranslateTo ( _platformHelper . GetScreenSize ( ) . Width - ( CardPadding . Left ) , 0.0 , 250 , Easing . CubicInOut ) ;
359+ tasks [ 1 ] = _contentView . TranslateTo ( _platformHelper . GetScreenSize ( ) . Width - ( CardPadding . Left ) , 0.0 , 250 , Easing . CubicInOut ) ;
360+ break ;
361+ default :
362+ throw new ArgumentException ( nameof ( Edge ) ) ;
363+ }
295364
296- #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
297- _shadowLayer . TranslateTo ( 0.0 ,
298-
299- #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
300- _platformHelper . GetScreenSize ( ) . Height - ( CardPadding . Top ) , 250 , Easing . CubicInOut ) ;
301-
302- await _contentView . TranslateTo ( 0.0 ,
303- _platformHelper . GetScreenSize ( ) . Height - ( CardPadding . Top ) , 250 , Easing . CubicInOut ) ;
304-
305- await _overlay . FadeTo ( 0.0F , 150 , Easing . CubicInOut ) ;
365+ tasks [ 2 ] = _overlay . FadeTo ( 0.0F , 150 , Easing . CubicInOut ) ;
306366
367+ await Task . WhenAll ( tasks ) ;
307368 }
308369
309370 await _platformHelper . CloseAsync ( this ) ;
0 commit comments