Skip to content

[Specs] CollapsibleToolbarLayout  #575

@roubachof

Description

@roubachof

A shot at a platform-agnostic implementation of the famous collapsible toolbar layout UX.
Could implement successfully #325.

A CollapsibleToolbarLayout has 2 main properties

Name Type Description
Toolbar ICollapsibleToolbar the toolbar to be collapsed or expanded
Content object the body of page that will be wrapped in a ScrollViewer
interface ICollapsibleToolbar 
{
	TextBlock Title { get; }

	Brush Background { get; }

	/// <summary>
	/// Called when the collapsible layout header height is changing (in fact it is just scroll up)
	/// </summary>
	/// <param name="state">The current state of the layout.</param>
	/// <param name="expandedRatio">The expanded ratio: 1 is fully expanded (the state will be Expanded), 0 fully collapsed (Collapsed), else would be InBetween.</param>
	void OnCollapsing(CollapsibleLayoutState state, double expandedRatio);
}

For now, we have the NavigationBar in the toolkit, so we could just made it implement ICollapsibleToolbar.
Now we would like also to support collapsibles background images:

collapsing_background

I propose the following properties:

Name Type Description
ExpandedHeight double the bar height when expanded
State CollapsibleToolbarLayoutState enum: Collapsed, InBetween, Expanded
ExpandedTitleMargin Thickness the title margins when expanded
ExpandedTitleFontSize double the title font size when expanded
ExpandedImage sting the image path displayed on the background when expanded

The pseudo-xaml implementation would look like this:

<Grid>
    <ScrollViewer>
	<StackPanel>
	        <ExpandedToolbarContent>
        	<Content>
	<StackPanel>
    </ScrollViewer>

    <Toolbar>
</Grid>

Basically the 'ExpandedToolbarContent' would contain the expanded UI, the title with expanded title font size and the background image.

And we used it like this:

<CollapsibleToolbarLayout ExpandedHeight="160"
                          State="Expanded"
                          ExpandedTitleFontSize="26"
                          ExpandedImage="MontrealSnowTornado.png">
    <CollapsibleToolbarLayout.Toolbar>
        <Toolbar />
    </CollapsibleToolbarLayout.Toolbar>

</CollapsibleToolbarLayout>

Use case: from expanded to collapsed

We are in expanded state: the ExpandedToolbarContent is displaying a montreal image in the background and a title with a font size of 26, height is 160dp.
In this state the Toolbar background is transparent, and the title is hidden, its CollapsibleState = "Expanded".
Our CollapsibleToolbarLayout state = "Expanded".

  1. Scroll up is detected. Our CollapsibleToolbarLayout and our Toolbar states = "InBetween".
  2. Thanks to interpolation based on the bottom of the ExpandedToolbarContent respectively to the Y scroll axis we are slowly fading background from image to our toolbar background. And scaling title font size to Toolbar font size.
  3. When the bottom of the ExpandedToolbarContent reaches the bottom of the Toolbar, we set our CollapsibleToolbarLayout state to "Collapsed". We also set Toolbar states = "Collapsed". It does make visible the Toolbar background and title.

This way we can mimic with little effort a collapsible bar.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions