Commit ec927d1d49a7a55a475debe6816294d81cb51228
1 parent
425a2591
no message
Showing
11 changed files
with
36 additions
and
62 deletions
CNLiveCommonClass/Classes/CNCommonListViewController.h
| ... | ... | @@ -9,13 +9,11 @@ |
| 9 | 9 | #import "CNCommonTableViewController.h" |
| 10 | 10 | |
| 11 | 11 | @interface CNCommonListViewController : CNCommonTableViewController |
| 12 | - | |
| 13 | 12 | @property(nonatomic, strong) QMUIOrderedDictionary *dataSource; |
| 14 | 13 | |
| 15 | 14 | @end |
| 16 | 15 | |
| 17 | 16 | @interface CNCommonListViewController (UISubclassingHooks) |
| 18 | - | |
| 19 | 17 | //子类继承,可以不调 super |
| 20 | 18 | - (void)initDataSource; |
| 21 | 19 | - (void)didSelectCellWithTitle:(NSString *)title; | ... | ... |
CNLiveCommonClass/Classes/CNCommonListViewController.m
| ... | ... | @@ -13,8 +13,6 @@ |
| 13 | 13 | @end |
| 14 | 14 | |
| 15 | 15 | @implementation CNCommonListViewController |
| 16 | - | |
| 17 | - | |
| 18 | 16 | - (instancetype)initWithStyle:(UITableViewStyle)style { |
| 19 | 17 | if (self = [super initWithStyle:style]) { |
| 20 | 18 | [self initDataSource]; |
| ... | ... | @@ -22,8 +20,7 @@ |
| 22 | 20 | return self; |
| 23 | 21 | } |
| 24 | 22 | |
| 25 | -- (void)viewWillAppear:(BOOL)animated | |
| 26 | -{ | |
| 23 | +- (void)viewWillAppear:(BOOL)animated { | |
| 27 | 24 | [super viewWillAppear:animated]; |
| 28 | 25 | } |
| 29 | 26 | |
| ... | ... | @@ -32,13 +29,11 @@ |
| 32 | 29 | // Do any additional setup after loading the view. |
| 33 | 30 | } |
| 34 | 31 | |
| 35 | --(void)viewDidAppear:(BOOL)animated | |
| 36 | -{ | |
| 32 | +- (void)viewDidAppear:(BOOL)animated { | |
| 37 | 33 | [super viewDidAppear:animated]; |
| 38 | 34 | [UIView setAnimationsEnabled:YES]; |
| 39 | 35 | } |
| 40 | 36 | #pragma mark - <QMUITableViewDataSource,QMUITableViewDelegate> |
| 41 | - | |
| 42 | 37 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { |
| 43 | 38 | return [self.dataSource count]; |
| 44 | 39 | } |
| ... | ... | @@ -77,7 +72,6 @@ |
| 77 | 72 | } |
| 78 | 73 | |
| 79 | 74 | #pragma mark - DataSource |
| 80 | - | |
| 81 | 75 | - (NSString *)titleForSection:(NSInteger)section { |
| 82 | 76 | return [[self.dataSource allKeys] objectAtIndex:section]; |
| 83 | 77 | } |
| ... | ... | @@ -93,14 +87,11 @@ |
| 93 | 87 | @end |
| 94 | 88 | |
| 95 | 89 | @implementation CNCommonTableViewController (UISubclassingHooks) |
| 96 | - | |
| 97 | --(void)initDataSource | |
| 98 | -{ | |
| 90 | +- (void)initDataSource { | |
| 99 | 91 | |
| 100 | 92 | } |
| 101 | 93 | |
| 102 | --(void)didSelectCellWithTitle:(NSString *)title | |
| 103 | -{ | |
| 94 | +- (void)didSelectCellWithTitle:(NSString *)title { | |
| 104 | 95 | |
| 105 | 96 | } |
| 106 | 97 | ... | ... |
CNLiveCommonClass/Classes/CNCommonTableViewController.h
| ... | ... | @@ -10,7 +10,6 @@ |
| 10 | 10 | #import "CNThemeProtocol.h" |
| 11 | 11 | |
| 12 | 12 | @interface CNCommonTableViewController : QMUICommonTableViewController <CNChangingThemeDelegate> |
| 13 | - | |
| 14 | 13 | - (void)setCNAPIErrorEmptyView;//接口错误 |
| 15 | 14 | - (void)setCNNoNetworkingEmptyView;//无网络连接 |
| 16 | 15 | - (void)setCNNoDataEmptyView;//没有相关内容 |
| ... | ... | @@ -18,6 +17,7 @@ |
| 18 | 17 | - (void)cn_noNetworking; |
| 19 | 18 | ////子类重写 有网络时调用 |
| 20 | 19 | - (void)cn_wifiOrWWANNetworking; |
| 20 | + | |
| 21 | 21 | @end |
| 22 | 22 | |
| 23 | 23 | ... | ... |
CNLiveCommonClass/Classes/CNCommonTableViewController.m
| ... | ... | @@ -18,9 +18,7 @@ |
| 18 | 18 | @end |
| 19 | 19 | |
| 20 | 20 | @implementation CNCommonTableViewController |
| 21 | - | |
| 22 | -- (void)viewWillAppear:(BOOL)animated | |
| 23 | -{ | |
| 21 | +- (void)viewWillAppear:(BOOL)animated { | |
| 24 | 22 | [super viewWillAppear:animated]; |
| 25 | 23 | // if ([self isKindOfClass:[CNAttentionViewController class]] || [self isKindOfClass:[CNMineHomeController class]]) { |
| 26 | 24 | // self.tabBarController.tabBar.hidden = NO; |
| ... | ... | @@ -31,14 +29,12 @@ |
| 31 | 29 | // self.navigationController.interactivePopGestureRecognizer.delegate = (id)self; |
| 32 | 30 | } |
| 33 | 31 | |
| 34 | -- (void)viewWillDisappear:(BOOL)animated | |
| 35 | -{ | |
| 32 | +- (void)viewWillDisappear:(BOOL)animated { | |
| 36 | 33 | [super viewWillDisappear:animated]; |
| 37 | 34 | |
| 38 | 35 | } |
| 39 | 36 | |
| 40 | --(void)viewDidAppear:(BOOL)animated | |
| 41 | -{ | |
| 37 | +- (void)viewDidAppear:(BOOL)animated { | |
| 42 | 38 | [super viewDidAppear:animated]; |
| 43 | 39 | [UIView setAnimationsEnabled:YES]; |
| 44 | 40 | } |
| ... | ... | @@ -55,8 +51,7 @@ |
| 55 | 51 | } |
| 56 | 52 | |
| 57 | 53 | |
| 58 | -- (void)initSubviews | |
| 59 | -{ | |
| 54 | +- (void)initSubviews { | |
| 60 | 55 | [super initSubviews]; |
| 61 | 56 | if (@available(iOS 11.0, *)) { |
| 62 | 57 | self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; |
| ... | ... | @@ -67,8 +62,7 @@ |
| 67 | 62 | self.tableView.height = KScreenHeight - kNavigationBarHeight - kVerticalTabBarTotalHeight; |
| 68 | 63 | } |
| 69 | 64 | |
| 70 | -- (void)setCNNoNetworkingEmptyView | |
| 71 | -{ | |
| 65 | +- (void)setCNNoNetworkingEmptyView { | |
| 72 | 66 | self.emptyView.backgroundColor = [UIColor whiteColor]; |
| 73 | 67 | self.emptyView.actionButton.backgroundColor = UIColorMake(0, 194, 0); |
| 74 | 68 | self.emptyView.actionButton.layer.masksToBounds = YES; |
| ... | ... | @@ -82,8 +76,7 @@ |
| 82 | 76 | [self.emptyView setDetailTextLabelTextColor:UIColorMake(153, 153, 153)]; |
| 83 | 77 | } |
| 84 | 78 | |
| 85 | -- (void)setCNAPIErrorEmptyView | |
| 86 | -{ | |
| 79 | +- (void)setCNAPIErrorEmptyView { | |
| 87 | 80 | self.emptyView.actionButton.backgroundColor = UIColorMake(0, 194, 0); |
| 88 | 81 | self.emptyView.actionButton.layer.masksToBounds = YES; |
| 89 | 82 | self.emptyView.actionButton.layer.cornerRadius = 6; |
| ... | ... | @@ -96,26 +89,23 @@ |
| 96 | 89 | [self.emptyView setDetailTextLabelTextColor:UIColorMake(153, 153, 153)]; |
| 97 | 90 | } |
| 98 | 91 | |
| 99 | -- (void)setCNNoDataEmptyView | |
| 100 | -{ | |
| 92 | +- (void)setCNNoDataEmptyView { | |
| 101 | 93 | [self.emptyView setTextLabelFont:UIFontMake(17)]; |
| 102 | 94 | [self.emptyView setTextLabelTextColor:UIColorMake(102, 102, 102)]; |
| 103 | 95 | self.emptyView.imageViewInsets = UIEdgeInsetsMake(0, 0, 36, 0); |
| 104 | 96 | |
| 105 | 97 | } |
| 106 | 98 | |
| 107 | -- (UIStatusBarStyle)preferredStatusBarStyle | |
| 108 | -{ | |
| 99 | +- (UIStatusBarStyle)preferredStatusBarStyle { | |
| 109 | 100 | return UIStatusBarStyleDefault; |
| 101 | + | |
| 110 | 102 | } |
| 111 | 103 | |
| 112 | -- (BOOL)shouldAutorotate | |
| 113 | -{ | |
| 104 | +- (BOOL)shouldAutorotate { | |
| 114 | 105 | return NO; |
| 115 | 106 | } |
| 116 | 107 | |
| 117 | -- (UIImage *)navigationBarBackgroundImage | |
| 118 | -{ | |
| 108 | +- (UIImage *)navigationBarBackgroundImage { | |
| 119 | 109 | return [self imageWithColor:[UIColor whiteColor]]; |
| 120 | 110 | } |
| 121 | 111 | - (UIImage *)imageWithColor:(UIColor *)color { |
| ... | ... | @@ -126,7 +116,6 @@ |
| 126 | 116 | if (color == nil) { |
| 127 | 117 | return nil; |
| 128 | 118 | } |
| 129 | - | |
| 130 | 119 | CGRect rect=CGRectMake(0.0f, 0.0f, size.width, size.height); |
| 131 | 120 | UIGraphicsBeginImageContext(rect.size); |
| 132 | 121 | CGContextRef context = UIGraphicsGetCurrentContext(); |
| ... | ... | @@ -135,15 +124,16 @@ |
| 135 | 124 | UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext(); |
| 136 | 125 | UIGraphicsEndImageContext(); |
| 137 | 126 | return theImage; |
| 127 | + | |
| 138 | 128 | } |
| 139 | -- (UIInterfaceOrientationMask)supportedOrientationMask | |
| 140 | -{ | |
| 129 | +- (UIInterfaceOrientationMask)supportedOrientationMask { | |
| 141 | 130 | return UIInterfaceOrientationMaskPortrait; |
| 131 | + | |
| 142 | 132 | } |
| 143 | 133 | |
| 144 | -- (BOOL)forceEnableInteractivePopGestureRecognizer | |
| 145 | -{ | |
| 134 | +- (BOOL)forceEnableInteractivePopGestureRecognizer { | |
| 146 | 135 | return YES; |
| 136 | + | |
| 147 | 137 | } |
| 148 | 138 | ///// 开始网络监控 |
| 149 | 139 | //- (void)p_startNetworkMonitoring |
| ... | ... | @@ -162,13 +152,11 @@ |
| 162 | 152 | // [manager startMonitoring]; |
| 163 | 153 | //} |
| 164 | 154 | |
| 165 | -- (void)cn_noNetworking | |
| 166 | -{//子类重写 | |
| 155 | +- (void)cn_noNetworking {//子类重写 | |
| 167 | 156 | |
| 168 | 157 | } |
| 169 | 158 | |
| 170 | -- (void)cn_wifiOrWWANNetworking | |
| 171 | -{//子类重写 | |
| 159 | +- (void)cn_wifiOrWWANNetworking {//子类重写 | |
| 172 | 160 | |
| 173 | 161 | } |
| 174 | 162 | |
| ... | ... | @@ -183,7 +171,6 @@ |
| 183 | 171 | } |
| 184 | 172 | |
| 185 | 173 | #pragma mark - <CNChangingThemeDelegate> |
| 186 | - | |
| 187 | 174 | - (void)themeBeforeChanged:(NSObject<CNThemeProtocol> *)themeBeforeChanged afterChanged:(NSObject<CNThemeProtocol> *)themeAfterChanged { |
| 188 | 175 | [self.tableView reloadData]; |
| 189 | 176 | } | ... | ... |
CNLiveCommonClass/Classes/CNCommonView.h
CNLiveCommonClass/Classes/CNCommonView.m
| ... | ... | @@ -10,7 +10,6 @@ |
| 10 | 10 | #import "CNThemeManager.h" |
| 11 | 11 | |
| 12 | 12 | @implementation CNCommonView |
| 13 | - | |
| 14 | 13 | - (instancetype)initWithFrame:(CGRect)frame { |
| 15 | 14 | self = [super initWithFrame:frame]; |
| 16 | 15 | if (self) { |
| ... | ... | @@ -26,8 +25,7 @@ |
| 26 | 25 | return self; |
| 27 | 26 | } |
| 28 | 27 | |
| 29 | -- (void)didInitialized | |
| 30 | -{ | |
| 28 | +- (void)didInitialized { | |
| 31 | 29 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleThemeChangedNotification:) name:CNThemeChangedNotification object:nil]; |
| 32 | 30 | } |
| 33 | 31 | |
| ... | ... | @@ -38,7 +36,6 @@ |
| 38 | 36 | } |
| 39 | 37 | |
| 40 | 38 | #pragma mark - <CNChangingThemeDelegate> |
| 41 | - | |
| 42 | 39 | - (void)themeBeforeChanged:(NSObject<CNThemeProtocol> *)themeBeforeChanged afterChanged:(NSObject<CNThemeProtocol> *)themeAfterChanged { |
| 43 | 40 | |
| 44 | 41 | } | ... | ... |
CNLiveCommonClass/Classes/CNCommonViewController.h
| ... | ... | @@ -10,7 +10,6 @@ |
| 10 | 10 | #import "QMUICommonViewController.h" |
| 11 | 11 | |
| 12 | 12 | @interface CNCommonViewController : QMUICommonViewController <CNChangingThemeDelegate> |
| 13 | - | |
| 14 | 13 | @property (nonatomic, assign) NSInteger netStatus;//当前网络状态 |
| 15 | 14 | |
| 16 | 15 | - (void)setCNAPIErrorEmptyView;//接口错误 |
| ... | ... | @@ -20,4 +19,5 @@ |
| 20 | 19 | - (void)cn_noNetworking; |
| 21 | 20 | ////子类重写 有网络时调用 |
| 22 | 21 | - (void)cn_wifiOrWWANNetworking; |
| 22 | + | |
| 23 | 23 | @end | ... | ... |
CNLiveCommonClass/Classes/CNCommonViewController.m
| ... | ... | @@ -36,10 +36,12 @@ |
| 36 | 36 | [super initSubviews]; |
| 37 | 37 | self.automaticallyAdjustsScrollViewInsets = NO; |
| 38 | 38 | } |
| 39 | + | |
| 39 | 40 | - (void)viewWillDisappear:(BOOL)animated{ |
| 40 | 41 | [super viewWillDisappear:animated]; |
| 41 | 42 | |
| 42 | 43 | } |
| 44 | + | |
| 43 | 45 | #pragma mark - UI |
| 44 | 46 | - (void)setCNNoNetworkingEmptyView { |
| 45 | 47 | self.emptyView.backgroundColor = [UIColor whiteColor]; |
| ... | ... | @@ -73,6 +75,7 @@ |
| 73 | 75 | [self.emptyView setTextLabelTextColor:UIColorMake(102, 102, 102)]; |
| 74 | 76 | self.emptyView.imageViewInsets = UIEdgeInsetsMake(0, 0, 36, 0); |
| 75 | 77 | } |
| 78 | + | |
| 76 | 79 | #pragma mark - Network Monitoring |
| 77 | 80 | - (void)p_startNetworkMonitoring { |
| 78 | 81 | __weak typeof(self) weakSelf = self; |
| ... | ... | @@ -119,6 +122,7 @@ |
| 119 | 122 | NSObject<CNThemeProtocol> *themeAfterChanged = notification.userInfo[CNThemeAfterChangedName]; |
| 120 | 123 | [self themeBeforeChanged:themeBeforeChanged afterChanged:themeAfterChanged]; |
| 121 | 124 | } |
| 125 | + | |
| 122 | 126 | #pragma mark - Navigation Delegate |
| 123 | 127 | - (UIImage *)navigationBarBackgroundImage { |
| 124 | 128 | return [self imageWithColor:[UIColor whiteColor]]; |
| ... | ... | @@ -131,7 +135,6 @@ |
| 131 | 135 | if (color == nil) { |
| 132 | 136 | return nil; |
| 133 | 137 | } |
| 134 | - | |
| 135 | 138 | CGRect rect=CGRectMake(0.0f, 0.0f, size.width, size.height); |
| 136 | 139 | UIGraphicsBeginImageContext(rect.size); |
| 137 | 140 | CGContextRef context = UIGraphicsGetCurrentContext(); |
| ... | ... | @@ -140,6 +143,7 @@ |
| 140 | 143 | UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext(); |
| 141 | 144 | UIGraphicsEndImageContext(); |
| 142 | 145 | return theImage; |
| 146 | + | |
| 143 | 147 | } |
| 144 | 148 | |
| 145 | 149 | #pragma mark - System Delegate | ... | ... |
CNLiveCommonClass/Classes/CNThemeManager.h
| ... | ... | @@ -9,13 +9,13 @@ |
| 9 | 9 | #import <Foundation/Foundation.h> |
| 10 | 10 | #import "CNThemeProtocol.h" |
| 11 | 11 | |
| 12 | -/// 当主题发生变化时,会发送这个通知 | |
| 12 | +// 当主题发生变化时,会发送这个通知 | |
| 13 | 13 | extern NSString *const CNThemeChangedNotification; |
| 14 | 14 | |
| 15 | -/// 主题发生改变前的值,类型为 NSObject<CNThemeProtocol>,可能为 NSNull | |
| 15 | +// 主题发生改变前的值,类型为 NSObject<CNThemeProtocol>,可能为 NSNull | |
| 16 | 16 | extern NSString *const CNThemeBeforeChangedName; |
| 17 | 17 | |
| 18 | -/// 主题发生改变后的值,类型为 NSObject<CNThemeProtocol>,可能为 NSNull | |
| 18 | +// 主题发生改变后的值,类型为 NSObject<CNThemeProtocol>,可能为 NSNull | |
| 19 | 19 | extern NSString *const CNThemeAfterChangedName; |
| 20 | 20 | |
| 21 | 21 | /** |
| ... | ... | @@ -23,7 +23,8 @@ extern NSString *const CNThemeAfterChangedName; |
| 23 | 23 | * 可通过监听 CNThemeChangedNotification 通知来捕获换肤事件,默认地,CNCommonViewController 及 CNCommonTableViewController 均已支持响应换肤,其响应方法是通过 CNChangingThemeDelegate 接口来实现的。 |
| 24 | 24 | */ |
| 25 | 25 | @interface CNThemeManager : NSObject |
| 26 | +@property(nonatomic, strong) NSObject<CNThemeProtocol> *currentTheme; | |
| 27 | + | |
| 26 | 28 | + (instancetype)sharedInstance; |
| 27 | 29 | |
| 28 | -@property(nonatomic, strong) NSObject<CNThemeProtocol> *currentTheme; | |
| 29 | 30 | @end | ... | ... |
CNLiveCommonClass/Classes/CNThemeManager.m
| ... | ... | @@ -13,7 +13,6 @@ NSString *const CNThemeBeforeChangedName = @"CNThemeBeforeChangedName"; |
| 13 | 13 | NSString *const CNThemeAfterChangedName = @"CNThemeAfterChangedName"; |
| 14 | 14 | |
| 15 | 15 | @implementation CNThemeManager |
| 16 | - | |
| 17 | 16 | + (instancetype)sharedInstance { |
| 18 | 17 | static dispatch_once_t onceToken; |
| 19 | 18 | static CNThemeManager *instance = nil; | ... | ... |
CNLiveCommonClass/Classes/CNThemeProtocol.h
| ... | ... | @@ -16,22 +16,18 @@ |
| 16 | 16 | @required |
| 17 | 17 | /// 来自于 QMUIConfigurationTemplate 里的自带方法,用于应用配置表里的设置 |
| 18 | 18 | - (void)setupConfigurationTemplate; |
| 19 | - | |
| 20 | 19 | - (UIColor *)themeTintColor; |
| 21 | 20 | - (UIColor *)themeListTextColor; |
| 22 | 21 | - (UIColor *)themeCodeColor; |
| 23 | 22 | - (UIColor *)themeGridItemTintColor; |
| 24 | - | |
| 25 | 23 | - (NSString *)themeName; |
| 26 | 24 | |
| 27 | 25 | @end |
| 28 | 26 | |
| 29 | - | |
| 30 | 27 | /// 所有能响应主题变化的对象均应实现这个协议,目前主要用于 CNCommonViewController 及 CNCommonTableViewController |
| 31 | 28 | @protocol CNChangingThemeDelegate <NSObject> |
| 32 | 29 | |
| 33 | 30 | @required |
| 34 | - | |
| 35 | 31 | - (void)themeBeforeChanged:(NSObject<CNThemeProtocol> *)themeBeforeChanged afterChanged:(NSObject<CNThemeProtocol> *)themeAfterChanged; |
| 36 | 32 | |
| 37 | 33 | @end | ... | ... |