-
Notifications
You must be signed in to change notification settings - Fork 450
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
123 changed files
with
9,649 additions
and
192 deletions.
There are no files selected for viewing
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// BQMVVM.h | ||
// MVVMFramework | ||
// | ||
// Created by yuantao on 16/1/21. | ||
// Copyright © 2016年 momo. All rights reserved. | ||
// | ||
|
||
#ifndef BQMVVM_h | ||
#define BQMVVM_h | ||
|
||
#import "MVVMBaseViewModel.h" | ||
#import "MVVMBaseViewManger.h" | ||
#import "MVVMTableDataDelegate.h" | ||
#import "MVVMCollectionDataDelegate.H" | ||
#import "MVVMExtend.h" | ||
#import "MVVMConstant.h" | ||
#import "MVVMSingleton.h" | ||
#import "SUIUtils.h" | ||
#import "UITableView+FDTemplateLayoutCell.h" | ||
#import "PMKVObserver.h" | ||
|
||
#endif /* BQMVVM_h */ |
17 changes: 17 additions & 0 deletions
17
SUIMVVMDemo/SUIMVVMDemo/SUIMVVMKit/SUIMVVMKit/Base/ViewManger/MVVMBaseViewManger.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// MVVMBaseViewManger.h | ||
// SUIMVVMDemo | ||
// | ||
// Created by yuantao on 16/2/22. | ||
// Copyright © 2016年 lovemo. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "MVVMViewMangerProtocol.h" | ||
|
||
@interface MVVMBaseViewManger : NSObject <MVVMViewMangerProtocol> | ||
|
||
/** 用于传递数据的基模型 */ | ||
@property (nonatomic, strong) NSObject *vm_model; | ||
|
||
@end |
20 changes: 20 additions & 0 deletions
20
SUIMVVMDemo/SUIMVVMDemo/SUIMVVMKit/SUIMVVMKit/Base/ViewManger/MVVMBaseViewManger.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// MVVMBaseViewManger.m | ||
// SUIMVVMDemo | ||
// | ||
// Created by yuantao on 16/2/22. | ||
// Copyright © 2016年 lovemo. All rights reserved. | ||
// | ||
|
||
#import "MVVMBaseViewManger.h" | ||
|
||
@implementation MVVMBaseViewManger | ||
|
||
- (instancetype)init { | ||
if (self = [super init]) { | ||
[self vm_handleViewMangerWithSubView:nil]; | ||
} | ||
return self; | ||
} | ||
|
||
@end |
24 changes: 24 additions & 0 deletions
24
SUIMVVMDemo/SUIMVVMDemo/SUIMVVMKit/SUIMVVMKit/Base/ViewModel/MVVMBaseViewModel.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// MVVMBaseViewModel.h | ||
// DevelopFramework | ||
// | ||
// Created by momo on 15/12/5. | ||
// Copyright © 2015年 teason. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
#import "MVVMViewModelProtocol.h" | ||
|
||
@interface MVVMBaseViewModel : NSObject <MVVMViewModelProtocol> | ||
|
||
@property (nonatomic, weak) UIViewController *viewController; | ||
@property (nonatomic, strong) NSMutableArray *dataArrayList; | ||
|
||
+ (instancetype)vm_modelWithViewController:(UIViewController *)viewController; | ||
|
||
/** | ||
* 用来判断是否加载成功,方便外部根据不同需求处理 (外部使用) | ||
*/ | ||
- (void)vm_getDataSuccessHandler:(void (^)( ))successHandler; | ||
|
||
@end |
42 changes: 42 additions & 0 deletions
42
SUIMVVMDemo/SUIMVVMDemo/SUIMVVMKit/SUIMVVMKit/Base/ViewModel/MVVMBaseViewModel.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// MVVMBaseViewModel.m | ||
// DevelopFramework | ||
// | ||
// Created by momo on 15/12/5. | ||
// Copyright © 2015年 teason. All rights reserved. | ||
// | ||
|
||
#import "MVVMBaseViewModel.h" | ||
|
||
@implementation MVVMBaseViewModel | ||
|
||
/** | ||
* 懒加载存放请求到的数据数组 | ||
*/ | ||
- (NSMutableArray *)dataArrayList { | ||
if (_dataArrayList == nil) { | ||
_dataArrayList = [NSMutableArray array]; | ||
} | ||
return _dataArrayList; | ||
} | ||
|
||
+ (instancetype)vm_modelWithViewController:(UIViewController *)viewController{ | ||
MVVMBaseViewModel *model = self.new; | ||
if (model) { | ||
model.viewController = viewController; | ||
} | ||
return model; | ||
} | ||
|
||
- (void)vm_getDataSuccessHandler:(void (^)())successHandler { | ||
|
||
} | ||
|
||
- (NSString *)description{ | ||
return [NSString stringWithFormat:@"View model:%@ viewController:%@", | ||
super.description, | ||
self.viewController.description | ||
]; | ||
} | ||
|
||
@end |
15 changes: 15 additions & 0 deletions
15
SUIMVVMDemo/SUIMVVMDemo/SUIMVVMKit/SUIMVVMKit/Constant/MVVMConstant.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// MVVMConstant.h | ||
// SUIMVVMDemo | ||
// | ||
// Created by yuantao on 16/2/29. | ||
// Copyright © 2016年 lovemo. All rights reserved. | ||
// | ||
|
||
#ifndef MVVMConstant_h | ||
#define MVVMConstant_h | ||
|
||
// 过期提醒 | ||
#define MVVMDeprecated(instead) NS_DEPRECATED(2_0, 2_0, 2_0, 2_0, instead) | ||
|
||
#endif /* MVVMConstant_h */ |
66 changes: 66 additions & 0 deletions
66
SUIMVVMDemo/SUIMVVMDemo/SUIMVVMKit/SUIMVVMKit/Constant/MVVMSingleton.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// .h文件 | ||
#define MVVMSingletonH(name) + (instancetype)shared##name; | ||
|
||
// .m文件 | ||
#if __has_feature(objc_arc) | ||
|
||
#define MVVMSingletonM(name) \ | ||
static id _instace; \ | ||
\ | ||
+ (id)allocWithZone:(struct _NSZone *)zone \ | ||
{ \ | ||
static dispatch_once_t onceToken; \ | ||
dispatch_once(&onceToken, ^{ \ | ||
_instace = [super allocWithZone:zone]; \ | ||
}); \ | ||
return _instace; \ | ||
} \ | ||
\ | ||
+ (instancetype)shared##name \ | ||
{ \ | ||
static dispatch_once_t onceToken; \ | ||
dispatch_once(&onceToken, ^{ \ | ||
_instace = [[self alloc] init]; \ | ||
}); \ | ||
return _instace; \ | ||
} \ | ||
\ | ||
- (id)copyWithZone:(NSZone *)zone \ | ||
{ \ | ||
return _instace; \ | ||
} | ||
|
||
#else | ||
|
||
#define MVVMSingletonM(name) \ | ||
static id _instace; \ | ||
\ | ||
+ (id)allocWithZone:(struct _NSZone *)zone \ | ||
{ \ | ||
static dispatch_once_t onceToken; \ | ||
dispatch_once(&onceToken, ^{ \ | ||
_instace = [super allocWithZone:zone]; \ | ||
}); \ | ||
return _instace; \ | ||
} \ | ||
\ | ||
+ (instancetype)shared##name \ | ||
{ \ | ||
static dispatch_once_t onceToken; \ | ||
dispatch_once(&onceToken, ^{ \ | ||
_instace = [[self alloc] init]; \ | ||
}); \ | ||
return _instace; \ | ||
} \ | ||
\ | ||
- (id)copyWithZone:(NSZone *)zone \ | ||
{ \ | ||
return _instace; \ | ||
} \ | ||
\ | ||
- (oneway void)release { } \ | ||
- (id)retain { return self; } \ | ||
- (NSUInteger)retainCount { return 1;} \ | ||
- (id)autorelease { return self;} | ||
|
||
#endif |
Binary file not shown.
18 changes: 18 additions & 0 deletions
18
SUIMVVMDemo/SUIMVVMDemo/SUIMVVMKit/SUIMVVMKit/Extend/MVVMExtend.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// MVVMExtend.h | ||
// SUIMVVMDemo | ||
// | ||
// Created by yuantao on 16/2/22. | ||
// Copyright © 2016年 lovemo. All rights reserved. | ||
// | ||
|
||
#ifndef MVVMExtend_h | ||
#define MVVMExtend_h | ||
|
||
#import "UIView+Configure.h" | ||
#import "UICollectionView+CollectionDataDelegateAdditions.h" | ||
#import "UICollectionViewCell+Extension.h" | ||
#import "UITableView+TableDataDelegateAdditions.h" | ||
#import "UITableViewCell+Extension.h" | ||
|
||
#endif /* MVVMExtend_h */ |
20 changes: 20 additions & 0 deletions
20
...IMVVMDemo/SUIMVVMKit/SUIMVVMKit/Extend/UICollectionView+CollectionDataDelegateAdditions.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// UICollectionView+CollectionDataDelegateAdditions.h | ||
// MVVMFramework | ||
// | ||
// Created by zzZ on 16/1/8. | ||
// Copyright © 2016年 momo. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
@class MVVMCollectionDataDelegate; | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface UICollectionView (CollectionDataDelegateAdditions) | ||
|
||
@property (nullable,nonatomic,strong) MVVMCollectionDataDelegate *collectionHander; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
30 changes: 30 additions & 0 deletions
30
...IMVVMDemo/SUIMVVMKit/SUIMVVMKit/Extend/UICollectionView+CollectionDataDelegateAdditions.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// UICollectionView+CollectionDataDelegateAdditions.m | ||
// MVVMFramework | ||
// | ||
// Created by zzZ on 16/1/8. | ||
// Copyright © 2016年 momo. All rights reserved. | ||
// | ||
|
||
#import "UICollectionView+CollectionDataDelegateAdditions.h" | ||
#import "MVVMCollectionDataDelegate.h" | ||
#import <objc/runtime.h> | ||
|
||
@implementation UICollectionView (CollectionDataDelegateAdditions) | ||
|
||
|
||
- (MVVMCollectionDataDelegate *)collectionHander | ||
{ | ||
return objc_getAssociatedObject(self, _cmd); | ||
} | ||
- (void)setCollectionHander:(MVVMCollectionDataDelegate *)collectionHander | ||
{ | ||
if (collectionHander) { | ||
[collectionHander handleCollectionViewDatasourceAndDelegate:self]; | ||
} | ||
objc_setAssociatedObject(self, @selector(collectionHander), collectionHander, OBJC_ASSOCIATION_RETAIN_NONATOMIC); | ||
} | ||
|
||
|
||
@end | ||
|
30 changes: 30 additions & 0 deletions
30
SUIMVVMDemo/SUIMVVMDemo/SUIMVVMKit/SUIMVVMKit/Extend/UICollectionViewCell+Extension.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// UITableViewCell+Extension.h | ||
// DevelopFramework | ||
// | ||
// Created by momo on 15/12/16. | ||
// Copyright © 2015年 teason. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface UICollectionViewCell (Extension) | ||
|
||
/** | ||
* 从nib文件中根据重用标识符注册UICollectionViewcell | ||
*/ | ||
+ (void)registerCollect:(UICollectionView *)table | ||
nibIdentifier:(NSString *)identifier ; | ||
/** | ||
* 配置UICollectionViewcell,设置UICollectionViewcell内容 | ||
*/ | ||
- (void)configure:(UICollectionViewCell *)cell | ||
customObj:(id)obj | ||
indexPath:(NSIndexPath *)indexPath ; | ||
/** | ||
* 获取自定义对象的cell高度 | ||
*/ | ||
+ (CGFloat)getCellHeightWithCustomObj:(id)obj | ||
indexPath:(NSIndexPath *)indexPath ; | ||
|
||
@end |
47 changes: 47 additions & 0 deletions
47
SUIMVVMDemo/SUIMVVMDemo/SUIMVVMKit/SUIMVVMKit/Extend/UICollectionViewCell+Extension.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// UITableViewCell+Extension.m | ||
// DevelopFramework | ||
// | ||
// Created by momo on 15/12/16. | ||
// Copyright © 2015年 teason. All rights reserved. | ||
// | ||
|
||
#import "UICollectionViewCell+Extension.h" | ||
|
||
@implementation UICollectionViewCell (Extension) | ||
|
||
#pragma mark -- | ||
+ (UINib *)nibWithIdentifier:(NSString *)identifier | ||
{ | ||
return [UINib nibWithNibName:identifier bundle:nil]; | ||
} | ||
|
||
#pragma mark - Public | ||
+ (void)registerCollect:(UICollectionView *)collect | ||
nibIdentifier:(NSString *)identifier | ||
{ | ||
[collect registerNib:[self nibWithIdentifier:identifier] forCellWithReuseIdentifier:identifier]; | ||
|
||
} | ||
|
||
#pragma mark -- | ||
#pragma mark - Rewrite these func in SubClass ! | ||
- (void)configure:(UICollectionViewCell *)cell | ||
customObj:(id)obj | ||
indexPath:(NSIndexPath *)indexPath | ||
{ | ||
// Rewrite this func in SubClass ! | ||
|
||
} | ||
|
||
+ (CGFloat)getCellHeightWithCustomObj:(id)obj | ||
indexPath:(NSIndexPath *)indexPath | ||
{ | ||
// Rewrite this func in SubClass if necessary | ||
if (!obj) { | ||
return 0.0f ; // if obj is null . | ||
} | ||
return 44.0f ; // default cell height | ||
} | ||
|
||
@end |
Oops, something went wrong.