Browse Source

@liuql6 @添加showNotification插件

liuql6 3 years ago
parent
commit
13d8aac515

BIN
IPUCommon/IPUMobileFunc.framework/IPUMobileFunc


+ 8 - 0
IPUMobileFunc/IPUMobileFunc.xcodeproj/project.pbxproj

@ -115,6 +115,8 @@
115 115
		B2EB105923A788C500EBB34D /* IPUMobile.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B2EB105523A788C500EBB34D /* IPUMobile.framework */; };
116 116
		B2EE784822D2D25A00E2C466 /* IPUStorageUtil.h in Headers */ = {isa = PBXBuildFile; fileRef = B2EE784622D2D25A00E2C466 /* IPUStorageUtil.h */; settings = {ATTRIBUTES = (Public, ); }; };
117 117
		B2EE784922D2D25A00E2C466 /* IPUStorageUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = B2EE784722D2D25A00E2C466 /* IPUStorageUtil.m */; };
118
		B2FB3BFB273B9DD200A522E0 /* IPUNotificationPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = B2FB3BF9273B9DD200A522E0 /* IPUNotificationPlugin.h */; };
119
		B2FB3BFC273B9DD200A522E0 /* IPUNotificationPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = B2FB3BFA273B9DD200A522E0 /* IPUNotificationPlugin.m */; };
118 120
/* End PBXBuildFile section */
119 121
120 122
/* Begin PBXFileReference section */
@ -228,6 +230,8 @@
228 230
		B2EB105523A788C500EBB34D /* IPUMobile.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IPUMobile.framework; path = ../IPUCommon/IPUMobile.framework; sourceTree = "<group>"; };
229 231
		B2EE784622D2D25A00E2C466 /* IPUStorageUtil.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IPUStorageUtil.h; sourceTree = "<group>"; };
230 232
		B2EE784722D2D25A00E2C466 /* IPUStorageUtil.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IPUStorageUtil.m; sourceTree = "<group>"; };
233
		B2FB3BF9273B9DD200A522E0 /* IPUNotificationPlugin.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IPUNotificationPlugin.h; sourceTree = "<group>"; };
234
		B2FB3BFA273B9DD200A522E0 /* IPUNotificationPlugin.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IPUNotificationPlugin.m; sourceTree = "<group>"; };
231 235
/* End PBXFileReference section */
232 236
233 237
/* Begin PBXFrameworksBuildPhase section */
@ -285,6 +289,8 @@
285 289
				B2DB0D4C273A6BCB0010074A /* EBBannerView */,
286 290
				04449842267997990024A808 /* IPUSysLocationPlugin.h */,
287 291
				04449843267997990024A808 /* IPUSysLocationPlugin.m */,
292
				B2FB3BF9273B9DD200A522E0 /* IPUNotificationPlugin.h */,
293
				B2FB3BFA273B9DD200A522E0 /* IPUNotificationPlugin.m */,
288 294
				04C30B9A22E6ADF200BA7B68 /* IPUTipsHUDPlugin.h */,
289 295
				04C30B9922E6ADF200BA7B68 /* IPUTipsHUDPlugin.m */,
290 296
				B2D71A0122A6528F00604504 /* Implementation */,
@ -445,6 +451,7 @@
445 451
				B273BFDE2468F0C800A96CEE /* IPUVerifyCodePlugin.h in Headers */,
446 452
				B281A32A22CB3C6300D69B25 /* IPUFilesUtil.h in Headers */,
447 453
				B2EB0F2123A7287E00EBB34D /* IPUAMapPlugin.h in Headers */,
454
				B2FB3BFB273B9DD200A522E0 /* IPUNotificationPlugin.h in Headers */,
448 455
				B28E56C221F1BBA800422D15 /* IPUStoragePlugin.h in Headers */,
449 456
				B28E567A21F18C1C00422D15 /* UIImage+Rotate.h in Headers */,
450 457
				B2DB0D62273A6BCB0010074A /* EBBannerView+Categories.h in Headers */,
@ -571,6 +578,7 @@
571 578
				B2464E8522CF25E9002A159E /* IPUSystemLocationUtil.m in Sources */,
572 579
				B2DB0D69273A6BCB0010074A /* EBBannerWindow.m in Sources */,
573 580
				B2D5191E23B5ADE1008086A7 /* IPUBMapPlugin.m in Sources */,
581
				B2FB3BFC273B9DD200A522E0 /* IPUNotificationPlugin.m in Sources */,
574 582
				B281A33C22CC877700D69B25 /* IPUFilePlugin.m in Sources */,
575 583
				B20C89672397AFF900471783 /* IPUVideoRecordPlugin.m in Sources */,
576 584
				B28E56D721F1C3D100422D15 /* IPUAuthenticationPlugin.m in Sources */,

