B4A Class [B4X] [XUI] AS Bottom Menu V2

Discussion in 'Additional libraries, classes and official updates' started by Alexander Stolte, Feb 20, 2019.

  1. RWK

    RWK Member Licensed User

    Hallo Alex,

    the redirection of the Click Events for the Events Tab1Click to Tab5Click are still missing.

    For the MiddleButton Clicks you are doing it in the asbuttonmenu.bas
    Code:
    Private Sub middle_button_click_handler
        
        
    If xui.SubExists(mCallBack, mEventName & "_MiddleButtonClick",0Then
            
    CallSub(mCallBack, mEventName & "_MiddleButtonClick")
        
    End If
        
    End Sub
    But in the Tab Click Handler they are missing

    Code:
    Private Sub tab_1_MouseClicked (EventData As MouseEvent)
        
        
        tab_1_handler(
    True,250,150)
            
    End Sub
    Code:
    'this is missing for Event Tab1Click to Tab5Click in Tab_x_Mouseclicked or in the tab_x_handler

        
    If xui.SubExists(mCallBack, mEventName & "_Tab1Click",0Then
            
    CallSub(mCallBack, mEventName & "_Tab1Click")
        
    End If
    Grüße
    Rainer
     
  2. Alexander Stolte

    Alexander Stolte Well-Known Member Licensed User

    Fixed, thanks.

    - V2.3
    • Fix TabClick Event
     
  3. Brandsum

    Brandsum Active Member Licensed User

    mcqueccu and asales like this.
  4. Alberto Iglesias

    Alberto Iglesias Well-Known Member Licensed User

    wooowww this is great! i will test right now


    thank youuuuu
     
  5. itgirl

    itgirl Active Member Licensed User

    Amazing class thanks, i just found a little bug if you enable EnableMiddleButtonAsTab and you click on already active tab the underline get little messy the solution i found is in underline_slide_animation_withtext_2

    Code:
    If enable_middlebutton_astab = True Then
                
    Dim tmp As Double = xpnl_underline.Left - totab.Left  - 40dip/4
            
    Else
                
    Dim tmp As Double = xpnl_underline.Left - totab.Left  - 40dip/2
            
    End If
    amazing work with calculations by the way ;)
     
    Alexander Stolte likes this.
  6. oparra

    oparra New Member Licensed User

    if you want to see the halo effect on the middle button

    Code:
    Private Sub Middle_Button_Click_Handler
        
    If xui.SubExists(mCallBack, mEventName & "_MiddleButtonClick",0Then
            
    CallSub(mCallBack, mEventName & "_MiddleButtonClick")
        
    End If
        RippleEffect(PanelMiddlebutton, Ripple_Effect_Color, 
    250)
    End Sub
    Code:
    'https://www.b4x.com/android/forum/threads/b4x-xui-simple-halo-animation.80267/#content
    Private Sub RippleEffect (Parent As B4XView, Color As Int, Duration As Int)
        
    Dim cvs As B4XCanvas
        
    Dim p As B4XView = xui.CreatePanel("")
        
    Dim InnerRadius As Int = Parent.Height * 1.30
        
    If Parent.Width <> Parent.Height Then InnerRadius = Max(Parent.Width, Parent.Height) * 1.60
        p.SetLayoutAnimated(
    000, InnerRadius, InnerRadius)
        cvs.Initialize(p)
        cvs.DrawCircle(cvs.TargetRect.CenterX, cvs.TargetRect.CenterY, cvs.TargetRect.Width / 
    2, Color, True0)
        
    Dim bmp As B4XBitmap = cvs.CreateBitmap
        p.RemoveViewFromParent
        
    Dim iv As ImageView
        iv.Initialize(
    "")
        
    Dim p As B4XView = iv
        
    Dim Radius As Int = InnerRadius/2
        
    Dim x As Int = Parent.Width/2
        
    Dim y As Int = Parent.Height/2
        p.SetBitmap(bmp)
        Parent.AddView(p, x, y, 
    00)
        p.SetLayoutAnimated(Duration, x - Radius, y - Radius, Radius * 
    2, Radius * 2)
        p.SetVisibleAnimated(Duration, 
    False)
        Sleep(Duration)
        p.RemoveViewFromParent
    End Sub
     
  7. AllanH

    AllanH Member Licensed User

    Great bottom tab

    However, changing the current tab in code does not change the current tab visually.
    I've amended the code below to call the relevant click but this is a bit untidy and could probably be better written.


    Code:
    Public Sub setCurrentTab(tabnumber As Int)
      
        
    If tabnumber = 1 Or tabnumber = 2 Or tabnumber = 3 Or tabnumber = 4 Or tabnumber = 5 Then
          
            
    If current_tab <> tabnumber Then
              current_tab = tabnumber
          
          
    'extra code below:
          Select tabnumber
              
    Case 1
                    tab_1_Click   
              
    Case 2
                    tab_2_Click
                
    Case 3
                    tab_3_Click
                
    Case 4
                  tab_4_Click     
                
    Case 5
                    tab_5_Click
            
    End Select
            
    End If
          
            
    Else
              
                
    Log("Tab Number not in range")
          
        
    End If
      
    End Sub
     
  8. Alberto Iglesias

    Alberto Iglesias Well-Known Member Licensed User

    Hello Alexander,

    I tried to use setMiddleButtonSize but have no effect (i'm using on iOS) like this: Because the button middle is too big

    Code:
    ASBottomMenu1.setMiddleButtonSize(20dip,2dip)
    Do you have any sample?

    thank you!
     
  9. Alexander Stolte

    Alexander Stolte Well-Known Member Licensed User

    I see it, the issue is in the Base_Resize Sub, i fix it.
    I add a private global variable for the middle button size, this should fix the issue.

    Can you try it now? i cant test it with B4I, because my Apple Dev. account has expired for 2 months.

    V2.5
    • Fix setMiddleButtonSize is not working
     
  10. Alberto Iglesias

    Alberto Iglesias Well-Known Member Licensed User

    Perfect! I will test right now! thank you
     
  11. Kope

    Kope Member Licensed User

    hi Please the TabChange (CurrentTab as int) event is not responding in b4i

    please any help?
     
  12. Gabino A. de la Gala

    Gabino A. de la Gala Active Member Licensed User

    I had problems with the SetCurrentTab and finally I solved it by modifying one of the procedures.

    Here I leave it.

    Code:
    Public Sub setCurrentTab(tabnumber As Int)
            
    Select Case tabnumber
                
    Case 1
                    tab_1_handler(
    True,250,150)
                    current_tab = tabnumber
                
    Case 2
                    tab_2_handler(
    True,250,150)
                    current_tab = tabnumber
                
    Case 3
                    tab_3_handler(
    True,250,150)
                    current_tab = tabnumber
                
    Case 4
                    tab_4_handler(
    True,250,150)
                    current_tab = tabnumber
                
    Case 5
                    tab_5_handler(
    True,250,150)
                    current_tab = tabnumber
                
    Case Else
                    
    Log("Tab Number not in range")
            
    End Select
    End Sub
    I suppose that in later versions I can solve it in a more appropriate way.

    A greeting.
     
    Alexander Stolte likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice