Skip to content

Commit d31113b

Browse files
committed
Refactor icon color opacity handling and update example icons
1 parent 9777a6a commit d31113b

File tree

9 files changed

+126
-45
lines changed

9 files changed

+126
-45
lines changed

example/lib/icons.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ final icons = <ExampleIcon>[
348348
ExampleIcon(FontAwesomeIcons.solidChartBar, 'solidChartBar'),
349349
ExampleIcon(FontAwesomeIcons.chartBar, 'chartBar'),
350350
ExampleIcon(FontAwesomeIcons.chartColumn, 'chartColumn'),
351+
ExampleIcon(FontAwesomeIcons.chartDiagram, 'chartDiagram'),
351352
ExampleIcon(FontAwesomeIcons.chartGantt, 'chartGantt'),
352353
ExampleIcon(FontAwesomeIcons.chartLine, 'chartLine'),
353354
ExampleIcon(FontAwesomeIcons.chartPie, 'chartPie'),
@@ -476,6 +477,7 @@ final icons = <ExampleIcon>[
476477
ExampleIcon(FontAwesomeIcons.solidCommentDots, 'solidCommentDots'),
477478
ExampleIcon(FontAwesomeIcons.commentDots, 'commentDots'),
478479
ExampleIcon(FontAwesomeIcons.commentMedical, 'commentMedical'),
480+
ExampleIcon(FontAwesomeIcons.commentNodes, 'commentNodes'),
479481
ExampleIcon(FontAwesomeIcons.commentSlash, 'commentSlash'),
480482
ExampleIcon(FontAwesomeIcons.commentSms, 'commentSms'),
481483
ExampleIcon(FontAwesomeIcons.solidComments, 'solidComments'),
@@ -528,6 +530,7 @@ final icons = <ExampleIcon>[
528530
ExampleIcon(FontAwesomeIcons.crown, 'crown'),
529531
ExampleIcon(FontAwesomeIcons.crutch, 'crutch'),
530532
ExampleIcon(FontAwesomeIcons.cruzeiroSign, 'cruzeiroSign'),
533+
ExampleIcon(FontAwesomeIcons.css, 'css'),
531534
ExampleIcon(FontAwesomeIcons.css3, 'css3'),
532535
ExampleIcon(FontAwesomeIcons.css3Alt, 'css3Alt'),
533536
ExampleIcon(FontAwesomeIcons.cube, 'cube'),
@@ -764,6 +767,8 @@ final icons = <ExampleIcon>[
764767
ExampleIcon(FontAwesomeIcons.solidFileExcel, 'solidFileExcel'),
765768
ExampleIcon(FontAwesomeIcons.fileExcel, 'fileExcel'),
766769
ExampleIcon(FontAwesomeIcons.fileExport, 'fileExport'),
770+
ExampleIcon(FontAwesomeIcons.fileFragment, 'fileFragment'),
771+
ExampleIcon(FontAwesomeIcons.fileHalfDashed, 'fileHalfDashed'),
767772
ExampleIcon(FontAwesomeIcons.solidFileImage, 'solidFileImage'),
768773
ExampleIcon(FontAwesomeIcons.fileImage, 'fileImage'),
769774
ExampleIcon(FontAwesomeIcons.fileImport, 'fileImport'),
@@ -787,6 +792,7 @@ final icons = <ExampleIcon>[
787792
ExampleIcon(FontAwesomeIcons.fileWord, 'fileWord'),
788793
ExampleIcon(FontAwesomeIcons.solidFileZipper, 'solidFileZipper'),
789794
ExampleIcon(FontAwesomeIcons.fileZipper, 'fileZipper'),
795+
ExampleIcon(FontAwesomeIcons.filesPinwheel, 'filesPinwheel'),
790796
ExampleIcon(FontAwesomeIcons.fill, 'fill'),
791797
ExampleIcon(FontAwesomeIcons.fillDrip, 'fillDrip'),
792798
ExampleIcon(FontAwesomeIcons.film, 'film'),
@@ -998,6 +1004,8 @@ final icons = <ExampleIcon>[
9981004
ExampleIcon(FontAwesomeIcons.helicopterSymbol, 'helicopterSymbol'),
9991005
ExampleIcon(FontAwesomeIcons.helmetSafety, 'helmetSafety'),
10001006
ExampleIcon(FontAwesomeIcons.helmetUn, 'helmetUn'),
1007+
ExampleIcon(FontAwesomeIcons.hexagonNodes, 'hexagonNodes'),
1008+
ExampleIcon(FontAwesomeIcons.hexagonNodesBolt, 'hexagonNodesBolt'),
10011009
ExampleIcon(FontAwesomeIcons.highlighter, 'highlighter'),
10021010
ExampleIcon(FontAwesomeIcons.hillAvalanche, 'hillAvalanche'),
10031011
ExampleIcon(FontAwesomeIcons.hillRockslide, 'hillRockslide'),
@@ -1676,6 +1684,8 @@ final icons = <ExampleIcon>[
16761684
ExampleIcon(FontAwesomeIcons.square, 'square'),
16771685
ExampleIcon(FontAwesomeIcons.squareArrowUpRight, 'squareArrowUpRight'),
16781686
ExampleIcon(FontAwesomeIcons.squareBehance, 'squareBehance'),
1687+
ExampleIcon(FontAwesomeIcons.squareBinary, 'squareBinary'),
1688+
ExampleIcon(FontAwesomeIcons.squareBluesky, 'squareBluesky'),
16791689
ExampleIcon(FontAwesomeIcons.solidSquareCaretDown, 'solidSquareCaretDown'),
16801690
ExampleIcon(FontAwesomeIcons.squareCaretDown, 'squareCaretDown'),
16811691
ExampleIcon(FontAwesomeIcons.solidSquareCaretLeft, 'solidSquareCaretLeft'),

lib/font_awesome_flutter.dart

Lines changed: 97 additions & 38 deletions
Large diffs are not rendered by default.

lib/fonts/fa-brands-400.ttf

1.38 KB
Binary file not shown.

lib/fonts/fa-regular-400.ttf

88 Bytes
Binary file not shown.

lib/fonts/fa-solid-900.ttf

2.38 KB
Binary file not shown.

lib/src/fa_icon.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class FaIcon extends StatelessWidget {
136136
final double iconOpacity = iconTheme.opacity ?? 1.0;
137137
Color iconColor = color ?? iconTheme.color!;
138138
if (iconOpacity != 1.0) {
139-
iconColor = iconColor.withOpacity(iconColor.opacity * iconOpacity);
139+
iconColor = iconColor.withValues(alpha: iconColor.a * iconOpacity);
140140
}
141141

142142
Widget iconWidget = RichText(

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ flutter:
5959
# - family: FontAwesomeSharpSolid
6060
# fonts:
6161
# - asset: lib/fonts/fa-sharp-solid-900.ttf
62-
# weight: 900
62+
# weight: 900

test/fa_icon_test.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ void main() {
2121
),
2222
);
2323
final RichText text = tester.widget(find.byType(RichText));
24-
expect(text.text.style!.color, const Color(0xFF666666).withOpacity(0.5));
24+
expect(
25+
text.text.style!.color, const Color(0xFF666666).withValues(alpha: 0.5));
2526
});
2627

2728
testWidgets('Icon sizing - no theme, default size',

util/lib/main.dart

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ void adjustPubspecFontIncludes(Set<String> styles) {
194194
if (!line.trimLeft().startsWith('- family:')) continue;
195195

196196
styleName = line.substring(25).toLowerCase(); // - family: FontAwesomeXXXXXX
197-
if (styles.any((element) => element.replaceAll(' ', '') == styleName)) { //Because of 'sharp thin' we need to remove spaces here
197+
if (styles.any((element) => element.replaceAll(' ', '') == styleName)) {
198+
//Because of 'sharp thin' we need to remove spaces here
198199
pubspec[i] = uncommentYamlLine(pubspec[i]);
199200
pubspec[i + 1] = uncommentYamlLine(pubspec[i + 1]);
200201
pubspec[i + 2] = uncommentYamlLine(pubspec[i + 2]);
@@ -562,10 +563,12 @@ bool readAndPickMetadata(File iconsJson, List<IconMetadata> metadata,
562563
} else if (icon.containsKey("svgs")) {
563564
iconStyles.addAll((icon['svgs']['classic'] as Map<String, dynamic>).keys);
564565
if (icon['svgs']?['sharp'] != null) {
565-
iconStyles.addAll((icon['svgs']['sharp'] as Map<String, dynamic>).keys.map((key) => 'sharp $key')); //"sharp thin ..."
566+
iconStyles.addAll((icon['svgs']['sharp'] as Map<String, dynamic>)
567+
.keys
568+
.map((key) => 'sharp $key')); //"sharp thin ..."
566569
}
567570
}
568-
//TODO: Remove line once duotone support discontinuation notice is removed
571+
//Remove line once duotone support discontinuation notice is removed
569572
if (iconStyles.contains('duotone')) hasDuotoneIcons = true;
570573

571574
for (var excluded in excludedStyles) {
@@ -640,7 +643,15 @@ ArgParser setUpArgParser() {
640643
argParser.addMultiOption('exclude',
641644
abbr: 'e',
642645
defaultsTo: [],
643-
allowed: ['brands', 'regular', 'solid', 'duotone', 'light', 'thin', 'sharp'],
646+
allowed: [
647+
'brands',
648+
'regular',
649+
'solid',
650+
'duotone',
651+
'light',
652+
'thin',
653+
'sharp'
654+
],
644655
help: 'icon styles which are excluded by the generator');
645656

646657
argParser.addFlag('dynamic',

0 commit comments

Comments
 (0)