From 8cffc3f5e893486834dd274832698d3707d1747f Mon Sep 17 00:00:00 2001 From: Angelo Silvestre Date: Thu, 23 Nov 2023 01:37:15 -0300 Subject: [PATCH] Add FunctionalAligner (#42) --- lib/src/follower.dart | 15 +++++++++++++++ ...er_fade-when-out-of-bounds_bottom-left.png | Bin 2231 -> 2229 bytes ...r_fade-when-out-of-bounds_bottom-right.png | Bin 2224 -> 2224 bytes ...lower_fade-when-out-of-bounds_top-left.png | Bin 2227 -> 2236 bytes ...ower_fade-when-out-of-bounds_top-right.png | Bin 2222 -> 2225 bytes ...ower_restricts-to-boundary_bottom-left.png | Bin 2258 -> 2255 bytes ...wer_restricts-to-boundary_bottom-right.png | Bin 2249 -> 2249 bytes ...ollower_restricts-to-boundary_top-left.png | Bin 2251 -> 2257 bytes ...llower_restricts-to-boundary_top-right.png | Bin 2258 -> 2260 bytes ...tic_initial-placement_in-bounds_center.png | Bin 2267 -> 2257 bytes ...-fade-when-partial-overlap_bottom-left.png | Bin 2252 -> 2257 bytes ...fade-when-partial-overlap_bottom-right.png | Bin 2246 -> 2250 bytes ..._no-fade-when-partial-overlap_top-left.png | Bin 2231 -> 2235 bytes ...no-fade-when-partial-overlap_top-right.png | Bin 2232 -> 2236 bytes 14 files changed, 15 insertions(+) diff --git a/lib/src/follower.dart b/lib/src/follower.dart index 4f7a800..69b8372 100644 --- a/lib/src/follower.dart +++ b/lib/src/follower.dart @@ -128,6 +128,21 @@ class StaticOffsetAligner implements FollowerAligner { } } +/// A [FollowerAligner] that delegates to a callback function. +class FunctionalAligner implements FollowerAligner { + FunctionalAligner({ + required this.delegate, + }); + + /// Called to determine the position of the [Follower]. + final FollowerAlignment Function(Rect globalLeaderRect, Size followerSize) delegate; + + @override + FollowerAlignment align(Rect globalLeaderRect, Size followerSize) { + return delegate(globalLeaderRect, followerSize); + } +} + class FollowerAlignment { const FollowerAlignment({ required this.leaderAnchor, diff --git a/test_goldens/goldens/follower_fade-when-out-of-bounds_bottom-left.png b/test_goldens/goldens/follower_fade-when-out-of-bounds_bottom-left.png index ba44d593cd5c6f172635489fe18899175e0a8fe2..037553b3e6bd9c6981b06c73a6c4cc0d75abc3e3 100644 GIT binary patch literal 2229 zcmeAS@N?(olHy`uVBq!ia0y~yVEh8Y9Be?5)7S2I0V&4fAa^H*b?0PW0y!+jPM#qg zKv2Vx(!s#M5%1~Z7*a9k?F~ae8Akz!i}yr}n1tFRx;IZO5(>(D+Q8HEK0#6_?97Bm zJe;P?@$Y39tlG5x-QB8~Ym5vv*}vEFGcefsU0_sj7{vn~1`kqRGyk~%em{Toe1;Et z_UD200qM9G3<3(Hcr*+~)4*sN802YSLv;V?U0($m4jivo$n4OtVCdrmC(k@QefVz0 zzMb=SCcWVoe|-Gu)hn_LAFlfH{`&RBA}+7~Yz!jAmvFJsYiUrGFnj3U!AS!w1WnowNz+1KKkmYWN9m=3)XiJs3P){an^LB{Ts5a=xVM literal 2231 zcmeAS@N?(olHy`uVBq!ia0y~yVEh8Y9Be?5)7S2I0V&4fAa^H*b?0PW0y!+jPM#qg zKv2Vx(!s#Mk?85-7*a9k?F~b(I7g9&i{-i(KIlc1_pT=*l^bJ`{I6JjdGk@mVt?77~pkbeD~w$9h=`C zuN~ggeS3Fd<^STBd<+)l+0AuUy?;M`KPCFOwx@7s2{XeS`}lXXE2=?3n|k@a-{ZeO zGjIMdJa%K<`r~EA+e_FP=Iq|;$j-2@MZcVZL!gBE_y_lHwC(5t0KoB+-v+#s?*^=s?*}ddKqqw(9x5+>;*yS|MPw9Oh;82mlyq-tVU6{cY7dwwE{4 o=Ing6^93CM0(`lVk5(4I7XTnD10vZC-2eap07*qoM6N<$f)AE)5C8xG literal 2224 zcmeAS@N?(olHy`uVBq!ia0y~yVEh8Y9Be?5)7S2I0V&4fAa^H*b?0PW0y!+jPM#qg zKv2Vx(!s#M5#{OP7*a9k?F~aO7DoYxi;_2e4q9v6J9}ocM3wfzg2?v@Iad}WubQdg zym|h2zJSo1%d2IRbGR7_F0MY!zdo`FgTF-jqy*}uZsD#Ob6!Qxqt7h zU8DS-3yca5qj)q7M$^D(8W`khAOTpbZ0=`Z_;;LJmVt?77+}85{0t2@?c(Q6Uw^sq zx@`OL<*9qCZ{+{Wo6PvYsb+59>2Ke5z3zKk6L(Ga`R^k31_npk;D*wkjc4tc7}9Rt z>pxv)_kP#oSN{?t*X5VZ)_=hu@ZdC!f_fjLS+&;vbm8|KfvpY(Pgg&ebxsLQ07s2? A6951J diff --git a/test_goldens/goldens/follower_fade-when-out-of-bounds_top-left.png b/test_goldens/goldens/follower_fade-when-out-of-bounds_top-left.png index 9cc926e18ad06beed64bc1998dd6d8cc3109ed3d..a05c25e80c9195004bbb19a814f7e34c3c23a168 100644 GIT binary patch literal 2236 zcmeAS@N?(olHy`uVBq!ia0y~yVEh8Y9Be?5)7S2I0V&4fAa^H*b?0PW0y!+jPM#qg zKv2Vx(!s#Mk>=^*7*a9k?F~n-7)KF@i@$RDnYi>89i7R%eJbmYP925r%RAZ=*c#jZ z8}}M7)Z7<$F7iNie%Z>XZJ&4XGCc6MepAc9P+;lE-oQX*-0=9!!`t(>Z`@~hKE`m` z>)C}Ccm3}&GR(hwWx@LO=O4en{C%eOv8#t4|M>R!`4w4)4>x}nQQr|TPk|hB`s>*p zRTXn~Cdv4H4}Q*kAbdm4^U~YDIT#)o?YqOM;BaB+;|DvwGw%8R>G$<}>I^j}?!L`@ zFZ`ol+=_vPV-$~u!Dt#7O#_2G4d~piy!*|LiD5_2XsI=LO6@<)2K(eUYQCEH3)li- N@O1TaS?83{1ORZXNI3ui literal 2227 zcmeAS@N?(olHy`uVBq!ia0y~yVEh8Y9Be?5)7S2I0V&4fAa^H*b?0PW0y!+jPM#qg zKv2Vx(!s#M5$oyV7*a9k?F~aO7DoYxi;|I>S>JC+(x@;@exLB>ZOY!}1)j?5R;C@g z)KhoQ+95P`{=3qi!YGD@`nO51nHd^Bb6PR5a8Mb)S>{(?A8prvJ~({M@4uVm@|L}0 zXxN{Zb-}*>{ORL||DF*&T~)n3#?H?7E+a$zT>Wwe4uKNd;2URU_PzTKw9dTvXi;IU zaj6}{ANJQ0kGFgkWH?Y+vy<7OVZqSH2l8Gs|9JW1*QT$W4Eu{}OK<#Q+4s?jy@A1T z6px0%Xc`zz1A{vaGyv-@L=$C^>bP0 Hl+XkKC>Nt0(_*t}NX|MahK+g|qleOVNF zu5b2P@e+oAd%yp_omyLSqvZI*XL&c{WAn}KPq(JN3t&Eixa6(>^wY3o7TpB4IT$=${an^LB{Ts5#TayE diff --git a/test_goldens/goldens/follower_restricts-to-boundary_bottom-left.png b/test_goldens/goldens/follower_restricts-to-boundary_bottom-left.png index e3a6cc1af67d625c8df167d97c44b9a5d2bbb59f..ce42f3aeb7d24077b100cfd74ba7c83a50068919 100644 GIT binary patch literal 2255 zcmeAS@N?(olHy`uVBq!ia0y~yVEh8Y9Be?5)7S2I0V&4fAa^H*b?0PW0y!+jPM#qg zKv2Vx(!s#MQR(U87*a9k?TwAOA&v~L7jIteVo_OsPJE|`*8;YnaHm&NF-*P!6ByOh zTyJ!S|MBlKRxz$Awp`vYb9(IAH`gw2;$wI)f7|^k28It6O?(WDqj=!MpnWa-hYQd1 z&7=Jpe(36-?~C?-ARhOEK|o;?kA}f$8W^@|px{Oo1OMJ#cK53e$$xzJ_4-!>_A)cf z+qKd${(au@e*X9Aaf}Q+@$VQW(5l$p5bb~3>h*`O-+o8ztC>~$MAZFZ`of+=_vPV-$~u!Dt#7wrN1-n_a_myPE3#-#Pyu`QFc8J)hyj zvWkVw4h;*2Ha-BXXtsS9WH@koIQRw>8wV1feR%t??9abnsn5C!%Svs}+1Jk7#mwM$ z_s#t|?~`0Q|96wtPN8~^@Ey;bvL$E}}D md<=~H?l3AiT%bOFz`5*(Zb1L(WzT`l5e83JKbLh*2~7aVB>DaT literal 2249 zcmeAS@N?(olHy`uVBq!ia0y~yVEh8Y9Be?5)7S2I0V&4fAa^H*b?0PW0y!+jPM#qg zKv2Vx(!s#MQS9mB7*a9k?F~b(SVxAoi`7p{Ia3(Rx@H&3ioM)4ZOS^u*@A1He7xiQ zAe8yzva5Otdd>5n>m)pTZ@Yps62Kie@-!L*9_|0j>z``+#2Rsa9()b^&z5M?9 zO<{(AC%JU=bVz{El${7spE z{`!27eG|idb|1cb;WOg{p);>DBe%;jGR!$X-I{@g!)oZ`H{0b7xNkqdfBU=-@q1+M zZ=c7&^X={H#MhjE4s+8eWN8&+*v$PF&HrHW^vA!i2{Y_)h!-6|G_0y+H>1`dHyJSf882lw68N~=5gd=!Dr5(ZCKKbLh*2~7a-*8+n8 literal 2251 zcmeAS@N?(olHy`uVBq!ia0y~yVEh8Y9Be?5)7S2I0V&4fAa^H*b?0PW0y!+jPM#qg zKv2Vx(!s#MQR?a97*a9k?TwATF^&wb7ynReJoP1oE zKZDxtpEY}{nDQ$Y(k5VO6=B%SJ&^d7;a+u3MWiib1NW0wJ_g37Q9K$3qiJB+rh(rQ skGE8@Fciq?moRV$jN(BN20z%Rd{nIWVUTSEHb@veUHx3vIVCg!0KGcH#Q*>R diff --git a/test_goldens/goldens/follower_restricts-to-boundary_top-right.png b/test_goldens/goldens/follower_restricts-to-boundary_top-right.png index d2b28a48358e276f27ba1fdc29deec2f5abec665..ba610279f6139fbf0632f77c9385fbe81cb8ee10 100644 GIT binary patch literal 2260 zcmeAS@N?(olHy`uVBq!ia0y~yVEh8Y9Be?5)7S2I0V&4fAa^H*b?0PW0y!+jPM#qg zKv2Vx(!s#MQRnI67*a9k?TwAOB907g7wzyduZgomTg{h* zlPYs=s2)l2NHcl#crR1hzc-i9?3%y5mXYCKX8TQMhKAq5B@7$_RK^zP=PuVj z{qJqr3)%MN=cj-DbaBIHR@sLC_rCMLpC&)wo_Fu#hqu3{K7A@jEVUB~G3G^l|Ge$I+(G^8=F4viGyFTT`FQwd^@4VBD+U&hQ9K$3 zqiJB+rhzrTD{rUwGcde6&P}7rfmW5ya5lG&Nx(v*{QRRgTYxPS22WQ%mvv4FO#q6R BI&S~~ literal 2258 zcmeAS@N?(olHy`uVBq!ia0y~yVEh8Y9Be?5)7S2I0V&4fAa^H*b?0PW0y!+jPM#qg zKv2Vx(!s#MQRC_27*a9k?Tw9{QydxE9@bB1Wfs>taOP>yL9;c7(|C>^k;`#25Zd|n z;e$nv@65lPX(^Vdsh!7^w(m{qGlOF{%o!fcFN?8dV5qQiWN%=gGH$s1ijiT%t-8Pa z-hTfc{N5riZ`<3SmA8I2@g1mte|$Or?SEfSU$ORkZ=ZMkdj7Jx?@!AzFtN}G`>keY zIFNPx^x1C)Kl={U01Hof9j3@jX@cu<7FAC|utG`(hiJ=X|qmoRv``njxgN@xNAWSU|l diff --git a/test_goldens/goldens/follower_static_initial-placement_in-bounds_center.png b/test_goldens/goldens/follower_static_initial-placement_in-bounds_center.png index 7901e28f48939ec5714779e598554ba339a27feb..b490121a82ae5db76a72938d1f45d7e7c2c31d4a 100644 GIT binary patch literal 2257 zcmeAS@N?(olHy`uVBq!ia0y~yVEh8Y9Be?5)7S2I0V&4fAa^H*b?0PW0y!+jPM#qg zKv2Vx(!s#MQSIsC7*a9k?Tv%J(T);s7uzdOdx$Vj)49mQ8z9TOVX=^kx0-X*J7lj|J;k4pWdvU<{Ig!QsNt#R+n@3_s@l&9mP7ew+HbP0 Hl+XkKaumR4 literal 2267 zcmeAS@N?(olHy`uVBq!ia0y~yVEh8Y9Be?5)7S2I0V&4fAa^H*b?0PW0y!+jPM#qg zKv2Vx(!s#M(dy~q7*a9k?Tv%E!hsTQ7bT6N7qCxA?G%~J6cf*t;I6C?DfY$TMsLd; z-45Qs9NV*BEqVXkfA?x{W$g9OEDSlfW?y7xXt*w1!oVRgiU&LlBHZ{NFYG+H>Y-$((b`ABX0j+5Ok# z{kQPFj4{&|96mP3|M<)A)6a+REi|{~u*&JtFQ;9B08HczacTG7F5ms~;VbioT)~nX zGb*=>$2^eVcZX5I;ld~$4Fl|HAR+GhSDPvph7VS8L%4Vu%0(kKw}0T#Hdkc~SfLgQ QY@jfBy85}Sb4q9e0Ce(JCjbBd diff --git a/test_goldens/goldens/follower_static_no-fade-when-partial-overlap_bottom-left.png b/test_goldens/goldens/follower_static_no-fade-when-partial-overlap_bottom-left.png index bdaf5cdd814cb89fbb6c127c509d3817c7b3983f..afd0d26780011a9d06ae6d5d9bda13da9f4f4a4a 100644 GIT binary patch literal 2257 zcmeAS@N?(olHy`uVBq!ia0y~yVEh8Y9Be?5)7S2I0V&4fAa^H*b?0PW0y!+jPM#qg zKv2Vx(!s#MQSIsC7*a9k?e&emGJz6q7h|(ICp4cG*f_n1P2-?%fXE_7sV1%kj7BN~ zLdtI~Oipl`Dcjaqs?T|Fc6#jJ*Oj-4V2CvJ6b4c;LgpY%%+XYi|$V zeZk4_zG&0k-gyVK^-35x1V-^_7z~3naHB^qps?`ord>N`idDRZyxtBD21+l-ZJ04|H1a#?Yl1uGu(TcvRm4=F+Ao4gMh*i#~UPVA81$qs{D3* z`}4)kuKx=wD!0C8n#UvlXX9hpMl|?{{=<`hfzG>VUS>4&EOw^e|{`4{q*_# z6<&rt^SEUhm{^85zLwnc_l@A6^3rPCYNi9-GWq43)jxC$2cMa3X0J(o{C$1;{dau) zVtT4fD6F4dGEw(-~TS#{-T};#YXOUtLNnV54xOfn zHquN=hMOLCt}Z^rd9UW?)%|mp|J}pDP`A~7F*^gpap4jM4uMfT;9(HaD|f)XU*CVR zI)hBg?t4A+4p{4rM$3Rl%V^f1PVoRt-V6t>-?fX;$&=S(TYp3L@1e6#Z$5hV>JLkF z!9r$-h6O_#A1Ipl?eh!4J(V?;Qnri_6mEY_`@(Xsa5(rZ3s^JN9ee$C|Kxq!tLNF( z{;n>szf@mfA#TOM!a*gx#*P2M;bP0l+XkKaS_jp literal 2246 zcmeAS@N?(olHy`uVBq!ia0y~yVEh8Y9Be?5)7S2I0V&4fAa^H*b?0PW0y!+jPM#qg zKv2Vx(!s#MQQ+y~7*a9k?e&d;(T);sfhVs`ko>Ap>fpVkZQY7Swv2-*0SuCgs~z|R zot4}US???M`_WVzU-mq{&+r>J!-M_blD{!9JSb`6V_+P`10M#fZ!-UQ@$zfsHO~>y85}Sb4q9e0G5W&1ONa4 diff --git a/test_goldens/goldens/follower_static_no-fade-when-partial-overlap_top-left.png b/test_goldens/goldens/follower_static_no-fade-when-partial-overlap_top-left.png index 2cd52f6341a42f2a2b536d47de220c5c08e96f1d..40a3024009128db3b685be4a858f2982a23a46f5 100644 GIT binary patch literal 2235 zcmeAS@N?(olHy`uVBq!ia0y~yVEh8Y9Be?5)7S2I0V&4fAa^H*b?0PW0y!+jPM#qg zKv2Vx(!s#Mk?QH<7*a9k?X82lEQvDh4`Usb`0}I{FzI<+=#45_%p$Jkz|W_rcC%2Z zFQx4B$=8)!Kc1CWfA&wa^`BjNG-*5k`_;FPXMX89ny1GXWbdogf4r-EexD)1MjS07erUey zue7wi@v7Q={rTux{s)(Tp1k>jvxb`fZ}@7H`|P6fk56BI*;Fwd=$|uxPVc+}=6WRz z90H?wGz>=5z-StvavF#@e>qLgmWd(aSSud`W78-e6k#C$x>4zM-<_1@zy=6|r>mdK II;Vst08N{N6951J literal 2231 zcmeAS@N?(olHy`uVBq!ia0y~yVEh8Y9Be?5)7S2I0V&4fAa^H*b?0PW0y!+jPM#qg zKv2Vx(!s#Mk?85-7*a9k?XA7O%#ISSfwT8d>0v5hKVssbAHe&?iTOxLL$!izqfbi# zN7Nd}>BU?#YHwaue_PeFF?!>Tzn^cvdib;UThGzF^?l*x;p&^y89q3>Z)OMD&1uEJ z!ZAefn&T3?Zz?l1q{h5p5KtK6xWK6TK)qSsI{tsXn~yJVu4iueiSDfj%XiqPRTutR z{eJGgy!x-U4gRw~pS~%4=^*7*a9k?X8Wvu8A`3535;wozfY69FkdX--*mgX5kgy(BP*iq`uSL zbKwM;nmv{C825dCeeciY&GVMO-NW=Ce&?>**x0+ii_>+sS>BG$J@?)HyvGemTLy** zzYB~C4nqVd*!thD{KCPIASrIez``-a@tZz5h6C>__U-xcF<&O;{+}P_Kjv`DGBB|q z;XfkZkKeJk?U~2mvRCG9?d$5}{g=1zJ8q;`!oVRwB^+`7a+#cMQ~7s){>ADHH78#_ zJo$pN=7AG?1B2rz9u0%hG%%V5sG9~FzS`tIzo^X6kQ(!XK|o;?4~j7Oz^1xIwWI#$ S$GgB52!p4qpUXO@geCwsd;;45 delta 285 zcmdlZxI=J)V^or-i(^Q|oVU038@dF_v^|XdA2gHcg~J-gy#c&?GaS}5-(^a<)EueU zc;L*@hjX86KDeV_{oK6xdUDTQu7>)j&mN|h{{CQ9eJm;b`R~=QKR4er7W$UP&%iKE zcyc_G{p36*11RR@Qs0??)Z*9KR)Km+`aq%hxv~= z+_DTzEJ*l|$oJzp^R{hPX9zs6-hThry_b(aPxfO96ayRfA@B2+xwecCywCOdr~5x( z7M~o?xP5XS;|eS|hHK4niQPAq85&Y!Hp{cOGfFAEU=aAgrn6r)?bfve4;X;J)78&q Iol`;+0FT^%AOHXW