From 8da191e0fe7452043724bc9fcd4ad81ba0106ffe Mon Sep 17 00:00:00 2001 From: Guillaume Roux Date: Thu, 14 Oct 2021 14:28:36 +0200 Subject: [PATCH 1/3] working for shadows and borders separately --- README.md | 1 + lib/src/decorated_icon.dart | 12 +++- lib/src/icon_decoration.dart | 4 +- test/borders_test.dart | 3 - test/goldens/base_gradient.png | Bin 0 -> 1098 bytes test/goldens/gradient_with_border.png | Bin 0 -> 1739 bytes test/goldens/gradient_with_shadows.png | Bin 0 -> 2817 bytes test/gradient_test.dart | 86 +++++++++++++++++++++++++ test/shadows_test.dart | 4 -- test/test_utils/custom_golden.dart | 1 + 10 files changed, 101 insertions(+), 10 deletions(-) create mode 100644 test/goldens/base_gradient.png create mode 100644 test/goldens/gradient_with_border.png create mode 100644 test/goldens/gradient_with_shadows.png create mode 100644 test/gradient_test.dart diff --git a/README.md b/README.md index ee123ed..e24aa18 100644 --- a/README.md +++ b/README.md @@ -42,3 +42,4 @@ DecoratedIcon( ## TODO * Add support for gradients +* Document API diff --git a/lib/src/decorated_icon.dart b/lib/src/decorated_icon.dart index 9ac3fd1..bb5493f 100644 --- a/lib/src/decorated_icon.dart +++ b/lib/src/decorated_icon.dart @@ -21,12 +21,13 @@ class DecoratedIcon extends StatelessWidget { final iconSize = icon.size ?? iconTheme.size ?? 24.0; final iconOpacity = iconTheme.opacity ?? 1.0; final border = decoration?.border; + final gradient = decoration?.gradient; Color iconColor = icon.color ?? iconTheme.color!; if (iconOpacity != 1.0) { iconColor = iconColor.withOpacity(iconColor.opacity * iconOpacity); } - final iconStyle = TextStyle( + TextStyle iconStyle = TextStyle( inherit: false, color: iconColor, fontSize: iconSize, @@ -35,6 +36,15 @@ class DecoratedIcon extends StatelessWidget { shadows: decoration?.shadows, ); + if (gradient != null) { + iconStyle = iconStyle.copyWith( + foreground: Paint() + ..shader = gradient.createShader( + Rect.fromLTWH(0, 0, iconSize, iconSize), + ), + ); + } + Widget iconWidget = RichText( overflow: TextOverflow.visible, textDirection: textDirection, diff --git a/lib/src/icon_decoration.dart b/lib/src/icon_decoration.dart index fc6f743..99501cb 100644 --- a/lib/src/icon_decoration.dart +++ b/lib/src/icon_decoration.dart @@ -14,12 +14,12 @@ class IconDecoration { /// sources. final List? shadows; final IconBorder? border; - // final Gradient? gradient; + final Gradient? gradient; /// Creates a `DecoratedIcon` decoration. const IconDecoration({ this.shadows, this.border, - // this.gradient, + this.gradient, }); } diff --git a/test/borders_test.dart b/test/borders_test.dart index cff058b..30afb4d 100644 --- a/test/borders_test.dart +++ b/test/borders_test.dart @@ -19,7 +19,6 @@ void main() { ), ), ); - addTearDown(tester.binding.window.clearPhysicalSizeTestValue); }); customGoldenTest('Border with colorized icon', (tester) async { @@ -34,7 +33,6 @@ void main() { ), ), ); - addTearDown(tester.binding.window.clearPhysicalSizeTestValue); }); customGoldenTest('Border with shadows', (tester) async { @@ -58,7 +56,6 @@ void main() { ), ), ); - addTearDown(tester.binding.window.clearPhysicalSizeTestValue); }); }); } diff --git a/test/goldens/base_gradient.png b/test/goldens/base_gradient.png new file mode 100644 index 0000000000000000000000000000000000000000..572a8322e43009eb13040a628e949e20de5e3fe6 GIT binary patch literal 1098 zcmeAS@N?(olHy`uVBq!ia0vp^DIm?@VN1aW0C$%$+cWeL=2%aQJ#9kzJ(-|1(U>^7F0 zmLcN2`{v)XHjB?cH)7lL{`aHny}zGN_hoSuaLCvr{FU)ZDwmU+;|UE8Nmj+h3MnEj zJxvn=1&jy_&e>r0>)|t=x;@Vy=N)Z-u4eF>VIDI}AG?Jd)Aj6sH`g<4Wikk^sC)Z* z-GcMF_WPH`@@twqoZ_5NRJ&vj!^?M8L3y$--?3fFlRX_He{vnmq*#YbnQ?)u87^Oa zwl$1(ne75G2GjpXw{Bt4__k-qx(Mc+8;m*kL{HtH{L^+xz{=#)<&Q0jc6QyFlD{|h z`P1S9FApEs*X!_d<Z& z*XqlDi0O?%;1@87<i~U+1pd_N6az!*hppv$_wS+3zJ5EjRwXO+oDYgo!JUztz7akzL;_a75|E zg&!WjyU)bsLwG+gM!(g66q^O%ojutuA-8|?i`(XVRy+L7WA{%{7jtBI@L+4PM#a-< z`Okj`fABia>zATz<|yYY{_*PtLy^6g{_pcWJm2ZzM>&>%OCFxI(l&EsNLcg7yo~?- z@!tBn|L5Q9`o|wU+&MSn%KP?$P3JnFRC-v?yTWBr^_Ro$U3~9X=GPn7{SW@~osWUR z%lP}pEx)8sUFG&Ld8cr5D#I=%yMpc{@sxA(j|$qXymz=DZ(-o275+Ocmf3G&3)kHm zV<$Cp&C5^A9JkeNJOvECoEwR|_GC_YJKIPiM)Kcl$26nJ&zcpV-6NNOt83x^mHdmj zcAt-!Mai`q>CXza@2!43oz3{>?;7!&Pd8RgxjW?~)9rn%elbiz?`P&uzwrE9QRhSZ zo943-DRRcXXN>ZHpj?R0g82|NhM*6wWQX6-) zXPjv4X_Gktp*S+ZJP>tZwKJdmvhc@$zeF({Ncn1}Wn7`*?}ZFDNQ)m~;Ow WbF|%16#*;{7(8A5T-G@yGywp=TJ*&L literal 0 HcmV?d00001 diff --git a/test/goldens/gradient_with_border.png b/test/goldens/gradient_with_border.png new file mode 100644 index 0000000000000000000000000000000000000000..9c2e754475a0bc54f73911b0a4209d63396c7aeb GIT binary patch literal 1739 zcmb7_c{Cf?9>-&-iC9}hX`>^ds%0!4TVAV6q$C=m5^8_cGI@Wz_s;w8%{}LLf4|Q?_nz}R=X<`to8oA1BM&+P z0ssK=C?vvJoc;e5Kxy$FHl6J%P7)E$HgEu=A1n}qR0JI53KXwcpnoy|ARUQ9Ty%{t z5EXa_dRzf>&NrZ1%#Z?(?r1tLYu}o?I_1Wd z&GrJMnlF_UEnX=-=6Pv6uahJ(Ej=g~ZuIIcd0BAJA-!V+KvwJ%US6?2X`Im~ta)vr z`Z)2=B41;BU*o`Qs|<{>7bibTvTFGsH$MGPIu1s&d`_d6)Q=_v*9vy8$ua))MaS1x z@OQr+QtP4dH@)6kfRD|-U_k(*V`KcffXwpe=yC8NP{LO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!$OsGUJ3AA9?wh}*My_Pf~^!ncZiWXGlM*y4gu!Yb!itS z75_3uXNIz#nNoOJJUZIjX-I9TaLQZo8f%7mK32=es>e{6AQ;k`=h@rr{a^q7kD32Z b*pm#pd}r>d!c}YWhXg=fvPUrBKEM41WGFQ@ literal 0 HcmV?d00001 diff --git a/test/goldens/gradient_with_shadows.png b/test/goldens/gradient_with_shadows.png new file mode 100644 index 0000000000000000000000000000000000000000..0a4c68c32042c993e542acdf994b3c33b55fd456 GIT binary patch literal 2817 zcmbtW_ct318;!SBqgG1I7>Q9eYOk7!O;M?>ni@5WS}j$ziJh3C^i3*MOQSU!YIY#h zrZlx1YQ-+GeZK$TJLh}Od7gXjxzD-3-E(frZA)WTW`1S>0KjT$VgNr!kN+;?rStpf zcb?5T(1pN_VE{ruX!)F641t;2FrLpdMh_$az+7o+0JRA(UMsOcJ}|!86}|YpW#IXg zHiC)Ys6#AGQehSricXY7A~jtq1c2h7UGydm?p9z4%FJ;vc}N@w6ZEc_7?^iRQex|} zc#el+PI~vP&X>!}&k?kphKk6URiVY*=5@lv#$Nc@=3#5ninA>Z@p@(Q&eZu0^$gMZ+-WUe+|5@Bz!S;~j?WVlyJ@`$>Y;@hoWO>C^V*-74w| zm69>CSsVBzN;omYyv*KS2>ce?!y^=4sN@&q^8>^?tkbPEMpB@}8$ zMXnTgoEjo=MvF1mI5i5E3d}9n+Wt$wN<^r?+^5I;_~g44pe7YbaOG5uNY{tEdwJ~# zO5R-h`S7H&pR}4`mJCkbEKlx6`TY-k56D`ASCIKJWl<`A>nXM1N44z}E^%IMPu3JE zK&d#9*-uBl<3HY;o9NgA6PF&z*E;O|BEKQq18a8T$L0V*E{{Mvzz=ry+AtgN_rYS0 z!xyz__nuw8ec#-ey6Y1-SQ$;mK~F5am2d0He?vNmc5L%!LyNE!g_{_EumM=CJ5-3k z(tBu}jZy8FQsF%p@F~l+h7QFwqg6~1UcI>sh^C4S{nC_uy70zj`_Be7EZJNcqKsXr zUP%p*NDe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m}+pFew`g& z08C!}`h3_c8*|(&So4UM+JgigzKCFR%gfP8D`?iT8W4+Gmm{A!H8{<067nY08y`O2 zI#t?dI2md)Jz1hu|-T0`f3J8Otx#k9zTZ8&fJqZVEm@{BQL@eO+rGt^#rD`up zb0L8`{a#kOZhOuCNRX4iH!%dQzdlj^2B^W3{HLQYiS(J)d+(4{Iyj~!4P=u+0yDeH z$B5`%h;AZ*Q!||TGcs07nkvq{rwYNrjC~)BB7qv}Zg>0CpFI(woh%ahcA!;j zBnU)KCVf`2i#UJ&si0*8Nw&Pkqrp-Q4o3FH*UAQSD2%xo&d*}p@gGw_nT4{GmW%Jx zK%)c_t|D-?UQa=AStqj%b3Ir+h-Ap-m}Gr+FgOhfMwYsO;v(85%R8CCvPu@R)%@tM zW{nVrBPLBk{4DO5qUdN4N(AGOoZdHSRrD%fwCtn&(Bp{2kYS@wF7CT)Y|75ajaa|4 zcQ`GyevF3Mk1*U&jOF+(SL<|7COjY9jnQoYb)38^lIb)Lv>kOHFi#4z8Q z*XyJxZ1;Z)*Ac(;rwWJpD3Sl0&#Nr_dgzW4L^g-+0q~y*ZhPh|DcuyP($u|jUy^Vg z*A0JY{}_GqMMdl_*he>bVnCCPQ1Fj}Y?GgM3$Yw<_W;n__zS1P|6Aodqc7h~S|r`v SZ$GcG08>Lt0|M-R+Xp* literal 0 HcmV?d00001 diff --git a/test/gradient_test.dart b/test/gradient_test.dart new file mode 100644 index 0000000..41ba4d1 --- /dev/null +++ b/test/gradient_test.dart @@ -0,0 +1,86 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:icon_decoration/icon_decoration.dart'; + +import 'test_utils/base_widget.dart'; +import 'test_utils/custom_golden.dart'; + +void main() { + group('Goldens Gradients', () { + const _rainbowGradient = LinearGradient(colors: [ + Colors.red, + Colors.pink, + Colors.purple, + Colors.deepPurple, + 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, + ]); + + customGoldenTest('Base gradient', (tester) async { + tester.binding.window.physicalSizeTestValue = const Size.square(100); + await tester.pumpWidget( + generateBaseApp( + child: const Center( + child: DecoratedIcon( + icon: Icon(Icons.all_inbox), + decoration: IconDecoration( + gradient: _rainbowGradient, + ), + ), + ), + ), + ); + }); + + customGoldenTest('Gradient with shadows', (tester) async { + tester.binding.window.physicalSizeTestValue = const Size.square(100); + await tester.pumpWidget( + generateBaseApp( + child: const Center( + child: DecoratedIcon( + icon: Icon(Icons.all_inbox), + decoration: IconDecoration( + gradient: _rainbowGradient, + shadows: [ + Shadow( + color: Colors.red, + blurRadius: 3, + offset: Offset(0, 2), + ) + ], + ), + ), + ), + ), + ); + }); + + customGoldenTest('Gradient with border', (tester) async { + tester.binding.window.physicalSizeTestValue = const Size.square(100); + await tester.pumpWidget( + generateBaseApp( + child: const Center( + child: DecoratedIcon( + icon: Icon(Icons.all_inbox), + decoration: IconDecoration( + gradient: _rainbowGradient, + border: IconBorder(), + ), + ), + ), + ), + ); + }); + }); +} diff --git a/test/shadows_test.dart b/test/shadows_test.dart index 31e4d04..29aa166 100644 --- a/test/shadows_test.dart +++ b/test/shadows_test.dart @@ -13,7 +13,6 @@ void main() { child: baseWidget, backgroundColor: Colors.black, )); - addTearDown(tester.binding.window.clearPhysicalSizeTestValue); }); customGoldenTest('Default shadow', (tester) async { @@ -28,7 +27,6 @@ void main() { ), ), ); - addTearDown(tester.binding.window.clearPhysicalSizeTestValue); }); customGoldenTest('Shadow with Offset(0, 6)', (tester) async { @@ -45,7 +43,6 @@ void main() { ), ), ); - addTearDown(tester.binding.window.clearPhysicalSizeTestValue); }); customGoldenTest('Shadow with Offset(3, 0)', (tester) async { @@ -62,7 +59,6 @@ void main() { ), ), ); - addTearDown(tester.binding.window.clearPhysicalSizeTestValue); }); }); } diff --git a/test/test_utils/custom_golden.dart b/test/test_utils/custom_golden.dart index 3ab4616..8bcf20e 100644 --- a/test/test_utils/custom_golden.dart +++ b/test/test_utils/custom_golden.dart @@ -21,5 +21,6 @@ void customGoldenTest( .replaceAll(' ', '_') .replaceAll(RegExp(r'(?:|[^\w\s])+'), ''), ); + addTearDown(tester.binding.window.clearPhysicalSizeTestValue); }); } From 998df2fb028f1455ed28b663b7efa7e8be711073 Mon Sep 17 00:00:00 2001 From: Guillaume Roux Date: Thu, 14 Oct 2021 14:30:15 +0200 Subject: [PATCH 2/3] works with both --- .../gradient_with_border_and_shadow.png | Bin 0 -> 3171 bytes test/gradient_test.dart | 24 ++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 test/goldens/gradient_with_border_and_shadow.png diff --git a/test/goldens/gradient_with_border_and_shadow.png b/test/goldens/gradient_with_border_and_shadow.png new file mode 100644 index 0000000000000000000000000000000000000000..eef327267ef30925c02b9108c364996beef63990 GIT binary patch literal 3171 zcma)9hf@<+6AvFqCl`Lo!C5hNg0gFuKhsR~GtE=Z6f0)mtS3Fx>BSIXsAaB zhJ+%$7o(^YLnxuQ0|WtueDOcHH}l?a-tKRAW@mPHc9X0vjRklmcmV)_fT;=UCJQ}( zUv5s;8#w>MmIZ9VH;s{i+EJ-h)`ue)X==;OI#Jx7H~@fOz!YU*`#68IAjZ$xj;&8` zx$S2(bM4O8fQypBFtR{0E%qkylCE*IJ4gn{7%z3jX{N zIkvs6BXZL$Db*W(zW`9QdWe0@?+Qwt4cpb~kO|RHOM3mBiBBoq?=i)?nVj(iIP59csQ#&UfK9bf0 z-bI76;Q@6A_x@`= ze948BJKNGgOCHsDDIfRi5NkB!NWxVF#*U6!9&FLp9iwV_2tJ?W0WYhWXXbkCNu{~J zi7g>seDGW?t-$MP9Z%RO6pF(?e!A(yxdAAfvn=&D!a0lEx5eVv*=xH?TtOFBnX~MG zrGnssgIV7Z3-5A(t&B4!dY>0&_oi%n)&Ky*e`@61KEtvEgvykM+I&wnOcw1jG(6wx zwX&X+j78j!xtGZE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sZ2MJVU_AaxC`7xad7 z(Kz+zbX&wJ$_7$INas>p1P)H}cF1n#FOb&$fL1K=+EA^|B1_r_GwWnZe?AqvvFCN3$xU&6oNg== z(=MH92(8<#Bx`<9z%|Gz{Xx!ebMu$V?4s;{eYiJ58lPdL4dGkt)feEGk4Z$4!EfKu zXHo{{2Dl0tGvU+ZmC|QT-#^|!6ET8-M43f0x#gVPH8m~2G!x?Ku9B{Xk&Xvkj z6Q?t*7Y3<$t~@RZN`$0c%CS6oRu)5MfZX*gNr$my!A?- ziaG5l=D^W!B5%n=d}%&mpo3_oe4N8#)fr|QB3J?UTDk@GX9FML;n>VqQt|p=HVb(! z!^!6rxl&7tEQ*V(JeN4HAq*d{z)(%=w+4$_LHhb2MTS|``fot=@v696(x&K>$aRNU zEEJ_)0UY%4v-LNUXHP1tJhRrrn6*W(J>j#X_s!!HILrLmJ5}q*VIRXEY1`d3O?z8e z!K&4Jz*6XCw3o$xyiX@9pW0D_Z)q};IP15zSGv37H^&rHoCrf>BfR{R$yd zIiqvQ+z1fmq#O4CZbTJh literal 0 HcmV?d00001 diff --git a/test/gradient_test.dart b/test/gradient_test.dart index 41ba4d1..ec76348 100644 --- a/test/gradient_test.dart +++ b/test/gradient_test.dart @@ -82,5 +82,29 @@ void main() { ), ); }); + + customGoldenTest('Gradient with border and shadow', (tester) async { + tester.binding.window.physicalSizeTestValue = const Size.square(100); + await tester.pumpWidget( + generateBaseApp( + child: const Center( + child: DecoratedIcon( + icon: Icon(Icons.all_inbox), + decoration: IconDecoration( + gradient: _rainbowGradient, + border: IconBorder(), + shadows: [ + Shadow( + color: Colors.red, + blurRadius: 3, + offset: Offset(0, 2), + ) + ], + ), + ), + ), + ), + ); + }); }); } From 214bb21cef8ec4f9ef12bae04755fcef52fd56af Mon Sep 17 00:00:00 2001 From: Guillaume Roux Date: Thu, 14 Oct 2021 14:34:04 +0200 Subject: [PATCH 3/3] added comments and update README --- README.md | 6 +----- lib/src/icon_decoration.dart | 5 +++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e24aa18..e9e5558 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ Add decoration capabilities for the `Icon` widget with shadows, borders, gradien * Add shadows to icons * Add borders to icons +* Add gradients to icons ![](https://raw.githubusercontent.com/TesteurManiak/icon_decoration/main/test/goldens/shadow_base_widget.png) @@ -38,8 +39,3 @@ DecoratedIcon( ), ) ``` - -## TODO - -* Add support for gradients -* Document API diff --git a/lib/src/icon_decoration.dart b/lib/src/icon_decoration.dart index 99501cb..df8a2fe 100644 --- a/lib/src/icon_decoration.dart +++ b/lib/src/icon_decoration.dart @@ -13,7 +13,12 @@ class IconDecoration { /// Multiple shadows are supported to replicate lighting from multiple light /// sources. final List? shadows; + + /// A border to draw above the icon color or [gradient]. final IconBorder? border; + + /// Apply a gradient to the icon. If this is specified the [Icon.color] + /// property has no effect. final Gradient? gradient; /// Creates a `DecoratedIcon` decoration.