Extended ButtonTheme, RoundedRectangleBorder, gallery buttons demo (#15723)
This commit is contained in:
@@ -53,25 +53,40 @@ class ButtonsDemo extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ButtonsDemoState extends State<ButtonsDemo> {
|
||||
ShapeBorder _buttonShape;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ButtonThemeData buttonTheme = ButtonTheme.of(context).copyWith(
|
||||
shape: _buttonShape
|
||||
);
|
||||
|
||||
final List<ComponentDemoTabData> demos = <ComponentDemoTabData>[
|
||||
new ComponentDemoTabData(
|
||||
tabName: 'RAISED',
|
||||
description: _raisedText,
|
||||
demoWidget: buildRaisedButton(),
|
||||
demoWidget: new ButtonTheme.fromButtonThemeData(
|
||||
data: buttonTheme,
|
||||
child: buildRaisedButton(),
|
||||
),
|
||||
exampleCodeTag: _raisedCode,
|
||||
),
|
||||
new ComponentDemoTabData(
|
||||
tabName: 'FLAT',
|
||||
description: _flatText,
|
||||
demoWidget: buildFlatButton(),
|
||||
demoWidget: new ButtonTheme.fromButtonThemeData(
|
||||
data: buttonTheme,
|
||||
child: buildFlatButton(),
|
||||
),
|
||||
exampleCodeTag: _flatCode,
|
||||
),
|
||||
new ComponentDemoTabData(
|
||||
tabName: 'OUTLINE',
|
||||
description: _outlineText,
|
||||
demoWidget: buildOutlineButton(),
|
||||
demoWidget: new ButtonTheme.fromButtonThemeData(
|
||||
data: buttonTheme,
|
||||
child: buildOutlineButton(),
|
||||
),
|
||||
exampleCodeTag: _outlineCode,
|
||||
),
|
||||
new ComponentDemoTabData(
|
||||
@@ -97,6 +112,16 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
|
||||
return new TabbedComponentDemoScaffold(
|
||||
title: 'Buttons',
|
||||
demos: demos,
|
||||
actions: <Widget>[
|
||||
new IconButton(
|
||||
icon: const Icon(Icons.sentiment_very_satisfied),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_buttonShape = _buttonShape == null ? const StadiumBorder() : null;
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -63,9 +63,9 @@ class ScrollableTabsDemoState extends State<ScrollableTabsDemo> with SingleTicke
|
||||
});
|
||||
}
|
||||
|
||||
ShapeDecoration getIndicator() {
|
||||
Decoration getIndicator() {
|
||||
if (!_customIndicator)
|
||||
return null;
|
||||
return const UnderlineTabIndicator();
|
||||
|
||||
switch(_demoStyle) {
|
||||
case TabsDemoStyle.iconsAndText:
|
||||
|
||||
@@ -35,11 +35,13 @@ class ComponentDemoTabData {
|
||||
class TabbedComponentDemoScaffold extends StatelessWidget {
|
||||
const TabbedComponentDemoScaffold({
|
||||
this.title,
|
||||
this.demos
|
||||
this.demos,
|
||||
this.actions,
|
||||
});
|
||||
|
||||
final List<ComponentDemoTabData> demos;
|
||||
final String title;
|
||||
final List<Widget> actions;
|
||||
|
||||
void _showExampleCode(BuildContext context) {
|
||||
final String tag = demos[DefaultTabController.of(context).index].exampleCodeTag;
|
||||
@@ -57,19 +59,21 @@ class TabbedComponentDemoScaffold extends StatelessWidget {
|
||||
child: new Scaffold(
|
||||
appBar: new AppBar(
|
||||
title: new Text(title),
|
||||
actions: <Widget>[
|
||||
new Builder(
|
||||
builder: (BuildContext context) {
|
||||
return new IconButton(
|
||||
icon: const Icon(Icons.description),
|
||||
tooltip: 'Show example code',
|
||||
onPressed: () {
|
||||
_showExampleCode(context);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
actions: (actions ?? <Widget>[])..addAll(
|
||||
<Widget>[
|
||||
new Builder(
|
||||
builder: (BuildContext context) {
|
||||
return new IconButton(
|
||||
icon: const Icon(Icons.description),
|
||||
tooltip: 'Show example code',
|
||||
onPressed: () {
|
||||
_showExampleCode(context);
|
||||
},
|
||||
);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
bottom: new TabBar(
|
||||
isScrollable: true,
|
||||
tabs: demos.map((ComponentDemoTabData data) => new Tab(text: data.tabName)).toList(),
|
||||
|
||||
Reference in New Issue
Block a user