Unverified Commit 16cba903 authored by Michael Spiss's avatar Michael Spiss Committed by GitHub

Merge pull request #78 from fluttercommunity/duotone

Move non-public files to src, Add duotone support, Fix #76
parents 0360a0ef 621f69ef
......@@ -76,14 +76,15 @@ icon fonts and want to use them with Flutter, please follow these instructions.
to keep these files private. This includes **not** uploading your package to
a public github repository or other public file sharing services.
* Download this package's newest release, extract the folder and move it to a location of your choice
* Download this package's
[newest release](https://github.com/fluttercommunity/font_awesome_flutter/archive/master.zip),
extract the folder and move it to a location of your choice
* Remove `#`s from `pubspec.yaml` at the indicated position
* run `flutter packages get`
* Download your font awesome pro icons (web version)
* Move all `.ttf` files from the `webfonts` directory to this package's lib/fonts (replace existing fonts)
* Move `icons.json` from `metadata` to this directory
* Run `./tool/update.sh`
* Uncomment `IconDataLight` in `lib/icon_data.dart`
* In your project's dependencies, replace the version tag for `font_awesome_flutter` with the path to your custom installation.
```yaml
......@@ -93,6 +94,21 @@ dependencies:
...
```
### Duotone icons
Duotone icons require special treatment. Instead of `FaIcon` a special class
`FaDuotoneIcon` needs to be used. It allows to set the primary and secondary colors
for the icon. If primary and / or secondary color are not defined, they will default
to the standard `IconTheme` color.
```dart
FaDuotoneIcon(
FontAwesomeIcons.abacus,
primaryColor: Colors.black.withOpacity(.4),
secondaryColor: Colors.black,
);
```
## Contributors
- Brian Egan
......
library font_awesome_flutter;
import 'package:flutter/widgets.dart';
import 'package:font_awesome_flutter/icon_data.dart';
export 'fa_icon.dart';
import 'package:font_awesome_flutter/src/icon_data.dart';
export 'package:font_awesome_flutter/src/fa_icon.dart';
// THIS FILE IS AUTOMATICALLY GENERATED!
......
import 'package:flutter/widgets.dart';
import 'package:font_awesome_flutter/src/fa_icon.dart';
import 'package:font_awesome_flutter/src/icon_data.dart';
/// Special icon style which can have two colors
class FaDuotoneIcon extends StatelessWidget {
/// The icon to display. The available icons are described in
/// [FontAwesomeIcons]. Applicable icons start with "duotone".
final IconDataDuotone icon;
/// The font size of the icon.
///
/// Defaults to the current [IconTheme] size, if any. If there is no
/// [IconTheme], or it does not specify an explicit size, then it defaults to
/// 24.0.
///
/// If this [FaIcon] is being placed inside an [IconButton], then use
/// [IconButton.iconSize] instead, so that the [IconButton] can make the
/// splash area the appropriate size as well. The [IconButton] uses an
/// [IconTheme] to pass down the size to the [FaIcon].
final double size;
/// Color used for the icon's main body
final Color primaryColor;
/// Color used for the icon's accents
final Color secondaryColor;
/// Semantic label for the icon.
///
/// Announced in accessibility modes (e.g TalkBack/VoiceOver).
/// This label does not show in the UI.
///
/// See also:
///
/// * [Semantics.label], which is set to [semanticLabel] in the underlying
/// [Semantics] widget.
final String semanticLabel;
const FaDuotoneIcon(
this.icon, {
Key key,
this.size,
this.primaryColor,
this.secondaryColor,
this.semanticLabel,
}) : assert(icon != null),
super(key: key);
@override
Widget build(BuildContext context) {
return Semantics(
label: semanticLabel,
child: Stack(
key: key,
children: <Widget>[
FaIcon(
IconDataDuotone(icon.codePoint),
size: size,
color: secondaryColor,
),
FaIcon(
IconDataDuotone(icon.codePoint + 0x100000),
size: size,
color: primaryColor,
),
],
),
);
}
}
......@@ -29,8 +29,6 @@ class IconDataRegular extends IconData {
);
}
// Uncomment to be able to use (pro) light icons if installed
/*
class IconDataLight extends IconData {
const IconDataLight(int codePoint)
: super(
......@@ -39,5 +37,12 @@ class IconDataLight extends IconData {
fontPackage: 'font_awesome_flutter',
);
}
*/
class IconDataDuotone extends IconData {
const IconDataDuotone(int codePoint)
: super(
codePoint,
fontFamily: 'FontAwesomeDuotone',
fontPackage: 'font_awesome_flutter',
);
}
......@@ -31,9 +31,12 @@ flutter:
fonts:
- asset: lib/fonts/fa-solid-900.ttf
weight: 900
# To support pro icons, drop fa-light-300.ttf into lib/fonts,
# regenerate the icon collection and uncomment the following lines:
# Uncomment the following lines to support pro icons
# - family: FontAwesomeLight
# fonts:
# - asset: lib/fonts/fa-light-300.ttf
# weight: 300
# - family: FontAwesomeDuotone
# fonts:
# - asset: lib/fonts/fa-duotone-900.ttf
# weight: 900
......@@ -15,6 +15,8 @@ void main(List<String> arguments) {
Map<String, String> iconDefinitions = {};
bool hasDuotone = false;
for (String iconName in icons.keys) {
var icon = icons[iconName];
var unicode = icon['unicode'];
......@@ -30,6 +32,10 @@ void main(List<String> arguments) {
);
}
if(styles.contains('duotone')) {
hasDuotone = true;
}
for (String style in styles) {
String name = '${style}_$iconName';
iconDefinitions[name] = generateIconDefinition(
......@@ -51,13 +57,20 @@ void main(List<String> arguments) {
'library font_awesome_flutter;',
'',
"import 'package:flutter/widgets.dart';",
"import 'package:font_awesome_flutter/icon_data.dart';",
"export 'fa_icon.dart';",
"import 'package:font_awesome_flutter/src/icon_data.dart';",
"export 'package:font_awesome_flutter/src/fa_icon.dart';",
];
if(hasDuotone) {
generatedOutput.add("export 'package:font_awesome_flutter/src/fa_duotone_icon.dart';");
}
generatedOutput.addAll([
'',
'// THIS FILE IS AUTOMATICALLY GENERATED!',
'',
'class FontAwesomeIcons {',
];
]);
generatedOutput.addAll(iconDefinitions.values);
......
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