Skip to content

Commit

Permalink
viper -- Note(待完成)
Browse files Browse the repository at this point in the history
  • Loading branch information
big show committed Dec 9, 2018
1 parent 39b8e60 commit 14af6f4
Show file tree
Hide file tree
Showing 46 changed files with 934 additions and 53 deletions.
Binary file modified .DS_Store
Binary file not shown.
110 changes: 94 additions & 16 deletions BigShow1949.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// YFEditorBuilder.h
// BigShow1949
//
// Created by big show on 2018/12/9.
// Copyright © 2018年 BigShowCompany. All rights reserved.
//

#import <Foundation/Foundation.h>

@protocol YFEditorDelegate,YFViperRouter;
@interface YFEditorBuilder : NSObject
+ (UIViewController *)viewForCreatingNoteWithDelegate:(id<YFEditorDelegate>)delegate router:(id<YFViperRouter>)router;
+ (UIViewController *)viewForEditingNoteWithUUID:(NSString *)uuid title:(NSString *)title content:(NSString *)content delegate:(id<YFEditorDelegate>)delegate router:(id<YFViperRouter>)router;
@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// YFEditorBuilder.m
// BigShow1949
//
// Created by big show on 2018/12/9.
// Copyright © 2018年 BigShowCompany. All rights reserved.
//

#import "YFEditorBuilder.h"
#import "YFEditorViewController.h"
#import "YFEditorViewPresenter.h"
#import "YFEditorInteractor.h"
#import "YFEditorWireframe.h"

#import "YFViperViewPrivate.h"
#import "YFViperInteractorPrivate.h"
#import "YFViperPresenterPrivate.h"
#import "YFNoteModel.h"

#import "NSObject+YFViperAssembly.h"

@implementation YFEditorBuilder
+ (UIViewController *)viewForCreatingNoteWithDelegate:(id<YFEditorDelegate>)delegate router:(id<YFViperRouter>)router {
YFEditorViewController *view = [[YFEditorViewController alloc] init];
view.delegate = delegate;
[self buildView:(id<YFViperViewPrivate>)view note:nil router:router];
return view;
}

+ (UIViewController *)viewForEditingNoteWithUUID:(NSString *)uuid title:(NSString *)title content:(NSString *)content delegate:(id<YFEditorDelegate>)delegate router:(id<YFViperRouter>)router {
return nil;
}

+ (void)buildView:(id<YFViperViewPrivate>)view note:(nullable YFNoteModel *)note router:(id<YFViperRouter>)router {
YFEditorViewPresenter *presenter = [[YFEditorViewPresenter alloc] init];
YFEditorInteractor *interactor = [[YFEditorInteractor alloc] initWithEditingNote:note];
id<YFViperWireframePrivate> wireframe = (id)[[YFEditorWireframe alloc] init];

[self assembleViperForView:view
presenter:(id<YFViperPresenterPrivate>)presenter
interactor:(id<YFViperInteractorPrivate>)interactor
wireframe:(id<YFViperWireframePrivate>)wireframe
router:(id<YFViperRouter>)router];
}
@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// YFEditorInteractor.h
// BigShow1949
//
// Created by big show on 2018/12/9.
// Copyright © 2018年 BigShowCompany. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "YFViperInteractor.h"

@class YFNoteModel;
@interface YFEditorInteractor : NSObject<YFViperInteractor>
- (instancetype)initWithEditingNote:(nullable YFNoteModel *)note;
@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// YFEditorInteractor.m
// BigShow1949
//
// Created by big show on 2018/12/9.
// Copyright © 2018年 BigShowCompany. All rights reserved.
//

#import "YFEditorInteractor.h"
#import "YFNoteModel.h"

@interface YFEditorInteractor()
@property (nonatomic, strong, nullable) YFNoteModel *currentEditingNote;

@end

@implementation YFEditorInteractor
- (instancetype)initWithEditingNote:(nullable YFNoteModel*)note {
if (self = [super init]) {
if (note) {
_currentEditingNote = note;
}
}
return self;
}
@synthesize dataSource;

@synthesize eventHandler;

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// YFEditorInteractorDataSource.h
// BigShow1949
//
// Created by big show on 2018/12/9.
// Copyright © 2018年 BigShowCompany. All rights reserved.
//

#ifndef YFEditorInteractorDataSource_h
#define YFEditorInteractorDataSource_h


#endif /* YFEditorInteractorDataSource_h */
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// YFEditorInteractorEventHandler.h
// BigShow1949
//
// Created by big show on 2018/12/9.
// Copyright © 2018年 BigShowCompany. All rights reserved.
//

#ifndef YFEditorInteractorEventHandler_h
#define YFEditorInteractorEventHandler_h


#endif /* YFEditorInteractorEventHandler_h */
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// YFEditorInteractorInput.h
// BigShow1949
//
// Created by big show on 2018/12/9.
// Copyright © 2018年 BigShowCompany. All rights reserved.
//

#ifndef YFEditorInteractorInput_h
#define YFEditorInteractorInput_h


#endif /* YFEditorInteractorInput_h */
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// YFEditorViewPresenter.h
// BigShow1949
//
// Created by big show on 2018/12/9.
// Copyright © 2018年 BigShowCompany. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "YFViperPresenter.h"
#import "YFEditorViewEventHandler.h"
@interface YFEditorViewPresenter : NSObject<YFViperPresenter,YFEditorViewEventHandler>

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// YFEditorViewPresenter.m
// BigShow1949
//
// Created by big show on 2018/12/9.
// Copyright © 2018年 BigShowCompany. All rights reserved.
//

#import "YFEditorViewPresenter.h"

@implementation YFEditorViewPresenter

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// YFEditorDelegate.h
// BigShow1949
//
// Created by big show on 2018/12/9.
// Copyright © 2018年 BigShowCompany. All rights reserved.
//

#ifndef YFEditorDelegate_h
#define YFEditorDelegate_h
@protocol YFEditorDelegate

@end

#endif /* YFEditorDelegate_h */
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// YFEditorViewController.h
// BigShow1949
//
// Created by big show on 2018/12/9.
// Copyright © 2018年 BigShowCompany. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "YFEditorViewProtocol.h"
#import "YFViperView.h"
@protocol YFEditorDelegate;
@interface YFEditorViewController : UIViewController<YFViperView,YFEditorViewProtocol>
@property (nonatomic, weak) id<YFEditorDelegate> delegate;

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//
// YFEditorViewController.m
// BigShow1949
//
// Created by big show on 2018/12/9.
// Copyright © 2018年 BigShowCompany. All rights reserved.
//

#import "YFEditorViewController.h"

#import "YFEditorViewDataSource.h"
#import "YFEditorViewEventHandler.h"

@interface YFEditorViewController ()
@property (nonatomic, strong) id<YFEditorViewEventHandler> eventHandler;
@property (nonatomic, strong) id<YFEditorViewDataSource> viewDataSource;
@end

@implementation YFEditorViewController

- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
[self setupNav];
}

- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
}

- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
}

#pragma mark - Private
- (void)setupNav {
self.title = @"Editor";
UIBarButtonItem *addNoteItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self.eventHandler action:@selector(didTouchNavigationBarDoneButton)];
self.navigationItem.rightBarButtonItem = addNoteItem;

// if ([self.eventHandler respondsToSelector:@selector(handleViewReady)]) {
// [self.eventHandler handleViewReady];
// }
}

- (void)done {

}




@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// YFEditorViewDataSource.h
// BigShow1949
//
// Created by big show on 2018/12/9.
// Copyright © 2018年 BigShowCompany. All rights reserved.
//

#ifndef YFEditorViewDataSource_h
#define YFEditorViewDataSource_h

@protocol YFEditorViewDataSource

@end

#endif /* YFEditorViewDataSource_h */
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// YFEditorViewEventHandler.h
// BigShow1949
//
// Created by big show on 2018/12/9.
// Copyright © 2018年 BigShowCompany. All rights reserved.
//

#ifndef YFEditorViewEventHandler_h
#define YFEditorViewEventHandler_h

@protocol YFViperRouter;
@protocol YFEditorViewEventHandler
- (void)didTouchNavigationBarDoneButton;
- (id<YFViperRouter>)router;
@end

#endif /* YFEditorViewEventHandler_h */
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// YFEditorViewViewProtocol.h
// BigShow1949
//
// Created by big show on 2018/12/9.
// Copyright © 2018年 BigShowCompany. All rights reserved.
//

#ifndef YFEditorViewProtocol_h
#define YFEditorViewProtocol_h

@protocol YFEditorViewProtocol

@end

#endif /* YFEditorViewViewProtocol_h */
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// YFEditorWireframe.m
// BigShow1949
//
// Created by big show on 2018/12/9.
// Copyright © 2018年 BigShowCompany. All rights reserved.
//

#import "YFEditorWireframe.h"

@implementation YFEditorWireframe

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// YFEditorWireframeInput.h
// BigShow1949
//
// Created by big show on 2018/12/9.
// Copyright © 2018年 BigShowCompany. All rights reserved.
//

#ifndef YFEditorWireframeInput_h
#define YFEditorWireframeInput_h


#endif /* YFEditorWireframeInput_h */
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,16 @@ + (void)buildView:(id<YFViperViewPrivate>)view noteListDataService:(id<YFNoteLis
interactor.dataSource = presenter;

id<YFViperWireframePrivate>wireframe = (id)[[YFNoteListWireframe alloc] init];
// view是weak,router是strong
wireframe.view = view;
wireframe.router = router;

// view是weak,wireframe跟interactor是strong
[(id<YFViperPresenterPrivate>)presenter setView:view];
[(id<YFViperPresenterPrivate>)presenter setWireframe:wireframe];
[(id<YFViperPresenterPrivate>)presenter setInteractor:interactor];

// 这里强指针指向presenter,以免被释放
view.eventHandler = presenter;
view.viewDataSource = presenter;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// YFNoteModel.h
// BigShow1949
//
// Created by big show on 2018/12/9.
// Copyright © 2018年 BigShowCompany. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface YFNoteModel : NSObject
@property (nonatomic, readonly, copy) NSString *uuid;
@property (nonatomic, readonly, copy) NSString *title;
@property (nonatomic, readonly, copy) NSString *content;
@end
Loading

0 comments on commit 14af6f4

Please sign in to comment.