mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

* Update project.pbxproj files to say Flutter rather than Chromium Also, the templates now have an empty organization so that we don't cause people to give their apps a Flutter copyright. * Update the copyright notice checker to require a standard notice on all files * Update copyrights on Dart files. (This was a mechanical commit.) * Fix weird license headers on Dart files that deviate from our conventions; relicense Shrine. Some were already marked "The Flutter Authors", not clear why. Their dates have been normalized. Some were missing the blank line after the license. Some were randomly different in trivial ways for no apparent reason (e.g. missing the trailing period). * Clean up the copyrights in non-Dart files. (Manual edits.) Also, make sure templates don't have copyrights. * Fix some more ORGANIZATIONNAMEs
139 lines
3.6 KiB
Dart
139 lines
3.6 KiB
Dart
// Copyright 2014 The Flutter 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/material.dart';
|
|
|
|
import '../../gallery/demo.dart';
|
|
|
|
class IconsDemo extends StatefulWidget {
|
|
static const String routeName = '/material/icons';
|
|
|
|
@override
|
|
IconsDemoState createState() => IconsDemoState();
|
|
}
|
|
|
|
class IconsDemoState extends State<IconsDemo> {
|
|
static final List<MaterialColor> iconColors = <MaterialColor>[
|
|
Colors.red,
|
|
Colors.pink,
|
|
Colors.purple,
|
|
Colors.deepPurple,
|
|
Colors.indigo,
|
|
Colors.blue,
|
|
Colors.lightBlue,
|
|
Colors.cyan,
|
|
Colors.teal,
|
|
Colors.green,
|
|
Colors.lightGreen,
|
|
Colors.lime,
|
|
Colors.yellow,
|
|
Colors.amber,
|
|
Colors.orange,
|
|
Colors.deepOrange,
|
|
Colors.brown,
|
|
Colors.grey,
|
|
Colors.blueGrey,
|
|
];
|
|
|
|
int iconColorIndex = 8; // teal
|
|
|
|
Color get iconColor => iconColors[iconColorIndex];
|
|
|
|
void handleIconButtonPress() {
|
|
setState(() {
|
|
iconColorIndex = (iconColorIndex + 1) % iconColors.length;
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text('Icons'),
|
|
actions: <Widget>[MaterialDemoDocumentationButton(IconsDemo.routeName)],
|
|
),
|
|
body: IconTheme(
|
|
data: IconThemeData(color: iconColor),
|
|
child: SafeArea(
|
|
top: false,
|
|
bottom: false,
|
|
child: Scrollbar(
|
|
child: ListView(
|
|
padding: const EdgeInsets.all(24.0),
|
|
children: <Widget>[
|
|
_IconsDemoCard(handleIconButtonPress, Icons.face), // direction-agnostic icon
|
|
const SizedBox(height: 24.0),
|
|
_IconsDemoCard(handleIconButtonPress, Icons.battery_unknown), // direction-aware icon
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _IconsDemoCard extends StatelessWidget {
|
|
const _IconsDemoCard(this.handleIconButtonPress, this.icon);
|
|
|
|
final VoidCallback handleIconButtonPress;
|
|
final IconData icon;
|
|
|
|
Widget _buildIconButton(double iconSize, IconData icon, bool enabled) {
|
|
return IconButton(
|
|
icon: Icon(icon),
|
|
iconSize: iconSize,
|
|
tooltip: "${enabled ? 'Enabled' : 'Disabled'} icon button",
|
|
onPressed: enabled ? handleIconButtonPress : null,
|
|
);
|
|
}
|
|
|
|
Widget _centeredText(String label) =>
|
|
Padding(
|
|
// Match the default padding of IconButton.
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Text(label, textAlign: TextAlign.center),
|
|
);
|
|
|
|
TableRow _buildIconRow(double size) {
|
|
return TableRow(
|
|
children: <Widget> [
|
|
_centeredText(size.floor().toString()),
|
|
_buildIconButton(size, icon, true),
|
|
_buildIconButton(size, icon, false),
|
|
],
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final ThemeData theme = Theme.of(context);
|
|
final TextStyle textStyle = theme.textTheme.subhead.copyWith(color: theme.textTheme.caption.color);
|
|
return Card(
|
|
child: DefaultTextStyle(
|
|
style: textStyle,
|
|
child: Semantics(
|
|
explicitChildNodes: true,
|
|
child: Table(
|
|
defaultVerticalAlignment: TableCellVerticalAlignment.middle,
|
|
children: <TableRow> [
|
|
TableRow(
|
|
children: <Widget> [
|
|
_centeredText('Size'),
|
|
_centeredText('Enabled'),
|
|
_centeredText('Disabled'),
|
|
]
|
|
),
|
|
_buildIconRow(18.0),
|
|
_buildIconRow(24.0),
|
|
_buildIconRow(36.0),
|
|
_buildIconRow(48.0),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|