forked from BigShow1949/BigShow1949
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
viper----Todo
- Loading branch information
big show
committed
Dec 7, 2018
1 parent
7d31da4
commit 511e137
Showing
20 changed files
with
582 additions
and
27 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
BigShow1949/Classes/10 - DesignPattern(设计模式)/Viper/ToDo/YFToDoBaseViewController.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,13 @@ | ||
// | ||
// YFToDoBaseViewController.h | ||
// BigShow1949 | ||
// | ||
// Created by big show on 2018/12/7. | ||
// Copyright © 2018年 BigShowCompany. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface YFToDoBaseViewController : UIViewController | ||
|
||
@end |
47 changes: 47 additions & 0 deletions
47
BigShow1949/Classes/10 - DesignPattern(设计模式)/Viper/ToDo/YFToDoBaseViewController.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 @@ | ||
// | ||
// YFToDoBaseViewController.m | ||
// BigShow1949 | ||
// | ||
// Created by big show on 2018/12/7. | ||
// Copyright © 2018年 BigShowCompany. All rights reserved. | ||
// | ||
|
||
#import "YFToDoBaseViewController.h" | ||
#import "YFToDoRouter.h" | ||
#import "YFToDoViewController.h" | ||
|
||
@interface YFToDoBaseViewController () | ||
|
||
@end | ||
|
||
@implementation YFToDoBaseViewController | ||
|
||
- (void)viewDidLoad { | ||
[super viewDidLoad]; | ||
|
||
self.view.backgroundColor = [UIColor whiteColor]; | ||
|
||
UIButton *redBtn = [[UIButton alloc] initWithFrame:CGRectMake(100, 100, 80, 44)]; | ||
[redBtn setTitle:@"Button" forState:UIControlStateNormal]; | ||
[redBtn addTarget:self action:@selector(buttonClick) forControlEvents:UIControlEventTouchUpInside]; | ||
redBtn.titleLabel.textColor = [UIColor blackColor]; | ||
redBtn.backgroundColor = [UIColor blueColor]; | ||
[self.view addSubview:redBtn]; | ||
} | ||
|
||
- (void)buttonClick { | ||
YFToDoViewController *vc = [YFToDoRouter createModule]; | ||
[self.navigationController pushViewController:vc animated:YES]; | ||
} | ||
|
||
/* | ||
#pragma mark - Navigation | ||
// In a storyboard-based application, you will often want to do a little preparation before navigation | ||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { | ||
// Get the new view controller using [segue destinationViewController]. | ||
// Pass the selected object to the new view controller. | ||
} | ||
*/ | ||
|
||
@end |
16 changes: 16 additions & 0 deletions
16
BigShow1949/Classes/10 - DesignPattern(设计模式)/Viper/ToDo/YFToDoInteractor.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,16 @@ | ||
// | ||
// YFToDoInteractor.h | ||
// BigShow1949 | ||
// | ||
// Created by big show on 2018/12/7. | ||
// Copyright © 2018年 BigShowCompany. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "YFToDoProtocols.h" | ||
NS_ASSUME_NONNULL_BEGIN | ||
@interface YFToDoInteractor : NSObject<ToDoInteractorInputProtocol> | ||
@property (nonatomic, weak, nullable) id<ToDoInteractorOutputProtocol> output; | ||
|
||
@end | ||
NS_ASSUME_NONNULL_END |
29 changes: 29 additions & 0 deletions
29
BigShow1949/Classes/10 - DesignPattern(设计模式)/Viper/ToDo/YFToDoInteractor.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,29 @@ | ||
// | ||
// YFToDoInteractor.m | ||
// BigShow1949 | ||
// | ||
// Created by big show on 2018/12/7. | ||
// Copyright © 2018年 BigShowCompany. All rights reserved. | ||
// | ||
|
||
#import "YFToDoInteractor.h" | ||
#import "YFToDoItem.h" | ||
|
||
@implementation YFToDoInteractor | ||
#pragma mark - InteractorProtocol | ||
|
||
- (void)setOutput:(id<ToDoInteractorOutputProtocol>)output | ||
{ | ||
_output = output; | ||
} | ||
|
||
- (id<ToDoInteractorOutputProtocol>)getOutputProtocol | ||
{ | ||
return self.output; | ||
} | ||
|
||
- (void)addToDoItem:(YFToDoItem *)item | ||
{ | ||
[self.output sendAddedItem:item]; | ||
} | ||
@end |
13 changes: 13 additions & 0 deletions
13
BigShow1949/Classes/10 - DesignPattern(设计模式)/Viper/ToDo/YFToDoItem.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,13 @@ | ||
// | ||
// YFToDoItem.h | ||
// BigShow1949 | ||
// | ||
// Created by big show on 2018/12/7. | ||
// Copyright © 2018年 BigShowCompany. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface YFToDoItem : NSObject | ||
@property (nonatomic) NSString *text; | ||
@end |
13 changes: 13 additions & 0 deletions
13
BigShow1949/Classes/10 - DesignPattern(设计模式)/Viper/ToDo/YFToDoItem.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,13 @@ | ||
// | ||
// YFToDoItem.m | ||
// BigShow1949 | ||
// | ||
// Created by big show on 2018/12/7. | ||
// Copyright © 2018年 BigShowCompany. All rights reserved. | ||
// | ||
|
||
#import "YFToDoItem.h" | ||
|
||
@implementation YFToDoItem | ||
|
||
@end |
24 changes: 24 additions & 0 deletions
24
BigShow1949/Classes/10 - DesignPattern(设计模式)/Viper/ToDo/YFToDoPresenter.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 @@ | ||
// | ||
// YFToDoPresenter.h | ||
// BigShow1949 | ||
// | ||
// Created by big show on 2018/12/7. | ||
// Copyright © 2018年 BigShowCompany. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "YFToDoProtocols.h" | ||
#import "YFToDoItem.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
@interface YFToDoPresenter : NSObject<ToDoInteractorOutputProtocol> | ||
@property (nonatomic, weak, nullable) id<ToDoViewProtocol> view; | ||
@property (nonatomic) id<ToDoInteractorInputProtocol> interactor; | ||
@property (nonatomic, weak) id<ToDoWireframeProtocol> router; | ||
|
||
- (instancetype)initWithInterface:(id<ToDoViewProtocol>)interface | ||
interactor:(id<ToDoInteractorInputProtocol>)interactor | ||
router:(id<ToDoWireframeProtocol>)router; | ||
- (void)addToDoItem:(YFToDoItem *)item; | ||
@end | ||
NS_ASSUME_NONNULL_END |
39 changes: 39 additions & 0 deletions
39
BigShow1949/Classes/10 - DesignPattern(设计模式)/Viper/ToDo/YFToDoPresenter.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,39 @@ | ||
// | ||
// YFToDoPresenter.m | ||
// BigShow1949 | ||
// | ||
// Created by big show on 2018/12/7. | ||
// Copyright © 2018年 BigShowCompany. All rights reserved. | ||
// | ||
|
||
#import "YFToDoPresenter.h" | ||
|
||
@implementation YFToDoPresenter | ||
- (instancetype)initWithInterface:(id<ToDoViewProtocol>)interface | ||
interactor:(id<ToDoInteractorInputProtocol>)interactor | ||
router:(id<ToDoWireframeProtocol>)router | ||
{ | ||
if (self = [super init]) | ||
{ | ||
self.view = interface; | ||
self.interactor = interactor; | ||
self.router = router; | ||
[self.interactor setOutput:self]; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)addToDoItem:(YFToDoItem *)item | ||
{ | ||
[self.interactor addToDoItem:item]; | ||
} | ||
|
||
|
||
#pragma mark - ToDoInteractorOutputProtocol | ||
|
||
- (void)sendAddedItem:(YFToDoItem *)item | ||
{ | ||
[self.view showAddedItem:item]; | ||
} | ||
|
||
@end |
47 changes: 47 additions & 0 deletions
47
BigShow1949/Classes/10 - DesignPattern(设计模式)/Viper/ToDo/YFToDoProtocols.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,47 @@ | ||
// | ||
// YFToDoProtocols.m | ||
// | ||
// | ||
// Created by big show on 2018/12/7. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <Foundation/Foundation.h> | ||
#import "YFToDoItem.h" | ||
|
||
#pragma mark - WireFrameProtocol | ||
|
||
@protocol ToDoWireframeProtocol <NSObject> | ||
|
||
@end | ||
|
||
#pragma mark - PresenterProtocol | ||
|
||
@protocol ToDoPresenterProtocol <NSObject> | ||
|
||
@end | ||
|
||
#pragma mark - InteractorProtocol | ||
|
||
@protocol ToDoInteractorOutputProtocol <NSObject> | ||
|
||
- (void)sendAddedItem:(YFToDoItem *)item; | ||
|
||
@end | ||
|
||
@protocol ToDoInteractorInputProtocol <NSObject> | ||
|
||
- (void)setOutput:(id<ToDoInteractorOutputProtocol>)output; | ||
- (id<ToDoInteractorOutputProtocol>)getOutputProtocol; | ||
|
||
- (void)addToDoItem:(YFToDoItem *)item; | ||
|
||
@end | ||
|
||
#pragma mark - ViewProtocol | ||
|
||
@protocol ToDoViewProtocol <NSObject> | ||
|
||
- (void)showAddedItem:(YFToDoItem *)item; | ||
|
||
@end |
17 changes: 17 additions & 0 deletions
17
BigShow1949/Classes/10 - DesignPattern(设计模式)/Viper/ToDo/YFToDoRouter.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 @@ | ||
// | ||
// YFToDoRouter.h | ||
// BigShow1949 | ||
// | ||
// Created by big show on 2018/12/7. | ||
// Copyright © 2018年 BigShowCompany. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "YFToDoProtocols.h" | ||
#import "YFToDoViewController.h" | ||
@interface YFToDoRouter : NSObject<ToDoWireframeProtocol> | ||
@property (nonatomic, weak) YFToDoViewController *viewController; | ||
|
||
+ (YFToDoViewController *)createModule; | ||
|
||
@end |
26 changes: 26 additions & 0 deletions
26
BigShow1949/Classes/10 - DesignPattern(设计模式)/Viper/ToDo/YFToDoRouter.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,26 @@ | ||
// | ||
// YFToDoRouter.m | ||
// BigShow1949 | ||
// | ||
// Created by big show on 2018/12/7. | ||
// Copyright © 2018年 BigShowCompany. All rights reserved. | ||
// | ||
|
||
#import "YFToDoRouter.h" | ||
#import "YFToDoViewController.h" | ||
#import "YFToDoInteractor.h" | ||
#import "YFToDoPresenter.h" | ||
|
||
@implementation YFToDoRouter | ||
+ (YFToDoViewController *)createModule | ||
{ | ||
NSString *viewName = NSStringFromClass([YFToDoViewController class]); | ||
YFToDoViewController *viewController = [[YFToDoViewController alloc] initWithNibName:viewName bundle:nil]; | ||
YFToDoInteractor *interactor = [[YFToDoInteractor alloc] init]; | ||
YFToDoRouter *router = [[YFToDoRouter alloc] init]; | ||
YFToDoPresenter *presenter = [[YFToDoPresenter alloc] initWithInterface:viewController interactor:interactor router:router]; | ||
viewController.presenter = presenter; | ||
router.viewController = viewController; | ||
return viewController; | ||
} | ||
@end |
14 changes: 14 additions & 0 deletions
14
BigShow1949/Classes/10 - DesignPattern(设计模式)/Viper/ToDo/YFToDoTableViewCell.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,14 @@ | ||
// | ||
// YFToDoTableViewCell.h | ||
// BigShow1949 | ||
// | ||
// Created by big show on 2018/12/7. | ||
// Copyright © 2018年 BigShowCompany. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface YFToDoTableViewCell : UITableViewCell | ||
@property (weak, nonatomic) IBOutlet UILabel *titleLabel; | ||
|
||
@end |
24 changes: 24 additions & 0 deletions
24
BigShow1949/Classes/10 - DesignPattern(设计模式)/Viper/ToDo/YFToDoTableViewCell.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,24 @@ | ||
// | ||
// YFToDoTableViewCell.m | ||
// BigShow1949 | ||
// | ||
// Created by big show on 2018/12/7. | ||
// Copyright © 2018年 BigShowCompany. All rights reserved. | ||
// | ||
|
||
#import "YFToDoTableViewCell.h" | ||
|
||
@implementation YFToDoTableViewCell | ||
|
||
- (void)awakeFromNib { | ||
[super awakeFromNib]; | ||
// Initialization code | ||
} | ||
|
||
- (void)setSelected:(BOOL)selected animated:(BOOL)animated { | ||
[super setSelected:selected animated:animated]; | ||
|
||
// Configure the view for the selected state | ||
} | ||
|
||
@end |
41 changes: 41 additions & 0 deletions
41
BigShow1949/Classes/10 - DesignPattern(设计模式)/Viper/ToDo/YFToDoTableViewCell.xib
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,41 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES"> | ||
<device id="retina4_7" orientation="portrait"> | ||
<adaptation id="fullscreen"/> | ||
</device> | ||
<dependencies> | ||
<deployment identifier="iOS"/> | ||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/> | ||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> | ||
</dependencies> | ||
<objects> | ||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/> | ||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> | ||
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="KGk-i7-Jjw" customClass="YFToDoTableViewCell"> | ||
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/> | ||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> | ||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM"> | ||
<rect key="frame" x="0.0" y="0.0" width="320" height="43.5"/> | ||
<autoresizingMask key="autoresizingMask"/> | ||
<subviews> | ||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qPU-GP-Q3g"> | ||
<rect key="frame" x="0.0" y="0.0" width="320" height="43.5"/> | ||
<fontDescription key="fontDescription" type="system" pointSize="17"/> | ||
<nil key="textColor"/> | ||
<nil key="highlightedColor"/> | ||
</label> | ||
</subviews> | ||
<constraints> | ||
<constraint firstAttribute="trailing" secondItem="qPU-GP-Q3g" secondAttribute="trailing" id="8zX-Qw-abT"/> | ||
<constraint firstAttribute="bottom" secondItem="qPU-GP-Q3g" secondAttribute="bottom" id="FAx-gP-vmp"/> | ||
<constraint firstItem="qPU-GP-Q3g" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="nlg-FQ-h8h"/> | ||
<constraint firstItem="qPU-GP-Q3g" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="tbR-q3-cKz"/> | ||
</constraints> | ||
</tableViewCellContentView> | ||
<connections> | ||
<outlet property="titleLabel" destination="qPU-GP-Q3g" id="Zl0-bg-ipB"/> | ||
</connections> | ||
<point key="canvasLocation" x="-89" y="108"/> | ||
</tableViewCell> | ||
</objects> | ||
</document> |
16 changes: 16 additions & 0 deletions
16
BigShow1949/Classes/10 - DesignPattern(设计模式)/Viper/ToDo/YFToDoViewController.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,16 @@ | ||
// | ||
// YFToDoViewController.h | ||
// BigShow1949 | ||
// | ||
// Created by big show on 2018/12/7. | ||
// Copyright © 2018年 BigShowCompany. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
#import "YFToDoPresenter.h" | ||
#import "YFToDoProtocols.h" | ||
|
||
@interface YFToDoViewController : UIViewController<ToDoViewProtocol, UITableViewDelegate, UITableViewDataSource> | ||
@property (weak, nonatomic) IBOutlet UITableView *tableView; | ||
@property (nonatomic, nullable) YFToDoPresenter *presenter; | ||
@end |
Oops, something went wrong.