-
Notifications
You must be signed in to change notification settings - Fork 518
Expand file tree
/
Copy pathAppBoard_iPhone.m
More file actions
280 lines (222 loc) · 6.51 KB
/
Copy pathAppBoard_iPhone.m
File metadata and controls
280 lines (222 loc) · 6.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
//
// __
// /\ \ _
// ____ ____ ___\ \ \_/ \ _____ ___ ___
// / _ \ / __ \ / __ \ \ < __ /\__ \ / __ \ / __ \
// /\ \_\ \/\ __//\ __/\ \ \\ \ /\_\ \/_/ / /\ \_\ \/\ \_\ \
// \ \____ \ \____\ \____\\ \_\\_\ \/_/ /\____\\ \____/\ \____/
// \/____\ \/____/\/____/ \/_//_/ \/____/ \/___/ \/___/
// /\____/
// \/___/
//
// Powered by BeeFramework
//
#import "AppBoard_iPhone.h"
#import "B0_IndexBoard_iPhone.h"
#import "D0_SearchBoard_iPhone.h"
#import "C0_ShoppingCartBoard_iPhone.h"
#import "E0_ProfileBoard_iPhone.h"
#import "B1_ProductListBoard_iPhone.h"
#import "B3_ProductPhotoBoard_iPhone.h"
#import "B2_ProductDetailBoard_iPhone.h"
#import "B5_ProductCommentBoard_iPhone.h"
#import "C0_ShoppingCartBoard_iPhone.h"
#import "A0_SigninBoard_iPhone.h"
#import "A1_SignupBoard_iPhone.h"
#import "OrderCell_iPhone.h"
#import "F1_NewAddressBoard_iPhone.h"
#import "F0_AddressListBoard_iPhone.h"
#import "C1_CheckOutBoard_iPhone.h"
#import "H0_BrowserBoard_iPhone.h"
#import "UIViewController+ErrorTips.h"
#import "bee.services.alipay.h"
#import "bee.services.share.weixin.h"
#import "bee.services.share.sinaweibo.h"
#import "bee.services.share.tencentweibo.h"
#pragma mark -
#undef TAB_HEIGHT
#define TAB_HEIGHT 44.0f
#pragma mark -
DEF_UI( AppBoard_iPhone, appBoard )
#pragma mark -
@implementation AppBoard_iPhone
{
CGFloat _tabbarOriginY;
}
DEF_SINGLETON( AppBoard_iPhone )
DEF_SIGNAL( TAB_HOME )
DEF_SIGNAL( TAB_SEARCH )
DEF_SIGNAL( TAB_CART )
DEF_SIGNAL( TAB_USER )
DEF_SIGNAL( NOTIFY_FORWARD )
DEF_SIGNAL( NOTIFY_IGNORE )
DEF_MODEL( ConfigModel, configModel )
DEF_MODEL( UserModel, userModel )
#pragma mark -
- (void)load
{
self.configModel = [ConfigModel modelWithObserver:self];
self.userModel = [UserModel modelWithObserver:self];
}
- (void)unload
{
SAFE_RELEASE_MODEL( self.configModel );
SAFE_RELEASE_MODEL( self.userModel );
}
#pragma mark -
ON_SIGNAL2( BeeUIBoard, signal )
{
if ( [signal is:BeeUIBoard.CREATE_VIEWS] )
{
self.view.backgroundColor = [UIColor whiteColor];
bee.ui.router[self.TAB_HOME] = [B0_IndexBoard_iPhone class];
bee.ui.router[self.TAB_SEARCH] = [D0_SearchBoard_iPhone class];
bee.ui.router[self.TAB_CART] = [C0_ShoppingCartBoard_iPhone class];
bee.ui.router[self.TAB_USER] = [E0_ProfileBoard_iPhone sharedInstance];
[self.view addSubview:bee.ui.router.view];
[self.view addSubview:bee.ui.tabbar];
[bee.ui.router open:self.TAB_HOME animated:YES];
[self observeNotification:BeeUIRouter.STACK_DID_CHANGED];
[self observeNotification:UserModel.LOGIN];
[self observeNotification:UserModel.LOGOUT];
[self observeNotification:UserModel.KICKOUT];
// [self observeNotification:BeeNetworkReachability.WIFI_REACHABLE];
// [self observeNotification:BeeNetworkReachability.WLAN_REACHABLE];
// [self observeNotification:BeeNetworkReachability.UNREACHABLE];
_tabbarOriginY = self.viewBound.size.height - TAB_HEIGHT + 1;
}
else if ( [signal is:BeeUIBoard.DELETE_VIEWS] )
{
[self unobserveAllNotifications];
}
else if ( [signal is:BeeUIBoard.LAYOUT_VIEWS] )
{
bee.ui.tabbar.frame = CGRectMake( 0, _tabbarOriginY, self.viewBound.size.width, TAB_HEIGHT );
bee.ui.router.view.frame = CGRectMake( 0, 0, self.viewBound.size.width, self.viewBound.size.height );
}
else if ( [signal is:BeeUIBoard.LOAD_DATAS] )
{
}
else if ( [signal is:BeeUIBoard.FREE_DATAS] )
{
}
else if ( [signal is:BeeUIBoard.WILL_APPEAR] )
{
}
else if ( [signal is:BeeUIBoard.DID_APPEAR] )
{
[self.configModel reload];
}
else if ( [signal is:BeeUIBoard.DID_APPEAR] )
{
[E0_ProfileBoard_iPhone sharedInstance];
}
else if ( [signal is:BeeUIBoard.WILL_DISAPPEAR] )
{
}
else if ( [signal is:BeeUIBoard.DID_DISAPPEAR] )
{
}
else if ( [signal is:BeeUIBoard.ORIENTATION_WILL_CHANGE] )
{
}
else if ( [signal is:BeeUIBoard.ORIENTATION_DID_CHANGED] )
{
}
}
#pragma mark -
ON_SIGNAL3( AppBoard_iPhone, EXPIRE_TOUCHED, signal )
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.ecmobile.cn"]];
}
#pragma mark -
ON_NOTIFICATION3( BeeNetworkReachability, WIFI_REACHABLE, notification )
{
[self presentMessageTips:__TEXT(@"network_wifi")];
}
ON_NOTIFICATION3( BeeNetworkReachability, WLAN_REACHABLE, notification )
{
[self presentMessageTips:__TEXT(@"network_wlan")];
}
ON_NOTIFICATION3( BeeNetworkReachability, UNREACHABLE, notification )
{
[self presentMessageTips:__TEXT(@"network_unreachable")];
}
#pragma mark -
ON_SIGNAL3( AppTabbar_iPhone, home_button, signal )
{
[bee.ui.tabbar selectHome];
[bee.ui.router open:AppBoard_iPhone.TAB_HOME animated:NO];
}
ON_SIGNAL3( AppTabbar_iPhone, search_button, signal )
{
[bee.ui.tabbar selectSearch];
[bee.ui.router open:AppBoard_iPhone.TAB_SEARCH animated:NO];
}
ON_SIGNAL3( AppTabbar_iPhone, cart_button, signal )
{
[bee.ui.tabbar selectCart];
[bee.ui.router open:AppBoard_iPhone.TAB_CART animated:NO];
}
ON_SIGNAL3( AppTabbar_iPhone, user_button, signal )
{
[bee.ui.tabbar selectUser];
[bee.ui.router open:AppBoard_iPhone.TAB_USER animated:NO];
}
#pragma mark -
ON_NOTIFICATION3( UserModel, KICKOUT, n )
{
[self showLogin];
// 登录用户过期后,执行当前页面viewWillApper
[bee.ui.router.currentBoard viewWillAppear:YES];
}
ON_NOTIFICATION3( UserModel, LOGOUT, n )
{
}
ON_NOTIFICATION3( UserModel, LOGIN, n )
{
}
#pragma mark -
- (void)showLogin
{
if ( self.modalStack )
{
return;
}
[self presentModalStack:[BeeUIStack stackWithFirstBoard:[A0_SigninBoard_iPhone board]] animated:YES];
}
- (void)hideLogin
{
if ( nil == self.modalStack )
{
return;
}
[self dismissModalStackAnimated:YES];
}
#pragma mark -
- (void)showTabbar
{
_tabbarOriginY = self.view.height - TAB_HEIGHT + 1;
CGRect tabbarFrame = bee.ui.tabbar.frame;
tabbarFrame.origin.y = _tabbarOriginY;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
[UIView setAnimationDelay:0.2];
[UIView setAnimationBeginsFromCurrentState:YES];
bee.ui.tabbar.frame = tabbarFrame;
[UIView commitAnimations];
}
- (void)hideTabbar
{
_tabbarOriginY = self.view.height;
CGRect tabbarFrame = bee.ui.tabbar.frame;
tabbarFrame.origin.y = _tabbarOriginY;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
[UIView setAnimationDelay:0.2];
[UIView setAnimationBeginsFromCurrentState:YES];
bee.ui.tabbar.frame = tabbarFrame;
[UIView commitAnimations];
}
#pragma mark -
@end