cocoapods-mPaaS 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. checksums.yaml +7 -0
  2. data/lib/cocoapods-mPaaS/baselineTools.rb +493 -0
  3. data/lib/cocoapods-mPaaS/checkUpdateTools.rb +42 -0
  4. data/lib/cocoapods-mPaaS/cocoapods_hook.rb +929 -0
  5. data/lib/cocoapods-mPaaS/command/mPaaS.rb +44 -0
  6. data/lib/cocoapods-mPaaS/command/mpaas/dev.rb +17 -0
  7. data/lib/cocoapods-mPaaS/command/mpaas/info.rb +170 -0
  8. data/lib/cocoapods-mPaaS/command/mpaas/init.rb +112 -0
  9. data/lib/cocoapods-mPaaS/command/mpaas/local_command.rb +49 -0
  10. data/lib/cocoapods-mPaaS/command/mpaas/open.rb +17 -0
  11. data/lib/cocoapods-mPaaS/command/mpaas/update.rb +223 -0
  12. data/lib/cocoapods-mPaaS/command/mpaas/version.rb +32 -0
  13. data/lib/cocoapods-mPaaS/command.rb +1 -0
  14. data/lib/cocoapods-mPaaS/dsl.rb +498 -0
  15. data/lib/cocoapods-mPaaS/gem_version.rb +5 -0
  16. data/lib/cocoapods-mPaaS/installNew.rb +303 -0
  17. data/lib/cocoapods-mPaaS/locales/en.yml +140 -0
  18. data/lib/cocoapods-mPaaS/locales/zh-Hans.yml +144 -0
  19. data/lib/cocoapods-mPaaS/localization.rb +238 -0
  20. data/lib/cocoapods-mPaaS/logTools.rb +67 -0
  21. data/lib/cocoapods-mPaaS/mPaaSPodfile.rb +117 -0
  22. data/lib/cocoapods-mPaaS/module_config.rb +298 -0
  23. data/lib/cocoapods-mPaaS/podfileTools.rb +48 -0
  24. data/lib/cocoapods-mPaaS/post_install_hook_processor.rb +61 -0
  25. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/DemoViewController.h +13 -0
  26. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/DemoViewController.m +43 -0
  27. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/Contents.json +6 -0
  28. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Discovery.imageset/Contents.json +22 -0
  29. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Discovery.imageset/TabBar_Discovery@2x.png +0 -0
  30. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Discovery.imageset/TabBar_Discovery@3x.png +0 -0
  31. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Discovery_Sel.imageset/Contents.json +22 -0
  32. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Discovery_Sel.imageset/TabBar_Discovery_Sel@2x.png +0 -0
  33. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Discovery_Sel.imageset/TabBar_Discovery_Sel@3x.png +0 -0
  34. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Friends.imageset/Contents.json +22 -0
  35. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Friends.imageset/TabBar_Friends@2x.png +0 -0
  36. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Friends.imageset/TabBar_Friends@3x.png +0 -0
  37. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Friends_Sel.imageset/Contents.json +22 -0
  38. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Friends_Sel.imageset/TabBar_Friends_Sel@2x.png +0 -0
  39. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Friends_Sel.imageset/TabBar_Friends_Sel@3x.png +0 -0
  40. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_HomeBar.imageset/Contents.json +22 -0
  41. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_HomeBar.imageset/icon30-line@2x.png +0 -0
  42. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_HomeBar.imageset/icon30-line@3x.png +0 -0
  43. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_HomeBar_Sel.imageset/Contents.json +22 -0
  44. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_HomeBar_Sel.imageset/icon30@2x.png +0 -0
  45. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_HomeBar_Sel.imageset/icon30@3x.png +0 -0
  46. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_PublicService.imageset/Contents.json +22 -0
  47. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_PublicService.imageset/TabBar_PublicService@2x.png +0 -0
  48. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_PublicService.imageset/TabBar_PublicService@3x.png +0 -0
  49. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_PublicService_Sel.imageset/Contents.json +22 -0
  50. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_PublicService_Sel.imageset/TabBar_PublicService_Sel@2x.png +0 -0
  51. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_PublicService_Sel.imageset/TabBar_PublicService_Sel@3x.png +0 -0
  52. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPAppDelegate.h +10 -0
  53. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPAppDelegate.m +43 -0
  54. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerController.h +8 -0
  55. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerController.m +135 -0
  56. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerLauncherAppDelegate.h +10 -0
  57. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerLauncherAppDelegate.m +43 -0
  58. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerLeftView.h +16 -0
  59. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerLeftView.m +86 -0
  60. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerMainViewController.h +21 -0
  61. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerMainViewController.m +104 -0
  62. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPLauncherAppDelegate.h +10 -0
  63. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPLauncherAppDelegate.m +91 -0
  64. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPNavigationController.h +8 -0
  65. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPNavigationController.m +25 -0
  66. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPNavigationLauncherAppDelegate.h +10 -0
  67. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPNavigationLauncherAppDelegate.m +43 -0
  68. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPTabBarController.h +8 -0
  69. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPTabBarController.m +27 -0
  70. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPViewController.h +8 -0
  71. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPViewController.m +19 -0
  72. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MobileRuntime.plist +26 -0
  73. data/lib/cocoapods-mPaaS/write_info_list_mPaaSApp.rb +125 -0
  74. data/lib/cocoapods-mPaaS/xcode_helper.rb +334 -0
  75. data/lib/cocoapods-mPaaS.rb +41 -0
  76. data/lib/cocoapods_plugin.rb +15 -0
  77. metadata +160 -0
