Commit 1af5ebba739d26165ce860a3ab5fa947f484e6db

Authored by zhangxiaowen
1 parent efb4111a

no message

CNLiveCommonClass.podspec
... ... @@ -38,5 +38,7 @@ TODO: Add long description of the pod here.
38 38  
39 39 # s.public_header_files = 'Pod/Classes/**/*.h'
40 40 # s.frameworks = 'UIKit', 'MapKit'
41   - # s.dependency 'AFNetworking', '~> 2.3'
  41 + s.dependency 'QMUIKit'
  42 + s.dependency 'CNLiveBaseKit'
  43 + s.dependency 'CNLiveRequestBastKit'
42 44 end
... ...
CNLiveCommonClass/Classes/CNCommonTableViewController.h
... ... @@ -7,6 +7,7 @@
7 7 //
8 8  
9 9 #import "QMUIKit.h"
  10 +#import "CNThemeProtocol.h"
10 11  
11 12 @interface CNCommonTableViewController : QMUICommonTableViewController <CNChangingThemeDelegate>
12 13  
... ...
CNLiveCommonClass/Classes/CNCommonTableViewController.m
... ... @@ -7,8 +7,11 @@
7 7 //
8 8  
9 9 #import "CNCommonTableViewController.h"
10   -#import "CNAttentionViewController.h"
11   -#import "CNMineHomeController.h"
  10 +//#import "CNAttentionViewController.h"
  11 +//#import "CNMineHomeController.h"
  12 +#import "QMUIKit.h"
  13 +#import "CNThemeManager.h"
  14 +#import "CNLiveBaseKit.h"
