Skip to content

CupertinoSliverNavigationBar & CupertinoNavigationBar should support differing style||widget for largeTitle and middle #53788

Closed

Description

@shamilovtim

Once you scroll down on CupertinoSliverNavigationBar the middle widget automatically appears -- this widget cannot be customized while simultaneously having a customized largeTitle. If you try to use a custom middle widget it will appear even while the largeTitle is active in its regular state. There's really no option to customize the middle state of the largeTitle.

Can't customize:
image

Can customize:
image

Right now both have to change together. Ideally you could set a different font weight, or even a different widget when the large title is gone.

Activity

  1. added
    p: cupertino_uicupertino_ui package in flutter/packages
    frameworkflutter/packages/flutter repository. See also f: labels.
    c: proposalA detailed proposal for a change to Flutter
    on Apr 2, 2020
  2. jackie099 commented on May 21, 2020

    @jackie099

    That will be nice to have. Also, CupertinoSliverNavigationBar needs a slight visual update to match what it looks on iOS13.

  3. xster commented on Oct 30, 2020

    @xster
    Member

    @shamilovtim I'm not sure I understood the bug. Could you describe a bit more what the desired behavior is? Having some flag to allow the middle widget on top and the largeTitle below to appear simultaneously? Do you have a native iOS example to model after?

    @jackie099 let's keep bugs single purposed. Could you open a separate issue to describe the visual update you meant?

  4. shamilovtim commented on Oct 30, 2020

    @shamilovtim
    Author

    @xster thanks for responding. The middle position and the large position are not customizable separately and cannot have separate typography. If you use the middle property in order to customize the middle position, it doesn't have the desired effect because it will appear overtop of your largetitle. Overall, there is no way to customize the typography of the two separate elements at the same time. You can only customize largetitle, but you cannot customize both at the same time.

  5. xster commented on Oct 30, 2020

    @xster
    Member

    Thanks for the details. I'm still trying to parse the action item.

    The middle position and the large position are not customizable separately

    Can't you supply a middle and a largeTitle widget separately with whatever customization you need?

    cannot have separate typography

    They receive a default DefaultTextStyle above those widgets but whatever text styling your supply to the actual widgets themselves take priority.

    it doesn't have the desired effect because it will appear overtop of your largetitle

    I imagine this is the main ask? Add a shouldTheMiddleWidgetYouSuppliedFadeAwayWhenTheLargeTitleAppears type flag?

    Overall, there is no way to customize the typography of the two separate elements at the same time.

    I think that's true. Maybe so by design since the font are different. Perhaps you're asking for a way to force some subset of the styling (excluding font size, letter spacing etc) to be the same via a single inherited widget? Unless this is a big impediment, I'd consider this a low-prio ask since the fonts are indeed different by design.

  6. shamilovtim commented on Oct 30, 2020

    @shamilovtim
    Author

    Can't you supply a middle and a largeTitle widget separately with whatever customization you need?

    No you cant if you use the 'middle' widget it unceremoniously appears while the largeTitle is active (which according to the docs isn't a bug, but I don't understand why that's not a bug).

    I imagine this is the main ask? Add a shouldTheMiddleWidgetYouSuppliedFadeAwayWhenTheLargeTitleAppears type flag?

    Yes that would be one way of solving this issue

    I think that's true. Maybe so by design since the font are different. Perhaps you're asking for a way to force some subset of the styling (excluding font size, letter spacing etc) to be the same via a single inherited widget? Unless this is a big impediment, I'd consider this a low-prio ask since the fonts are indeed different by design.

    No I'm specifically asking that there be an option for them to be considered separate widgets. Consider this: for whatever reason a dev wants them to be two different colors, typefaces, weighs, etc. in the middle state or the large state. It's not about stopping/enforcing inheritance, it's about allowing two separate styles.

  7. holland-hng commented on Nov 10, 2020

    @holland-hng

    i have same isssue :v

  8. GabRoyer commented on Mar 15, 2021

    @GabRoyer

    No you cant if you use the 'middle' widget it unceremoniously appears while the largeTitle is active (which according to the docs isn't a bug, but I don't understand why that's not a bug).

    I'm surprised that this isn't a bug. From the docs:

    For advanced uses, an optional middle widget can be supplied to show a different widget in the middle of the navigation bar when the sliver is collapsed.

    This to me implies that the middle widget wouldn't show up when the sliver is not collapsed.

  9. kstam commented on Jun 19, 2021

    @kstam

    The bug seems to be here btw. I wonder if this is a parameter that should be passed into the Cupertino header instead of the current logic. Changing this line to false makes the header behave as per the description.
    https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/cupertino/nav_bar.dart#L716

  10. subzero911 commented on Jan 27, 2022

    @subzero911

    I have the similar issue.
    If I supply just Text widget as a largeTitle, everything works okay: large title and small middle text on scroll.
    But if I style it, both largeTitle and middle share the same style. And large middle text looks ugly.

    upd.
    I managed to do that, but that's not easy.
    I wrapped by NavBar into CupertinoTheme and set custom sizes for titles.

    CupertinoTheme(
              data: CupertinoThemeData(
                textTheme: CupertinoTextThemeData(
                  navLargeTitleTextStyle: TextStyle(fontSize: 32, color: Colors.black),
                  navTitleTextStyle: TextStyle(fontSize: 18, color: Colors.black),              
                ),
                barBackgroundColor: Colors.white,
              ),
              child: CustomScrollView(
                slivers: [
                  CupertinoSliverNavigationBar(
                    largeTitle: Text('Афиша'),
                    leading: IconButton(
                      color: AppConstants.blackColor,
                      icon: Icon(Icons.arrow_back, color: AppConstants.blackColor, size: 28),
                      onPressed: () => Navigator.of(context).pop(),
                    ),
                  ),
  11. SimonVillage commented on Mar 12, 2022

    @SimonVillage

    Is someone willing to make a PR for this?

  12. added
    workaround availableThere is a workaround available to overcome the issue
    P2Important issues not at the top of the work list
    on Aug 22, 2024
  13. changed the title [-]CupertinoSliverNavigationBar largeTitle cannot be customized in its middle state[/-] [+]CupertinoSliverNavigationBar & CupertinoNavigationBar should support differing style||widget for `largeTitle` and `middle`[/+] on Aug 22, 2024
  14. added
    P3Issues that are less important to the Flutter project
    and removed
    P2Important issues not at the top of the work list
    on Aug 22, 2024
  15. victorsanni commented on Sep 27, 2024

    @victorsanni
    Contributor

    Hi @shamilovtim @SimonVillage is this still an issue? I'm able to customize the largeTitle and middle properties separately in CupertinoSliverNavigationBar with the flag alwaysShowMiddle set to false.

    ezgif com-video-to-gif-converter (9)

  16. victorsanni commented on Oct 12, 2024

    @victorsanni
    Contributor

    Closing as duplicate of #113542.

  17. github-actions commented on Oct 26, 2024

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  18. locked as resolved and limited conversation to collaborators on Oct 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: proposalA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.p: cupertino_uicupertino_ui package in flutter/packagesteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages teamworkaround availableThere is a workaround available to overcome the issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions