Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support iPhone X #65

Merged
merged 1 commit into from
Feb 22, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions ios/RNSnackBarView.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ - (instancetype)init
}

- (void)buildView {
CGFloat topPadding = 14;
CGFloat bottomPadding = topPadding;

if (@available(iOS 11.0, *)) {
UIWindow *window = UIApplication.sharedApplication.keyWindow;

if (window.safeAreaInsets.bottom > bottomPadding)
bottomPadding = window.safeAreaInsets.bottom;
}

self.backgroundColor = [UIColor colorWithRed:0.196078F green:0.196078F blue:0.196078F alpha:1.0F];
self.accessibilityIdentifier = @"snackbar";

Expand All @@ -98,8 +108,8 @@ - (void)buildView {
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:
@"H:|-24-[titleLabel]-24-[actionButton]-24-|"
options:0 metrics:nil views:@{@"titleLabel": titleLabel, @"actionButton": actionButton}]];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-14-[titleLabel]-14-|" options:0 metrics:nil views:@{@"titleLabel": titleLabel}]];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[actionButton]|" options:0 metrics:nil views:@{@"actionButton": actionButton}]];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:[NSString stringWithFormat:@"V:|-%f-[titleLabel]-%f-|", topPadding, bottomPadding] options:0 metrics:nil views:@{@"titleLabel": titleLabel}]];
[self addConstraint:[NSLayoutConstraint constraintWithItem:actionButton attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:titleLabel attribute:NSLayoutAttributeCenterY multiplier:1 constant:0]];
[titleLabel setContentCompressionResistancePriority:250 forAxis:UILayoutConstraintAxisHorizontal];
[titleLabel setContentHuggingPriority:250 forAxis:UILayoutConstraintAxisHorizontal];
[actionButton setContentCompressionResistancePriority:750 forAxis:UILayoutConstraintAxisHorizontal];
Expand Down