[ios] Fix one Magic Stack card layout
UX would like the Magic Stack card to match the width of the MVT card
when there is only one (e.g. no peeking card).
Video: https://drive.google.com/file/d/1utgacd9AichLLnbTQa6FAwojkkpTHZfi/view?usp=sharing
Bug: 370949874
Change-Id: If2f13d63d49bce288d26c0febbe23949c88656eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5905843
Commit-Queue: Chris Lu <thegreenfrog@chromium.org>
Reviewed-by: Scott Yoder <scottyoder@google.com>
Cr-Commit-Position: refs/heads/main@{#1363632}
diff --git a/ios/chrome/browser/ui/content_suggestions/magic_stack/magic_stack_layout_configurator.mm b/ios/chrome/browser/ui/content_suggestions/magic_stack/magic_stack_layout_configurator.mm
index 8b6d6184..8dfa8f9 100644
--- a/ios/chrome/browser/ui/content_suggestions/magic_stack/magic_stack_layout_configurator.mm
+++ b/ios/chrome/browser/ui/content_suggestions/magic_stack/magic_stack_layout_configurator.mm
@@ -49,15 +49,17 @@
[NSCollectionLayoutItem itemWithLayoutSize:item_size];
CGSize size = layoutEnvironment.container.contentSize;
+ CGFloat peekingInset = ModuleNarrowerWidthToAllowPeekingForTraitCollection(
+ layoutEnvironment.traitCollection);
+ if ([self.dataSource.snapshot
+ numberOfItemsInSection:kMagicStackSectionIdentifier] == 1) {
+ peekingInset = 0;
+ }
// Group size of fixed width for a module and height matching that of the
// CollectionView.
NSCollectionLayoutSize* group_size = [NSCollectionLayoutSize
- sizeWithWidthDimension:
- [NSCollectionLayoutDimension
- absoluteDimension:
- size.width -
- ModuleNarrowerWidthToAllowPeekingForTraitCollection(
- layoutEnvironment.traitCollection)]
+ sizeWithWidthDimension:[NSCollectionLayoutDimension
+ absoluteDimension:size.width - peekingInset]
heightDimension:[NSCollectionLayoutDimension
fractionalHeightDimension:1.]];
if (sectionIndex ==