Commit 578d98ea authored by Hans Muller's avatar Hans Muller Committed by GitHub

Gallery demo tweaks (#5116)

parent a25da4af
...@@ -7,14 +7,12 @@ import 'package:flutter/material.dart'; ...@@ -7,14 +7,12 @@ import 'package:flutter/material.dart';
import '../gallery/demo.dart'; import '../gallery/demo.dart';
const String _raisedText = const String _raisedText =
"# Raised buttons\n"
"Raised buttons add dimension to mostly flat layouts. They emphasize " "Raised buttons add dimension to mostly flat layouts. They emphasize "
"functions on busy or wide spaces."; "functions on busy or wide spaces.";
const String _raisedCode = 'buttons_raised'; const String _raisedCode = 'buttons_raised';
const String _flatText = const String _flatText =
"# Flat buttons\n"
"A flat button displays an ink splash on press " "A flat button displays an ink splash on press "
"but does not lift. Use flat buttons on toolbars, in dialogs and " "but does not lift. Use flat buttons on toolbars, in dialogs and "
"inline with padding"; "inline with padding";
...@@ -22,7 +20,6 @@ const String _flatText = ...@@ -22,7 +20,6 @@ const String _flatText =
const String _flatCode = 'buttons_flat'; const String _flatCode = 'buttons_flat';
const String _dropdownText = const String _dropdownText =
"# Dropdown buttons\n"
"A dropdown button displays a menu that's used to select a value from a " "A dropdown button displays a menu that's used to select a value from a "
"small set of values. The button displays the current value and a down " "small set of values. The button displays the current value and a down "
"arrow."; "arrow.";
...@@ -36,7 +33,6 @@ const String _iconText = ...@@ -36,7 +33,6 @@ const String _iconText =
const String _iconCode = 'buttons_icon'; const String _iconCode = 'buttons_icon';
const String _actionText = const String _actionText =
"# Floating action buttons\n"
"Floating action buttons are used for a promoted action. They are " "Floating action buttons are used for a promoted action. They are "
"distinguished by a circled icon floating above the UI and can have motion " "distinguished by a circled icon floating above the UI and can have motion "
"behaviors that include morphing, launching, and a transferring anchor " "behaviors that include morphing, launching, and a transferring anchor "
......
...@@ -4,11 +4,6 @@ ...@@ -4,11 +4,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
final TextStyle _kTextStyle = new TextStyle(
color: Colors.indigo[400],
fontSize: 24.0
);
class ModalBottomSheetDemo extends StatelessWidget { class ModalBottomSheetDemo extends StatelessWidget {
static const String routeName = '/modal-bottom-sheet'; static const String routeName = '/modal-bottom-sheet';
...@@ -25,8 +20,11 @@ class ModalBottomSheetDemo extends StatelessWidget { ...@@ -25,8 +20,11 @@ class ModalBottomSheetDemo extends StatelessWidget {
child: new Padding( child: new Padding(
padding: const EdgeInsets.all(32.0), padding: const EdgeInsets.all(32.0),
child: new Text('This is the modal bottom sheet. Click anywhere to dismiss.', child: new Text('This is the modal bottom sheet. Click anywhere to dismiss.',
style: _kTextStyle, textAlign: TextAlign.center,
textAlign: TextAlign.center style: new TextStyle(
color: Theme.of(context).accentColor,
fontSize: 24.0
)
) )
) )
); );
......
...@@ -4,11 +4,6 @@ ...@@ -4,11 +4,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
final TextStyle _kTextStyle = new TextStyle(
color: Colors.indigo[400],
fontSize: 24.0
);
class PersistentBottomSheetDemo extends StatefulWidget { class PersistentBottomSheetDemo extends StatefulWidget {
static const String routeName = '/persistent-bottom-sheet'; static const String routeName = '/persistent-bottom-sheet';
...@@ -33,15 +28,19 @@ class _PersistentBottomSheetDemoState extends State<PersistentBottomSheetDemo> { ...@@ -33,15 +28,19 @@ class _PersistentBottomSheetDemoState extends State<PersistentBottomSheetDemo> {
_showBottomSheetCallback = null; _showBottomSheetCallback = null;
}); });
_scaffoldKey.currentState.showBottomSheet/*<Null>*/((BuildContext context) { _scaffoldKey.currentState.showBottomSheet/*<Null>*/((BuildContext context) {
final ThemeData themeData = Theme.of(context);
return new Container( return new Container(
decoration: new BoxDecoration( decoration: new BoxDecoration(
border: new Border(top: new BorderSide(color: Colors.black26)) border: new Border(top: new BorderSide(color: themeData.disabledColor))
), ),
child: new Padding( child: new Padding(
padding: const EdgeInsets.all(32.0), padding: const EdgeInsets.all(32.0),
child: new Text('This is a Material persistent bottom sheet. Drag downwards to dismiss it.', child: new Text('This is a Material persistent bottom sheet. Drag downwards to dismiss it.',
style: _kTextStyle, textAlign: TextAlign.center,
textAlign: TextAlign.center style: new TextStyle(
color: themeData.accentColor,
fontSize: 24.0
)
) )
) )
); );
......
...@@ -7,7 +7,7 @@ import 'dart:math'; ...@@ -7,7 +7,7 @@ import 'dart:math';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
const String _kUserName = 'Jonathan'; const String _kUserName = 'Jonathan';
const String _kUserEmail = 'heyfromjonathan@gmail.com'; const String _kUserEmail = 'jonathan@example.com';
const String _kUserImage = 'packages/flutter_gallery_assets/pesto/avatar.jpg'; const String _kUserImage = 'packages/flutter_gallery_assets/pesto/avatar.jpg';
// Map of logo images keyed by the minimum height their container needs to be. // Map of logo images keyed by the minimum height their container needs to be.
final Map<double, String> _kLogoImages = <double, String>{ final Map<double, String> _kLogoImages = <double, String>{
......
...@@ -75,11 +75,6 @@ class _ProgressIndicatorDemoState extends State<ProgressIndicatorDemo> { ...@@ -75,11 +75,6 @@ class _ProgressIndicatorDemoState extends State<ProgressIndicatorDemo> {
height: 20.0, height: 20.0,
child: new CircularProgressIndicator(value: _animation.value) child: new CircularProgressIndicator(value: _animation.value)
), ),
new SizedBox(
width: 50.0,
height: 30.0,
child: new CircularProgressIndicator(value: _animation.value)
),
new Text('${(_animation.value * 100.0).toStringAsFixed(1)}%${ _controller.isAnimating ? "" : " (paused)" }') new Text('${(_animation.value * 100.0).toStringAsFixed(1)}%${ _controller.isAnimating ? "" : " (paused)" }')
]; ];
return new Column( return new Column(
......
...@@ -7,13 +7,11 @@ import 'package:flutter/material.dart'; ...@@ -7,13 +7,11 @@ import 'package:flutter/material.dart';
import '../gallery/demo.dart'; import '../gallery/demo.dart';
const String _checkboxText = const String _checkboxText =
"# Checkboxes\n"
"Checkboxes allow the user to select multiple options from a set."; "Checkboxes allow the user to select multiple options from a set.";
const String _checkboxCode = 'selectioncontrols_checkbox'; const String _checkboxCode = 'selectioncontrols_checkbox';
const String _radioText = const String _radioText =
"# Radio buttons\n"
"Radio buttons allow the user to select one option from a set. Use radio " "Radio buttons allow the user to select one option from a set. Use radio "
"buttons for exclusive selection if you think that the user needs to see " "buttons for exclusive selection if you think that the user needs to see "
"all available options side-by-side."; "all available options side-by-side.";
...@@ -21,7 +19,6 @@ const String _radioText = ...@@ -21,7 +19,6 @@ const String _radioText =
const String _radioCode = 'selectioncontrols_radio'; const String _radioCode = 'selectioncontrols_radio';
const String _switchText = const String _switchText =
"# Switches\n"
"On/off switches toggle the state of a single settings option. The option " "On/off switches toggle the state of a single settings option. The option "
"that the switch controls, as well as the state it’s in, should be made " "that the switch controls, as well as the state it’s in, should be made "
"clear from the corresponding inline label."; "clear from the corresponding inline label.";
......
...@@ -9,7 +9,6 @@ import 'package:flutter/material.dart'; ...@@ -9,7 +9,6 @@ import 'package:flutter/material.dart';
class _Page { class _Page {
_Page({ this.label }); _Page({ this.label });
final GlobalKey<ScrollableState<Scrollable>> key = new GlobalKey<ScrollableState<Scrollable>>();
final String label; final String label;
String get id => label[0]; String get id => label[0];
} }
...@@ -115,36 +114,14 @@ class _CardDataItem extends StatelessWidget { ...@@ -115,36 +114,14 @@ class _CardDataItem extends StatelessWidget {
} }
} }
class TabsDemo extends StatefulWidget { class TabsDemo extends StatelessWidget {
static const String routeName = '/tabs'; static const String routeName = '/tabs';
@override
TabsDemoState createState() => new TabsDemoState();
}
class TabsDemoState extends State<TabsDemo> {
_Page _selectedPage;
double _scrollOffset = 0.0;
@override
void initState() {
super.initState();
_selectedPage = _allPages.keys.first;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final double statusBarHeight = MediaQuery.of(context).padding.top;
return new TabBarSelection<_Page>( return new TabBarSelection<_Page>(
values: _allPages.keys.toList(), values: _allPages.keys.toList(),
onChanged: (_Page value) {
setState(() {
_selectedPage = value;
_selectedPage.key.currentState.scrollTo(_scrollOffset);
});
},
child: new Scaffold( child: new Scaffold(
appBarBehavior: AppBarBehavior.under,
appBar: new AppBar( appBar: new AppBar(
title: new Text('Tabs and scrolling'), title: new Text('Tabs and scrolling'),
bottom: new TabBar<_Page>( bottom: new TabBar<_Page>(
...@@ -155,17 +132,15 @@ class TabsDemoState extends State<TabsDemo> { ...@@ -155,17 +132,15 @@ class TabsDemoState extends State<TabsDemo> {
), ),
body: new TabBarView<_Page>( body: new TabBarView<_Page>(
children: _allPages.keys.map((_Page page) { children: _allPages.keys.map((_Page page) {
return new Padding( return new ScrollableList(
padding: const EdgeInsets.all(16.0), padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0),
child: new ScrollableList( itemExtent: _CardDataItem.height,
padding: new EdgeInsets.only(top: kTextTabBarHeight + kToolBarHeight + statusBarHeight), children: _allPages[page].map((_CardData data) {
itemExtent: _CardDataItem.height, return new Padding(
scrollableKey: page.key, padding: const EdgeInsets.symmetric(vertical: 8.0),
onScroll: (double value) { _scrollOffset = value; }, child: new _CardDataItem(page: page, data: data)
children: _allPages[page].map((_CardData data) { );
return new _CardDataItem(page: page, data: data); }).toList()
}).toList()
)
); );
}).toList() }).toList()
) )
......
...@@ -17,14 +17,15 @@ class TwoLevelListDemo extends StatelessWidget { ...@@ -17,14 +17,15 @@ class TwoLevelListDemo extends StatelessWidget {
new TwoLevelListItem(title: new Text('Top')), new TwoLevelListItem(title: new Text('Top')),
new TwoLevelSublist( new TwoLevelSublist(
title: new Text('Sublist'), title: new Text('Sublist'),
children: <Widget>[ backgroundColor: Theme.of(context).accentColor.withOpacity(0.025),
new TwoLevelListItem(title: new Text('One')), children: <Widget>[
new TwoLevelListItem(title: new Text('Two')), new TwoLevelListItem(title: new Text('One')),
// https://en.wikipedia.org/wiki/Free_Four new TwoLevelListItem(title: new Text('Two')),
new TwoLevelListItem(title: new Text('Free')), // https://en.wikipedia.org/wiki/Free_Four
new TwoLevelListItem(title: new Text('Four')) new TwoLevelListItem(title: new Text('Free')),
] new TwoLevelListItem(title: new Text('Four'))
), ]
),
new TwoLevelListItem(title: new Text('Bottom')) new TwoLevelListItem(title: new Text('Bottom'))
] ]
) )
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'example_code_parser.dart'; import 'example_code_parser.dart';
import 'syntax_highlighter.dart'; import 'syntax_highlighter.dart';
...@@ -88,7 +87,9 @@ class TabbedComponentDemoScaffold extends StatelessWidget { ...@@ -88,7 +87,9 @@ class TabbedComponentDemoScaffold extends StatelessWidget {
children: <Widget>[ children: <Widget>[
new Padding( new Padding(
padding: const EdgeInsets.all(16.0), padding: const EdgeInsets.all(16.0),
child: new MarkdownBody(data: demo.description) child: new Text(demo.description,
style: Theme.of(context).textTheme.subhead
)
), ),
new Flexible(child: demo.widget) new Flexible(child: demo.widget)
] ]
......
...@@ -61,7 +61,7 @@ class GalleryHomeState extends State<GalleryHome> { ...@@ -61,7 +61,7 @@ class GalleryHomeState extends State<GalleryHome> {
_listItems.add(new SizedBox(height: _kFlexibleSpaceMaxHeight + statusBarHeight)); _listItems.add(new SizedBox(height: _kFlexibleSpaceMaxHeight + statusBarHeight));
final ThemeData themeData = Theme.of(context); final ThemeData themeData = Theme.of(context);
final TextStyle headerStyle = themeData.textTheme.body2.copyWith(color: themeData.primaryColor); final TextStyle headerStyle = themeData.textTheme.body2.copyWith(color: themeData.accentColor);
String category; String category;
for (GalleryItem galleryItem in kAllGalleryItems) { for (GalleryItem galleryItem in kAllGalleryItems) {
if (category != galleryItem.category) { if (category != galleryItem.category) {
......
...@@ -57,6 +57,7 @@ class TwoLevelSublist extends StatefulWidget { ...@@ -57,6 +57,7 @@ class TwoLevelSublist extends StatefulWidget {
Key key, Key key,
this.leading, this.leading,
this.title, this.title,
this.backgroundColor,
this.onOpenChanged, this.onOpenChanged,
this.children this.children
}) : super(key: key); }) : super(key: key);
...@@ -65,6 +66,7 @@ class TwoLevelSublist extends StatefulWidget { ...@@ -65,6 +66,7 @@ class TwoLevelSublist extends StatefulWidget {
final Widget title; final Widget title;
final ValueChanged<bool> onOpenChanged; final ValueChanged<bool> onOpenChanged;
final List<Widget> children; final List<Widget> children;
final Color backgroundColor;
@override @override
_TwoLevelSublistState createState() => new _TwoLevelSublistState(); _TwoLevelSublistState createState() => new _TwoLevelSublistState();
...@@ -77,6 +79,7 @@ class _TwoLevelSublistState extends State<TwoLevelSublist> { ...@@ -77,6 +79,7 @@ class _TwoLevelSublistState extends State<TwoLevelSublist> {
ColorTween _borderColor; ColorTween _borderColor;
ColorTween _headerColor; ColorTween _headerColor;
ColorTween _iconColor; ColorTween _iconColor;
ColorTween _backgroundColor;
Animation<double> _iconTurns; Animation<double> _iconTurns;
bool _isExpanded = false; bool _isExpanded = false;
...@@ -91,6 +94,7 @@ class _TwoLevelSublistState extends State<TwoLevelSublist> { ...@@ -91,6 +94,7 @@ class _TwoLevelSublistState extends State<TwoLevelSublist> {
_headerColor = new ColorTween(); _headerColor = new ColorTween();
_iconColor = new ColorTween(); _iconColor = new ColorTween();
_iconTurns = new Tween<double>(begin: 0.0, end: 0.5).animate(_easeInAnimation); _iconTurns = new Tween<double>(begin: 0.0, end: 0.5).animate(_easeInAnimation);
_backgroundColor = new ColorTween();
_isExpanded = PageStorage.of(context)?.readState(context) ?? false; _isExpanded = PageStorage.of(context)?.readState(context) ?? false;
if (_isExpanded) if (_isExpanded)
...@@ -119,6 +123,7 @@ class _TwoLevelSublistState extends State<TwoLevelSublist> { ...@@ -119,6 +123,7 @@ class _TwoLevelSublistState extends State<TwoLevelSublist> {
Widget buildList(BuildContext context, Widget child) { Widget buildList(BuildContext context, Widget child) {
return new Container( return new Container(
decoration: new BoxDecoration( decoration: new BoxDecoration(
backgroundColor: _backgroundColor.evaluate(_easeOutAnimation),
border: new Border( border: new Border(
top: new BorderSide(color: _borderColor.evaluate(_easeOutAnimation)), top: new BorderSide(color: _borderColor.evaluate(_easeOutAnimation)),
bottom: new BorderSide(color: _borderColor.evaluate(_easeOutAnimation)) bottom: new BorderSide(color: _borderColor.evaluate(_easeOutAnimation))
...@@ -163,6 +168,9 @@ class _TwoLevelSublistState extends State<TwoLevelSublist> { ...@@ -163,6 +168,9 @@ class _TwoLevelSublistState extends State<TwoLevelSublist> {
_iconColor _iconColor
..begin = theme.unselectedWidgetColor ..begin = theme.unselectedWidgetColor
..end = theme.accentColor; ..end = theme.accentColor;
_backgroundColor
..begin = Colors.transparent
..end = config.backgroundColor ?? Colors.transparent;
return new AnimatedBuilder( return new AnimatedBuilder(
animation: _controller.view, animation: _controller.view,
......
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