mirror of
https://github.com/flutter/samples.git
synced 2026-07-15 05:21:30 +00:00
Update web/ samples to work with Flutter SDK (#134)
* add package:http dependency in dad_jokes * add package:http dependency in filipino_cuisine * don't build package:http demos until flutter/flutter#34858 is resolved * update gallery * update github_dataviz * update particle_background * don't build github_dataviz (uses package:http) * update slide_puzzle * update spinning_square * update timeflow * update vision_challenge * update charts * update dad_jokes * update filipino cuisine * ignore build output * update timeflow and vision_challenge * update slide_puzzle * don't commit build/ directory * move preview.png images to assets * fix path url join * update readme * update web/readme.md
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
// Copyright 2018 The Chromium Authors. All rights reserved.
|
||||
// Copyright 2015 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter_web/material.dart';
|
||||
import 'package:flutter_web/services.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class _ContactCategory extends StatelessWidget {
|
||||
const _ContactCategory({Key key, this.icon, this.children}) : super(key: key);
|
||||
const _ContactCategory({ Key key, this.icon, this.children }) : super(key: key);
|
||||
|
||||
final IconData icon;
|
||||
final List<Widget> children;
|
||||
@@ -17,7 +17,8 @@ class _ContactCategory extends StatelessWidget {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||
decoration: BoxDecoration(
|
||||
border: Border(bottom: BorderSide(color: themeData.dividerColor))),
|
||||
border: Border(bottom: BorderSide(color: themeData.dividerColor))
|
||||
),
|
||||
child: DefaultTextStyle(
|
||||
style: Theme.of(context).textTheme.subhead,
|
||||
child: SafeArea(
|
||||
@@ -27,10 +28,11 @@ class _ContactCategory extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 24.0),
|
||||
width: 72.0,
|
||||
child: Icon(icon, color: themeData.primaryColor)),
|
||||
Expanded(child: Column(children: children))
|
||||
padding: const EdgeInsets.symmetric(vertical: 24.0),
|
||||
width: 72.0,
|
||||
child: Icon(icon, color: themeData.primaryColor),
|
||||
),
|
||||
Expanded(child: Column(children: children)),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -40,9 +42,9 @@ class _ContactCategory extends StatelessWidget {
|
||||
}
|
||||
|
||||
class _ContactItem extends StatelessWidget {
|
||||
_ContactItem({Key key, this.icon, this.lines, this.tooltip, this.onPressed})
|
||||
: assert(lines.length > 1),
|
||||
super(key: key);
|
||||
const _ContactItem({ Key key, this.icon, this.lines, this.tooltip, this.onPressed })
|
||||
: assert(lines.length > 1),
|
||||
super(key: key);
|
||||
|
||||
final IconData icon;
|
||||
final List<String> lines;
|
||||
@@ -52,32 +54,35 @@ class _ContactItem extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ThemeData themeData = Theme.of(context);
|
||||
final List<Widget> columnChildren = lines
|
||||
.sublist(0, lines.length - 1)
|
||||
.map<Widget>((String line) => Text(line))
|
||||
.toList();
|
||||
final List<Widget> columnChildren = lines.sublist(0, lines.length - 1).map<Widget>((String line) => Text(line)).toList();
|
||||
columnChildren.add(Text(lines.last, style: themeData.textTheme.caption));
|
||||
|
||||
final List<Widget> rowChildren = <Widget>[
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: columnChildren))
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: columnChildren,
|
||||
),
|
||||
),
|
||||
];
|
||||
if (icon != null) {
|
||||
rowChildren.add(SizedBox(
|
||||
width: 72.0,
|
||||
child: IconButton(
|
||||
icon: Icon(icon),
|
||||
color: themeData.primaryColor,
|
||||
onPressed: onPressed)));
|
||||
width: 72.0,
|
||||
child: IconButton(
|
||||
icon: Icon(icon),
|
||||
color: themeData.primaryColor,
|
||||
onPressed: onPressed,
|
||||
),
|
||||
));
|
||||
}
|
||||
return MergeSemantics(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: rowChildren)),
|
||||
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: rowChildren,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -92,8 +97,7 @@ class ContactsDemo extends StatefulWidget {
|
||||
enum AppBarBehavior { normal, pinned, floating, snapping }
|
||||
|
||||
class ContactsDemoState extends State<ContactsDemo> {
|
||||
static final GlobalKey<ScaffoldState> _scaffoldKey =
|
||||
GlobalKey<ScaffoldState>();
|
||||
static final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
final double _appBarHeight = 256.0;
|
||||
|
||||
AppBarBehavior _appBarBehavior = AppBarBehavior.pinned;
|
||||
@@ -113,8 +117,7 @@ class ContactsDemoState extends State<ContactsDemo> {
|
||||
SliverAppBar(
|
||||
expandedHeight: _appBarHeight,
|
||||
pinned: _appBarBehavior == AppBarBehavior.pinned,
|
||||
floating: _appBarBehavior == AppBarBehavior.floating ||
|
||||
_appBarBehavior == AppBarBehavior.snapping,
|
||||
floating: _appBarBehavior == AppBarBehavior.floating || _appBarBehavior == AppBarBehavior.snapping,
|
||||
snap: _appBarBehavior == AppBarBehavior.snapping,
|
||||
actions: <Widget>[
|
||||
IconButton(
|
||||
@@ -122,8 +125,8 @@ class ContactsDemoState extends State<ContactsDemo> {
|
||||
tooltip: 'Edit',
|
||||
onPressed: () {
|
||||
_scaffoldKey.currentState.showSnackBar(const SnackBar(
|
||||
content:
|
||||
Text("Editing isn't supported in this screen.")));
|
||||
content: Text("Editing isn't supported in this screen."),
|
||||
));
|
||||
},
|
||||
),
|
||||
PopupMenuButton<AppBarBehavior>(
|
||||
@@ -132,20 +135,23 @@ class ContactsDemoState extends State<ContactsDemo> {
|
||||
_appBarBehavior = value;
|
||||
});
|
||||
},
|
||||
itemBuilder: (BuildContext context) =>
|
||||
<PopupMenuItem<AppBarBehavior>>[
|
||||
itemBuilder: (BuildContext context) => <PopupMenuItem<AppBarBehavior>>[
|
||||
const PopupMenuItem<AppBarBehavior>(
|
||||
value: AppBarBehavior.normal,
|
||||
child: Text('App bar scrolls away')),
|
||||
value: AppBarBehavior.normal,
|
||||
child: Text('App bar scrolls away'),
|
||||
),
|
||||
const PopupMenuItem<AppBarBehavior>(
|
||||
value: AppBarBehavior.pinned,
|
||||
child: Text('App bar stays put')),
|
||||
value: AppBarBehavior.pinned,
|
||||
child: Text('App bar stays put'),
|
||||
),
|
||||
const PopupMenuItem<AppBarBehavior>(
|
||||
value: AppBarBehavior.floating,
|
||||
child: Text('App bar floats')),
|
||||
value: AppBarBehavior.floating,
|
||||
child: Text('App bar floats'),
|
||||
),
|
||||
const PopupMenuItem<AppBarBehavior>(
|
||||
value: AppBarBehavior.snapping,
|
||||
child: Text('App bar snaps')),
|
||||
value: AppBarBehavior.snapping,
|
||||
child: Text('App bar snaps'),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -156,7 +162,7 @@ class ContactsDemoState extends State<ContactsDemo> {
|
||||
children: <Widget>[
|
||||
Image.asset(
|
||||
'people/ali_landscape.png',
|
||||
// package: 'flutter_gallery_assets',
|
||||
package: 'flutter_gallery_assets',
|
||||
fit: BoxFit.cover,
|
||||
height: _appBarHeight,
|
||||
),
|
||||
@@ -187,8 +193,8 @@ class ContactsDemoState extends State<ContactsDemo> {
|
||||
tooltip: 'Send message',
|
||||
onPressed: () {
|
||||
_scaffoldKey.currentState.showSnackBar(const SnackBar(
|
||||
content: Text(
|
||||
'Pretend that this opened your SMS application.')));
|
||||
content: Text('Pretend that this opened your SMS application.'),
|
||||
));
|
||||
},
|
||||
lines: const <String>[
|
||||
'(650) 555-1234',
|
||||
@@ -200,7 +206,8 @@ class ContactsDemoState extends State<ContactsDemo> {
|
||||
tooltip: 'Send message',
|
||||
onPressed: () {
|
||||
_scaffoldKey.currentState.showSnackBar(const SnackBar(
|
||||
content: Text('A messaging app appears.')));
|
||||
content: Text('A messaging app appears.'),
|
||||
));
|
||||
},
|
||||
lines: const <String>[
|
||||
'(323) 555-6789',
|
||||
@@ -212,8 +219,8 @@ class ContactsDemoState extends State<ContactsDemo> {
|
||||
tooltip: 'Send message',
|
||||
onPressed: () {
|
||||
_scaffoldKey.currentState.showSnackBar(const SnackBar(
|
||||
content: Text(
|
||||
'Imagine if you will, a messaging application.')));
|
||||
content: Text('Imagine if you will, a messaging application.'),
|
||||
));
|
||||
},
|
||||
lines: const <String>[
|
||||
'(650) 555-6789',
|
||||
@@ -231,8 +238,8 @@ class ContactsDemoState extends State<ContactsDemo> {
|
||||
tooltip: 'Send personal e-mail',
|
||||
onPressed: () {
|
||||
_scaffoldKey.currentState.showSnackBar(const SnackBar(
|
||||
content: Text(
|
||||
'Here, your e-mail application would open.')));
|
||||
content: Text('Here, your e-mail application would open.'),
|
||||
));
|
||||
},
|
||||
lines: const <String>[
|
||||
'ali_connors@example.com',
|
||||
@@ -244,8 +251,8 @@ class ContactsDemoState extends State<ContactsDemo> {
|
||||
tooltip: 'Send work e-mail',
|
||||
onPressed: () {
|
||||
_scaffoldKey.currentState.showSnackBar(const SnackBar(
|
||||
content: Text(
|
||||
'Summon your favorite e-mail application here.')));
|
||||
content: Text('Summon your favorite e-mail application here.'),
|
||||
));
|
||||
},
|
||||
lines: const <String>[
|
||||
'aliconnors@example.com',
|
||||
@@ -262,8 +269,8 @@ class ContactsDemoState extends State<ContactsDemo> {
|
||||
tooltip: 'Open map',
|
||||
onPressed: () {
|
||||
_scaffoldKey.currentState.showSnackBar(const SnackBar(
|
||||
content: Text(
|
||||
'This would show a map of San Francisco.')));
|
||||
content: Text('This would show a map of San Francisco.'),
|
||||
));
|
||||
},
|
||||
lines: const <String>[
|
||||
'2000 Main Street',
|
||||
@@ -276,8 +283,8 @@ class ContactsDemoState extends State<ContactsDemo> {
|
||||
tooltip: 'Open map',
|
||||
onPressed: () {
|
||||
_scaffoldKey.currentState.showSnackBar(const SnackBar(
|
||||
content: Text(
|
||||
'This would show a map of Mountain View.')));
|
||||
content: Text('This would show a map of Mountain View.'),
|
||||
));
|
||||
},
|
||||
lines: const <String>[
|
||||
'1600 Amphitheater Parkway',
|
||||
@@ -290,8 +297,8 @@ class ContactsDemoState extends State<ContactsDemo> {
|
||||
tooltip: 'Open map',
|
||||
onPressed: () {
|
||||
_scaffoldKey.currentState.showSnackBar(const SnackBar(
|
||||
content: Text(
|
||||
'This would also show a map, if this was not a demo.')));
|
||||
content: Text('This would also show a map, if this was not a demo.'),
|
||||
));
|
||||
},
|
||||
lines: const <String>[
|
||||
'126 Severyns Ave',
|
||||
|
||||
Reference in New Issue
Block a user