From 9ce3ba314eed296812f2176d7a5bbc66e01ba199 Mon Sep 17 00:00:00 2001 From: xster Date: Mon, 16 Oct 2017 18:59:28 -0700 Subject: [PATCH] Add Cupertino icon fonts helper and dependency for default template (#12559) * add CupertinoIcons * Use new font name convention * review --- packages/flutter/lib/cupertino.dart | 1 + packages/flutter/lib/src/cupertino/icons.dart | 61 +++++++++++++++++++ .../templates/create/pubspec.yaml.tmpl | 8 ++- 3 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 packages/flutter/lib/src/cupertino/icons.dart diff --git a/packages/flutter/lib/cupertino.dart b/packages/flutter/lib/cupertino.dart index 2fcff8c8c58..81456969ad3 100644 --- a/packages/flutter/lib/cupertino.dart +++ b/packages/flutter/lib/cupertino.dart @@ -12,6 +12,7 @@ export 'src/cupertino/bottom_tab_bar.dart'; export 'src/cupertino/button.dart'; export 'src/cupertino/colors.dart'; export 'src/cupertino/dialog.dart'; +export 'src/cupertino/icons.dart'; export 'src/cupertino/nav_bar.dart'; export 'src/cupertino/page_scaffold.dart'; export 'src/cupertino/route.dart'; diff --git a/packages/flutter/lib/src/cupertino/icons.dart b/packages/flutter/lib/src/cupertino/icons.dart new file mode 100644 index 00000000000..62f0bae4650 --- /dev/null +++ b/packages/flutter/lib/src/cupertino/icons.dart @@ -0,0 +1,61 @@ +// Copyright 2017 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/widgets.dart'; + +/// Identifiers for the supported Cupertino icons. +/// +/// Use with the [Icon] class to show specific icons. +/// +/// Icons are identified by their name as listed below. +/// +/// To use this class, make sure you add a dependency on `cupertino_icons` in your +/// project's `pubspec.yaml` file. This ensures that the CupertinoIcons font is +/// included in your application. This font is used to display the icons. For example: +/// +/// ```yaml +/// name: my_awesome_application +/// +/// dependencies: +/// cupertino_icons: ^0.1.0 +/// ``` +/// +/// See also: +/// +/// * [Icon] +class CupertinoIcons { + CupertinoIcons._(); + + static const String iconFont = 'packages/cupertino_icons/CupertinoIcons'; + + // Manually maintained list + + static const IconData left_chevron = const IconData(0xf3f0, fontFamily: iconFont); + + static const IconData right_chevron = const IconData(0xf3f2, fontFamily: iconFont); + + static const IconData share = const IconData(0xf4ca, fontFamily: iconFont); + + static const IconData book = const IconData(0xf3e7, fontFamily: iconFont); + + static const IconData info = const IconData(0xf44c, fontFamily: iconFont); + + static const IconData reply = const IconData(0xf4c6, fontFamily: iconFont); + + static const IconData conversation_bubble = const IconData(0xf3fb, fontFamily: iconFont); + + static const IconData profile_circled = const IconData(0xf419, fontFamily: iconFont); + + static const IconData plus_circled = const IconData(0xf48a, fontFamily: iconFont); + + static const IconData minus_circled = const IconData(0xf463, fontFamily: iconFont); + + static const IconData flag = const IconData(0xf42c, fontFamily: iconFont); + + static const IconData search = const IconData(0xf4c6, fontFamily: iconFont); + + static const IconData check_mark = const IconData(0xf41e, fontFamily: iconFont); + + static const IconData check_mark_circled = const IconData(0xf41f, fontFamily: iconFont); +} \ No newline at end of file diff --git a/packages/flutter_tools/templates/create/pubspec.yaml.tmpl b/packages/flutter_tools/templates/create/pubspec.yaml.tmpl index a2b11b629b2..c175f6471f9 100644 --- a/packages/flutter_tools/templates/create/pubspec.yaml.tmpl +++ b/packages/flutter_tools/templates/create/pubspec.yaml.tmpl @@ -5,6 +5,10 @@ dependencies: flutter: sdk: flutter + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^0.1.0 + dev_dependencies: flutter_test: sdk: flutter @@ -26,7 +30,7 @@ flutter: # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in - # the Icons class. + # the material Icons class. uses-material-design: true # To add assets to your application, add an assets section, like this: @@ -39,7 +43,7 @@ flutter: # For details regarding adding assets from package dependencies, see # https://flutter.io/assets-and-images/#from-packages - + # To add custom fonts to your application, add a fonts section here, # in this "flutter" section. Each entry in this list should have a # "family" key with the font family name, and a "fonts" key with a