Repository navigation
Suggestion: CupertinoSliverNavigationBar allow forcing condensed title #59525
Copy link
Copy link
Closed
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projecta: fidelityMatching the OEM platforms betterMatching the OEM platforms betterc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.p: cupertino_uicupertino_ui package in flutter/packagescupertino_ui package in flutter/packagesteam-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team
Description
Use case
See: iOS 13 Settings app search, App Store Search, or News app's Following tab search.
While searching and viewing results, the title is hidden.
My thoughts were something like this:
Widget _buildSliverBar(BuildContext context) {
return CupertinoSliverNavigationBar(
middle: _isSearching
? TextField(
autofocus: true,
controller: _filter,
decoration: InputDecoration(
hintText: 'Search by name...', border: InputBorder.none),
)
: null,
largeTitle: _isSearching ? null : _buildTitle(),
trailing: IconButton(
icon: Icon(_isSearching ? Icons.clear : Icons.search),
onPressed: () {
setState(() {
_isSearching = !_isSearching;
if (!_isSearching) {
_resetTitle();
}
});
},
),
);
}Alternatives: The built-in iOS apps that I mentioned probably actually behave by hiding the title bar and having a separate pinned search bar, e.g. SliverPersistentHeader. SliverPersistentHeader, however, doesn't seem to be very easily extensible.
SliverAppBar has a bottom option for easily appending a widget as well as allowing flexibleSpace (analogous to largeTitle) to be set to null, while placing widgets in title (analogous to middle).
Proposal
Proposal:
Apple News app
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projecta: fidelityMatching the OEM platforms betterMatching the OEM platforms betterc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.p: cupertino_uicupertino_ui package in flutter/packagescupertino_ui package in flutter/packagesteam-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team




Activity
cpboyd commentedon Jun 26, 2020
Perhaps a more flexible way to implement this would be to publicly expose the
largebooland allow the user to specifyfalseto force a condensed title?cpboyd commentedon Jun 26, 2020
As an example: cpboyd@972b591
I made some basic necessary changes to getting this to work, including those related to calculating the
components.largebasically allows you to specifyfalseto force a condensed title.[-]Suggestion: CupertinoSliverNavigationBar allow null largeTitle to hide[/-][+]Suggestion: CupertinoSliverNavigationBar allow forcing condensed title[/+]Piinks commentedon Aug 22, 2024
The native Messages has a good example of this. In the all messages page, the navigation bar is always collapsed. CupertinoSliverNavigationBar should have this option too. 👍
victorsanni commentedon Oct 14, 2024
I've been investigating this behavior in stock iOS apps. So far, it looks like when the search bar is tapped/focused, it rises (or autoscrolls) to the collapsed navigation bar. The search bar becomes the
middle, the 'cancel' button becomes thetrailing, while there is noleading:collapsed.search.bar.mov
I wonder if after #18103 is completed (and there is a
CupertinoSliverNavigationBar.searchconstructor), we can internally bake in that on tap/on focused behavior and modify the collapsed navigation bar as needed.victorsanni commentedon Nov 7, 2024
Playing around with it a little more, I'm increasingly thinking that it is a hero animation between the route with the CupertinoSliverNavigationBar.search and a new route with a CupertinoNavigationBar (with a
CupertinoSearchTextFieldmiddle and aCupertinoButtontrailing). In this case, how do we bake this transition into the framework?victorsanni commentedon Nov 11, 2024
Made progress on the forward transition animation, but still having difficulties with the reverse:
Flutter
flutter.current.searchable.hero.mp4
Native
native.searchable.hero.mp4
Sample code
Support CupertinoSliverNavigationBar.search with condensed large title (
Support CupertinoSliverNavigationBar.search with condensed large title (
github-actions commentedon Feb 21, 2025
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 -vand a minimal reproduction of the issue.