From 64ae77f7d16ad8dd0cde104c4f9b5884b270bd0d Mon Sep 17 00:00:00 2001 From: Kate Lovett Date: Fri, 27 Oct 2023 15:35:55 -0500 Subject: [PATCH] [two_dimensional_scrollables] Fix pinned row painting when one axis is reversed (#5187) Fixes https://github.com/flutter/flutter/issues/136897 There are a bunch of changes out for TableView right now, so I will update the changelog/pubspec when I have a better idea of which ones are landing before this. --- .../two_dimensional_scrollables/CHANGELOG.md | 4 ++ .../lib/src/table_view/table.dart | 2 +- .../single-reversed.pinned.painting.png | Bin 0 -> 4868 bytes .../test/table_view/table_test.dart | 54 +++++++++++++++++- 4 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 packages/two_dimensional_scrollables/test/table_view/goldens/single-reversed.pinned.painting.png diff --git a/packages/two_dimensional_scrollables/CHANGELOG.md b/packages/two_dimensional_scrollables/CHANGELOG.md index 0a76c0b187e3..3a35f1e9c514 100644 --- a/packages/two_dimensional_scrollables/CHANGELOG.md +++ b/packages/two_dimensional_scrollables/CHANGELOG.md @@ -1,3 +1,7 @@ +## NEXT + +* Fixes bug where having one reversed axis caused incorrect painting of a pinned row. + ## 0.0.4 * Adds TableSpanPadding, TableSpan.padding, and TableSpanDecoration.consumeSpanPadding. diff --git a/packages/two_dimensional_scrollables/lib/src/table_view/table.dart b/packages/two_dimensional_scrollables/lib/src/table_view/table.dart index b6e249c2e026..d94bbfe325b5 100644 --- a/packages/two_dimensional_scrollables/lib/src/table_view/table.dart +++ b/packages/two_dimensional_scrollables/lib/src/table_view/table.dart @@ -803,7 +803,7 @@ class RenderTableViewport extends RenderTwoDimensionalViewport { axisDirectionIsReversed(horizontalAxisDirection) ? 0.0 : _pinnedColumnsExtent, - axisDirectionIsReversed(horizontalAxisDirection) + axisDirectionIsReversed(verticalAxisDirection) ? viewportDimension.height - _pinnedRowsExtent : 0.0, viewportDimension.width - _pinnedColumnsExtent, diff --git a/packages/two_dimensional_scrollables/test/table_view/goldens/single-reversed.pinned.painting.png b/packages/two_dimensional_scrollables/test/table_view/goldens/single-reversed.pinned.painting.png new file mode 100644 index 0000000000000000000000000000000000000000..a89a27353c148f83a667094f6a545146ef5116f6 GIT binary patch literal 4868 zcmeH~YgAKL7RN6y11b;2f}hxXsJ+MNijeO3Q<&2tB^PEAT-6s{=x_8sW)%$$?VxMb3d`7bp=1J>@&OOvlZ{0|11de zVM~AO?x^Wr00GRSOw*-I-tDvaDF9Bu%aM;os031BS0ia;5nK=MFv~~ah zkDUcjY<_P){c|`l@l6{H03?X0L0ezCi-uX0z@15C=czkhMe;+pQkgg6leKIcQ7O@= zAlxst9WPoe1I!9ONO{~b{z$lTX-8Zy@?{Mrf#oe|4Y=Nh~(Sz*V;&t>&q9C7yneRKg3ZtsZLj0B%ip;S_B0L`vBBE(T9 zdG&9y*d(ugBl8$3X5se8UBoTa8bczH&s$$ii4hDeq?Hy^eBKQQZlEhSq3Q)o_b)#A zJoML|Lwws9Cqy7UDZVU>)pqM~&{fYwfNvr3M#cL$AymHLGt4V!p|Vp95DcN%le1G& zQidLqA64+bE0?4Z?`Er)l1>Pt9Syb_5xmtN0KcN7nDV}2C%sWltSxs52D1uh&R?)! ztT0;#l=hPNGZ~i;2sN5S^7!|Qzu4j`H=|H@7So*t7!N2k82s{;qoQUI zjH0acHBd;Y(qFal_-*6llR9egGil!-MU=+E0Jkq=c=kcSy3-n#?;Q= z+33VOB$WR|s$p}=AMkVuhXyA$kkaxpV|r1U$ExSFCs)V^-^bODPc!Rdqp=;Yza2J? z&!-LldQ7~;rxL(oO6xW}d0od$ohL5`3ZW2QLc!&$?q#?+BI4qxO3&1J+$ko_5us{$ z0D>>rW$+?OeSJ;vf@(BNG2rd`2<@C{;|A1RaW;V9nUKJA6hn!;;fg=V>Z0X+k$@dl zdyx9>tm??vZLcxwH{|_g-JOV?8r;&-r1{04ApPZ5fNm_r zS?h7;}`b2)&6|Y&7%Ku)guuxmP_yQ;GS6||n7PsMl)W!QWAz|vl=>|kSmvwnye3sjfELNDU>USyQo892{ z>Z{TDBq_bBsSfo0u(75*tgbLUNz$E2;=Zq%QN3tnDr8JXqnnE+90D!;z?eYDmcK~@yX$DM1i|C7y0`*FMTuvkEADTMML~D?Bc2!|6oYZFV z2cvsdZ2}Al$(kW4E7Ux@>@*wg&e00--gf5Lsg7z2RIhK5{{QGe*6!bqe+qI3wLEvC z#YWVIM>LUi6?6X?_I>+meYP3Dak)PB<%7Y5M=(8JfLtMeQpK*ddwM+}U3nfo`_3EU zQBJWm8iuInA3L^}<*_vF^2Zsh&2eN$h@TH0!uG@vv%R1~3*Ak;_u?V?wF#?d-pGL_ zdFLB>ej`Nc9gv=WTQjvK8p}D#)=aI2`l+uTK7KBH>0RAAPXM3?MUH~hT`cxc;_#N_OZh9Ft%L* z`=J?9_2-J^8v}_ax;2_t@;lf)8K(p@XUh%k5HsS-ocEwwa1>o_62-SK>Aw#_eHs%QxXfX?Z=3?-qa z)=E$lce%vzc$F7brjUT4YhS&EifREWV~< zjNeBF=GA)xYRnjoCUl zYkVRtqLiANzu2E^yz&oWXyltpzZ)BW2lz;;D%AAPkA3+=9V_QjoE!5QxR|O)6EVZ; z1Gmx{p+@bj(iY~8`ETK!n&E!&%F&iO5qU0KNd&bnZk5T^f?6THY*0i?2y6>|uVvzU zysNzH+o-g@)18Dxd7&J{d!oA#QInhKu*i?oOwHy`&4CreuLalzDI=ZEg4HJYXR2O* zmV;mXM0rveW35-1rkLTd*|Z^2%IIsE8X|rg)2Ss0YcyrEtcGVup&G7Ig!fuNjyE&y z8r5NOr2A@9>v7(&%W=CBjBbhlUdX%Nb5M?Nwpy7#))K7uL^Ozfjf(cxaZ%ggQ#PXh zyIMoUifh|-PHv;g4eG|GJ4bPUO;?8a^BQn&q$Y^s&$^H3cNGBl*7#{o3*=96+TJ#9 z0lj5vOr12} TableSpan( + extent: const FixedTableSpanExtent(200.0), + foregroundDecoration: const TableSpanDecoration( + border: TableSpanBorder( + trailing: BorderSide( + color: Colors.orange, + width: 3, + ), + ), + ), + backgroundDecoration: TableSpanDecoration( + color: index.isEven ? Colors.red : null, + ), + ), + rowBuilder: (int index) => TableSpan( + extent: const FixedTableSpanExtent(200.0), + foregroundDecoration: const TableSpanDecoration( + border: TableSpanBorder( + leading: BorderSide( + color: Colors.green, + width: 3, + ), + ), + ), + backgroundDecoration: TableSpanDecoration( + color: index.isOdd ? Colors.blue : null, + ), + ), + cellBuilder: (_, TableVicinity vicinity) { + return const SizedBox.square( + dimension: 200, + child: Center(child: FlutterLogo()), + ); + }, + ); + + await tester.pumpWidget(MaterialApp(home: tableView)); + await tester.pumpAndSettle(); + await expectLater( + find.byType(TableView), + matchesGoldenFile('goldens/single-reversed.pinned.painting.png'), + skip: !runGoldens, + ); }); testWidgets('mouse handling', (WidgetTester tester) async {