Skip to content

Commit

Permalink
perf(UI): improve tag scrollView layout
Browse files Browse the repository at this point in the history
  • Loading branch information
tisfeng committed Feb 27, 2024
1 parent a65792b commit 5306bde
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ - (void)refreshWithResult:(EZQueryResult *)result {
__block NSView *tagContentView = nil;
__block CGFloat tagContentViewWidth = 0;
CGFloat padding = 6;
CGFloat leftMargin = kHorizontalMargin_8 + 2;

__block NSButton *lastTagButton = nil;
[wordResult.tags enumerateObjectsUsingBlock:^(NSString *_Nonnull tag, NSUInteger idx, BOOL *_Nonnull stop) {
Expand All @@ -374,7 +375,7 @@ - (void)refreshWithResult:(EZQueryResult *)result {
tagScrollView = [[NSScrollView alloc] init];
[self addSubview:tagScrollView];
[tagScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.offset(kHorizontalMargin_8);
make.left.offset(leftMargin);
make.height.mas_equalTo(newSize.height);
CGFloat topOffset = kVerticalMargin_12 + 3;
if (lastView) {
Expand Down Expand Up @@ -418,7 +419,7 @@ - (void)refreshWithResult:(EZQueryResult *)result {

tagContentView.width = tagContentViewWidth;

CGFloat maxTagScrollViewWidth = self.width - (kHorizontalMargin_8 + padding * 2);
CGFloat maxTagScrollViewWidth = self.width - (leftMargin + padding);
CGFloat tagScrollViewWidth = MIN(tagContentViewWidth, maxTagScrollViewWidth);
[tagScrollView mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(tagScrollViewWidth);
Expand Down

0 comments on commit 5306bde

Please sign in to comment.