Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android optioncontainer #2350

Merged
merged 12 commits into from
Jan 31, 2024
Merged

Conversation

freakboy3742
Copy link
Member

Adds an OptionContainer widget for Android.

Android's BottomNavigationBar only allows 5 items. This implementation will allow you to add more items, raising a warning if you have too many, or try to select an index beyond the maximum. If you delete a visible tab (making room for more content), the lowest tab index from the "extra" tabs will be made visible.

Requires beeware/briefcase#1610, because of the need for build_gradle_dependencies and base_theme

TODO:

  • Disabling tabs doesn't seem to be working
  • I'm not convinced this does colors right - in particular, the background color of the tab bar seems off, given the examples in the Material3 docs
  • The content probe for tabs isn't computing the size of content correctly. Possibly related - the background color of tabs aren't being set.

Fixes #2346

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

@mhsmith
Copy link
Member

mhsmith commented Jan 23, 2024

I'm not convinced this does colors right - in particular, the background color of the tab bar seems off, given the examples in the Material3 docs

They're always changing the recommended style, but it looks basically the same as it does in these screenshots of Electron Cash, so I don't think it's worth looking into.

@mhsmith
Copy link
Member

mhsmith commented Jan 23, 2024

Disabling tabs doesn't seem to be working

It works fine for me, at least for tabs disabled at construction time:

        toga.OptionContainer(
            content=[
                toga.OptionItem(
                    "Blue", toga.Box(style=Pack(background_color="cornflowerblue"))),
                toga.OptionItem(
                    "Green", toga.Box(style=Pack(background_color="green")), enabled=False),
                toga.OptionItem(
                    "Red", toga.Box(style=Pack(background_color="red"))),
            ],
            ...

There's no visual difference, because inactive tabs are already gray, but the Green tab no longer responds to clicks.

@mhsmith
Copy link
Member

mhsmith commented Jan 23, 2024

The content probe for tabs isn't computing the size of content correctly

The Container base class requires resize_content to be called to set the available space, otherwise it'll default to zero. I've just pushed a commit that fixes this, at least for the simple red/green/blue example above.

@freakboy3742 freakboy3742 force-pushed the android-optioncontainer branch from 8d26c4f to 3fcf169 Compare January 31, 2024 01:42
@freakboy3742 freakboy3742 requested a review from mhsmith January 31, 2024 02:42
@mhsmith mhsmith merged commit e6db06e into beeware:main Jan 31, 2024
35 checks passed
@freakboy3742 freakboy3742 deleted the android-optioncontainer branch January 31, 2024 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add OptionContainer for Android
2 participants