+ 1 - 1
IPUMobileFunc/IPUMobileFunc/EBBannerView/EBBannerView.h

@ -11,7 +11,7 @@
11 11
typedef enum : NSInteger {
12 12
    EBBannerViewStyleiOS9 = 9,
13 13
    EBBannerViewStyleiOS10 = 10,
14
    EBBannerViewStyleiOS11 = 11
14
    EBBannerViewStyleiOS11
15 15
} EBBannerViewStyle;
16 16
17 17
@protocol EBCustomBannerViewProtocol;

+ 26 - 40
IPUMobileFunc/IPUMobileFunc/EBBannerView/EBBannerView.m

@ -12,6 +12,8 @@
12 12
#import "EBBannerView+Categories.h"
13 13
#import "EBBannerWindow.h"
14 14
15
#import <IPUMobile/IPUMobile.h>
16
15 17
NSString *const EBBannerViewDidClickNotification = @"EBBannerViewDidClickNotification";
16 18
17 19
@interface EBBannerView(){
@ -43,8 +45,7 @@ static EBBannerWindow *sharedWindow;
43 45
44 46
#pragma mark - public
45 47
46
+(instancetype)bannerWithBlock:(void(^)(EBBannerViewMaker *make))block{
47
    
48
+ (instancetype)bannerWithBlock:(void(^)(EBBannerViewMaker *make))block{
48 49
    static dispatch_once_t onceToken;
49 50
    dispatch_once(&onceToken, ^{
50 51
        sharedWindow = [EBBannerWindow sharedWindow];
@ -65,11 +66,12 @@ static EBBannerWindow *sharedWindow;
65 66
    return bannerView;
66 67
}
67 68
68
-(void)show{
69
- (void)show {
69 70
    if (_hideTimer) {
70 71
        [_hideTimer invalidate];
71 72
        _hideTimer = nil;
72 73
    }
74
    
73 75
    SystemSoundID soundID = _maker.soundID;
74 76
    if (_maker.soundName) {
75 77
        NSURL *url = [[NSBundle mainBundle] URLForResource:_maker.soundName withExtension:nil];
@ -95,30 +97,23 @@ static EBBannerWindow *sharedWindow;
95 97
    }];
96 98
}
97 99
98
+(void)showWithContent:(NSString*)content{
100
+ (void)showWithContent:(NSString*)content{
99 101
    [[EBBannerView bannerWithBlock:^(EBBannerViewMaker *make) {
100 102
        make.content = content;
101 103
    }] show];
102 104
}
103 105
104
+(void)clearMemoryForStyle:(EBBannerViewStyle)style{
106
+ (void)clearMemoryForStyle:(EBBannerViewStyle)style{
105 107
    // next version to do
106 108
}
107 109
108
+(void)clearMemories{
110
+ (void)clearMemories{
109 111
    // next version to do
110 112
}
111 113
112
113
114
115
116
117
118
119 114
#pragma mark - private
120 115
121
+(instancetype)bannerViewWithStyle:(EBBannerViewStyle)style{
116
+ (instancetype)bannerViewWithStyle:(EBBannerViewStyle)style {
122 117
    __block EBBannerView *bannerView;
123 118
    [sharedBannerViews enumerateObjectsUsingBlock:^(EBBannerView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
124 119
        if (obj.maker.style == style) {
@ -126,7 +121,8 @@ static EBBannerWindow *sharedWindow;
126 121
        }
127 122
    }];
128 123
    if (bannerView == nil) {
129
        bannerView = [[NSBundle bundleForClass:self.class] loadNibNamed:@"EBBannerView" owner:nil options:nil][style-9];
124
        NSBundle *bundle = [NSBundle bundleWithURL:[[NSBundle mainBundle] URLForResource:@"Frameworks/IPUMobileFunc" withExtension:@"framework"]];
125
        bannerView = [bundle loadNibNamed:@"EBBannerView" owner:nil options:nil][style - 9];
130 126
        [[NSNotificationCenter defaultCenter] addObserver:bannerView selector:@selector(applicationDidChangeStatusBarOrientationNotification) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
131 127
        [bannerView addGestureRecognizer];
132 128
        [sharedBannerViews addObject:bannerView];
@ -134,7 +130,7 @@ static EBBannerWindow *sharedWindow;
134 130
    return bannerView;
135 131
}
136 132
137
-(void)hide{
133
- (void)hide {
138 134
    WEAK_SELF(weakSelf);
139 135
    [UIView animateWithDuration:_maker.animationDuration animations:^{
140 136
        weakSelf.frame = CGRectMake(weakSelf.fixedX, -weakSelf.standardHeight, weakSelf.fixedWidth, weakSelf.standardHeight);
@ -143,14 +139,14 @@ static EBBannerWindow *sharedWindow;
143 139
    }];
144 140
}
145 141
146
-(void)applicationDidChangeStatusBarOrientationNotification{
142
- (void)applicationDidChangeStatusBarOrientationNotification {
147 143
    if (!self.superview) {
148 144
        return;
149 145
    }
150 146
    self.frame = CGRectMake(self.fixedX, self.fixedY, self.fixedWidth, self.standardHeight);
151 147
}
152 148
153
-(void)addGestureRecognizer{
149
- (void)addGestureRecognizer {
154 150
    UISwipeGestureRecognizer *swipeUpGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeUpGesture:)];
155 151
    swipeUpGesture.direction = UISwipeGestureRecognizerDirectionUp;
156 152
    [self addGestureRecognizer:swipeUpGesture];
@ -163,18 +159,18 @@ static EBBannerWindow *sharedWindow;
163 159
    [self addGestureRecognizer:swipeDownGesture];
164 160
}
165 161
166
-(void)tapGesture:(UITapGestureRecognizer*)tapGesture{
162
- (void)tapGesture:(UITapGestureRecognizer*)tapGesture {
167 163
    [[NSNotificationCenter defaultCenter] postNotificationName:EBBannerViewDidClickNotification object:_maker.object];
168 164
    [self hide];
169 165
}
170 166
171
-(void)swipeUpGesture:(UISwipeGestureRecognizer*)gesture{
167
- (void)swipeUpGesture:(UISwipeGestureRecognizer*)gesture {
172 168
    if (gesture.direction == UISwipeGestureRecognizerDirectionUp) {
173 169
        [self hide];
174 170
    }
175 171
}
176 172
177
-(void)swipeDownGesture:(UISwipeGestureRecognizer*)gesture{
173
- (void)swipeDownGesture:(UISwipeGestureRecognizer *)gesture {
178 174
    if (gesture.direction == UISwipeGestureRecognizerDirectionDown && !self.lineView.hidden) {
179 175
        self.isExpand = YES;
180 176
        WEAK_SELF(weakSelf);
@ -189,7 +185,7 @@ static EBBannerWindow *sharedWindow;
189 185
190 186
#pragma mark - @property
191 187
192
-(CGFloat)standardHeight{
188
- (CGFloat)standardHeight {
193 189
    CGFloat height;
194 190
    switch (_maker.style) {
195 191
        case EBBannerViewStyleiOS9:
@ -208,36 +204,26 @@ static EBBannerWindow *sharedWindow;
208 204
    return height;
209 205
}
210 206
211
-(CGFloat)calculatedContentHeight{
207
- (CGFloat)calculatedContentHeight {
212 208
    CGSize size = CGSizeMake(self.contentLabel.frame.size.width, MAXFLOAT);
213 209
    NSDictionary *dict = [NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:self.contentLabel.font.pointSize] forKey:NSFontAttributeName];
214 210
    CGFloat calculatedHeight = [self.contentLabel.text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dict context:nil].size.height;
215 211
    return calculatedHeight;
216 212
}
217 213
218
-(BOOL)isiPhoneX{
219
    static BOOL isiPhoneX = NO;
220
    static dispatch_once_t onceToken;
221
    dispatch_once(&onceToken, ^{
222
        CGSize size = UIScreen.mainScreen.bounds.size;
223
        isiPhoneX = MAX(size.width, size.height) == 812;
224
    });
225
    return isiPhoneX;
226
}
227
228
-(CGFloat)fixedX{
229
    return ([self isiPhoneX] && ![self isPortrait]) ? 128 : 0;
214
- (CGFloat)fixedX {
215
    return ([IPUUITool isBangsScreen] && ![self isPortrait]) ? 128 : 0;
230 216
}
231 217
232
-(CGFloat)fixedY{
233
    return ([self isiPhoneX] && [self isPortrait]) ? 33 : 0;
218
- (CGFloat)fixedY {
219
    return ([IPUUITool isBangsScreen] && [self isPortrait]) ?  [[UIApplication sharedApplication] statusBarFrame].size.height : 0;
234 220
}
235 221
236
-(CGFloat)fixedWidth{
237
    return ([self isiPhoneX] && ![self isPortrait]) ? 556 : ScreenWidth;
222
- (CGFloat)fixedWidth {
223
    return ([IPUUITool isBangsScreen] && ![self isPortrait]) ? 556 : ScreenWidth;
238 224
}
239 225
240
-(BOOL)isPortrait{
226
- (BOOL)isPortrait {
241 227
    return ScreenWidth < ScreenHeight;
242 228
}
243 229

+ 1 - 1
IPUMobileFunc/IPUMobileFunc/EBBannerView/EBBannerViewMaker.m

@ -11,7 +11,7 @@
11 11
12 12
-(EBBannerViewStyle)style{
13 13
    if (!_style) {
14
        _style = MAX(UIDevice.currentDevice.systemVersion.intValue, 9);
14
        _style = MAX(UIDevice.currentDevice.systemVersion.intValue, 9) < 12 ? : 11;
15 15
    }
16 16
    return _style;
17 17
}

+ 23 - 0
IPUMobileFunc/IPUMobileFunc/IPUNotificationPlugin.h

@ -0,0 +1,23 @@
1
//
2
//     ***   * * * *  *     *
3
//     *    *     *  *     *
4
//    *    * * * *  *     *
5
//   *    *        *     *
6
// ***   *        * * * *
7
//
8
//  IPUNotificationPlugin.h
9
//  IPUMobileFunc
10
//  Created by Benny (AsiaInfo PRD IPU) on 2021/11/10 14:27.
11
//  Copyright © 2021 Asiainfo. All rights reserved.
12
//
13
        
14
15
#import <IPUMobile/IPUMobile.h>
16
17
NS_ASSUME_NONNULL_BEGIN
18
19
@interface IPUNotificationPlugin : IPUPlugin
20
21
@end
22
23
NS_ASSUME_NONNULL_END

+ 72 - 0
IPUMobileFunc/IPUMobileFunc/IPUNotificationPlugin.m

@ -0,0 +1,72 @@
1
//
2
//     ***   * * * *  *     *
3
//     *    *     *  *     *
4
//    *    * * * *  *     *
5
//   *    *        *     *
6
// ***   *        * * * *
7
//
8
//  IPUNotificationPlugin.m
9
//  IPUMobileFunc
10
//  Created by Benny (AsiaInfo PRD IPU) on 2021/11/10 14:27.
11
//  Copyright © 2021 Asiainfo. All rights reserved.
12
//
13
        
14
15
#import "IPUNotificationPlugin.h"
16
17
#import "EBBannerView.h"
18
19
@implementation IPUNotificationPlugin
20
21
- (instancetype)init {
22
    if (self = [super init]) {
23
        [[NSNotificationCenter defaultCenter] addObserver:self
24
                                                 selector:@selector(clickLocalPush:)
25
                                                     name:EBBannerViewDidClickNotification
26
                                                   object:nil];
27
    }
28
    return self;
29
}
30
31
- (void)showNotification:(NSArray *)params {
32
    if (!params && !params.count) {
33
        [self error:@"参数缺失"];
34
        return;
35
    }
36
    NSString *content = params[0];
37
    
38
    NSString *title = @"";
39
    if (params.count > 1) {
40
        title = params[1];
41
    }
42
    
43
    NSString *icon = @"";
44
    if (params.count > 2) {
45
        icon = params[2];
46
    }
47
    
48
    NSString *notificationID = @"";
49
    if (params.count > 3) {
50
        notificationID = params[3];
51
    }
52
    
53
    EBBannerView *bannerView = [EBBannerView bannerWithBlock:^(EBBannerViewMaker *make) {
54
        make.content = content;
55
        make.title = title;
56
        make.icon = icon ? [UIImage imageNamed:icon] : nil;
57
        make.object = notificationID;
58
    }];
59
    [bannerView show];
60
}
61
62
- (void)clickLocalPush:(NSNotification *)notification {
63
    [[NSNotificationCenter defaultCenter] removeObserver:self
64
                                                    name:EBBannerViewDidClickNotification
65
                                                  object:nil];
66
}
67
68
- (void)dealloc {
69
    
70
}
71
72
@end

BIN
display-center/display-center.xcworkspace/xcuserdata/benny.xcuserdatad/UserInterfaceState.xcuserstate


+ 0 - 16
display-center/display-center.xcworkspace/xcuserdata/benny.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@ -15,21 +15,5 @@
15 15
            stopOnStyle = "0">
16 16
         </BreakpointContent>
17 17
      </BreakpointProxy>
18
      <BreakpointProxy
19
         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
20
         <BreakpointContent
21
            uuid = "D1A207A6-7359-4501-AE08-564966C3BA2C"
22
            shouldBeEnabled = "Yes"
23
            ignoreCount = "0"
24
            continueAfterRunningActions = "No"
25
            filePath = "../../iOS/IPUMobile/IPUMobile/Utils/Net/IPUNetWork.m"
26
            startingColumnNumber = "9223372036854775807"
27
            endingColumnNumber = "9223372036854775807"
28
            startingLineNumber = "37"
29
            endingLineNumber = "37"
30
            landmarkName = "+asyncDownloadFile:path:completion:"
31
            landmarkType = "7">
32
         </BreakpointContent>
33
      </BreakpointProxy>
34 18
   </Breakpoints>
35 19
</Bucket>