Skip to content

Commit

Permalink
Merge pull request flutter#2 from perclasson/gallery-master
Browse files Browse the repository at this point in the history
Move to using new Focus traversal classes/apis and remove references to deprecated APIs

Former-commit-id: c14d8a6
  • Loading branch information
perclasson authored Mar 6, 2020
2 parents 251d624 + 7cf09f0 commit b1324a1
Show file tree
Hide file tree
Showing 41 changed files with 194 additions and 173 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,27 @@ wild.

![Flutter Gallery](https://user-images.githubusercontent.com/6655696/73928238-0d7fcc80-48d3-11ea-8a7e-ea7dc5d6e713.png)

## Running Flutter Gallery on Flutter's master channel

The Flutter Gallery targets Flutter's master channel. As such, it can take advantage
of new SDK features that haven't landed in the stable channel.

If you'd like to run the Flutter Gallery, make sure to switch to the master channel
first:

```bash
flutter channel master
flutter upgrade
```

When you're done, use this command to return to the safety of the stable
channel:

```bash
flutter channel stable
flutter upgrade
```

## Supported Platforms

Flutter Gallery has been built to support multiple platforms.
Expand Down
2 changes: 1 addition & 1 deletion lib/codeviewer/code_segments.dart.REMOVED.git-id
Original file line number Diff line number Diff line change
@@ -1 +1 @@
168387e611e0056dc39f18c168080f682cda792a
de069186f83593427a029ce56089cf175628ffde
2 changes: 1 addition & 1 deletion lib/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// height of the 'Gallery' header
const double galleryHeaderHeight = 64;

// The font size delta for display1 font.
// The font size delta for headline4 font.
const double desktopDisplay1FontDelta = 16;

// The width of the settingsDesktop.
Expand Down
6 changes: 3 additions & 3 deletions lib/demos/material/cards_demo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class SectionTitle extends StatelessWidget {
padding: const EdgeInsets.fromLTRB(4, 4, 4, 12),
child: Align(
alignment: Alignment.centerLeft,
child: Text(title, style: Theme.of(context).textTheme.subhead),
child: Text(title, style: Theme.of(context).textTheme.subtitle1),
),
);
}
Expand All @@ -280,8 +280,8 @@ class TravelDestinationContent extends StatelessWidget {
Widget build(BuildContext context) {
final ThemeData theme = Theme.of(context);
final TextStyle titleStyle =
theme.textTheme.headline.copyWith(color: Colors.white);
final TextStyle descriptionStyle = theme.textTheme.subhead;
theme.textTheme.headline5.copyWith(color: Colors.white);
final TextStyle descriptionStyle = theme.textTheme.subtitle1;

return Column(
crossAxisAlignment: CrossAxisAlignment.start,
Expand Down
6 changes: 3 additions & 3 deletions lib/demos/material/dialog_demo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class DialogDemo extends StatelessWidget {
void _showAlertDialog(BuildContext context) {
final ThemeData theme = Theme.of(context);
final TextStyle dialogTextStyle =
theme.textTheme.subhead.copyWith(color: theme.textTheme.caption.color);
theme.textTheme.subtitle1.copyWith(color: theme.textTheme.caption.color);
_showDemoDialog<String>(
context: context,
child: AlertDialog(
Expand All @@ -79,7 +79,7 @@ class DialogDemo extends StatelessWidget {
void _showAlertDialogWithTitle(BuildContext context) {
final ThemeData theme = Theme.of(context);
final TextStyle dialogTextStyle =
theme.textTheme.subhead.copyWith(color: theme.textTheme.caption.color);
theme.textTheme.subtitle1.copyWith(color: theme.textTheme.caption.color);
_showDemoDialog<String>(
context: context,
child: AlertDialog(
Expand Down Expand Up @@ -261,7 +261,7 @@ class _FullScreenDialogDemo extends StatelessWidget {
FlatButton(
child: Text(
GalleryLocalizations.of(context).dialogFullscreenSave,
style: theme.textTheme.body1.copyWith(
style: theme.textTheme.bodyText2.copyWith(
color: theme.colorScheme.onPrimary,
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/demos/material/sliders_demo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ class _CustomSlidersState extends State<_CustomSliders> {
valueIndicatorColor: Colors.deepPurpleAccent,
thumbShape: _CustomThumbShape(),
valueIndicatorShape: _CustomValueIndicatorShape(),
valueIndicatorTextStyle: theme.accentTextTheme.body2
valueIndicatorTextStyle: theme.accentTextTheme.bodyText1
.copyWith(color: theme.colorScheme.onSurface),
),
child: Slider(
Expand Down
4 changes: 2 additions & 2 deletions lib/demos/reference/colors_demo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@ class PaletteTabView extends StatelessWidget {
@override
Widget build(BuildContext context) {
final TextTheme textTheme = Theme.of(context).textTheme;
final TextStyle whiteTextStyle = textTheme.body1.copyWith(
final TextStyle whiteTextStyle = textTheme.bodyText2.copyWith(
color: Colors.white,
);
final TextStyle blackTextStyle = textTheme.body1.copyWith(
final TextStyle blackTextStyle = textTheme.bodyText2.copyWith(
color: Colors.black,
);
return Scrollbar(
Expand Down
40 changes: 20 additions & 20 deletions lib/demos/reference/typography_demo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,53 +49,53 @@ class TypographyDemo extends StatelessWidget {
final textTheme = Theme.of(context).textTheme;
final styleItems = [
_TextStyleItem(
name: 'Display 4',
style: textTheme.display4,
name: 'Headline 1',
style: textTheme.headline1,
text: 'Light 96sp',
),
_TextStyleItem(
name: 'Display 3',
style: textTheme.display3,
name: 'Headline 2',
style: textTheme.headline2,
text: 'Light 60sp',
),
_TextStyleItem(
name: 'Display 2',
style: textTheme.display2,
name: 'Headline 3',
style: textTheme.headline3,
text: 'Regular 48sp',
),
_TextStyleItem(
name: 'Display 1',
style: textTheme.display1,
name: 'Headline 4',
style: textTheme.headline4,
text: 'Regular 34sp',
),
_TextStyleItem(
name: 'Headline',
style: textTheme.headline,
name: 'Headline 5',
style: textTheme.headline5,
text: 'Regular 24sp',
),
_TextStyleItem(
name: 'Title',
style: textTheme.title,
name: 'Headline 6',
style: textTheme.headline6,
text: 'Medium 20sp',
),
_TextStyleItem(
name: 'Subhead',
style: textTheme.subhead,
name: 'Subtitle 1',
style: textTheme.subtitle1,
text: 'Regular 16sp',
),
_TextStyleItem(
name: 'Subtitle',
style: textTheme.subtitle,
name: 'Subtitle 2',
style: textTheme.subtitle2,
text: 'Medium 14sp',
),
_TextStyleItem(
name: 'Body 1',
style: textTheme.body1,
name: 'Body Text 2',
style: textTheme.bodyText2,
text: 'Regular 16sp',
),
_TextStyleItem(
name: 'Body 2',
style: textTheme.body2,
name: 'Body Text 1',
style: textTheme.bodyText1,
text: 'Regular 14sp',
),
_TextStyleItem(
Expand Down
4 changes: 2 additions & 2 deletions lib/feature_discovery/overlay.dart
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class Content extends StatelessWidget {
title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: theme.title.copyWith(color: Colors.white),
style: theme.headline6.copyWith(color: Colors.white),
);
}

Expand All @@ -244,7 +244,7 @@ class Content extends StatelessWidget {
description,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: theme.subhead.copyWith(color: Colors.white70),
style: theme.subtitle1.copyWith(color: Colors.white70),
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/layout/focus_traversal_policy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:flutter/material.dart';
///
/// This can be used to for example make sure that you can request focus outside
/// of the MaterialApp you are currently in.
class EdgeChildrenFocusTraversalPolicy extends WidgetOrderFocusTraversalPolicy {
class EdgeChildrenFocusTraversalPolicy extends WidgetOrderTraversalPolicy {
EdgeChildrenFocusTraversalPolicy({
@required this.firstFocusNodeOutsideScope,
@required this.lastFocusNodeOutsideScope,
Expand Down
10 changes: 6 additions & 4 deletions lib/pages/about.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class _AboutDialog extends StatelessWidget {
Widget build(BuildContext context) {
final colorScheme = Theme.of(context).colorScheme;
final textTheme = Theme.of(context).textTheme;
final bodyTextStyle = textTheme.body2.apply(color: colorScheme.onPrimary);
final bodyTextStyle =
textTheme.bodyText1.apply(color: colorScheme.onPrimary);

final name = 'Flutter Gallery'; // Don't need to localize.
final legalese = '© 2019 The Flutter team'; // Don't need to localize.
Expand All @@ -57,7 +58,7 @@ class _AboutDialog extends StatelessWidget {
future: getVersionNumber(),
builder: (context, snapshot) => Text(
snapshot.hasData ? '$name ${snapshot.data}' : '$name',
style: textTheme.display1.apply(color: colorScheme.onPrimary),
style: textTheme.headline4.apply(color: colorScheme.onPrimary),
),
),
SizedBox(height: 24),
Expand Down Expand Up @@ -109,8 +110,9 @@ class _AboutDialog extends StatelessWidget {
Navigator.of(context).push(MaterialPageRoute<void>(
builder: (context) => Theme(
data: Theme.of(context).copyWith(
textTheme:
Typography(platform: Theme.of(context).platform).black,
textTheme: Typography.material2018(
platform: Theme.of(context).platform,
).black,
scaffoldBackgroundColor: Colors.white,
),
child: LicensePage(
Expand Down
6 changes: 3 additions & 3 deletions lib/pages/backdrop.dart
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ class _BackdropState extends State<Backdrop>
final safeAreaTopPadding = MediaQuery.of(context).padding.top;

final Widget frontLayer = ExcludeSemantics(
child: DefaultFocusTraversal(
policy: WidgetOrderFocusTraversalPolicy(),
child: FocusTraversalGroup(
policy: WidgetOrderTraversalPolicy(),
child: Focus(
skipTraversal: !widget.isSettingsOpenNotifier.value,
child: widget.frontLayer,
Expand All @@ -227,7 +227,7 @@ class _BackdropState extends State<Backdrop>
excluding: widget.isSettingsOpenNotifier.value,
);

return DefaultFocusTraversal(
return FocusTraversalGroup(
child: InheritedBackdropFocusNodes(
frontLayerFocusNode: frontLayerFocusNode,
backLayerFocusNode: backLayerFocusNode,
Expand Down
4 changes: 2 additions & 2 deletions lib/pages/category_list_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class _CategoryHeader extends StatelessWidget {
padding: const EdgeInsetsDirectional.only(start: 8),
child: Text(
title,
style: Theme.of(context).textTheme.headline.apply(
style: Theme.of(context).textTheme.headline5.apply(
color: colorScheme.onSurface,
),
),
Expand Down Expand Up @@ -280,7 +280,7 @@ class CategoryDemoItem extends StatelessWidget {
children: [
Text(
demo.title,
style: textTheme.subhead
style: textTheme.subtitle1
.apply(color: colorScheme.onSurface),
),
Text(
Expand Down
8 changes: 4 additions & 4 deletions lib/pages/demo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ class _DemoSectionOptions extends StatelessWidget {
),
child: Text(
GalleryLocalizations.of(context).demoOptionsTooltip,
style: textTheme.display1.apply(
style: textTheme.headline4.apply(
color: colorScheme.onSurface,
fontSizeDelta:
isDisplayDesktop(context) ? desktopDisplay1FontDelta : 0,
Expand Down Expand Up @@ -562,7 +562,7 @@ class _DemoSectionOptionsItem extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
child: Text(
title,
style: Theme.of(context).textTheme.body1.apply(
style: Theme.of(context).textTheme.bodyText2.apply(
color:
isSelected ? colorScheme.primary : colorScheme.onSurface,
),
Expand Down Expand Up @@ -609,7 +609,7 @@ class _DemoSectionInfo extends StatelessWidget {
children: [
Text(
title,
style: textTheme.display1.apply(
style: textTheme.headline4.apply(
color: colorScheme.onSurface,
fontSizeDelta:
isDisplayDesktop(context) ? desktopDisplay1FontDelta : 0,
Expand All @@ -618,7 +618,7 @@ class _DemoSectionInfo extends StatelessWidget {
SizedBox(height: 12),
Text(
description,
style: textTheme.body1.apply(color: colorScheme.onSurface),
style: textTheme.bodyText2.apply(color: colorScheme.onSurface),
),
],
),
Expand Down
12 changes: 6 additions & 6 deletions lib/pages/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ class Header extends StatelessWidget {
),
child: Text(
text,
style: Theme.of(context).textTheme.display1.apply(
style: Theme.of(context).textTheme.headline4.apply(
color: color,
fontSizeDelta:
isDisplayDesktop(context) ? desktopDisplay1FontDelta : 0,
Expand Down Expand Up @@ -410,8 +410,8 @@ class _DesktopCategoryItem extends StatelessWidget {
color: colorScheme.surface,
child: Semantics(
container: true,
child: DefaultFocusTraversal(
policy: WidgetOrderFocusTraversalPolicy(),
child: FocusTraversalGroup(
policy: WidgetOrderTraversalPolicy(),
child: Column(
children: [
_DesktopCategoryHeader(
Expand Down Expand Up @@ -479,7 +479,7 @@ class _DesktopCategoryHeader extends StatelessWidget {
header: true,
child: Text(
title,
style: Theme.of(context).textTheme.headline.apply(
style: Theme.of(context).textTheme.headline5.apply(
color: colorScheme.onSurface,
),
maxLines: 4,
Expand Down Expand Up @@ -1053,7 +1053,7 @@ class _StudyWrapperState extends State<_StudyWrapper> {
final colorScheme = Theme.of(context).colorScheme;
final textTheme = Theme.of(context).textTheme;
return ApplyTextOptions(
child: DefaultFocusTraversal(
child: FocusTraversalGroup(
policy: StudyWrapperFocusTraversalPolicy(
backButtonFocusNode: backButtonFocusNode,
studyNavigatorKey: widget.navigatorKey,
Expand Down Expand Up @@ -1118,7 +1118,7 @@ class InheritedFocusNodes extends InheritedWidget {
bool updateShouldNotify(InheritedFocusNodes old) => true;
}

class StudyWrapperFocusTraversalPolicy extends WidgetOrderFocusTraversalPolicy {
class StudyWrapperFocusTraversalPolicy extends WidgetOrderTraversalPolicy {
StudyWrapperFocusTraversalPolicy({
@required this.backButtonFocusNode,
@required this.studyNavigatorKey,
Expand Down
4 changes: 2 additions & 2 deletions lib/pages/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ class SettingsAttribution extends StatelessWidget {
),
child: Text(
GalleryLocalizations.of(context).settingsAttribution,
style: Theme.of(context).textTheme.body2.copyWith(
style: Theme.of(context).textTheme.bodyText1.copyWith(
fontSize: 12,
color: Theme.of(context).colorScheme.onSecondary,
),
Expand Down Expand Up @@ -402,7 +402,7 @@ class _SettingsLink extends StatelessWidget {
),
child: Text(
title,
style: textTheme.subtitle.apply(
style: textTheme.subtitle2.apply(
color: colorScheme.onSecondary,
),
textAlign: isDesktop ? TextAlign.end : TextAlign.start,
Expand Down
Loading

0 comments on commit b1324a1

Please sign in to comment.