Skip to content

Commit 161dc25

Browse files
committed
all_channels: Make toggle transparent and non-interactive when
noContentAccess If the toggle's height exceeds 44px, unsubsribing from the channel causes the row to shrink to 44px, resulting a ui jump. Making the toggle transparent and non-interactive prevents this jump.
1 parent eaf79c7 commit 161dc25

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

lib/widgets/all_channels.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@ class AllChannelsListEntry extends StatelessWidget {
121121
height: 20 / 17,
122122
).merge(weightVariableTextStyle(context, wght: 600)),
123123
channel.name)),
124-
hasContentAccess ? _SubscribeToggle(channel: channel) : const SizedBox(height: 40, width: 52)
124+
IgnorePointer(ignoring: !hasContentAccess,
125+
child: AnimatedOpacity(opacity: !hasContentAccess ? 0 : 1,
126+
duration: Duration(milliseconds: 200),
127+
child: _SubscribeToggle(channel: channel)))
125128
]))));
126129
}
127130
}

test/widgets/all_channels_test.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,17 @@ void main() {
195195

196196
check(findInRow(find.text(channel.name))).findsOne();
197197

198-
final maybeToggle = tester.widgetList<Toggle>(
199-
findInRow(find.byType(Toggle))).singleOrNull;
198+
final toggle = tester.widget<Toggle>(findInRow(find.byType(Toggle)));
199+
final opacityWidget = tester.widget<AnimatedOpacity>(findInRow(find.byType(AnimatedOpacity)));
200+
final ignoreWidget = tester.widget<IgnorePointer>(findInRow(find.byType(IgnorePointer)));
200201
if (store.selfHasContentAccess(channel)) {
201202
final isSubscribed = channel is Subscription;
202-
check(maybeToggle).isNotNull().value.equals(isSubscribed);
203+
check(toggle).value.equals(isSubscribed);
204+
check(opacityWidget.opacity).equals(1);
205+
check(ignoreWidget.ignoring).isFalse();
203206
} else {
204-
check(maybeToggle).isNull();
207+
check(opacityWidget.opacity).equals(0);
208+
check(ignoreWidget.ignoring).isTrue();
205209
}
206210

207211
final touchTargetSize = tester.getSize(findElement);

0 commit comments

Comments
 (0)