Skip to content

Commit dfb17e7

Browse files
committed
添加高斯模糊和红点提醒
1 parent 176417d commit dfb17e7

8 files changed

Lines changed: 146 additions & 6 deletions

File tree

Coding_iOS/Controllers/RootControllers/Tweet_RootViewController.m

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ - (void)viewDidLoad
142142

143143
- (void)viewWillDisappear:(BOOL)animated{
144144
[super viewWillDisappear:animated];
145+
145146
if (_myMsgInputView) {
146147
[_myMsgInputView prepareToDismiss];
147148
}
@@ -150,6 +151,14 @@ - (void)viewWillDisappear:(BOOL)animated{
150151
- (void)viewDidAppear:(BOOL)animated{
151152
[super viewDidAppear:animated];
152153

154+
UIButton *leftItemView = (UIButton *)self.parentViewController.navigationItem.leftBarButtonItem.customView;
155+
if(![CSSearchModel hasClickedNewFeatureWithType:CSSNewFeatureTypeSearch]) {
156+
157+
[leftItemView addBadgePoint:3 withPointPosition:CGPointMake(35, 10)];
158+
}
159+
160+
// [leftItemView addBadgePoint:3 withPosition:BadgePositionTypeDefault];
161+
153162
[self refreshFirst];
154163

155164
// 键盘
@@ -256,6 +265,10 @@ - (void)deleteComment:(Comment *)comment ofTweet:(Tweet *)tweet{
256265

257266
- (void)searchItemClicked:(id)sender{
258267

268+
UIButton *leftItemView = (UIButton *)self.parentViewController.navigationItem.leftBarButtonItem.customView;
269+
[CSSearchModel clickNewFeatureWithType:CSSNewFeatureTypeSearch];
270+
[leftItemView removeBadgePoint];
271+
259272
if(!_searchBar) {
260273

261274
_searchBar = ({

Coding_iOS/Controllers/Search/CSSearchDisplayVC.m

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#import "Coding_NetAPIManager.h"
1313
#import "ODRefreshControl.h"
1414
#import "SVPullToRefresh.h"
15+
#import "XHRealTimeBlur.h"
1516

1617
#import "CSSearchModel.h"
1718

@@ -24,6 +25,7 @@
2425
@interface CSSearchDisplayVC () <UISearchBarDelegate, UITableViewDelegate, UITableViewDataSource>
2526

2627
@property (nonatomic, strong) UIView *contentView;
28+
@property (nonatomic, strong) XHRealTimeBlur *backgroundView;
2729
@property (nonatomic, strong) UIButton *btnMore;
2830
@property (nonatomic, strong) TopicHotkeyView *topicHotkeyView;
2931

@@ -41,6 +43,7 @@ - (void)initSearchResultsTableView;
4143
- (void)initSearchHistoryView;
4244
- (void)didClickedMoreHotkey:(id)sender;
4345
- (void)didCLickedCleanSearchHistory:(id)sender;
46+
- (void)didClickedContentView:(UIGestureRecognizer *)sender;
4447
@end
4548

4649
@implementation CSSearchDisplayVC
@@ -51,6 +54,7 @@ - (void)setActive:(BOOL)visible animated:(BOOL)animated {
5154

5255
if(_contentView) {
5356

57+
[_backgroundView removeFromSuperview];
5458
[_contentView removeFromSuperview];
5559
[_searchTableView removeFromSuperview];
5660
[super setActive:visible animated:animated];
@@ -75,14 +79,31 @@ - (void)setActive:(BOOL)visible animated:(BOOL)animated {
7579
}
7680

7781
if(!_contentView) {
82+
83+
_contentView = ({
84+
85+
UIView *view = [[UIView alloc] init];
86+
view.frame = CGRectMake(0.0f, 60.0f, kScreen_Width, kScreen_Height - 60.0f);
87+
view.backgroundColor = [UIColor clearColor];
88+
view.userInteractionEnabled = YES;
89+
90+
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didClickedContentView:)];
91+
[view addGestureRecognizer:tapGestureRecognizer];
92+
93+
view;
94+
});
95+
96+
_backgroundView = ({
7897

79-
_contentView = [[UIView alloc] init];
80-
_contentView.frame = CGRectMake(0.0f, 60.0f, kScreen_Width, kScreen_Height - 60.0f);
81-
_contentView.backgroundColor = [UIColor whiteColor];
98+
XHRealTimeBlur *blur = [[XHRealTimeBlur alloc] initWithFrame:_contentView.frame];
99+
blur.blurStyle = XHBlurStyleTranslucentWhite;
100+
blur;
101+
});
82102

83103
[self initSubViewsInContentView];
84104
}
85105

106+
[self.searchBar.superview addSubview:_backgroundView];
86107
[self.searchBar.superview addSubview:_contentView];
87108
[self.searchBar.superview bringSubviewToFront:_contentView];
88109
__weak typeof(self) weakSelf = self;
@@ -108,6 +129,8 @@ - (void)initSubViewsInContentView {
108129
[_btnMore addTarget:self action:@selector(didClickedMoreHotkey:) forControlEvents:UIControlEventTouchUpInside];
109130
[_contentView addSubview:_btnMore];
110131

132+
// [_btnMore addBadgePoint:2 withPosition:BadgePositionTypeMiddle];
133+
111134
_topicHotkeyView = [[TopicHotkeyView alloc] init];
112135
[_contentView addSubview:_topicHotkeyView];
113136
[_topicHotkeyView mas_makeConstraints:^(MASConstraintMaker *make) {
@@ -137,8 +160,6 @@ - (void)initSubViewsInContentView {
137160
make.width.mas_equalTo(kScreen_Width);
138161
make.height.mas_equalTo(weakSelf.topicHotkeyView.frame.size.height);
139162
}];
140-
// [weakSelf.searchHistoryView setFrame:CGRectMake(weakSelf.searchHistoryView.frame.origin.x, weakSelf.topicHotkeyView.frame.origin.y + weakSelf.topicHotkeyView.frame.size.height,
141-
// weakSelf.searchHistoryView.frame.size.width, weakSelf.searchHistoryView.frame.size.height)];
142163
}
143164
}];
144165
}
@@ -256,6 +277,11 @@ - (void)didCLickedCleanSearchHistory:(id)sender {
256277
[self initSearchHistoryView];
257278
}
258279

280+
- (void)didClickedContentView:(UIGestureRecognizer *)sender {
281+
282+
[self.searchBar resignFirstResponder];
283+
}
284+
259285
#pragma mark -
260286
#pragma mark Search Data Request
261287

Coding_iOS/Controllers/Search/CSSearchModel.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,17 @@
88

99
#import <Foundation/Foundation.h>
1010

11+
typedef NS_ENUM(NSInteger, CSSNewFeatureType) {
12+
13+
CSSNewFeatureTypeTopic = 0,
14+
CSSNewFeatureTypeSearch,
15+
CSSNewFeatureTypeHotTopic
16+
};
17+
1118
@interface CSSearchModel : NSObject
1219

20+
+ (BOOL)hasClickedNewFeatureWithType:(CSSNewFeatureType)type;
21+
+ (void)clickNewFeatureWithType:(CSSNewFeatureType)type;
1322

1423
+ (BOOL)hasSearchBadgeShown;
1524
+ (void)invalidSearchBadge;

Coding_iOS/Controllers/Search/CSSearchModel.m

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,30 @@
1111

1212
#define kHasSearchBadgeShown @"com.cs.search.badge.hasShown"
1313
#define kSearchHistory @"com.cs.search.history"
14+
#define kNewFeature @"com.cs.NewFeature"
1415

1516
@implementation CSSearchModel
1617

18+
+ (BOOL)hasClickedNewFeatureWithType:(CSSNewFeatureType)type {
19+
20+
NSString *key = [kNewFeature stringByAppendingString:[NSString stringWithFormat:@"_%ld", (long)type]];
21+
id hasClicked = [[TMCache TemporaryCache] objectForKey:key];
22+
if(!hasClicked) {
23+
24+
[[TMCache TemporaryCache] setObject:@(NO) forKey:key];
25+
}else {
26+
27+
return [hasClicked boolValue];
28+
}
29+
return NO;
30+
}
31+
32+
+ (void)clickNewFeatureWithType:(CSSNewFeatureType)type {
33+
34+
NSString *key = [kNewFeature stringByAppendingString:[NSString stringWithFormat:@"_%ld", (long)type]];
35+
[[TMCache TemporaryCache] setObject:@(YES) forKey:key];
36+
}
37+
1738
+ (BOOL)hasSearchBadgeShown {
1839
BOOL hasShown = [[[TMCache TemporaryCache] objectForKey:kHasSearchBadgeShown] boolValue];
1940
return hasShown;

Coding_iOS/Util/OC_Category/UIBarButtonItem+Common.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ + (UIBarButtonItem *)itemWithIcon:(NSString*)iconName showBadge:(BOOL)showbadge
2323
CGSize imgSize = button.imageView.image.size;
2424
button.size = CGSizeMake(imgSize.width + 20, imgSize.height + 20);
2525

26-
2726
if (showbadge) {
2827
[button addRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(2, 2)];
2928
// CGFloat pointX = button.frame.size.width - 15;

Coding_iOS/Util/OC_Category/UIView+Common.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ typedef NS_ENUM(NSInteger, EaseBlankPageType)
2727
EaseBlankPageTypePrivateMsg
2828
};
2929

30+
typedef NS_ENUM(NSInteger, BadgePositionType) {
31+
32+
BadgePositionTypeDefault = 0,
33+
BadgePositionTypeMiddle
34+
};
35+
3036
@interface UIView (Common)
3137
- (void)doCircleFrame;
3238
- (void)doNotCircleFrame;
@@ -35,6 +41,9 @@ typedef NS_ENUM(NSInteger, EaseBlankPageType)
3541
- (UIViewController *)findViewController;
3642
- (void)addBadgeTip:(NSString *)badgeValue withCenterPosition:(CGPoint)center;
3743
- (void)addBadgeTip:(NSString *)badgeValue;
44+
- (void)addBadgePoint:(NSInteger)pointRadius withPosition:(BadgePositionType)type;
45+
- (void)addBadgePoint:(NSInteger)pointRadius withPointPosition:(CGPoint)point;
46+
- (void)removeBadgePoint;
3847
- (void)removeBadgeTips;
3948
- (void)setY:(CGFloat)y;
4049
- (void)setX:(CGFloat)x;

Coding_iOS/Util/OC_Category/UIView+Common.m

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#import "UIView+Common.h"
1010
#define kTagBadgeView 1000
11+
#define kTagBadgePointView 1001
1112
#define kTagLineView 1007
1213
#import <objc/runtime.h>
1314
@implementation UIView (Common)
@@ -46,6 +47,57 @@ - (UIViewController *)findViewController
4647
return nil;
4748
}
4849

50+
- (void)addBadgePoint:(NSInteger)pointRadius withPosition:(BadgePositionType)type {
51+
52+
if(pointRadius < 1)
53+
return;
54+
55+
[self removeBadgePoint];
56+
57+
UIView *badgeView = [[UIView alloc]init];
58+
badgeView.tag = kTagBadgePointView;
59+
badgeView.layer.cornerRadius = pointRadius;
60+
badgeView.backgroundColor = [UIColor redColor];
61+
62+
switch (type) {
63+
64+
case BadgePositionTypeMiddle:
65+
badgeView.frame = CGRectMake(0, self.frame.size.height / 2 - pointRadius, 2 * pointRadius, 2 * pointRadius);
66+
break;
67+
68+
default:
69+
badgeView.frame = CGRectMake(self.frame.size.width - 2 * pointRadius, 0, 2 * pointRadius, 2 * pointRadius);
70+
break;
71+
}
72+
73+
[self addSubview:badgeView];
74+
}
75+
76+
- (void)addBadgePoint:(NSInteger)pointRadius withPointPosition:(CGPoint)point {
77+
78+
if(pointRadius < 1)
79+
return;
80+
81+
[self removeBadgePoint];
82+
83+
UIView *badgeView = [[UIView alloc]init];
84+
badgeView.tag = kTagBadgePointView;
85+
badgeView.layer.cornerRadius = pointRadius;
86+
badgeView.backgroundColor = [UIColor redColor];
87+
badgeView.frame = CGRectMake(0, 0, 2 * pointRadius, 2 * pointRadius);
88+
badgeView.center = point;
89+
[self addSubview:badgeView];
90+
}
91+
92+
- (void)removeBadgePoint {
93+
94+
for (UIView *subView in self.subviews) {
95+
96+
if(subView.tag == kTagBadgePointView)
97+
[subView removeFromSuperview];
98+
}
99+
}
100+
49101
- (void)addBadgeTip:(NSString *)badgeValue withCenterPosition:(CGPoint)center{
50102
if (!badgeValue || !badgeValue.length) {
51103
[self removeBadgeTips];

Coding_iOS/Views/Cell/TweetSendTextCell.m

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#import "TweetSendTextCell.h"
1414
#import "UsersViewController.h"
1515
#import "CSTopicCreateVC.h"
16+
#import "CSSearchModel.h"
1617

1718
@interface TweetSendTextCell () <AGEmojiKeyboardViewDelegate, AGEmojiKeyboardViewDataSource>
1819
@property (strong, nonatomic) AGEmojiKeyboardView *emojiKeyboardView;
@@ -125,6 +126,11 @@ - (UIView *)keyboardToolBar{
125126

126127
UIButton *atButton = [self toolButtonWithToolBarFrame:keyboardToolBar.frame index:3 imageStr:@"keyboard_at" andSelecter:@selector(atButtonClicked:)];
127128
[keyboardToolBar addSubview:atButton];
129+
130+
if(![CSSearchModel hasClickedNewFeatureWithType:CSSNewFeatureTypeTopic]) {
131+
132+
[topicButton addBadgePoint:3 withPointPosition:CGPointMake(27, 7)];
133+
}
128134
}
129135

130136
[_footerToolBar addSubview:keyboardToolBar];
@@ -192,6 +198,11 @@ - (void)atButtonClicked:(id)sender{
192198
}
193199

194200
- (void)topicButtonClicked:(id)sender{
201+
202+
UIButton *btnTopic = (UIButton *)sender;
203+
[btnTopic removeBadgePoint];
204+
[CSSearchModel clickNewFeatureWithType:CSSNewFeatureTypeTopic];
205+
195206
@weakify(self);
196207
[CSTopicCreateVC showATSomeoneWithBlock:^(NSString *topicName) {
197208
@strongify(self);

0 commit comments

Comments
 (0)