Sub Class_Globals
Private Root As B4XView 'ignore
Private xui As XUI 'ignore
Private overlay As B4XView
Private edtSelectPlan As EditText
Private pnlDimBackground As B4XView
Private pnlBottomSheet As B4XView
Private lblPlan1, lblPlan2, lblPlan3 As Label
End Sub
Public Sub Initialize
' B4XPages.GetManager.LogEvents = True
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage") ' Load the main layout
pnlDimBackground = xui.CreatePanel("")
pnlDimBackground.SetColorAndBorder(xui.Color_ARGB(120, 0, 0, 0), 0, 0, 0)
pnlDimBackground.Visible = False
Root.AddView(pnlDimBackground, 0, 0, 100%x, 100%y)
pnlBottomSheet = xui.CreatePanel("")
pnlBottomSheet.SetColorAndBorder(xui.Color_White, 0, 0, 0)
pnlBottomSheet.Visible = False
Root.AddView(pnlBottomSheet, 0, 100%y, 100%x, 40%y) ' Initially off-screen
lblPlan1.Initialize("lblPlan")
lblPlan1.Text = "Plan 1"
lblPlan1.Gravity = Gravity.CENTER
lblPlan1.TextSize = 18
pnlBottomSheet.AddView(lblPlan1, 0, 5%y, 100%x, 10%y)
lblPlan2.Initialize("lblPlan")
lblPlan2.Text = "Plan 2"
lblPlan2.Gravity = Gravity.CENTER
lblPlan2.TextSize = 18
pnlBottomSheet.AddView(lblPlan2, 0, 16%y, 100%x, 10%y)
lblPlan3.Initialize("lblPlan")
lblPlan3.Text = "Plan 3"
lblPlan3.Gravity = Gravity.CENTER
lblPlan3.TextSize = 18
pnlBottomSheet.AddView(lblPlan3, 0, 27%y, 100%x, 10%y)
edtSelectPlan.Initialize("edtSelectPlan")
Root.AddView(edtSelectPlan, 50dip, 100dip, 120dip, 40dip)
edtSelectPlan.Text = ""
edtSelectPlan.Hint = "Click to select a plan"
edtSelectPlan.InputType = Bit.Or(edtSelectPlan.INPUT_TYPE_NONE, 0)
End Sub
Private Sub edtSelectPlan_Click
ShowBottomSheet
End Sub
Private Sub lblPlan_Click
Dim lbl As Label = Sender
edtSelectPlan.Text = lbl.Text
HideBottomSheet
End Sub
Private Sub ShowBottomSheet
pnlDimBackground.Visible = True
pnlDimBackground.BringToFront
pnlBottomSheet.Visible = True
pnlBottomSheet.BringToFront
pnlBottomSheet.SetLayoutAnimated(300, 0, 60%y, 100%x, 40%y) ' Move to visible position
End Sub
Private Sub HideBottomSheet
pnlBottomSheet.SetLayoutAnimated(300, 0, 100%y, 100%x, 40%y)
Sleep(300) ' Wait for the animation to complete
pnlDimBackground.Visible = False
pnlBottomSheet.Visible = False
End Sub