12 15  
13 16 @interface CNCommonTableViewController ()
14 17  
... ... @@ -19,12 +22,12 @@
19 22 - (void)viewWillAppear:(BOOL)animated
20 23 {
21 24 [super viewWillAppear:animated];
22   - if ([self isKindOfClass:[CNAttentionViewController class]] || [self isKindOfClass:[CNMineHomeController class]]) {
23   - self.tabBarController.tabBar.hidden = NO;
24   - }else{
25   -
26   - self.tabBarController.tabBar.hidden = YES;
27   - }
  25 +// if ([self isKindOfClass:[CNAttentionViewController class]] || [self isKindOfClass:[CNMineHomeController class]]) {
  26 +// self.tabBarController.tabBar.hidden = NO;
  27 +// }else{
  28 +//
  29 +// self.tabBarController.tabBar.hidden = YES;
  30 +// }
28 31 // self.navigationController.interactivePopGestureRecognizer.delegate = (id)self;
29 32 }
30 33  
... ... @@ -66,7 +69,7 @@
66 69  
67 70 - (void)setCNNoNetworkingEmptyView
68 71 {
69   - self.emptyView.backgroundColor = kWhiteColor;
  72 + self.emptyView.backgroundColor = [UIColor whiteColor];
70 73 self.emptyView.actionButton.backgroundColor = UIColorMake(0, 194, 0);
71 74 self.emptyView.actionButton.layer.masksToBounds = YES;
72 75 self.emptyView.actionButton.layer.cornerRadius = 6;
... ... @@ -113,9 +116,26 @@
113 116  
114 117 - (UIImage *)navigationBarBackgroundImage
115 118 {
116   - return [UIImage imageWithColor:kWhiteColor];
  119 + return [self imageWithColor:[UIColor whiteColor]];
  120 +}
  121 +- (UIImage *)imageWithColor:(UIColor *)color {
  122 + return [self imageWithColor:color size:CGSizeMake(1, 1)];
117 123 }
118 124  
  125 +- (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size {
  126 + if (color == nil) {
  127 + return nil;
  128 + }
  129 +
  130 + CGRect rect=CGRectMake(0.0f, 0.0f, size.width, size.height);
  131 + UIGraphicsBeginImageContext(rect.size);
  132 + CGContextRef context = UIGraphicsGetCurrentContext();
  133 + CGContextSetFillColorWithColor(context, [color CGColor]);
  134 + CGContextFillRect(context, rect);
  135 + UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
  136 + UIGraphicsEndImageContext();
  137 + return theImage;
  138 +}
119 139 - (UIInterfaceOrientationMask)supportedOrientationMask
120 140 {
121 141 return UIInterfaceOrientationMaskPortrait;
... ...
CNLiveCommonClass/Classes/CNCommonView.h
... ... @@ -7,7 +7,7 @@
7 7 //
8 8  
9 9 #import <UIKit/UIKit.h>
10   -
  10 +#import "CNThemeProtocol.h"
11 11 @interface CNCommonView : UIView <CNChangingThemeDelegate>
12 12  
13 13 @end
... ...
CNLiveCommonClass/Classes/CNCommonView.m
... ... @@ -7,6 +7,7 @@
7 7 //
8 8  
9 9 #import "CNCommonView.h"
  10 +#import "CNThemeManager.h"
10 11  
11 12 @implementation CNCommonView
12 13  
... ...
CNLiveCommonClass/Classes/CNCommonViewController.h
... ... @@ -7,6 +7,7 @@
7 7 //
8 8  
9 9 #import "CNThemeProtocol.h"
  10 +#import "QMUICommonViewController.h"
10 11  
11 12 @interface CNCommonViewController : QMUICommonViewController <CNChangingThemeDelegate>
12 13  
... ...
CNLiveCommonClass/Classes/CNCommonViewController.m
... ... @@ -8,6 +8,8 @@
8 8  
9 9 #import "CNCommonViewController.h"
10 10 #import <CNLiveRequestBastKit/CNLiveNetworking.h>
  11 +#import "QMUIKit.h"
  12 +#import "CNThemeManager.h"
11 13  
12 14 @interface CNCommonViewController ()
13 15  
... ... @@ -40,7 +42,7 @@
40 42 }
41 43 #pragma mark - UI
42 44 - (void)setCNNoNetworkingEmptyView {
43   - self.emptyView.backgroundColor = kWhiteColor;
  45 + self.emptyView.backgroundColor = [UIColor whiteColor];
44 46 self.emptyView.actionButton.backgroundColor = UIColorMake(0, 194, 0);
45 47 self.emptyView.actionButton.layer.masksToBounds = YES;
46 48 self.emptyView.actionButton.layer.cornerRadius = 6;
... ... @@ -73,8 +75,7 @@
73 75 }
74 76 #pragma mark - Network Monitoring
75 77 - (void)p_startNetworkMonitoring {
76   - weakself
77   -
  78 + __weak typeof(self) weakSelf = self;
78 79 [CNLiveNetworking networkStatusWithBlock:^(CNLiveNetworkStatusType status) {
79 80 if (status == CNLiveNetworkStatusUnknown || status == CNLiveNetworkStatusNotReachable) {
80 81 weakSelf.netStatus = status;
... ... @@ -120,7 +121,25 @@
120 121 }
121 122 #pragma mark - Navigation Delegate
122 123 - (UIImage *)navigationBarBackgroundImage {
123   - return [UIImage imageWithColor:kWhiteColor];
  124 + return [self imageWithColor:[UIColor whiteColor]];
  125 +}
  126 +- (UIImage *)imageWithColor:(UIColor *)color {
  127 + return [self imageWithColor:color size:CGSizeMake(1, 1)];
  128 +}
  129 +
  130 +- (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size {
  131 + if (color == nil) {
  132 + return nil;
  133 + }
  134 +
  135 + CGRect rect=CGRectMake(0.0f, 0.0f, size.width, size.height);
  136 + UIGraphicsBeginImageContext(rect.size);
  137 + CGContextRef context = UIGraphicsGetCurrentContext();
  138 + CGContextSetFillColorWithColor(context, [color CGColor]);
  139 + CGContextFillRect(context, rect);
  140 + UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
  141 + UIGraphicsEndImageContext();
  142 + return theImage;
124 143 }
125 144  
126 145 #pragma mark - System Delegate
... ...
CNLiveCommonClass/Classes/CNLiveCommonClass.h 0 โ†’ 100644
  1 +//
  2 +// CNLiveCommonClass.h
  3 +// Pods
  4 +//
  5 +// Created by CNLive-zxw on 2019/4/12.
  6 +//
  7 +
  8 +#ifndef CNLiveCommonClass_h
  9 +#define CNLiveCommonClass_h
  10 +
  11 +#import "CNThemeManager.h"
  12 +#import "CNCommonView.h"
  13 +
  14 +#import "CNCommonViewController.h"
  15 +#import "CNCommonTableViewController.h"
  16 +#import "CNCommonListViewController.h"
  17 +
  18 +#endif /* CNLiveCommonClass_h */
... ...
CNLiveCommonClass/Classes/CNThemeManager.h 0 โ†’ 100644
  1 +//
  2 +// CNThemeManager.h
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by ๅผ ๆ—ญ on 2017/12/30.
  6 +// Copyright ยฉ 2017ๅนด cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +#import "CNThemeProtocol.h"
  11 +
  12 +/// ๅฝ“ไธป้ข˜ๅ‘็”Ÿๅ˜ๅŒ–ๆ—ถ๏ผŒไผšๅ‘้€่ฟ™ไธช้€š็Ÿฅ
  13 +extern NSString *const CNThemeChangedNotification;
  14 +
  15 +/// ไธป้ข˜ๅ‘็”Ÿๆ”นๅ˜ๅ‰็š„ๅ€ผ๏ผŒ็ฑปๅž‹ไธบ NSObject<CNThemeProtocol>๏ผŒๅฏ่ƒฝไธบ NSNull
  16 +extern NSString *const CNThemeBeforeChangedName;
  17 +
  18 +/// ไธป้ข˜ๅ‘็”Ÿๆ”นๅ˜ๅŽ็š„ๅ€ผ๏ผŒ็ฑปๅž‹ไธบ NSObject<CNThemeProtocol>๏ผŒๅฏ่ƒฝไธบ NSNull
  19 +extern NSString *const CNThemeAfterChangedName;
  20 +
  21 +/**
  22 + * QMUI Demo ็š„็šฎ่‚ค็ฎก็†ๅ™จ๏ผŒๅฝ“้œ€่ฆๆข่‚คๆ—ถ๏ผŒ่ฏทไธบ currentTheme ่ต‹ๅ€ผ๏ผ›ๅฝ“้œ€่ฆ่Žทๅ–ๅฝ“ๅ‰็šฎ่‚คๆ—ถ๏ผŒๅฏ่ฎฟ้—ฎ currentTheme ๅฑžๆ€งใ€‚
  23 + * ๅฏ้€š่ฟ‡็›‘ๅฌ CNThemeChangedNotification ้€š็Ÿฅๆฅๆ•่Žทๆข่‚คไบ‹ไปถ๏ผŒ้ป˜่ฎคๅœฐ๏ผŒCNCommonViewController ๅŠ CNCommonTableViewController ๅ‡ๅทฒๆ”ฏๆŒๅ“ๅบ”ๆข่‚ค๏ผŒๅ…ถๅ“ๅบ”ๆ–นๆณ•ๆ˜ฏ้€š่ฟ‡ CNChangingThemeDelegate ๆŽฅๅฃๆฅๅฎž็Žฐ็š„ใ€‚
  24 + */
  25 +@interface CNThemeManager : NSObject
  26 ++ (instancetype)sharedInstance;
  27 +
  28 +@property(nonatomic, strong) NSObject<CNThemeProtocol> *currentTheme;
  29 +@end
... ...
CNLiveCommonClass/Classes/CNThemeManager.m 0 โ†’ 100644
  1 +//
  2 +// CNThemeManager.m
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by ๅผ ๆ—ญ on 2017/12/30.
  6 +// Copyright ยฉ 2017ๅนด cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "CNThemeManager.h"
  10 +
  11 +NSString *const CNThemeChangedNotification = @"CNThemeChangedNotification";
  12 +NSString *const CNThemeBeforeChangedName = @"CNThemeBeforeChangedName";
  13 +NSString *const CNThemeAfterChangedName = @"CNThemeAfterChangedName";
  14 +
  15 +@implementation CNThemeManager
  16 +
  17 ++ (instancetype)sharedInstance {
  18 + static dispatch_once_t onceToken;
  19 + static CNThemeManager *instance = nil;
  20 + dispatch_once(&onceToken,^{
  21 + instance = [[super allocWithZone:NULL] init];
  22 + });
  23 + return instance;
  24 +}
  25 +
  26 ++ (id)allocWithZone:(struct _NSZone *)zone{
  27 + return [self sharedInstance];
  28 +}
  29 +
  30 +- (void)setCurrentTheme:(NSObject<CNThemeProtocol> *)currentTheme {
  31 + BOOL isThemeChanged = _currentTheme != currentTheme;
  32 + NSObject<CNThemeProtocol> *themeBeforeChanged = nil;
  33 + if (isThemeChanged) {
  34 + themeBeforeChanged = _currentTheme;
  35 + }
  36 + _currentTheme = currentTheme;
  37 + if (isThemeChanged) {
  38 + [currentTheme setupConfigurationTemplate];
  39 + [[NSNotificationCenter defaultCenter] postNotificationName:CNThemeChangedNotification object:self userInfo:@{CNThemeBeforeChangedName: themeBeforeChanged ?: [NSNull null], CNThemeAfterChangedName: currentTheme ?: [NSNull null]}];
  40 + }
  41 +}
  42 +
  43 +@end
... ...
CNLiveCommonClass/Classes/CNThemeProtocol.h 0 โ†’ 100644
  1 +//
  2 +// CNThemeProtocol.h
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by ๅผ ๆ—ญ on 2017/12/30.
  6 +// Copyright ยฉ 2017ๅนด cnlive. All rights reserved.
  7 +//
  8 +
  9 +
  10 +#import <Foundation/Foundation.h>
  11 +
  12 +/// ๆ‰€ๆœ‰ไธป้ข˜ๅ‡ๅบ”ๅฎž็Žฐ่ฟ™ไธชๅ่ฎฎ๏ผŒ่ง„ๅฎšไบ† QMUI Demo ้‡Œๅธธ็”จ็š„ๅ‡ ไธชๅ…ณ้”ฎๅค–่ง‚ๅฑžๆ€ง
  13 +@protocol CNThemeProtocol <NSObject>
  14 +
  15 +@required
  16 +
  17 +/// ๆฅ่‡ชไบŽ QMUIConfigurationTemplate ้‡Œ็š„่‡ชๅธฆๆ–นๆณ•๏ผŒ็”จไบŽๅบ”็”จ้…็ฝฎ่กจ้‡Œ็š„่ฎพ็ฝฎ
  18 +- (void)setupConfigurationTemplate;
  19 +
  20 +- (UIColor *)themeTintColor;
  21 +- (UIColor *)themeListTextColor;
  22 +- (UIColor *)themeCodeColor;
  23 +- (UIColor *)themeGridItemTintColor;
  24 +
  25 +- (NSString *)themeName;
  26 +
  27 +@end
  28 +
  29 +
  30 +/// ๆ‰€ๆœ‰่ƒฝๅ“ๅบ”ไธป้ข˜ๅ˜ๅŒ–็š„ๅฏน่ฑกๅ‡ๅบ”ๅฎž็Žฐ่ฟ™ไธชๅ่ฎฎ๏ผŒ็›ฎๅ‰ไธป่ฆ็”จไบŽ CNCommonViewController ๅŠ CNCommonTableViewController
  31 +@protocol CNChangingThemeDelegate <NSObject>
  32 +
  33 +@required
  34 +
  35 +- (void)themeBeforeChanged:(NSObject<CNThemeProtocol> *)themeBeforeChanged afterChanged:(NSObject<CNThemeProtocol> *)themeAfterChanged;
  36 +
  37 +@end
... ...
Example/CNLiveCommonClass.xcodeproj/project.pbxproj
... ... @@ -226,6 +226,7 @@
226 226 6003F5AA195388D20070C39A /* Sources */,
227 227 6003F5AB195388D20070C39A /* Frameworks */,
228 228 6003F5AC195388D20070C39A /* Resources */,
  229 + FAC38C7F6FF8CF304CD35A48 /* [CP] Embed Pods Frameworks */,
229 230 );
230 231 buildRules = (
231 232 );
... ... @@ -350,19 +351,59 @@
350 351 );
351 352 inputPaths = (
352 353 "${SRCROOT}/Pods/Target Support Files/Pods-CNLiveCommonClass_Example/Pods-CNLiveCommonClass_Example-frameworks.sh",
  354 + "${BUILT_PRODUCTS_DIR}/AFNetworking/AFNetworking.framework",
  355 + "${BUILT_PRODUCTS_DIR}/CNLiveBaseKit/CNLiveBaseKit.framework",
353 356 "${BUILT_PRODUCTS_DIR}/CNLiveCommonClass/CNLiveCommonClass.framework",
  357 + "${BUILT_PRODUCTS_DIR}/CNLiveRequestBastKit/CNLiveRequestBastKit.framework",
  358 + "${BUILT_PRODUCTS_DIR}/MJExtension/MJExtension.framework",
  359 + "${BUILT_PRODUCTS_DIR}/QMUIKit/QMUIKit.framework",
354 360 );
355 361 name = "[CP] Embed Pods Frameworks";
356 362 outputFileListPaths = (
357 363 );
358 364 outputPaths = (
  365 + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AFNetworking.framework",
  366 + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBaseKit.framework",
359 367 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCommonClass.framework",
  368 + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveRequestBastKit.framework",
  369 + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MJExtension.framework",
  370 + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/QMUIKit.framework",
360 371 );
361 372 runOnlyForDeploymentPostprocessing = 0;
362 373 shellPath = /bin/sh;
363 374 shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-CNLiveCommonClass_Example/Pods-CNLiveCommonClass_Example-frameworks.sh\"\n";
364 375 showEnvVarsInLog = 0;
365 376 };
  377 + FAC38C7F6FF8CF304CD35A48 /* [CP] Embed Pods Frameworks */ = {
  378 + isa = PBXShellScriptBuildPhase;
  379 + buildActionMask = 2147483647;
  380 + files = (
  381 + );
  382 + inputFileListPaths = (
  383 + );
  384 + inputPaths = (
  385 + "${SRCROOT}/Pods/Target Support Files/Pods-CNLiveCommonClass_Tests/Pods-CNLiveCommonClass_Tests-frameworks.sh",
  386 + "${BUILT_PRODUCTS_DIR}/AFNetworking/AFNetworking.framework",
  387 + "${BUILT_PRODUCTS_DIR}/CNLiveBaseKit/CNLiveBaseKit.framework",
  388 + "${BUILT_PRODUCTS_DIR}/CNLiveRequestBastKit/CNLiveRequestBastKit.framework",
  389 + "${BUILT_PRODUCTS_DIR}/MJExtension/MJExtension.framework",
  390 + "${BUILT_PRODUCTS_DIR}/QMUIKit/QMUIKit.framework",
  391 + );
  392 + name = "[CP] Embed Pods Frameworks";
  393 + outputFileListPaths = (
  394 + );
  395 + outputPaths = (
  396 + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AFNetworking.framework",
  397 + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBaseKit.framework",
  398 + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveRequestBastKit.framework",
  399 + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MJExtension.framework",
  400 + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/QMUIKit.framework",
  401 + );
  402 + runOnlyForDeploymentPostprocessing = 0;
  403 + shellPath = /bin/sh;
  404 + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-CNLiveCommonClass_Tests/Pods-CNLiveCommonClass_Tests-frameworks.sh\"\n";
  405 + showEnvVarsInLog = 0;
  406 + };
366 407 /* End PBXShellScriptBuildPhase section */
367 408  
368 409 /* Begin PBXSourcesBuildPhase section */
... ...
Example/CNLiveCommonClass/CNLiveViewController.m
... ... @@ -7,6 +7,7 @@
7 7 //
8 8  
9 9 #import "CNLiveViewController.h"
  10 +#import "CNLiveCommonClass.h"
10 11  
11 12 @interface CNLiveViewController ()
12 13  
... ... @@ -18,6 +19,7 @@
18 19 {
19 20 [super viewDidLoad];
20 21 // Do any additional setup after loading the view, typically from a nib.
  22 +
21 23 }
22 24  
23 25 - (void)didReceiveMemoryWarning
... ...
Example/Podfile
  1 +source 'https://github.com/CocoaPods/Specs.git'
  2 +source 'http://bj.gitlab.cnlive.com/ios-team/CNLiveRepos.git'
1 3 use_frameworks!
2 4  
3   -platform :ios, '8.0'
  5 +platform :ios, '9.0'
4 6  
5 7 target 'CNLiveCommonClass_Example' do
6 8 pod 'CNLiveCommonClass', :path => '../'
  9 + pod 'QMUIKit'
  10 + pod 'CNLiveRequestBastKit'
  11 + pod 'CNLiveBaseKit'
7 12  
8 13 target 'CNLiveCommonClass_Tests' do
9 14 inherit! :search_paths
10   -
  15 + pod 'QMUIKit'
  16 + pod 'CNLiveRequestBastKit'
  17 + pod 'CNLiveBaseKit'
11 18  
12 19 end
13 20 end
... ...