Skip to content

Commit

Permalink
fix: replace hoverButton with linkButton
Browse files Browse the repository at this point in the history
  • Loading branch information
AkaShark committed Feb 22, 2024
1 parent ad5dcc8 commit d592723
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 38 deletions.
6 changes: 0 additions & 6 deletions Easydict/Feature/ViewController/Cell/EZTableTipsCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,8 @@

NS_ASSUME_NONNULL_BEGIN

typedef void(^tipsButtonClick)(NSString *url);

@interface EZTableTipsCell : NSTableRowView

@property (nonatomic, copy) tipsButtonClick moreBtnClick;

@property (nonatomic, copy) tipsButtonClick solveBtnClick;

- (CGFloat)cellHeight;

@end
Expand Down
30 changes: 9 additions & 21 deletions Easydict/Feature/ViewController/Cell/EZTableTipsCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

#import "EZTableTipsCell.h"
#import "EZHoverButton.h"
#import "EZOpenLinkButton.h"
#import "NSImage+EZSymbolmage.h"
#import "EZLanguageManager.h"

Expand All @@ -16,8 +16,8 @@ @interface EZTableTipsCell()
@property (nonatomic, strong) NSImageView *tipsIconImageView;
@property (nonatomic, strong) NSTextField *tipsNameLabel;
@property (nonatomic, strong) NSTextField *tipsContentLabel;
@property (nonatomic, strong) EZHoverButton *moreBtn;
@property (nonatomic, strong) EZHoverButton *solveBtn;
@property (nonatomic, strong) EZOpenLinkButton *moreBtn;
@property (nonatomic, strong) EZOpenLinkButton *solveBtn;
@property (nonatomic, strong) NSDictionary *dataDict;
@property (nonatomic, strong) NSString *questionSolveURL;
@property (nonatomic, strong) NSString *seeMoreURL;
Expand Down Expand Up @@ -103,6 +103,7 @@ - (void)updateQuestionContent {
solves = self.dataDict[@"solveEn"];
}
self.questionSolveURL = solves[index];
self.solveBtn.link = self.questionSolveURL;
}

- (CGFloat)cellHeight {
Expand Down Expand Up @@ -186,9 +187,9 @@ - (NSTextField *)tipsContentLabel {
return _tipsContentLabel;
}

- (EZHoverButton *)moreBtn {
- (EZOpenLinkButton *)moreBtn {
if (!_moreBtn) {
_moreBtn = [[EZHoverButton alloc] init];
_moreBtn = [[EZOpenLinkButton alloc] init];
[self addSubview:_moreBtn];
NSImage *moreBtnImage = [NSImage ez_imageWithSymbolName:@"ellipsis.circle.fill"];
_moreBtn.image = moreBtnImage;
Expand All @@ -200,20 +201,14 @@ - (EZHoverButton *)moreBtn {
} dark:^(NSButton *button) {
button.image = [button.image imageWithTintColor:[NSColor ez_imageTintDarkColor]];
}];
mm_weakify(self);
[_moreBtn setClickBlock:^(EZButton *button) {
mm_strongify(self);
if (self.moreBtnClick) {
self.moreBtnClick(self.seeMoreURL);
}
}];
_moreBtn.link = self.seeMoreURL;
}
return _moreBtn;
}

- (EZHoverButton *)solveBtn {
- (EZOpenLinkButton *)solveBtn {
if (!_solveBtn) {
_solveBtn = [[EZHoverButton alloc] init];
_solveBtn = [[EZOpenLinkButton alloc] init];
[self addSubview:_solveBtn];
NSImage *solveBtnImage = [NSImage ez_imageWithSymbolName:@"link.circle.fill"];
_solveBtn.image = solveBtnImage;
Expand All @@ -225,13 +220,6 @@ - (EZHoverButton *)solveBtn {
} dark:^(NSButton *button) {
button.image = [button.image imageWithTintColor:[NSColor ez_imageTintDarkColor]];
}];
mm_weakify(self);
[_solveBtn setClickBlock:^(EZButton *button) {
mm_strongify(self);
if (self.solveBtnClick) {
self.solveBtnClick(self.questionSolveURL);
}
}];
}
return _solveBtn;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -811,17 +811,6 @@ - (nullable NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(null
tipsCell = [[EZTableTipsCell alloc] initWithFrame:[self tableViewContentBounds]];
tipsCell.identifier = EZTableTipsCellId;
}

tipsCell.moreBtnClick = ^(NSString * _Nonnull url) {
NSString *issueURL = [NSString stringWithFormat:@"%@", url];
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:issueURL]];
};

tipsCell.solveBtnClick = ^(NSString * _Nonnull url) {
NSString *issueURL = [NSString stringWithFormat:@"%@", url];
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:issueURL]];
};

self.tipsCell = tipsCell;
return tipsCell;
}
Expand Down

0 comments on commit d592723

Please sign in to comment.