Skip to content

Commit db866f9

Browse files
author
panshiyu
committed
修改小红点统计方式
1 parent 45d6f03 commit db866f9

6 files changed

Lines changed: 25 additions & 65 deletions

File tree

Coding_iOS/Controllers/RootControllers/Tweet_RootViewController.m

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#import "CSSearchVC.h"
2828
#import "CSSearchDisplayVC.h"
29+
#import "FunctionTipsManager.h"
2930

3031
@interface Tweet_RootViewController () <UISearchBarDelegate, UISearchDisplayDelegate>
3132
{
@@ -99,9 +100,7 @@ - (void)viewDidLoad
99100
// [self refreshFirst];
100101
// }];
101102

102-
BOOL isBadgeValid = ![CSSearchModel hasSearchBadgeShown];
103-
isBadgeValid = YES;
104-
UIBarButtonItem *leftBarItem =[UIBarButtonItem itemWithIcon:@"search_Nav" showBadge:isBadgeValid target:self action:@selector(searchItemClicked:)];
103+
UIBarButtonItem *leftBarItem =[UIBarButtonItem itemWithIcon:@"search_Nav" showBadge:NO target:self action:@selector(searchItemClicked:)];
105104
[self.parentViewController.navigationItem setLeftBarButtonItem:leftBarItem animated:NO];
106105

107106
_tweetsDict = [[NSMutableDictionary alloc] initWithCapacity:4];
@@ -152,13 +151,10 @@ - (void)viewDidAppear:(BOOL)animated{
152151
[super viewDidAppear:animated];
153152

154153
UIButton *leftItemView = (UIButton *)self.parentViewController.navigationItem.leftBarButtonItem.customView;
155-
if(![CSSearchModel hasClickedNewFeatureWithType:CSSNewFeatureTypeSearch]) {
156-
154+
if ([[FunctionTipsManager shareManager] needToTip:kFunctionTipStr_Search]) {
157155
[leftItemView addBadgePoint:3 withPointPosition:CGPointMake(35, 10)];
158156
}
159157

160-
// [leftItemView addBadgePoint:3 withPosition:BadgePositionTypeDefault];
161-
162158
[self refreshFirst];
163159

164160
// 键盘
@@ -264,10 +260,11 @@ - (void)deleteComment:(Comment *)comment ofTweet:(Tweet *)tweet{
264260
#pragma mark - search
265261

266262
- (void)searchItemClicked:(id)sender{
267-
268-
UIButton *leftItemView = (UIButton *)self.parentViewController.navigationItem.leftBarButtonItem.customView;
269-
[CSSearchModel clickNewFeatureWithType:CSSNewFeatureTypeSearch];
270-
[leftItemView removeBadgePoint];
263+
if ([[FunctionTipsManager shareManager] needToTip:kFunctionTipStr_Search]) {
264+
[[FunctionTipsManager shareManager] markTiped:kFunctionTipStr_Search];
265+
UIButton *leftItemView = (UIButton *)self.parentViewController.navigationItem.leftBarButtonItem.customView;
266+
[leftItemView removeBadgePoint];
267+
}
271268

272269
if(!_searchBar) {
273270

@@ -303,13 +300,6 @@ - (void)searchItemClicked:(id)sender{
303300
[self hideToolBar:YES];
304301
[_searchBar becomeFirstResponder];
305302

306-
// BOOL isBadgeValid = ![CSSearchModel hasSearchBadgeShown];
307-
// if (isBadgeValid) {
308-
// //存一下
309-
// [CSSearchModel invalidSearchBadge];
310-
// UIBarButtonItem *leftBarItem =[UIBarButtonItem itemWithIcon:@"search_Nav" showBadge:NO target:self action:@selector(searchItemClicked:)];
311-
// [self.navigationItem setLeftBarButtonItem:leftBarItem animated:NO];
312-
// }
313303
}
314304

315305
#pragma mark Refresh M

Coding_iOS/Controllers/Search/CSSearchModel.h

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

99
#import <Foundation/Foundation.h>
1010

11-
typedef NS_ENUM(NSInteger, CSSNewFeatureType) {
12-
13-
CSSNewFeatureTypeTopic = 0,
14-
CSSNewFeatureTypeSearch,
15-
CSSNewFeatureTypeHotTopic
16-
};
1711

1812
@interface CSSearchModel : NSObject
1913

20-
+ (BOOL)hasClickedNewFeatureWithType:(CSSNewFeatureType)type;
21-
+ (void)clickNewFeatureWithType:(CSSNewFeatureType)type;
22-
23-
+ (BOOL)hasSearchBadgeShown;
24-
+ (void)invalidSearchBadge;
25-
2614
+ (NSArray *)getSearchHistory;
2715
+ (void)addSearchHistory:(NSString *)searchString;
2816
+ (void)cleanAllSearchHistory;

Coding_iOS/Controllers/Search/CSSearchModel.m

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,6 @@
1515

1616
@implementation CSSearchModel
1717

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-
38-
+ (BOOL)hasSearchBadgeShown {
39-
BOOL hasShown = [[[TMCache TemporaryCache] objectForKey:kHasSearchBadgeShown] boolValue];
40-
return hasShown;
41-
}
42-
43-
+ (void)invalidSearchBadge{
44-
[[TMCache TemporaryCache] setObject:@(YES) forKey:kHasSearchBadgeShown];
45-
}
4618

4719
+ (NSArray *)getSearchHistory {
4820

Coding_iOS/Util/Manager/FunctionTipsManager.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@ static NSString *kFunctionTipStr_MR = @"MergeRequest";
1111
static NSString *kFunctionTipStr_PR = @"PullRequest";
1212
static NSString *kFunctionTipStr_ReadMe = @"ReadMe";
1313
static NSString *kFunctionTipStr_CommitList = @"Code_CommitList";
14+
static NSString *kFunctionTipStr_Search = @"hasSearch";
15+
static NSString *kFunctionTipStr_HotTopic = @"HotTopic";
16+
static NSString *kFunctionTipStr_TweetTopic = @"TweetTopic";
1417

18+
//CSSNewFeatureTypeTopic = 0,
19+
//CSSNewFeatureTypeSearch,
20+
//CSSNewFeatureTypeHotTopic
1521

1622
#import <Foundation/Foundation.h>
1723

Coding_iOS/Util/Manager/FunctionTipsManager.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ - (instancetype)init
3636
// kFunctionTipStr_PR: @(YES),
3737
// kFunctionTipStr_ReadMe: @(YES),
3838
// kFunctionTipStr_CommitList: @(YES),
39+
kFunctionTipStr_Search: @(YES),
40+
kFunctionTipStr_HotTopic: @(YES),
41+
kFunctionTipStr_TweetTopic: @(YES),
3942
} mutableCopy];
4043
[_tipsDict writeToFile:[self p_cacheFilePath] atomically:YES];
4144
}

Coding_iOS/Views/Cell/TweetSendTextCell.m

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

1818
@interface TweetSendTextCell () <AGEmojiKeyboardViewDelegate, AGEmojiKeyboardViewDataSource>
1919
@property (strong, nonatomic) AGEmojiKeyboardView *emojiKeyboardView;
@@ -127,8 +127,8 @@ - (UIView *)keyboardToolBar{
127127
UIButton *atButton = [self toolButtonWithToolBarFrame:keyboardToolBar.frame index:3 imageStr:@"keyboard_at" andSelecter:@selector(atButtonClicked:)];
128128
[keyboardToolBar addSubview:atButton];
129129

130-
if(![CSSearchModel hasClickedNewFeatureWithType:CSSNewFeatureTypeTopic]) {
131-
130+
131+
if ([[FunctionTipsManager shareManager] needToTip:kFunctionTipStr_TweetTopic]) {
132132
[topicButton addBadgePoint:3 withPointPosition:CGPointMake(27, 7)];
133133
}
134134
}
@@ -198,10 +198,11 @@ - (void)atButtonClicked:(id)sender{
198198
}
199199

200200
- (void)topicButtonClicked:(id)sender{
201-
202-
UIButton *btnTopic = (UIButton *)sender;
203-
[btnTopic removeBadgePoint];
204-
[CSSearchModel clickNewFeatureWithType:CSSNewFeatureTypeTopic];
201+
if ([[FunctionTipsManager shareManager] needToTip:kFunctionTipStr_TweetTopic]) {
202+
[[FunctionTipsManager shareManager] markTiped:kFunctionTipStr_TweetTopic];
203+
UIButton *btnTopic = (UIButton *)sender;
204+
[btnTopic removeBadgePoint];
205+
}
205206

206207
@weakify(self);
207208
[CSTopicCreateVC showATSomeoneWithBlock:^(NSString *topicName) {

0 commit comments

Comments
 (0)