Unverified Commit 04bd8779 authored by Anthony's avatar Anthony Committed by GitHub

[Material] Update slider gallery demo, including range slider (#34597)

Update the flutter_gallery Slider demo by aligning the text field in the first slider, adding range slider examples (including custom range thumbs), and separating single slider and range slider examples with tabs.
parent a276ab3d
...@@ -46,11 +46,15 @@ class TabbedComponentDemoScaffold extends StatelessWidget { ...@@ -46,11 +46,15 @@ class TabbedComponentDemoScaffold extends StatelessWidget {
this.title, this.title,
this.demos, this.demos,
this.actions, this.actions,
this.isScrollable = true,
this.showExampleCodeAction = true,
}); });
final List<ComponentDemoTabData> demos; final List<ComponentDemoTabData> demos;
final String title; final String title;
final List<Widget> actions; final List<Widget> actions;
final bool isScrollable;
final bool showExampleCodeAction;
void _showExampleCode(BuildContext context) { void _showExampleCode(BuildContext context) {
final String tag = demos[DefaultTabController.of(context).index].exampleCodeTag; final String tag = demos[DefaultTabController.of(context).index].exampleCodeTag;
...@@ -93,29 +97,28 @@ class TabbedComponentDemoScaffold extends StatelessWidget { ...@@ -93,29 +97,28 @@ class TabbedComponentDemoScaffold extends StatelessWidget {
child: Scaffold( child: Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text(title), title: Text(title),
actions: (actions ?? <Widget>[])..addAll( actions: (actions ?? <Widget>[])..add(
<Widget>[ Builder(
Builder( builder: (BuildContext context) {
builder: (BuildContext context) { return IconButton(
return IconButton( icon: const Icon(Icons.library_books, semanticLabel: 'Show documentation'),
icon: const Icon(Icons.library_books, semanticLabel: 'Show documentation'), onPressed: () => _showApiDocumentation(context),
onPressed: () => _showApiDocumentation(context), );
); },
}, ),
), )..addAll(showExampleCodeAction ? <Widget>[
Builder( Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
return IconButton( return IconButton(
icon: const Icon(Icons.code), icon: const Icon(Icons.code),
tooltip: 'Show example code', tooltip: 'Show example code',
onPressed: () => _showExampleCode(context), onPressed: () => _showExampleCode(context),
); );
}, },
), ),
], ] : <Widget>[]),
),
bottom: TabBar( bottom: TabBar(
isScrollable: true, isScrollable: isScrollable,
tabs: demos.map<Widget>((ComponentDemoTabData data) => Tab(text: data.tabName)).toList(), tabs: demos.map<Widget>((ComponentDemoTabData data) => Tab(text: data.tabName)).toList(),
), ),
), ),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment