Commit a5bcd183cbdaf367def2334ac72d0713cf428e18

Authored by zhangxiaowen
1 parent d197c76a

no message

Example/CNLiveServices.xcodeproj/project.pbxproj
... ... @@ -19,6 +19,7 @@
19 19 0882D6B222E5B3B3000859E7 /* CNLiveHomeService.m in Sources */ = {isa = PBXBuildFile; fileRef = 0882D6B122E5B3B3000859E7 /* CNLiveHomeService.m */; };
20 20 0882D6B522E5B3C1000859E7 /* CNLiveHomeModule.m in Sources */ = {isa = PBXBuildFile; fileRef = 0882D6B422E5B3C1000859E7 /* CNLiveHomeModule.m */; };
21 21 0882D6B822E5B3D1000859E7 /* CNLiveHomeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0882D6B722E5B3D1000859E7 /* CNLiveHomeViewController.m */; };
  22 + 08A5393122FC22C000CDA315 /* CNLiveUserInfoManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 08A5393022FC22C000CDA315 /* CNLiveUserInfoManager.m */; };
22 23 6003F58E195388D20070C39A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58D195388D20070C39A /* Foundation.framework */; };
23 24 6003F590195388D20070C39A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58F195388D20070C39A /* CoreGraphics.framework */; };
24 25 6003F592195388D20070C39A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F591195388D20070C39A /* UIKit.framework */; };
... ... @@ -72,6 +73,8 @@
72 73 0882D6B422E5B3C1000859E7 /* CNLiveHomeModule.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CNLiveHomeModule.m; sourceTree = "<group>"; };
73 74 0882D6B622E5B3D1000859E7 /* CNLiveHomeViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CNLiveHomeViewController.h; sourceTree = "<group>"; };
74 75 0882D6B722E5B3D1000859E7 /* CNLiveHomeViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CNLiveHomeViewController.m; sourceTree = "<group>"; };
  76 + 08A5392F22FC22C000CDA315 /* CNLiveUserInfoManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CNLiveUserInfoManager.h; sourceTree = "<group>"; };
  77 + 08A5393022FC22C000CDA315 /* CNLiveUserInfoManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CNLiveUserInfoManager.m; sourceTree = "<group>"; };
75 78 10E6387D4BC65CC1B77AD149 /* Pods-CNLiveServices_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CNLiveServices_Tests.debug.xcconfig"; path = "Target Support Files/Pods-CNLiveServices_Tests/Pods-CNLiveServices_Tests.debug.xcconfig"; sourceTree = "<group>"; };
76 79 1503DA066C26D47C2404BE70 /* Pods-CNLiveServices_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CNLiveServices_Example.release.xcconfig"; path = "Target Support Files/Pods-CNLiveServices_Example/Pods-CNLiveServices_Example.release.xcconfig"; sourceTree = "<group>"; };
77 80 34A5EA5BE443520ED4522B2F /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
... ... @@ -173,6 +176,8 @@
173 176 084124C822E72DE4006699C6 /* Model */ = {
174 177 isa = PBXGroup;
175 178 children = (
  179 + 08A5392F22FC22C000CDA315 /* CNLiveUserInfoManager.h */,
  180 + 08A5393022FC22C000CDA315 /* CNLiveUserInfoManager.m */,
176 181 );
177 182 path = Model;
178 183 sourceTree = "<group>";
... ... @@ -502,6 +507,7 @@
502 507 084124C022E7023A006699C6 /* CNLiveFoundService.m in Sources */,
503 508 0882D6B822E5B3D1000859E7 /* CNLiveHomeViewController.m in Sources */,
504 509 084124C622E702C6006699C6 /* CNLiveFoundViewController.m in Sources */,
  510 + 08A5393122FC22C000CDA315 /* CNLiveUserInfoManager.m in Sources */,
505 511 6003F59A195388D20070C39A /* main.m in Sources */,
506 512 );
507 513 runOnlyForDeploymentPostprocessing = 0;
... ...
Example/CNLiveServices/CNLiveAppDelegate.m
... ... @@ -29,11 +29,14 @@
29 29  
30 30 [super application:application didFinishLaunchingWithOptions:launchOptions];
31 31  
32   -// id<CNLiveEnvironmentServiceProtocol> environment = [[BeeHive shareInstance] createService:@protocol(CNLiveEnvironmentServiceProtocol)];
33   -// [environment setEnvironment:CNLiveProductionAppStore];
34 32  
35   - id<CNLiveLoginServiceProtocol> login = [[BeeHive shareInstance] createService:@protocol(CNLiveLoginServiceProtocol)];
36   - UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController:[login getLoginViewController]];
  33 +// id<CNLiveLoginServiceProtocol> login = [[BeeHive shareInstance] createService:@protocol(CNLiveLoginServiceProtocol)];
  34 +// UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController:[login getLoginViewController]];
  35 +
  36 +
  37 + id<CNLiveHomeServiceProtocol> home = [[BeeHive shareInstance] createService:@protocol(CNLiveHomeServiceProtocol)];
  38 + UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController:[home getHomeViewController]];
  39 +
37 40 self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
38 41 self.window.rootViewController = navCtrl;
39 42 [self.window makeKeyAndVisible];
... ...
Example/CNLiveServices/Found/CNLiveFoundViewController.m
... ... @@ -33,7 +33,7 @@
33 33  
34 34 - (void)testButtonClicked {
35 35 if ([self.delegate respondsToSelector:@selector(backToFoundViewControllerByName:)]) {
36   - [self.delegate backToFoundViewControllerByName:@"哈哈-faxian"];
  36 + [self.delegate backToFoundViewControllerByName:@"发现返回值是哈哈"];
37 37 }
38 38 UINavigationController *nav = (UINavigationController *)[UIApplication sharedApplication].delegate.window.rootViewController;
39 39 [nav popViewControllerAnimated:YES];
... ...
Example/CNLiveServices/Login/Controller/CNLoginViewController.m
... ... @@ -8,6 +8,7 @@
8 8  
9 9 #import "CNLoginViewController.h"
10 10 #import "CNLiveServices.h"
  11 +#import "CNLiveUserInfoManager.h"
11 12  
12 13 @interface CNLoginViewController ()
13 14  
... ... @@ -31,29 +32,31 @@
31 32 self.view.backgroundColor = [UIColor whiteColor];
32 33 self.title = @"登录";
33 34  
34   - UIButton *btn0 = [UIButton buttonWithType:UIButtonTypeCustom];
35   - btn0.frame = CGRectMake(0, 0, 100, 100);
36   - btn0.center = self.view.center;
37   - btn0.backgroundColor = [UIColor redColor];
38   - [btn0 setTitle:@"进入首页" forState:UIControlStateNormal];
39   - [btn0 addTarget:self action:@selector(testButtonClicked) forControlEvents:UIControlEventTouchUpInside];
40   - [self.view addSubview:btn0];
  35 +// UIButton *btn0 = [UIButton buttonWithType:UIButtonTypeCustom];
  36 +// btn0.frame = CGRectMake(0, 0, 100, 100);
  37 +// btn0.center = self.view.center;
  38 +// btn0.backgroundColor = [UIColor redColor];
  39 +// [btn0 setTitle:@"进入首页" forState:UIControlStateNormal];
  40 +// [btn0 addTarget:self action:@selector(testButtonClicked) forControlEvents:UIControlEventTouchUpInside];
  41 +// [self.view addSubview:btn0];
41 42  
42 43  
43 44 UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
44   - btn1.frame = CGRectMake([UIScreen mainScreen].bounds.size.width/2.0-50, 100, 100, 100);
  45 + btn1.frame = CGRectMake(0, 0, 100, 100);
  46 + btn1.center = self.view.center;
45 47 btn1.backgroundColor = [UIColor redColor];
46 48 [btn1 setTitle:@"登录" forState:UIControlStateNormal];
47 49 [btn1 addTarget:self action:@selector(testButtonClicked1) forControlEvents:UIControlEventTouchUpInside];
48 50 [self.view addSubview:btn1];
49 51 }
50 52  
51   -- (void)testButtonClicked {
52   - id<CNLiveHomeServiceProtocol> home = [[BeeHive shareInstance] createService:@protocol(CNLiveHomeServiceProtocol)];
53   - [home pushToHomeViewController];
54   -}
  53 +//- (void)testButtonClicked {
  54 +// id<CNLiveHomeServiceProtocol> home = [[BeeHive shareInstance] createService:@protocol(CNLiveHomeServiceProtocol)];
  55 +// [home pushToHomeViewController];
  56 +//}
55 57  
56 58 - (void)testButtonClicked1 {
  59 + [CNLiveUserInfoManager manager].isLogin = YES;
57 60 [self dismissViewControllerAnimated:YES completion:^{
58 61 self.completeBlock? self.completeBlock(YES):@"";
59 62  
... ...
Example/CNLiveServices/Login/Model/CNLiveUserInfoManager.h 0 → 100644
  1 +//
  2 +// CNLiveUserInfoManager.h
  3 +// CNLiveServices_Example
  4 +//
  5 +// Created by CNLive-zxw on 2019/8/8.
  6 +// Copyright © 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +
  11 +NS_ASSUME_NONNULL_BEGIN
  12 +
  13 +@interface CNLiveUserInfoManager : NSObject
  14 +@property (nonatomic, assign) BOOL isLogin;
  15 ++ (instancetype)manager;
  16 +
  17 +@end
  18 +
  19 +NS_ASSUME_NONNULL_END
... ...
Example/CNLiveServices/Login/Model/CNLiveUserInfoManager.m 0 → 100644
  1 +//
  2 +// CNLiveUserInfoManager.m
  3 +// CNLiveServices_Example
  4 +//
  5 +// Created by CNLive-zxw on 2019/8/8.
  6 +// Copyright © 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveUserInfoManager.h"
  10 +@interface CNLiveUserInfoManager()
  11 +
  12 +@end
  13 +
  14 +@implementation CNLiveUserInfoManager
  15 +static CNLiveUserInfoManager *_instance = nil;
  16 +
  17 +/**
  18 + * @abstract 单例初始化
  19 + */
  20 ++ (instancetype)manager{
  21 + static dispatch_once_t once;
  22 + dispatch_once(&once, ^{
  23 + _instance = [[CNLiveUserInfoManager alloc]init];
  24 + });
  25 + return _instance;
  26 +}
  27 +
  28 ++ (id)allocWithZone:(struct _NSZone *)zone{
  29 + static dispatch_once_t onceToken;
  30 + dispatch_once(&onceToken, ^{
  31 + _instance = [super allocWithZone:zone];
  32 + });
  33 + return _instance;
  34 +}
  35 +
  36 +- (nonnull id)copyWithZone:(nullable NSZone *)zone {
  37 + return _instance;
  38 +}
  39 +
  40 +- (nonnull id)mutableCopyWithZone:(nullable NSZone *)zone {
  41 + return _instance;
  42 +}
  43 +
  44 +
  45 +@end
... ...
Example/CNLiveServices/Login/Module/CNLiveLoginService.m
... ... @@ -9,6 +9,7 @@
9 9 #import "CNLiveLoginService.h"
10 10 #import "CNLiveServices.h"
11 11 #import "CNLoginViewController.h"
  12 +#import "CNLiveUserInfoManager.h"
12 13  
13 14 @BeeHiveService(CNLiveLoginServiceProtocol,CNLiveLoginService)
14 15 @interface CNLiveLoginService ()<CNLiveLoginServiceProtocol>
... ... @@ -31,7 +32,7 @@
31 32 }
32 33  
33 34 - (void)loginIfNeedWithCompleteBlock:(void (^)(BOOL))completeBlock{
34   - if (NO) {
  35 + if ([CNLiveUserInfoManager manager].isLogin) {
35 36 completeBlock(YES);
36 37  
37 38 }
... ...