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

TabBar enhancement #844

Closed
sharjeelyunus opened this issue Sep 28, 2023 · 5 comments · Fixed by #1055
Closed

TabBar enhancement #844

sharjeelyunus opened this issue Sep 28, 2023 · 5 comments · Fixed by #1055
Assignees

Comments

@sharjeelyunus
Copy link
Member

I have 2 items in TabBar and for both of the items there is a different button at the footer, I want to get the selectedIndex property from the TabBar to conditionally render each button in the footer, right now selectedIndex always stays 0

See these buttons (Preview Post, Post), I want to show them in the footer, and for that I have to conditionally render each button with TabBar selectedIndex
image

image

@vusters vusters added this to Ensemble Sep 28, 2023
@github-project-automation github-project-automation bot moved this to Backlog in Ensemble Sep 28, 2023
@vusters vusters moved this from Backlog to Ready for Work in Ensemble Sep 28, 2023
@vusters vusters assigned vinothvino42 and unassigned vusters Sep 28, 2023
@vinothvino42 vinothvino42 moved this from Ready for Work to In Progress in Ensemble Sep 29, 2023
@vinothvino42
Copy link
Collaborator

@sharjeelyunus Now I tested it and it looks like it's working fine. Try the following code

View:
  styles:
    useSafeArea: true
  body:
    Column:
      children:
        - TabBar:
            id: tabbarId
            styles:
              tabPadding: 10 20 0 20
              indicatorThickness: 4
              indicatorColor: green
              activeTabColor: blue
              tabBackgroundColor: white
              dividerColor: white
            items:
              - label: First Tab
                widget:
                  Column:
                    styles: { padding: 30, crossAxis: center }
                    children:
                      - Text:
                          text: First Tab content
                      - ContentView:
                          inputs:
                            selectedIndex: ${tabbarId.selectedIndex}
              - label: Second Tab
                widget:
                  Column:
                    styles: { padding: 30, crossAxis: center }
                    children:
                      - Text:
                          text: Second Tab content
                      - ContentView:
                          inputs:
                            selectedIndex: ${tabbarId.selectedIndex}

ContentView:
  inputs:
    - selectedIndex
  body:
    Column:
      styles: { gap: 30, crossAxis: center }
      children:
        - Text:
            text: Tab content ${selectedIndex}
        - Conditional:
            conditions:
              - if: ${selectedIndex == 0}
                Button:
                  label: Preview Post
                  onTap: |
                    //@code
                    console.log(tabbarId.selectedIndex);
              - else:
                Button:
                  label: Post
                  onTap: |
                    //@code
                    console.log(tabbarId.selectedIndex);

@vinothvino42 vinothvino42 moved this from In Progress to Released in Ensemble Sep 29, 2023
@sharjeelyunus
Copy link
Member Author

I need to use these buttons/condition inside the footer (outside TabBar), inside the tab bar you don't even need conditions, you can just dynamically render 2 widgets for each item

see this here, even though I'm changing the item, the selectedIndex stays 0 in footer and always shows the Preview Post button:

View:
  styles:
    useSafeArea: true

  footer:
    styles:
      height: 100
      padding: 24
    children:
      - Column:
          styles:
            crossAxis: stretch
          children:
            - Conditional:
                conditions:
                  - if: ${tabbarId.selectedIndex == 0}
                    Button:
                      label: Preview Post
                  - else:
                    Button:
                      label: Post
  body:
    Column:
      children:
        - TabBar:
            id: tabbarId
            styles:
              tabPadding: 10 20 0 20
              indicatorThickness: 4
              indicatorColor: green
              activeTabColor: blue
              tabBackgroundColor: white
              dividerColor: white
            items:
              - label: First Tab
                widget:
                  Column:
                    styles: { padding: 30, crossAxis: center }
                    children:
                      - Text:
                          text: First Tab content
                      - ContentView:
                          inputs:
                            selectedIndex: ${tabbarId.selectedIndex}
              - label: Second Tab
                widget:
                  Column:
                    styles: { padding: 30, crossAxis: center }
                    children:
                      - Text:
                          text: Second Tab content
                      - ContentView:
                          inputs:
                            selectedIndex: ${tabbarId.selectedIndex}

ContentView:
  inputs:
    - selectedIndex
  body:
    Column:
      styles: { gap: 30, crossAxis: center }
      children:
        - Text:
            text: Tab content ${selectedIndex}
        - Conditional:
            conditions:
              - if: ${selectedIndex == 0}
                Button:
                  label: Preview Post
                  onTap: |
                    //@code
                    console.log(tabbarId.selectedIndex);
              - else:
                Button:
                  label: Post
                  onTap: |
                    //@code
                    console.log(tabbarId.selectedIndex);

@vinothvino42 vinothvino42 moved this from Released to In Progress in Ensemble Oct 4, 2023
@vinothvino42
Copy link
Collaborator

@vusters
Currently, we can't able to access any of the widget's properties with the widget id from the footer right?

View:
  styles:
    useSafeArea: true
  body:
    Column:
      children:
        - Text:
            id: myTextId
            text: Second

  footer:
    styles:
      height: 100
      padding: 24
    children:
      - Text:
          text: ${myTextId.text}

Do we need to create footer as an invokable widget in order to get other widget's properties?

OR

Can we create the whole page or page group widget as a invokable one?

@kmahmood74
Copy link
Collaborator

@vusters Vinoth is waiting for your comment for 6 weeks now

@vinothvino42 vinothvino42 moved this from In Progress to Ready for Work in Ensemble Nov 14, 2023
@vinothvino42
Copy link
Collaborator

vinothvino42 commented Nov 17, 2023

@kmahmood74 Sneh is working on a similar issue I guess. Something related to the scopeManager issue.

@snehmehta snehmehta moved this from Ready for Work to In Progress in Ensemble Dec 14, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Released in Ensemble Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Released
Development

Successfully merging a pull request may close this issue.

5 participants