@@ -0,0 +1,22 @@
1
+ {
2
+ "images" : [
3
+ {
4
+ "idiom" : "universal",
5
+ "scale" : "1x"
6
+ },
7
+ {
8
+ "idiom" : "universal",
9
+ "scale" : "2x",
10
+ "filename" : "TabBar_PublicService_Sel@2x.png"
11
+ },
12
+ {
13
+ "idiom" : "universal",
14
+ "scale" : "3x",
15
+ "filename" : "TabBar_PublicService_Sel@3x.png"
16
+ }
17
+ ],
18
+ "info" : {
19
+ "version" : 1,
20
+ "author" : "xcode"
21
+ }
22
+ }
@@ -0,0 +1,10 @@
1
+ //
2
+ // MPAppDelegate.h
3
+
4
+ #import <Foundation/Foundation.h>
5
+
6
+ @interface MPAppDelegate : NSObject <DTMicroApplicationDelegate>
7
+
8
+ - (UIViewController *)rootControllerInApplication:(DTMicroApplication *)application;
9
+
10
+ @end
@@ -0,0 +1,43 @@
1
+ //
2
+ // MPAppDelegate.m
3
+
4
+ #import "MPAppDelegate.h"
5
+ #import "MPViewController.h"
6
+
7
+ @interface MPAppDelegate ()
8
+
9
+ @property (nonatomic, strong) UIViewController* rootController;
10
+ @property (nonatomic, strong) MPViewController* controller;
11
+
12
+ @end
13
+
14
+ @implementation MPAppDelegate
15
+
16
+ - (id)init
17
+ {
18
+ self = [super init];
19
+ if (self)
20
+ {
21
+ _controller = [[MPViewController alloc] init];
22
+ self.rootController = self.controller;
23
+ }
24
+ return self;
25
+ }
26
+
27
+
28
+ - (UIViewController *)rootControllerInApplication:(DTMicroApplication *)application
29
+ {
30
+ return self.rootController;
31
+ }
32
+
33
+ - (void)application:(DTMicroApplication *)app didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
34
+ {
35
+
36
+ }
37
+
38
+ - (void)application:(DTMicroApplication *)application willResumeWithOptions:(NSDictionary *)launchOptions
39
+ {
40
+
41
+ }
42
+
43
+ @end
@@ -0,0 +1,8 @@
1
+ //
2
+ // MPDrawerController.h
3
+
4
+ #import <UIKit/UIKit.h>
5
+
6
+ @interface MPDrawerController : DTViewController
7
+
8
+ @end
@@ -0,0 +1,135 @@
1
+ //
2
+ // MPDrawerController.m
3
+
4
+ #import "MPDrawerController.h"
5
+ #import "MPDrawerMainViewController.h"
6
+ #import "MPDrawerLeftView.h"
7
+
8
+
9
+
10
+ #define screenW [UIScreen mainScreen].bounds.size.width
11
+ #define targetL screenW * 0.8
12
+
13
+
14
+ @interface MPDrawerController() <MPDrawerMainViewControllerDelegate>{
15
+ UITapGestureRecognizer* _tapGesture;
16
+ }
17
+
18
+ @property (nonatomic, strong) MPDrawerLeftView* leftView;
19
+
20
+ @end
21
+
22
+ @implementation MPDrawerController
23
+
24
+ - (UIStatusBarStyle)preferredStatusBarStyle{
25
+
26
+ return UIStatusBarStyleLightContent;
27
+
28
+ }
29
+
30
+ - (void) viewDidLoad
31
+ {
32
+ [super viewDidLoad];
33
+
34
+ _leftView = [[MPDrawerLeftView alloc] initWithFrame:CGRectMake(0, 0, targetL, [UIScreen mainScreen].bounds.size.height)];
35
+ [self.view addSubview:_leftView];
36
+
37
+ MPDrawerMainViewController* mainViewController = [[MPDrawerMainViewController alloc] init];
38
+ mainViewController.delegate = self;
39
+ [self addChildViewController:mainViewController];
40
+ [self.view addSubview:mainViewController.view];
41
+ }
42
+
43
+ - (void) viewDidDisappear:(BOOL)animated
44
+ {
45
+ [super viewDidDisappear:animated];
46
+
47
+ MPDrawerMainViewController *mainViewController = self.childViewControllers[0];
48
+
49
+ [UIView animateWithDuration:0.5 animations:^{
50
+ mainViewController.view.frame = [UIScreen mainScreen].bounds;
51
+ }];
52
+
53
+ mainViewController.view.userInteractionEnabled = YES;
54
+
55
+ //移除手势,手势一添加,只要不移除,就永远会影响到事件的传递
56
+ if (_tapGesture){
57
+ [self.view removeGestureRecognizer:_tapGesture];
58
+ _tapGesture = nil;
59
+ }
60
+ }
61
+
62
+
63
+ - (void)mainViewControllerDidClickTheLeftButton:(MPDrawerMainViewController *)mainViewController withButton:(UIButton *)btn
64
+ {
65
+ [UIView animateWithDuration:0.5 animations:^{
66
+ mainViewController.view.transform = CGAffineTransformTranslate(mainViewController.view.transform, targetL, 0);
67
+ }];
68
+
69
+ mainViewController.view.userInteractionEnabled = NO;
70
+
71
+ UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap:)];
72
+ [self.view addGestureRecognizer:tap];
73
+ _tapGesture = tap;
74
+ }
75
+
76
+ - (void)mainViewController:(MPDrawerMainViewController *)mainViewController didPan:(UIPanGestureRecognizer *)pan
77
+ {
78
+
79
+ CGPoint offSet = [pan translationInView:self.view];
80
+
81
+ mainViewController.view.frame = [self frameWithOffsetX:offSet.x withOriginalFrame:mainViewController.view.frame];
82
+
83
+ //结束拖拽后
84
+ if (pan.state == UIGestureRecognizerStateEnded) {
85
+ CGFloat target = 0;
86
+ if (mainViewController.view.frame.origin.x > screenW * 0.3) {
87
+ target = targetL;
88
+ }
89
+
90
+ [UIView animateWithDuration:0.5 animations:^{
91
+ mainViewController.view.frame = [self frameWithOffsetX:target - mainViewController.view.frame.origin.x withOriginalFrame:mainViewController.view.frame];
92
+ }];
93
+ }
94
+
95
+ //每次偏移之后都需要复位
96
+ [pan setTranslation:CGPointZero inView:self.view];
97
+
98
+ //判断是否是显示了左视图
99
+ if (mainViewController.view.frame.origin.x == targetL) {
100
+
101
+ mainViewController.view.userInteractionEnabled = NO;
102
+
103
+ //添加点击手势
104
+ UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap:)];
105
+ [self.view addGestureRecognizer:tap];
106
+ _tapGesture = tap;
107
+ }
108
+
109
+ }
110
+
111
+ - (CGRect)frameWithOffsetX:(CGFloat)x withOriginalFrame:(CGRect)frame
112
+ {
113
+ frame.origin.x += x;
114
+ return frame;
115
+ }
116
+
117
+
118
+ //处理自己的点击手势
119
+ - (void)tap:(UITapGestureRecognizer *)tap
120
+ {
121
+
122
+ MPDrawerMainViewController *mainViewController = self.childViewControllers[0];
123
+
124
+ [UIView animateWithDuration:0.5 animations:^{
125
+ mainViewController.view.frame = [UIScreen mainScreen].bounds;
126
+ }];
127
+
128
+ mainViewController.view.userInteractionEnabled = YES;
129
+
130
+ //移除手势,手势一添加,只要不移除,就永远会影响到事件的传递
131
+ [self.view removeGestureRecognizer:tap];
132
+ _tapGesture = nil;
133
+ }
134
+
135
+ @end
@@ -0,0 +1,10 @@
1
+ //
2
+ // MPDrawerLauncherAppDelegate.h
3
+
4
+ #import <Foundation/Foundation.h>
5
+
6
+ @interface MPDrawerLauncherAppDelegate : NSObject <DTMicroApplicationDelegate>
7
+
8
+ - (UIViewController *)rootControllerInApplication:(DTMicroApplication *)application;
9
+
10
+ @end
@@ -0,0 +1,43 @@
1
+ //
2
+ // MPDrawerLauncherAppDelegate.m
3
+
4
+ #import "MPDrawerLauncherAppDelegate.h"
5
+ #import "MPDrawerController.h"
6
+
7
+ @interface MPDrawerLauncherAppDelegate ()
8
+
9
+ @property (nonatomic, strong) UIViewController* rootController;
10
+ @property (nonatomic, strong) MPDrawerController* drawerController;
11
+
12
+ @end
13
+
14
+ @implementation MPDrawerLauncherAppDelegate
15
+
16
+ - (id)init
17
+ {
18
+ self = [super init];
19
+ if (self)
20
+ {
21
+ _drawerController = [[MPDrawerController alloc] init];
22
+ self.rootController = self.drawerController;
23
+ }
24
+ return self;
25
+ }
26
+
27
+
28
+ - (UIViewController *)rootControllerInApplication:(DTMicroApplication *)application
29
+ {
30
+ return self.rootController;
31
+ }
32
+
33
+ - (void)application:(DTMicroApplication *)app didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
34
+ {
35
+
36
+ }
37
+
38
+ - (void)application:(DTMicroApplication *)application willResumeWithOptions:(NSDictionary *)launchOptions
39
+ {
40
+
41
+ }
42
+
43
+ @end
@@ -0,0 +1,16 @@
1
+ //
2
+ // MPDrawerLeftView.h
3
+
4
+ #import <UIKit/UIKit.h>
5
+
6
+ @interface MPDrawerLeftView : UIView
7
+
8
+ @property (strong) UIView* userBackgroundView;
9
+ @property (strong) UIImageView* userImageView;
10
+ @property (strong) UILabel* userNameLabel;
11
+
12
+ @property (strong) UIScrollView* buttonScrollView;
13
+ @property (strong) UIButton* userInfoButton;
14
+ @property (strong) UIButton* userCenterButton;
15
+
16
+ @end
@@ -0,0 +1,86 @@
1
+ //
2
+ // MPDrawerLeftView.m
3
+
4
+ #import "MPDrawerLeftView.h"
5
+
6
+ #define SCREEN_W [UIScreen mainScreen].bounds.size.width
7
+ #define SCREEN_H [UIScreen mainScreen].bounds.size.height
8
+ #define BACKGROUND_HEIGHT 160
9
+ #define BACKGROUND_MARGIN_LEFT 30
10
+ #define BUTTON_INSET_LEFT 30
11
+ #define BUTTON_MARGIN_TOP 30
12
+ #define BUTTON_HEIGHT 30
13
+
14
+ @implementation MPDrawerLeftView
15
+
16
+ - (instancetype)initWithFrame:(CGRect)frame
17
+ {
18
+ if (self = [super initWithFrame:frame]) {
19
+ [self setUp];
20
+ }
21
+
22
+ return self;
23
+ }
24
+
25
+ //初始化一些操作,创建子控件,布局子控件
26
+ - (void)setUp
27
+ {
28
+ _userBackgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, BACKGROUND_HEIGHT)];
29
+ _userBackgroundView.backgroundColor = [UIColor colorWithRed:95.0/255.0 green:95/255.0 blue:95/255.0 alpha:1.0];
30
+
31
+ _userImageView = [[UIImageView alloc] initWithFrame:CGRectMake(BACKGROUND_MARGIN_LEFT, 25, 100, 100)];
32
+ [_userImageView setImage:[UIImage imageNamed:@"ic_launcher.png"]];
33
+ [_userBackgroundView addSubview:_userImageView];
34
+
35
+ _userNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(BACKGROUND_MARGIN_LEFT, _userImageView.frame.origin.y+_userImageView.frame.size.height, 100, 20)];
36
+ _userNameLabel.textAlignment = NSTextAlignmentCenter;
37
+ _userNameLabel.textColor = [UIColor whiteColor];
38
+ _userNameLabel.text = @"金融云";
39
+ [_userBackgroundView addSubview:_userNameLabel];
40
+
41
+ [self addSubview:_userBackgroundView];
42
+
43
+
44
+
45
+ _buttonScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, BACKGROUND_HEIGHT, SCREEN_W, SCREEN_H-BACKGROUND_HEIGHT)];
46
+ _buttonScrollView.backgroundColor = [UIColor colorWithRed:210.0/255.0 green:210.0/255.0 blue:210.0/255.0 alpha:1.0];
47
+
48
+ _userInfoButton = [[UIButton alloc] initWithFrame:CGRectMake(0, BUTTON_MARGIN_TOP, SCREEN_W, BUTTON_HEIGHT)];
49
+ [self setButtonInfo:self.userInfoButton title:@"个人信息" image:[UIImage imageNamed:@"TabBar_Friends_Sel"]];
50
+ [self.userInfoButton addTarget:self action:@selector(userInfoButtonDidClick) forControlEvents:UIControlEventTouchUpInside];
51
+ [_buttonScrollView addSubview:_userInfoButton];
52
+
53
+
54
+ _userCenterButton = [[UIButton alloc] initWithFrame:CGRectMake(0, BUTTON_MARGIN_TOP+_userInfoButton.frame.origin.y+_userInfoButton.frame.size.height, SCREEN_W, BUTTON_HEIGHT)];
55
+ [self setButtonInfo:self.userCenterButton title:@"用户中心" image:[UIImage imageNamed:@"TabBar_Discovery_Sel"]];
56
+ [self.userCenterButton addTarget:self action:@selector(userCenterButtonDidClick) forControlEvents:UIControlEventTouchUpInside];
57
+ [_buttonScrollView addSubview:_userCenterButton];
58
+
59
+ [self addSubview:_buttonScrollView];
60
+ }
61
+
62
+ - (void) setButtonInfo:(UIButton*)button title:(NSString*)title image:(UIImage*)image
63
+ {
64
+ button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
65
+ button.imageView.tintColor = [UIColor whiteColor];
66
+ button.tintColor = [UIColor whiteColor];
67
+ [button setImage:image forState:UIControlStateNormal];
68
+ [button setTitle:title forState:UIControlStateNormal];
69
+
70
+ button.imageEdgeInsets = UIEdgeInsetsMake(0, -button.titleLabel.bounds.size.width+BUTTON_INSET_LEFT, 0, button.titleLabel.bounds.size.width);
71
+ button.titleEdgeInsets = UIEdgeInsetsMake(0, image.size.width+BUTTON_INSET_LEFT, 0, -image.size.width);
72
+ }
73
+
74
+ - (void)userInfoButtonDidClick
75
+ {
76
+ [DTContextGet() startApplication:@"20000003" params:@{} animated:YES];
77
+ NSLog(@"user info");
78
+ }
79
+
80
+ - (void)userCenterButtonDidClick
81
+ {
82
+ [DTContextGet() startApplication:@"20000002" params:@{} animated:YES];
83
+ NSLog(@"user center");
84
+ }
85
+
86
+ @end
@@ -0,0 +1,21 @@
1
+ //
2
+ // MPDrawerMainViewController.h
3
+
4
+ #import <UIKit/UIKit.h>
5
+
6
+ @class MPDrawerMainViewController;
7
+
8
+ @protocol MPDrawerMainViewControllerDelegate <NSObject>
9
+
10
+ @optional
11
+
12
+ - (void)mainViewControllerDidClickTheLeftButton:(MPDrawerMainViewController *)mainViewController withButton:(UIButton *)btn;
13
+ - (void)mainViewController:(MPDrawerMainViewController *)mainViewController didPan:(UIPanGestureRecognizer *)pan;
14
+
15
+ @end
16
+
17
+ @interface MPDrawerMainViewController : DTViewController
18
+
19
+ @property (nonatomic,weak)id<MPDrawerMainViewControllerDelegate>delegate;
20
+
21
+ @end
@@ -0,0 +1,104 @@
1
+ //
2
+ // MPDrawerMainViewController.m
3
+
4
+ #import "MPDrawerMainViewController.h"
5
+
6
+ #define TITLE_VIEW_HEIGHT 64
7
+ #define TITLE_VIEW_INNER_VIEW_Y 25
8
+
9
+ @interface MPDrawerMainViewController() <UIGestureRecognizerDelegate>
10
+
11
+ @end
12
+
13
+ @implementation MPDrawerMainViewController
14
+
15
+ - (BOOL)autohideNavigationBar
16
+ {
17
+ return YES;
18
+ }
19
+
20
+ - (void) viewDidLoad
21
+ {
22
+ [super viewDidLoad];
23
+
24
+ UIView* titleView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, TITLE_VIEW_HEIGHT)];
25
+ titleView.backgroundColor = [UIColor colorWithRed:62.0/255.0 green:68.0/255.0 blue:80.0/255.0 alpha:1.0];
26
+
27
+ UILabel* titleInfoLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, TITLE_VIEW_INNER_VIEW_Y, self.view.frame.size.width, 30)];
28
+ titleInfoLabel.text = @"主页";
29
+ titleInfoLabel.textColor = [UIColor whiteColor];
30
+ titleInfoLabel.textAlignment = NSTextAlignmentCenter;
31
+ [titleView addSubview:titleInfoLabel];
32
+
33
+
34
+ UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
35
+ [leftButton setImage:[UIImage imageNamed:@"menu_icon.png"] forState:UIControlStateNormal];
36
+ //[leftButton setOrigin:CGPointMake(15, TITLE_VIEW_INNER_VIEW_Y)];
37
+ leftButton.frame = CGRectMake(15, TITLE_VIEW_INNER_VIEW_Y, 50, 30);
38
+ //根据图片大小自适应;
39
+ [leftButton sizeToFit];
40
+ [leftButton addTarget:self action:@selector(leftBtnDidClick:) forControlEvents:UIControlEventTouchUpInside];
41
+ [titleView addSubview:leftButton];
42
+
43
+
44
+ UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
45
+ [rightButton setTitle:@"Test" forState:UIControlStateNormal];
46
+ [rightButton sizeToFit];
47
+ rightButton.frame = CGRectMake(self.view.frame.size.width-90, TITLE_VIEW_INNER_VIEW_Y, 70, 30);
48
+ [rightButton addTarget:self action:@selector(rightBtnDidClick) forControlEvents:UIControlEventTouchUpInside];
49
+ [titleView addSubview:rightButton];
50
+
51
+
52
+ [self.view addSubview:titleView];
53
+
54
+ //创建并添加手势
55
+ UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(pan:)];
56
+ [self.view addGestureRecognizer:pan];
57
+ pan.delegate = self;
58
+
59
+ }
60
+
61
+ - (void)leftBtnDidClick:(UIButton *)btn
62
+ {
63
+ if ([self.delegate respondsToSelector:@selector(mainViewControllerDidClickTheLeftButton:withButton:)]) {
64
+ [self.delegate mainViewControllerDidClickTheLeftButton:self withButton:btn ];
65
+ }
66
+
67
+ }
68
+
69
+ - (void)rightBtnDidClick
70
+ {
71
+ NSLog(@"Right click");
72
+ }
73
+
74
+ //处理手势
75
+ - (void)pan:(UIPanGestureRecognizer *)pan
76
+ {
77
+ if ([self.delegate respondsToSelector:@selector(mainViewController:didPan:)]) {
78
+ [self.delegate mainViewController:self didPan:pan];
79
+ }
80
+ }
81
+
82
+
83
+ #pragma mark ----------UIGestureRecognizerDelegate------------
84
+
85
+ //重写该方法,避免因为DTBaseViewController中的该函数导致的拖拉手势只能生效一次的情况
86
+ - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)recognizer
87
+ {
88
+ return YES;
89
+
90
+ }
91
+
92
+ //规定手势只在某一部分区域点击了才有用
93
+ - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
94
+ {
95
+ CGPoint touchP = [touch locationInView:self.view];
96
+ if (touchP.x < self.view.frame.size.width * 0.2) {
97
+ return YES;
98
+ }
99
+
100
+ return NO;
101
+ }
102
+
103
+
104
+ @end
@@ -0,0 +1,10 @@
1
+ //
2
+ // MPLauncherAppDelegate.h
3
+
4
+ #import <Foundation/Foundation.h>
5
+
6
+ @interface MPLauncherAppDelegate : NSObject <DTMicroApplicationDelegate>
7
+
8
+ - (UIViewController *)rootControllerInApplication:(DTMicroApplication *)application;
9
+
10
+ @end
@@ -0,0 +1,91 @@
1
+ //
2
+ // MPLauncherAppDelegate.m
3
+
4
+ #import "MPLauncherAppDelegate.h"
5
+ #import "MPTabBarController.h"
6
+
7
+ @interface MPLauncherAppDelegate ()
8
+
9
+ @property (nonatomic, strong) UITabBarController* tabBarController;
10
+ @property (nonatomic, strong) UIViewController *rootController;
11
+
12
+ @end
13
+
14
+ @implementation MPLauncherAppDelegate
15
+
16
+ - (id)init
17
+ {
18
+ self = [super init];
19
+ if (self)
20
+ {
21
+ // 这里指定Tab使用的图片
22
+ NSArray *baseImgs = [NSArray arrayWithObjects:
23
+ @"TabBar_HomeBar",
24
+ @"TabBar_Discovery",
25
+ @"TabBar_PublicService",
26
+ @"TabBar_Friends", nil];
27
+ NSArray *selectImgs = [NSArray arrayWithObjects:
28
+ @"TabBar_HomeBar_Sel",
29
+ @"TabBar_Discovery_Sel",
30
+ @"TabBar_PublicService_Sel",
31
+ @"TabBar_Friends_Sel", nil];
32
+
33
+ UIViewController* tab1ViewController = (UIViewController *) [self createLoggingViewController:@"DemoViewController"];
34
+ UIViewController* tab2ViewController = [[DTViewController alloc] init];
35
+ UIViewController* tab3ViewController = [[DTViewController alloc] init];
36
+ UIViewController* tab4ViewController = [[DTViewController alloc] init];
37
+
38
+ NSArray *navArray = @[tab1ViewController, tab2ViewController, tab3ViewController, tab4ViewController];
39
+ NSArray *titles = @[@"Tab1", @"Tab2", @"Tab3", @"Tab4"];
40
+ for (int i = 0; i < [navArray count]; i ++)
41
+ {
42
+ UIImage *bImg = [UIImage imageNamed:baseImgs[i]];
43
+ UIImage *selectImg = [UIImage imageNamed:selectImgs[i]];
44
+
45
+ UITabBarItem *item = [[UITabBarItem alloc] initWithTitle:titles[i] image:bImg selectedImage:selectImg];
46
+ item.selectedImage = [item.selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
47
+ item.image = [item.image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
48
+ item.tag = i;
49
+ [(UIViewController *)navArray[i] setTabBarItem:item];
50
+ ((UIViewController *)navArray[i]).title = titles[i];
51
+ }
52
+
53
+ self.tabBarController = [[MPTabBarController alloc] init];
54
+ self.tabBarController.viewControllers = navArray;
55
+ self.tabBarController.selectedIndex = 0;
56
+ [self.tabBarController.delegate tabBarController:self.tabBarController didSelectViewController:tab1ViewController];
57
+ self.rootController = self.tabBarController;
58
+ }
59
+ return self;
60
+ }
61
+
62
+ - (id)createLoggingViewController:(NSString *)className
63
+ {
64
+ id vc;
65
+ Class cl = NSClassFromString(className);
66
+ if (cl != Nil) {
67
+ vc = [[cl alloc]init];
68
+ }
69
+ else {
70
+ vc = (DTViewController *)[[DTViewController alloc] init];
71
+ }
72
+ return vc;
73
+ }
74
+
75
+
76
+ - (UIViewController *)rootControllerInApplication:(DTMicroApplication *)application
77
+ {
78
+ return self.rootController;
79
+ }
80
+
81
+ - (void)applicationDidFinishLaunching:(DTMicroApplication *)application
82
+ {
83
+
84
+ }
85
+
86
+ - (void)application:(DTMicroApplication *)application willResumeWithOptions:(NSDictionary *)launchOptions
87
+ {
88
+
89
+ }
90
+
91
+ @end
@@ -0,0 +1,8 @@
1
+ //
2
+ // MPNavigationController.h
3
+
4
+ #import <UIKit/UIKit.h>
5
+
6
+ @interface MPNavigationController : DTViewController
7
+
8
+ @end
@@ -0,0 +1,25 @@
1
+ //
2
+ // MPNavigationController.m
3
+
4
+ #import "MPNavigationController.h"
5
+
6
+ @interface MPNavigationController()
7
+
8
+ @end
9
+
10
+ @implementation MPNavigationController
11
+
12
+ - (void)viewDidLoad
13
+ {
14
+ [super viewDidLoad];
15
+
16
+ self.title = @"主页";
17
+ self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Test" style:UIBarButtonItemStylePlain target:self action:@selector(btnClick)];
18
+ }
19
+
20
+ - (void)btnClick
21
+ {
22
+ NSLog(@"Click");
23
+ }
24
+
25
+ @end
@@ -0,0 +1,10 @@
1
+ //
2
+ // MPNavigationLauncherAppDelegate.h
3
+
4
+ #import <Foundation/Foundation.h>
5
+
6
+ @interface MPNavigationLauncherAppDelegate : NSObject <DTMicroApplicationDelegate>
7
+
8
+ - (UIViewController *)rootControllerInApplication:(DTMicroApplication *)application;
9
+
10
+ @end