'Direction, choose between "LEFT" "TOP" "RIGHT" "BOTTOM"
Public Sub PrepareTransition_Swipe(Xui As XUI, RootWidth As Float, RootHeight As Float, CurrentPageRoot As B4XView, NewPageRoot As B4XView, Direction As String) As ResumableSub
Dim pnl As B4XView = Xui.CreatePanel("")
Dim pnl2 As B4XView = Xui.CreatePanel("")
NewPageRoot.AddView(pnl, 0, 0, RootWidth, RootHeight)
NewPageRoot.AddView(pnl2, RootWidth, RootHeight, RootWidth, RootHeight) 'put the panel outside the screen
pnl.As(Panel).Elevation = 10dip
pnl2.As(Panel).Elevation = 12dip
Dim cnv, cnv2 As B4XCanvas
cnv.Initialize(pnl)
Dim backBmp As B4XBitmap = CurrentPageRoot.Snapshot
cnv.ClearRect(cnv.TargetRect)
cnv.DrawBitmap(backBmp,getRect(0,0,RootWidth,RootHeight))
cnv.Invalidate
pnl.Visible = False 'we need to hide pnl so the snapshot of nextpage will not include it
cnv2.Initialize(pnl2)
Dim backBmp2 As B4XBitmap = NewPageRoot.Snapshot
cnv2.ClearRect(cnv2.TargetRect)
cnv2.DrawBitmap(backBmp2,getRect(0,0,RootWidth,RootHeight))
cnv2.Invalidate
pnl.Visible = True 'now we can show it again
pnl2.BringToFront
Select Direction.ToUpperCase
Case "LEFT"
pnl2.Left = RootWidth
pnl2.Top = 0
pnl.SetLayoutAnimated(400,-RootWidth,0,pnl.Width,pnl.Height)
Case "TOP"
pnl2.Left = 0
pnl2.Top = RootHeight
pnl.SetLayoutAnimated(400,0,-RootHeight,pnl.Width,pnl.Height)
Case "BOTTOM"
pnl2.Left = 0
pnl2.Top = -RootHeight
pnl.SetLayoutAnimated(400,0,RootHeight,pnl.Width,pnl.Height)
Case "RIGHT"
pnl2.Left = -RootWidth
pnl2.Top = 0
pnl.SetLayoutAnimated(400,RootWidth,0,pnl.Width,pnl.Height)
End Select
pnl2.SetLayoutAnimated(400,0,0,pnl2.Width,pnl2.Height)
Sleep(400)
pnl.RemoveViewFromParent
pnl2.RemoveViewFromParent
Return True
End Sub