Skip to content

Commit

Permalink
[iOS][vision][Showcase] Fixes image alpha of the thumbnail when the d…
Browse files Browse the repository at this point in the history
…escription for bird takes over half of the screen.
  • Loading branch information
calren committed Jun 17, 2020
1 parent 5f56609 commit bd6bf6d
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ @interface MLKLiveObjectDetectionViewController () <AVCaptureVideoDataOutputSamp
// Width to height ratio of the thumbnail.
@property(nonatomic) CGFloat thumbnailWidthHeightRatio;

// Target height of the bottom sheet.
@property(nonatomic) CGFloat bottomSheetTargetHeight;
// Target Y offset of the bottom sheet.
@property(nonatomic) CGFloat bottomSheetTargetOffsetY;

// Array of timers scheduled before Confirmation.
@property(nonatomic, nullable) NSMutableArray<NSTimer *> *timers;
Expand Down Expand Up @@ -273,7 +273,7 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput
#pragma mark - MDCBottomSheetControllerDelegate

- (void)bottomSheetControllerDidDismissBottomSheet:(nonnull MDCBottomSheetController *)controller {
self.bottomSheetTargetHeight = 0;
self.bottomSheetTargetOffsetY = 0;
[self startToDetect];
}

Expand All @@ -295,9 +295,9 @@ - (void)bottomSheetControllerDidChangeYOffset:(MDCBottomSheetController *)contro

CGFloat imageAlpha =
[self ratioOfCurrentValue:yOffset
from:(yOffset > self.bottomSheetTargetHeight) ? bottomFadeOutOffsetY
from:(yOffset > self.bottomSheetTargetOffsetY) ? bottomFadeOutOffsetY
: topFadeOutOffsetY
to:self.bottomSheetTargetHeight];
to:self.bottomSheetTargetOffsetY];
[self.overlayView showImageInRect:rect alpha:imageAlpha];
}

Expand Down Expand Up @@ -802,10 +802,10 @@ - (void)processSearchResponse:(nullable NSData *)response

UIEdgeInsets safeInsets = [MLKUIUtilities safeAreaInsets];

CGFloat toOffsetY = contentHeight > screenHeight
CGFloat toOffsetY = contentHeight > screenHeight / 2.0f
? screenHeight / 2.0f - safeInsets.bottom
: screenHeight - contentHeight - safeInsets.top - safeInsets.bottom;
self.bottomSheetTargetHeight = toOffsetY;
self.bottomSheetTargetOffsetY = toOffsetY;

CGRect toFrame =
CGRectMake(kThumbnailPaddingAround, // X
Expand Down

0 comments on commit bd6bf6d

Please sign in to comment.