-
Notifications
You must be signed in to change notification settings - Fork 11
Add multiple cells #1
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
Open
RedenticDev
wants to merge
11
commits into
LacertosusRepo:main
Choose a base branch
from
RedenticDev:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4424cf7
Add 2 new cells, update README
RedenticDev c615c29
update, new things & fix
RedenticDev 1595d9c
Merge remote-tracking branch 'upstream/main'
RedenticDev 55947db
Merge remote-tracking branch 'upstream/main'
RedenticDev 2950388
Merge branch 'LacertosusRepo:main' into main
RedenticDev ad5511f
Merge remote-tracking branch 'upstream/main'
RedenticDev f172b89
Add Refreshable Header Cell
RedenticDev 168ba5d
Add header button to README
RedenticDev 6d19989
Remove file that shouldn't be there
RedenticDev 3ea4963
Merge both animated title view classes
RedenticDev 221aaef
Improve method of SymbolsLinkCell
RedenticDev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| # Animated Banner | ||
| Great-looking animated banner for your preferences | ||
|
|
||
| ## Preview | ||
| <figure> | ||
| <img src="images/showcase.gif" alt="Showcase" width=500 /> | ||
| <figcaption>Showcase of the banner</figcaption> | ||
| </figure> | ||
|
|
||
| ## Features | ||
| - Simple but nice | ||
| - Looks good in both light and dark mode | ||
| - Endlessly customizable with animations and gradient | ||
| - Stays always vertically centered to fit the space | ||
| - Dynamically enabled/disabled by a specifier | ||
|
|
||
| ## Usage | ||
| ### Basic implementation | ||
| ```objective-c | ||
| - (void)viewDidLoad { | ||
| [super viewDidLoad]; | ||
|
|
||
| NSArray *myUIColorArray = @[ | ||
| [UIColor redColor], | ||
| [UIColor blueColor] | ||
| ]; | ||
| CGFloat navbarOffset = 64; // default navigation bar height for non-notched devices. Required for scroll animation. Can be obtain with: | ||
| // self.view.window.windowScene.statusBarManager.statusBarFrame.size.height + self.realNavigationController.navigationBar.frame.size.height | ||
|
|
||
| self.table.tableHeaderView = [[XXXAnimatedBanner alloc] initWithTitle:@"Title" subtitle:@"v1.0" colors:myUIColorArray defaultOffset:-navbarOffset]; | ||
| } | ||
| ``` | ||
|
|
||
| ### Animate on scroll | ||
| ```objective-c | ||
| - (void)scrollViewDidScroll:(UIScrollView *)scrollView { | ||
| if ([self.table.tableHeaderView isKindOfClass:[SPDAnimatedBanner class]]) { | ||
| [(SPDAnimatedBanner *)self.table.tableHeaderView adjustStackPositionToScrollOffset:scrollView.contentOffset.y]; | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### Tip 1: dynamically enable/disable | ||
| ```objective-c | ||
| - (void)setPreferenceValue:(id)value specifier:(PSSpecifier *)specifier { | ||
| [super setPreferenceValue:value specifier:specifier]; | ||
|
|
||
| if ([specifier.properties[@"key"] isEqualToString:@"enabled"] && [self.table.tableHeaderView isKindOfClass:[SPDAnimatedBanner class]]) { | ||
| ((SPDAnimatedBanner *)self.table.tableHeaderView).activateGradient = [value boolValue]; | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### Tip 2: relaunch animations when they get stopped by iOS | ||
| ```objective-c | ||
| - (void)viewDidLoad { | ||
| [super viewDidLoad]; | ||
|
|
||
| self.table.tableHeaderView = [[XXXAnimatedBanner alloc] initWithTitle:...]; | ||
| [self refreshBanner]; | ||
| [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshBanner) name:UIApplicationDidBecomeActiveNotification object:nil]; // revive after app closed and reopened | ||
| } | ||
|
|
||
| - (void)viewWillAppear:(BOOL)animated { | ||
| [super viewWillAppear:animated]; | ||
|
|
||
| if (!self.isMovingToParentViewController) [self refreshBanner]; // revive after going in sub pages | ||
| } | ||
|
|
||
| - (void)refreshBanner { | ||
| if ([self.table.tableHeaderView isKindOfClass:[SPDAnimatedBanner class]]) { | ||
| ((SPDAnimatedBanner *)self.table.tableHeaderView).activateGradient = yourSwitchValue; | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Gallery | ||
| <figure> | ||
| <img src="images/animated.gif" alt="Animatable" width=500 /> | ||
| <figcaption>Animatable</figcaption> | ||
| </figure> | ||
| <figure> | ||
| <img src="images/light_and_dark.gif" alt="Light and Dark modes" width=500 /> | ||
| <figcaption>Gorgeous in light or dark</figcaption> | ||
| </figure> | ||
| <figure> | ||
| <img src="images/togglable.gif" alt="Togglable" width=500 /> | ||
| <figcaption>Can be controlled from a specifier</figcaption> | ||
| </figure> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| #import <UIKit/UIKit.h> | ||
|
|
||
| @interface XXXAnimatedBanner : UIView | ||
| @property(nonatomic, strong) UILabel *titleLabel; | ||
| @property(nonatomic, strong) UIView *gradientView; | ||
| @property(nonatomic, strong) UILabel *subtitleLabel; | ||
| @property(nonatomic, strong) CAGradientLayer *gradient; | ||
| @property(nonatomic, strong) NSMutableArray *animations; | ||
| @property(nonatomic, strong) NSMutableArray *cgcolors; | ||
| @property(nonatomic) CGFloat defaultOffset; | ||
| @property(nonatomic, strong) NSLayoutConstraint *stackCenter; | ||
| @property(nonatomic, assign, getter=isGradientActivated) BOOL activateGradient; | ||
| - (instancetype)initWithTitle:(NSString *)title subtitle:(NSString *)subtitle colors:(NSArray<__kindof UIColor *> *)colors defaultOffset:(CGFloat)offset; | ||
| - (void)adjustStackPositionToScrollOffset:(CGFloat)offset; | ||
| @end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| #import "XXXAnimatedBanner.h" | ||
|
|
||
| @implementation XXXAnimatedBanner | ||
|
|
||
| - (instancetype)initWithTitle:(NSString *)title subtitle:(NSString *)subtitle colors:(NSArray<__kindof UIColor *> *)colors defaultOffset:(CGFloat)defaultOffset { | ||
| if (self = [super initWithFrame:CGRectMake(0, 0, self.superview.frame.size.width, 200)]) { | ||
| // Labels | ||
| self.titleLabel = [[UILabel alloc] init]; | ||
| self.titleLabel.text = title; | ||
| self.titleLabel.font = [UIFont boldSystemFontOfSize:42.f]; | ||
| self.titleLabel.lineBreakMode = NSLineBreakByWordWrapping; | ||
| [self.titleLabel sizeToFit]; | ||
| // CGPoint titleFrameAnchor = CGPointMake(CGRectGetMinX(self.titleLabel.frame), CGRectGetMaxY(self.titleLabel.frame)); | ||
| // self.titleLabel.layer.anchorPoint = CGPointMake(0, 1); | ||
| // self.titleLabel.layer.position = titleFrameAnchor; // ~ top center | ||
|
|
||
| self.subtitleLabel = [[UILabel alloc] init]; | ||
| self.subtitleLabel.text = subtitle; | ||
| self.subtitleLabel.font = [UIFont systemFontOfSize:24.f weight:UIFontWeightMedium]; | ||
| if (@available(iOS 13.0, *)) { | ||
| self.subtitleLabel.textColor = [UIColor secondaryLabelColor]; | ||
| } else { | ||
| self.subtitleLabel.textColor = [UIColor systemGrayColor]; | ||
| } | ||
| self.subtitleLabel.lineBreakMode = NSLineBreakByWordWrapping; | ||
| [self.subtitleLabel sizeToFit]; | ||
| // CGPoint subtitleFrameAnchor = CGPointMake(CGRectGetMinX(self.subtitleLabel.frame), CGRectGetMinY(self.subtitleLabel.frame)); | ||
| // self.subtitleLabel.layer.anchorPoint = CGPointMake(0, 0); | ||
| // self.subtitleLabel.layer.position = subtitleFrameAnchor; // bottom center | ||
|
|
||
| // Create gradient | ||
| self.gradient = [CAGradientLayer layer]; | ||
| self.gradient.frame = self.titleLabel.frame; | ||
| self.cgcolors = [NSMutableArray new]; | ||
| for (int i = 0; i < colors.count; i++) { | ||
| self.cgcolors[i] = (id)colors[i].CGColor; | ||
| } | ||
| self.gradient.colors = self.cgcolors; | ||
| self.gradient.locations = @[@0, @1]; | ||
|
|
||
| self.gradientView = [[UIView alloc] init]; | ||
| [self.gradientView.layer addSublayer:self.gradient]; | ||
| self.gradientView.maskView = self.titleLabel; | ||
| // CGPoint gradientFrameAnchor = CGPointMake(CGRectGetMinX(self.gradientView.frame), CGRectGetMaxY(self.gradientView.frame)); | ||
| // self.gradientView.layer.anchorPoint = CGPointMake(0, 1); | ||
| // self.gradientView.layer.position = gradientFrameAnchor; | ||
|
|
||
| // Animations | ||
| self.animations = [NSMutableArray new]; | ||
|
|
||
| CABasicAnimation *locations = [CABasicAnimation animationWithKeyPath:@"locations"]; | ||
| locations.fromValue = @[@0, @0]; | ||
| locations.toValue = @[@0, @1]; | ||
| locations.autoreverses = YES; | ||
| locations.repeatCount = FLT_MAX; | ||
| locations.duration = 5.0; | ||
| [self.animations addObject:locations]; | ||
|
|
||
| CABasicAnimation *opacity = [CABasicAnimation animationWithKeyPath:@"opacity"]; | ||
| opacity.fromValue = @.75; | ||
| opacity.toValue = @1; | ||
| opacity.autoreverses = YES; | ||
| opacity.repeatCount = FLT_MAX; | ||
| opacity.duration = 3.0; | ||
| [self.animations addObject:opacity]; | ||
|
|
||
| // Stack | ||
| UIStackView *stackView = [[UIStackView alloc] initWithArrangedSubviews:@[self.gradientView, self.subtitleLabel]]; | ||
| stackView.alignment = UIStackViewAlignmentLeading; | ||
| stackView.axis = UILayoutConstraintAxisVertical; | ||
| stackView.distribution = UIStackViewDistributionEqualCentering; | ||
| stackView.spacing = 0; | ||
| stackView.translatesAutoresizingMaskIntoConstraints = NO; | ||
| [self addSubview:stackView]; | ||
|
|
||
| [NSLayoutConstraint activateConstraints:@[ | ||
| [stackView.leadingAnchor constraintEqualToAnchor:self.leadingAnchor constant:25], | ||
| self.stackCenter = [stackView.centerYAnchor constraintEqualToAnchor:self.centerYAnchor constant:0], | ||
| [stackView.heightAnchor constraintEqualToConstant:self.titleLabel.frame.size.height + self.subtitleLabel.frame.size.height], | ||
|
|
||
| [self.gradientView.widthAnchor constraintEqualToConstant:self.titleLabel.frame.size.width], | ||
| [self.gradientView.heightAnchor constraintEqualToConstant:self.titleLabel.frame.size.height] | ||
| ]]; | ||
|
|
||
| self.defaultOffset = defaultOffset; | ||
| } | ||
|
|
||
| return self; | ||
| } | ||
|
|
||
| - (void)setActivateGradient:(BOOL)activated { | ||
| _activateGradient = activated; | ||
|
|
||
| // I would like to animate transition between activated and not but nvm | ||
| if (activated) { | ||
| self.gradient.colors = self.cgcolors; | ||
| for (CAAnimation *animation in self.animations) { | ||
| [self.gradient addAnimation:animation forKey:nil]; | ||
| } | ||
| } else { | ||
| if (@available(iOS 13.0, *)) { | ||
| self.gradient.colors = @[(id)[UIColor labelColor].CGColor, (id)[UIColor labelColor].CGColor]; | ||
| } else { | ||
| self.gradient.colors = @[(id)[UIColor blackColor].CGColor, (id)[UIColor blackColor].CGColor]; | ||
| } | ||
| [self.gradient removeAllAnimations]; | ||
| } | ||
| } | ||
|
|
||
| - (void)adjustStackPositionToScrollOffset:(CGFloat)offset { | ||
| // Smooth scroll effect | ||
| if (offset < self.defaultOffset) { | ||
| CGFloat space = self.defaultOffset - offset; | ||
| self.stackCenter.constant = -space / 2; | ||
| // This + comments above are to make the text a bit bigger on scrolling | ||
| // pretty much like the stock iOS behavior with big titles but I can't | ||
| // manage to make it look good so I gave up | ||
| /* if (space < 100) { | ||
| CGFloat titleScale = 1 + (space / 750); | ||
| CGFloat subtitleScale = 1 + (space / 1000); | ||
| self.titleLabel.transform = CGAffineTransformMakeScale(titleScale, titleScale); | ||
| self.subtitleLabel.transform = CGAffineTransformMakeScale(subtitleScale, subtitleScale); | ||
| } */ | ||
| } | ||
| } | ||
|
|
||
| @end | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,13 @@ | ||
| #import <UIKit/UIKit.h> | ||
|
|
||
| @interface LBMAnimatedTitleView : UIView | ||
| -(instancetype)initWithTitle:(NSString *)title minimumScrollOffsetRequired:(CGFloat)minimumOffset; | ||
| -(void)adjustLabelPositionToScrollOffset:(CGFloat)offset; | ||
| @interface XXXAnimatedTitleView : UIView { | ||
| NSLayoutConstraint *labelYConstraint; | ||
| NSLayoutConstraint *iconYConstraint; | ||
| CGFloat minimumOffsetRequired; | ||
| } | ||
| @property (nonatomic, strong, readonly) UIImageView *iconImageView; | ||
| @property (nonatomic, strong, readonly) UILabel *titleLabel; | ||
| - (instancetype)initWithTitle:(NSString *)title minimumScrollOffsetRequired:(CGFloat)minimumOffset; | ||
| - (instancetype)initWithTitle:(NSString *)title image:(_Nullable UIImage *)image minimumScrollOffsetRequired:(CGFloat)minimumOffset; | ||
| - (void)adjustItemsPositionToScrollOffset:(CGFloat)offset; | ||
| @end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,50 +1,60 @@ | ||
| #import "XXXAnimatedTitleView.h" | ||
|
|
||
| @implementation XXXAnimatedTitleView { | ||
| UILabel *_titleLabel; | ||
| NSLayoutConstraint *_yConstraint; | ||
| CGFloat _minimumOffsetRequired; | ||
| @implementation XXXAnimatedTitleView | ||
|
|
||
| - (instancetype)initWithTitle:(NSString *)title minimumScrollOffsetRequired:(CGFloat)minimumOffset { | ||
| return [self initWithTitle:title image:nil minimumScrollOffsetRequired:minimumOffset]; | ||
| } | ||
|
|
||
| - (instancetype)initWithTitle:(NSString *)title image:(_Nullable UIImage *)image minimumScrollOffsetRequired:(CGFloat)minimumOffset { | ||
| if (self = [super init]) { | ||
| self.superview.clipsToBounds = YES; | ||
|
|
||
| _titleLabel = [[UILabel alloc] init]; | ||
| _titleLabel.text = title; | ||
| _titleLabel.textAlignment = NSTextAlignmentCenter; | ||
| if (@available(iOS 13.0, *)) { | ||
| _titleLabel.textColor = [UIColor labelColor]; | ||
| } else { | ||
| _titleLabel.textColor = [UIColor blackColor]; | ||
| } | ||
| _titleLabel.font = [UIFont systemFontOfSize:[UIFont labelFontSize] weight:UIFontWeightSemibold]; | ||
| _titleLabel.translatesAutoresizingMaskIntoConstraints = NO; | ||
| [_titleLabel sizeToFit]; | ||
|
|
||
| _iconImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)]; | ||
| _iconImageView.image = image; | ||
| _iconImageView.contentMode = UIViewContentModeScaleAspectFit; | ||
| _iconImageView.translatesAutoresizingMaskIntoConstraints = NO; | ||
|
|
||
| [self addSubview:_titleLabel]; | ||
| [self addSubview:_iconImageView]; | ||
|
|
||
| [NSLayoutConstraint activateConstraints:@[ | ||
| [self.widthAnchor constraintEqualToAnchor:_titleLabel.widthAnchor], | ||
| [self.heightAnchor constraintEqualToAnchor:_titleLabel.heightAnchor], | ||
| [_titleLabel.centerXAnchor constraintEqualToAnchor:self.centerXAnchor], | ||
| labelYConstraint = [_titleLabel.centerYAnchor constraintEqualToAnchor:self.centerYAnchor constant:50], | ||
|
|
||
| [_iconImageView.centerXAnchor constraintEqualToAnchor:self.centerXAnchor], | ||
| iconYConstraint = [_iconImageView.centerYAnchor constraintEqualToAnchor:self.centerYAnchor constant:0] | ||
| ]]; | ||
|
|
||
| minimumOffsetRequired = minimumOffset; | ||
| } | ||
|
|
||
| return self; | ||
| } | ||
|
|
||
| -(instancetype)initWithTitle:(NSString *)title minimumScrollOffsetRequired:(CGFloat)minimumOffset { | ||
| if([super init]) { | ||
| self.superview.clipsToBounds = YES; | ||
|
|
||
| _titleLabel = [[UILabel alloc] init]; | ||
| _titleLabel.text = title; | ||
| _titleLabel.textAlignment = NSTextAlignmentCenter; | ||
| _titleLabel.textColor = [UIColor whiteColor]; | ||
| _titleLabel.font = [UIFont systemFontOfSize:17 weight:UIFontWeightHeavy]; | ||
| _titleLabel.translatesAutoresizingMaskIntoConstraints = NO; | ||
| [_titleLabel sizeToFit]; | ||
|
|
||
| [self addSubview:_titleLabel]; | ||
|
|
||
| [NSLayoutConstraint activateConstraints:@[ | ||
| [self.widthAnchor constraintEqualToAnchor:_titleLabel.widthAnchor], | ||
| [self.heightAnchor constraintEqualToAnchor:_titleLabel.heightAnchor], | ||
|
|
||
| [_titleLabel.centerXAnchor constraintEqualToAnchor:self.centerXAnchor], | ||
| _yConstraint = [_titleLabel.centerYAnchor constraintEqualToAnchor:self.centerYAnchor constant:100], | ||
| ]]; | ||
|
|
||
| _minimumOffsetRequired = minimumOffset; | ||
| } | ||
|
|
||
| return self; | ||
| } | ||
|
|
||
| -(void)adjustLabelPositionToScrollOffset:(CGFloat)offset { | ||
| CGFloat adjustment = 100 - (offset - _minimumOffsetRequired); | ||
| if(offset >= _minimumOffsetRequired) { | ||
| if(adjustment <= 0) { | ||
| _yConstraint.constant = 0; | ||
| } else { | ||
| _yConstraint.constant = adjustment; | ||
| } | ||
|
|
||
| } else { | ||
| _yConstraint.constant = -100; | ||
| } | ||
| } | ||
| - (void)adjustItemsPositionToScrollOffset:(CGFloat)offset { | ||
| CGFloat adjustment = 50 - (offset - minimumOffsetRequired); | ||
| if (offset >= minimumOffsetRequired) { | ||
| labelYConstraint.constant = adjustment <= 0 ? 0 : adjustment; | ||
| iconYConstraint.constant = adjustment <= 40 ? adjustment <= -10 ? -50 : adjustment - 40 : 0; // don't ask me i don't know | ||
| } else { | ||
| labelYConstraint.constant = 50; | ||
| iconYConstraint.constant = 0; | ||
| } | ||
| _iconImageView.alpha = labelYConstraint.constant / 50; | ||
| } | ||
| @end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,17 @@ | ||
| -(void)viewDidAppear:(BOOL)animated { | ||
| - (void)viewDidAppear:(BOOL)animated { | ||
| [super viewDidAppear:animated]; | ||
|
|
||
| //Create view and set as titleView of your navigation bar | ||
| //Set the title and the minimum scroll offset before starting the animation | ||
| if(!self.navigationItem.titleView) { | ||
| // Create view and set as titleView of your navigation bar | ||
| // Set the title and the minimum scroll offset before starting the animation | ||
| if (!self.navigationItem.titleView) { | ||
| LBMAnimatedTitleView *titleView = [[LBMAnimatedTitleView alloc] initWithTitle:@"Title" minimumScrollOffsetRequired:100]; | ||
| self.navigationItem.titleView = titleView; | ||
| } | ||
| } | ||
|
|
||
| -(void)scrollViewDidScroll:(UIScrollView *)scrollView { | ||
|
|
||
| //Send scroll offset updates to view | ||
| if([self.navigationItem.titleView respondsToSelector:@selector(adjustLabelPositionToScrollOffset:)]) { | ||
| - (void)scrollViewDidScroll:(UIScrollView *)scrollView { | ||
| // Send scroll offset updates to view | ||
| if ([self.navigationItem.titleView respondsToSelector:@selector(adjustLabelPositionToScrollOffset:)]) { | ||
| [(XXXAnimatedTitleView *)self.navigationItem.titleView adjustLabelPositionToScrollOffset:scrollView.contentOffset.y]; | ||
| } | ||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some ideas here about the constraints:
The stackview wont be centered on the X axis with the current constraints. All edges should be anchored or it could be centered with both centerX/centerY anchors.
Using edge anchors would also allow you to get rid of the heightAnchor by constraining the top anchor of the stackview to the
title label'sgradient's top anchor and the bottom anchor to the subtitle's bottom anchor:The gradient's height/width anchors should just be equal to the title label's anchors:I see that the label is used as the mask.EDIT: Fixed some incorrect suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the first part, the stack view isn't aimed to be centered on X, its left padding with a small indent of 25 (to leave some space and not stick it to the left border) looks great. In my opinion if the end user/developer wants it centered it's easily doable, but it's not the aim of my implementation.
For your edge anchors suggestion, it should work too, but I'm not sure if it'd break the gradient or the scrolling effect I made. Also I may add that it works great as-is, thus I don't get the point of changing that.
If you're really sure that it won't break the current look & feel of the banner, and that a change might be better in terms of performance or code practices, I'm open to any change. But honestly I don't see why anything should be changed on constraints' side with the current implementation.