Commit 1fe57277 authored by Ian Hickson's avatar Ian Hickson

Improve interactivity of the Contacts demo (#4479)

We're explicitly saying that making these icons do anything useful is
out of scope, so the best we'll do here is show a snackbar.
parent 479c7da9
...@@ -34,12 +34,14 @@ class _ContactCategory extends StatelessWidget { ...@@ -34,12 +34,14 @@ class _ContactCategory extends StatelessWidget {
} }
class _ContactItem extends StatelessWidget { class _ContactItem extends StatelessWidget {
_ContactItem({ Key key, this.icon, this.lines }) : super(key: key) { _ContactItem({ Key key, this.icon, this.lines, this.tooltip, this.onPressed }) : super(key: key) {
assert(lines.length > 1); assert(lines.length > 1);
} }
final IconData icon; final IconData icon;
final List<String> lines; final List<String> lines;
final String tooltip;
final VoidCallback onPressed;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -57,7 +59,7 @@ class _ContactItem extends StatelessWidget { ...@@ -57,7 +59,7 @@ class _ContactItem extends StatelessWidget {
if (icon != null) { if (icon != null) {
rowChildren.add(new SizedBox( rowChildren.add(new SizedBox(
width: 72.0, width: 72.0,
child: new Icon(icon: icon, color: Theme.of(context).disabledColor) child: new IconButton(icon: icon, onPressed: onPressed)
)); ));
} }
return new Padding( return new Padding(
...@@ -98,10 +100,10 @@ class ContactsDemoState extends State<ContactsDemo> { ...@@ -98,10 +100,10 @@ class ContactsDemoState extends State<ContactsDemo> {
actions: <Widget>[ actions: <Widget>[
new IconButton( new IconButton(
icon: Icons.create, icon: Icons.create,
tooltip: 'Search', tooltip: 'Edit',
onPressed: () { onPressed: () {
_scaffoldKey.currentState.showSnackBar(new SnackBar( _scaffoldKey.currentState.showSnackBar(new SnackBar(
content: new Text('Not supported.') content: new Text('This is actually just a demo. Editing isn\'t supported.')
)); ));
} }
), ),
...@@ -155,6 +157,12 @@ class ContactsDemoState extends State<ContactsDemo> { ...@@ -155,6 +157,12 @@ class ContactsDemoState extends State<ContactsDemo> {
children: <Widget>[ children: <Widget>[
new _ContactItem( new _ContactItem(
icon: Icons.message, icon: Icons.message,
tooltip: 'Send message',
onPressed: () {
_scaffoldKey.currentState.showSnackBar(new SnackBar(
content: new Text('Pretend that this opened your SMS application.')
));
},
lines: <String>[ lines: <String>[
'(650) 555-1234', '(650) 555-1234',
'Mobile' 'Mobile'
...@@ -162,6 +170,12 @@ class ContactsDemoState extends State<ContactsDemo> { ...@@ -162,6 +170,12 @@ class ContactsDemoState extends State<ContactsDemo> {
), ),
new _ContactItem( new _ContactItem(
icon: Icons.message, icon: Icons.message,
tooltip: 'Send message',
onPressed: () {
_scaffoldKey.currentState.showSnackBar(new SnackBar(
content: new Text('In this demo, this button doesn\'t do anything.')
));
},
lines: <String>[ lines: <String>[
'(323) 555-6789', '(323) 555-6789',
'Work' 'Work'
...@@ -169,6 +183,12 @@ class ContactsDemoState extends State<ContactsDemo> { ...@@ -169,6 +183,12 @@ class ContactsDemoState extends State<ContactsDemo> {
), ),
new _ContactItem( new _ContactItem(
icon: Icons.message, icon: Icons.message,
tooltip: 'Send message',
onPressed: () {
_scaffoldKey.currentState.showSnackBar(new SnackBar(
content: new Text('Imagine if you will, a messaging application.')
));
},
lines: <String>[ lines: <String>[
'(650) 555-6789', '(650) 555-6789',
'Home' 'Home'
...@@ -180,12 +200,26 @@ class ContactsDemoState extends State<ContactsDemo> { ...@@ -180,12 +200,26 @@ class ContactsDemoState extends State<ContactsDemo> {
icon: Icons.email, icon: Icons.email,
children: <Widget>[ children: <Widget>[
new _ContactItem( new _ContactItem(
icon: Icons.email,
tooltip: 'Send personal e-mail',
onPressed: () {
_scaffoldKey.currentState.showSnackBar(new SnackBar(
content: new Text('Here, your e-mail application would open.')
));
},
lines: <String>[ lines: <String>[
'ali_connors@example.com', 'ali_connors@example.com',
'Personal' 'Personal'
] ]
), ),
new _ContactItem( new _ContactItem(
icon: Icons.email,
tooltip: 'Send work e-mail',
onPressed: () {
_scaffoldKey.currentState.showSnackBar(new SnackBar(
content: new Text('This is a demo, so this button does not actually work.')
));
},
lines: <String>[ lines: <String>[
'aliconnors@example.com', 'aliconnors@example.com',
'Work' 'Work'
...@@ -197,6 +231,13 @@ class ContactsDemoState extends State<ContactsDemo> { ...@@ -197,6 +231,13 @@ class ContactsDemoState extends State<ContactsDemo> {
icon: Icons.location_on, icon: Icons.location_on,
children: <Widget>[ children: <Widget>[
new _ContactItem( new _ContactItem(
icon: Icons.map,
tooltip: 'Open map',
onPressed: () {
_scaffoldKey.currentState.showSnackBar(new SnackBar(
content: new Text('This would show a map of San Francisco.')
));
},
lines: <String>[ lines: <String>[
'2000 Main Street', '2000 Main Street',
'San Francisco, CA', 'San Francisco, CA',
...@@ -204,6 +245,13 @@ class ContactsDemoState extends State<ContactsDemo> { ...@@ -204,6 +245,13 @@ class ContactsDemoState extends State<ContactsDemo> {
] ]
), ),
new _ContactItem( new _ContactItem(
icon: Icons.map,
tooltip: 'Open map',
onPressed: () {
_scaffoldKey.currentState.showSnackBar(new SnackBar(
content: new Text('This would show a map of Mountain View.')
));
},
lines: <String>[ lines: <String>[
'1600 Amphitheater Parkway', '1600 Amphitheater Parkway',
'Mountain View, CA', 'Mountain View, CA',
...@@ -211,6 +259,13 @@ class ContactsDemoState extends State<ContactsDemo> { ...@@ -211,6 +259,13 @@ class ContactsDemoState extends State<ContactsDemo> {
] ]
), ),
new _ContactItem( new _ContactItem(
icon: Icons.map,
tooltip: 'Open map',
onPressed: () {
_scaffoldKey.currentState.showSnackBar(new SnackBar(
content: new Text('This would also show a map, if this was not a demo.')
));
},
lines: <String>[ lines: <String>[
'126 Severyns Ave', '126 Severyns Ave',
'Mountain View, CA', 'Mountain View, CA',
......
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