[MobileUI] Change buttons size to "large" and more...

Share your advanced knowledge/code with the community.
User avatar
Caronte3D
Posts: 187
Joined: Sat Nov 23, 2019 5:21 pm
Location: Some Universe

[MobileUI] Change buttons size to "large" and more...

Post by Caronte3D »

I think this kind of things should be part of the MobileUI implementation, but in the mean time, you can use workarounds like this one:

Code: Select all

If ContainerMobile(#PB_Any, #PB_Mobile_Page, "margin:8px")
  If ContainerMobile(#PB_Any, #PB_Mobile_Row, "margin:8px")
    ButtonMobile(0, "Button Small",#PB_Mobile_Right)
    ButtonMobile(1, "Button Large")    
    CloseMobileContainer()
  EndIf
  CloseMobileContainer()
EndIf

;This line does the trick and you can modify it to do more similar things:
! $('ons-button:contains("Button Large")').attr('modifier', 'large');
EDIT: viewtopic.php?p=10602#p10602
Last edited by Caronte3D on Mon Oct 14, 2024 4:48 pm, edited 1 time in total.
User avatar
Peter
Posts: 1197
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: [MobileUI] Change buttons size to "large" and more...

Post by Peter »

However, this only works if the button has a specific text.

This one is a little more flexible:

Code: Select all

If ContainerMobile(#PB_Any, #PB_Mobile_Page, "margin:8px")
  If ContainerMobile(#PB_Any, #PB_Mobile_Row, "margin:8px")
    ButtonMobile(0, "Button Small",#PB_Mobile_Right)
    
    LargeButton = ButtonMobile(1, "Hello World!")    
    ! $(v_largebutton.gadget).attr('modifier', 'large');

    CloseMobileContainer()
  EndIf
  CloseMobileContainer()
EndIf
User avatar
Caronte3D
Posts: 187
Joined: Sat Nov 23, 2019 5:21 pm
Location: Some Universe

Re: [MobileUI] Change buttons size to "large" and more...

Post by Caronte3D »

Perfect! 8-)
Thanks Peter ;)
Fred
Site Admin
Posts: 1820
Joined: Mon Feb 24, 2014 10:51 am

Re: [MobileUI] Change buttons size to "large" and more...

Post by Fred »

May be SetMobileAttribute() can work as well (not tested)
Fred
Site Admin
Posts: 1820
Joined: Mon Feb 24, 2014 10:51 am

Re: [MobileUI] Change buttons size to "large" and more...

Post by Fred »

Caronte3D wrote: Mon Oct 14, 2024 10:46 am I think this kind of things should be part of the MobileUI implementation
Actually I'm interested to know which features are missing from the wrapper, because I didn't created a real app with the UI for now, so I could have missed something useful.
User avatar
Peter
Posts: 1197
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: [MobileUI] Change buttons size to "large" and more...

Post by Peter »

Fred wrote: Mon Oct 14, 2024 2:02 pmMay be SetMobileAttribute() can work as well (not tested)
Image

Code: Select all

If ContainerMobile(#PB_Any, #PB_Mobile_Page, "margin:8px")
  If ContainerMobile(#PB_Any, #PB_Mobile_Row, "margin:8px")
    ButtonMobile(0, "Button Small",#PB_Mobile_Right)
    ButtonMobile(1, "Hello World!")    
    CloseMobileContainer()
  EndIf
  CloseMobileContainer()
EndIf

SetMobileAttribute(1, "modifier", "large") 
User avatar
Caronte3D
Posts: 187
Joined: Sat Nov 23, 2019 5:21 pm
Location: Some Universe

Re: [MobileUI] Change buttons size to "large" and more...

Post by Caronte3D »

Fred wrote: Mon Oct 14, 2024 2:02 pm May be SetMobileAttribute() can work as well (not tested)
I missed it :shock:
but... Peter too :lol:
Fred wrote: Mon Oct 14, 2024 2:02 pm Actually I'm interested to know which features are missing from the wrapper, because I didn't created a real app with the UI for now, so I could have missed something useful.
I just started my first SB app and... for example, I think it would be better to do things a bit more logically, so that when I want to insert a component, the most common parameters are in the definition (more in tune with SB/PB gadgets).

It's like the flags... I'd love for #PB_... constants to show only the ones that work on a specific component and not have them all.

Anyway, I can survive with that, if there is a workaround to make the UI near 100% configurable ;)
User avatar
Caronte3D
Posts: 187
Joined: Sat Nov 23, 2019 5:21 pm
Location: Some Universe

Re: [MobileUI] Change buttons size to "large" and more...

Post by Caronte3D »

Fred wrote: Mon Oct 14, 2024 2:28 pm Actually I'm interested to know which features are missing from the wrapper, because I didn't created a real app with the UI for now, so I could have missed something useful.
May be make the height of components configurable is needed in most UIs, like this one I'm using to make the button x2 taller:

Code: Select all

    !$(v_largebutton.gadget).css({
    !  'height': function(index, currentHeight) {
    !    return parseFloat(currentHeight) * 2 + 'px'; // Duplicate height
    !  },
    !  'display': 'flex',
    !  'align-items': 'center',  // Center vertically
    !  'justify-content': 'center', // Center horizontally
    !  'font-size': '1.5em'  // Tweak the text size
    !});
Quin
Posts: 118
Joined: Wed Nov 08, 2023 4:38 pm

Re: [MobileUI] Change buttons size to "large" and more...

Post by Quin »

Caronte3D wrote: Mon Oct 14, 2024 4:46 pm It's like the flags... I'd love for #PB_... constants to show only the ones that work on a specific component and not have them all.
+1, it puzzled me a bit when upgrading to SB 3.00, going to the flags field of a mobile call, typing #PB_, and seeing all the constants :shock:
Fred
Site Admin
Posts: 1820
Joined: Mon Feb 24, 2014 10:51 am

Re: [MobileUI] Change buttons size to "large" and more...

Post by Fred »

Ha yes I didn't added them in the IDE code source. Will do for the next version
Post Reply