Commit 68b0d770 authored by Javier Ernesto Flores Robles's avatar Javier Ernesto Flores Robles Committed by Chromium LUCI CQ

[iOS][QRScanner] Fix text animation

Worked on this doing pair programming with Sébastien today, and after
debugging we found out that the change in the width of the text is what
causes the animation to appear like it "jumps". Having the text width
to be constant fixes that, and looks good on normal dynamic size fonts.
However it does needs scrolling on the bigger a11y fonts. Would like to
get your input in the way i'm fixing the bug, as this will decrease the
horizontal space for text on iPads.

Another issue we found was that on compact height the text is cropped
into <1 line, and looks bad. Hiding it fixes that.

Fixed: 1005249
Change-Id: I0651ec85ddbb5bbbf30f50518bbb9c6be7f9392a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2595857Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Javier Flores <javierrobles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#838126}
parent 04bea55f
......@@ -37,6 +37,8 @@ const CGFloat kFlashDuration = 0.5;
} // namespace
@interface ScannerView () {
// A scrollview containing the viewport's caption.
UIScrollView* _captionContainer;
// A button to toggle the torch.
UIBarButtonItem* _torchButton;
// A view containing the preview layer for camera input.
......@@ -181,6 +183,12 @@ const CGFloat kFlashDuration = 0.5;
return @"";
}
- (void)traitCollectionDidChange:(UITraitCollection*)previousTraitCollection {
[super traitCollectionDidChange:previousTraitCollection];
_captionContainer.hidden =
UIUserInterfaceSizeClassCompact == self.traitCollection.verticalSizeClass;
}
#pragma mark - private methods
// Creates an image with template rendering mode for use in icons.
......@@ -263,35 +271,39 @@ const CGFloat kFlashDuration = 0.5;
[viewportCaption.layer setMasksToBounds:NO];
[viewportCaption.layer setShouldRasterize:YES];
UIScrollView* scrollView = [[UIScrollView alloc] init];
scrollView.showsVerticalScrollIndicator = NO;
[self addSubview:scrollView];
[scrollView addSubview:viewportCaption];
_captionContainer = [[UIScrollView alloc] init];
_captionContainer.showsVerticalScrollIndicator = NO;
[self addSubview:_captionContainer];
[_captionContainer addSubview:viewportCaption];
// Constraints for viewportCaption.
scrollView.translatesAutoresizingMaskIntoConstraints = NO;
_captionContainer.translatesAutoresizingMaskIntoConstraints = NO;
viewportCaption.translatesAutoresizingMaskIntoConstraints = NO;
[NSLayoutConstraint activateConstraints:@[
[scrollView.topAnchor
[_captionContainer.topAnchor
constraintEqualToAnchor:self.centerYAnchor
constant:[self viewportSize].height / 2 +
constant:self.viewportSize.height / 2 +
kViewportCaptionVerticalPadding],
[scrollView.bottomAnchor constraintEqualToAnchor:toolbar.topAnchor],
[scrollView.leadingAnchor
constraintEqualToAnchor:self.leadingAnchor
constant:kViewportCaptionHorizontalPadding],
[viewportCaption.leadingAnchor
constraintEqualToAnchor:self.leadingAnchor
constant:kViewportCaptionHorizontalPadding],
[scrollView.trailingAnchor
constraintEqualToAnchor:self.trailingAnchor
constant:-kViewportCaptionHorizontalPadding],
[viewportCaption.trailingAnchor
constraintEqualToAnchor:self.trailingAnchor
constant:-kViewportCaptionHorizontalPadding],
[_captionContainer.bottomAnchor constraintEqualToAnchor:toolbar.topAnchor],
[_captionContainer.centerXAnchor
constraintEqualToAnchor:_previewOverlay.centerXAnchor],
[_captionContainer.contentLayoutGuide.widthAnchor
constraintEqualToAnchor:_captionContainer.widthAnchor],
[_captionContainer.widthAnchor
constraintLessThanOrEqualToAnchor:self.widthAnchor
constant:-2 *
kViewportCaptionHorizontalPadding],
[_captionContainer.widthAnchor
constraintLessThanOrEqualToAnchor:self.heightAnchor
constant:-2 *
kViewportCaptionHorizontalPadding],
]];
AddSameConstraints(scrollView, viewportCaption);
AddSameConstraints(_captionContainer, viewportCaption);
// There is no space for at least 1 line of text in compact height.
_captionContainer.hidden =
UIUserInterfaceSizeClassCompact == self.traitCollection.verticalSizeClass;
}
// Adds a preview view to |self| and configures its layout constraints.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment