iOS Question [SOLVED] Combination of CLV + Drawer(sidemenu) + CLVswipe don‘t work

mike2ppc

Member
Licensed User
Longtime User
Hello,

could someone please support me with a working b4i example
with a combination of these elements on one page ?
CustomListView + CLVswipe + Drawer(SideMenu)

See my try in attached file.
In my test app the CLV and Swipe combination works when i commend out these lines.

B4X:
    Drawer.Initialize(Me, "drawer", Page1.RootPanel, 300dip)
    Drawer.CenterPanel.LoadLayout("Page1")
    Drawer.LeftPanel.LoadLayout("pgleftsidemenu")
    Dim bb As BarButton
    bb.InitializeBitmap(LoadBitmapResize(File.DirAssets, "hamburger.png", 32dip, 32dip, True), "hamburger")
    Page1.TopLeftButtons = Array(bb)
    clvLeftSideMenu.AddTextItem("Menu Entry 1",0)
    clvLeftSideMenu.AddTextItem("Menu Entry 2",1)
    clvLeftSideMenu.AddTextItem("Menu Entry 3",2)
    clvLeftSideMenu.AddTextItem("Menu Entry 4",3)

I'm in my own way right now. Perhaps someone have me a hint.

Best Regards and thanks in advance

Michael

Here the complete Code in the post.

B4X:
'Code module
#Region  Project Attributes
    #ApplicationLabel: B4i Example
    #Version: 1.0.0
    'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
    #iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
    #iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
    #Target: iPhone, iPad
    #ATSEnabled: True
    #MinVersion: 8
#End Region

Sub Process_Globals
    Public App As Application
    Public NavControl As NavigationController
    Private Page1 As Page
    Private xui As XUI
    Private swipe As CLVSwipe
    Private lblPullToRefresh As B4XView
    Private ProgressBar1 As B4XView
    Private clv1 As CustomListView
    Private clvLeftSideMenu As CustomListView
    Private Drawer As B4XDrawer
End Sub

Private Sub Application_Start (Nav As NavigationController)
    NavControl = Nav
    Page1.Initialize("Page1")
    Page1.RootPanel.LoadLayout("Page1")
    NavControl.ShowPage(Page1)
    Wait For Page1_Resize(Width As Int, Height As Int)
    swipe.Initialize(clv1, Me, "swipe")
    swipe.ActionColors = CreateMap("Delete": xui.Color_Red, "Do Something Else": xui.Color_Green, _
        "Action 1": xui.Color_Red, "Action 2": xui.Color_Blue, "Action 3": xui.Color_Yellow)
    Dim PullToRefreshPanel As B4XView = xui.CreatePanel("")
    PullToRefreshPanel.SetLayoutAnimated(0, 0, 0, 100%x, 70dip)
    PullToRefreshPanel.LoadLayout("PullToRefresh")
    swipe.PullToRefreshPanel = PullToRefreshPanel
    Drawer.Initialize(Me, "drawer", Page1.RootPanel, 300dip)
    Drawer.CenterPanel.LoadLayout("Page1")
    Drawer.LeftPanel.LoadLayout("pgleftsidemenu")
    Dim bb As BarButton
    bb.InitializeBitmap(LoadBitmapResize(File.DirAssets, "hamburger.png", 32dip, 32dip, True), "hamburger")
    Page1.TopLeftButtons = Array(bb)
    clvLeftSideMenu.AddTextItem("Menu Entry 1",0)
    clvLeftSideMenu.AddTextItem("Menu Entry 2",1)
    clvLeftSideMenu.AddTextItem("Menu Entry 3",2)
    clvLeftSideMenu.AddTextItem("Menu Entry 4",3)
    fillclv
End Sub

Sub fillclv
    clv1.AddTextItem("Row 1", swipe.CreateItemValue("", Array("Delete", "Do Something Else")))
    clv1.AddTextItem("Row 2", swipe.CreateItemValue("", Array("Delete", "Do Something Else")))
    clv1.AddTextItem("Row 3", swipe.CreateItemValue("", Array("Delete", "Do Something Else")))
    clv1.Add(clv1_CreateItem,swipe.CreateItemValue("", Array("Delete", "Duplizieren")))
    clv1.Add(clv1_CreateItem,swipe.CreateItemValue("", Array("Delete", "Duplizieren")))
    Dim ClvSize As Int = clv1.Size
    XUIViewsUtils.AddStubToCLVIfNeeded(clv1, clv1.DefaultTextBackgroundColor)
    If clv1.Size > ClvSize Then
        clv1.ResizeItem(clv1.Size - 1, clv1.GetPanel(clv1.Size - 1).Height + 20dip)
    End If
End Sub


Sub clv1_CreateItem() As B4XView
    Dim varPanel As B4XView = xui.CreatePanel(""), varColor As Int
    varPanel.LoadLayout("line")
    varPanel.Height = 80
    Return varPanel
End Sub

Private Sub Page1_Resize(Width As Int, Height As Int)
  
End Sub


Sub clv1_ItemClick (Index As Int, Value As Object)
    swipe.CloseLastSwiped
End Sub

Sub clv1_ScrollChanged (Offset As Int)
    If xui.IsB4i Then
        swipe.ScrollChanged(Offset)
    End If
    swipe.CloseLastSwiped
End Sub


Sub swipe_ActionClicked (Index As Int, ActionText As String)
    Log($"Action clicked: ${Index}, ${ActionText}"$)
    If ActionText = "Delete" Then
        clv1.RemoveAt(Index)
    Else If ActionText = "Do Something Else" Then
        Dim p As B4XView = clv1.GetPanel(Index)
        Dim lbl As B4XView = p.GetView(0)
        lbl.Text = "Done!!!"
    End If
End Sub

Sub swipe_RefreshRequested
    lblPullToRefresh.Text = "Loading..."
    ProgressBar1.Visible = True
    Sleep(3000)
    clv1.Clear
    fillclv
    swipe.RefreshCompleted
    lblPullToRefresh.Text = "Pull to refresh"
    ProgressBar1.Visible = False
End Sub
 

Attachments

  • testCLVDrawerSwipe.zip
    174.9 KB · Views: 231
Last edited:

mike2ppc

Member
Licensed User
Longtime User
Update: SideBar (Drawer) now works, I've forgotten some code snips.
But the combination with CLVswipe still doesn't work, maybe someone has a hint ?
 

Attachments

  • testCLVDrawerSwipe.zip
    176.3 KB · Views: 234
Upvote 0
Top