summaryrefslogtreecommitdiff
path: root/ios/shared/ios_sharedlo/objective_c/view_controllers/MLOMainViewController.m
diff options
context:
space:
mode:
Diffstat (limited to 'ios/shared/ios_sharedlo/objective_c/view_controllers/MLOMainViewController.m')
-rw-r--r--ios/shared/ios_sharedlo/objective_c/view_controllers/MLOMainViewController.m157
1 files changed, 43 insertions, 114 deletions
diff --git a/ios/shared/ios_sharedlo/objective_c/view_controllers/MLOMainViewController.m b/ios/shared/ios_sharedlo/objective_c/view_controllers/MLOMainViewController.m
index cb29994a7a09..cb34bc61e138 100644
--- a/ios/shared/ios_sharedlo/objective_c/view_controllers/MLOMainViewController.m
+++ b/ios/shared/ios_sharedlo/objective_c/view_controllers/MLOMainViewController.m
@@ -16,24 +16,15 @@
#import "MLORenderManager.h"
#import "NSObject+MLOUtils.h"
#import "MLOTopbarViewController.h"
-#import "MLOMainViewController_Impl.h"
+#import "MLOMainViewController_Private.h"
#import "MLOKeyboardManager.h"
+#import "MLOAppRoleFactory.h"
+#import "MLOAppRoleBase.h"
#import "mlo_uno.h"
-@interface MLOMainViewController ()
-
-@property BOOL focused;
-@property CGFloat topBarHeight;
-@property UIView * flasher;
-@property MLOTopbarViewController * topbar;
-@property MLOToolbarViewController * toolbar;
-
-@end
-
static const CGFloat
FLASH_DURATION= 0.2f,
- EXPAND_DURATION=0.5f,
- ROTATE_FLASH_DURATION=0.5f;
+ EXPAND_DURATION=0.5f;
@implementation MLOMainViewController
@@ -47,19 +38,19 @@ static const CGFloat
-(void)showLibreOffice:(UIWindow *) window{
- _topBarHeight = TOP_BAR_HEIGHT;
+ self.topBarHeight = TOP_BAR_HEIGHT;
+
[[UIApplication sharedApplication]setStatusBarHidden:YES];
self.view.bounds = self.view.frame = [self getFullFrameForRect:self.view.frame];
-
- [_renderManager setWidth:self.view.frame.size.width height:self.view.frame.size.height];
-
- [_gestureEngine showLibreOffice:window];
+ [self.role initWindow:window];
+
[self onStart];
- [_topbar showLibreOffice];
- [_toolbar showLibreOffice];
+ [self.topbar showLibreOffice];
+
+ [self.role showLibreOffice];
}
@@ -72,21 +63,12 @@ static const CGFloat
if(self.focused){
self.focused = NO;
+
[self.topbar hideLibreOffice];
- [self.toolbar hideLibreOffice];
-
- [self resetSubviews];
-
+
[[UIApplication sharedApplication]setStatusBarHidden:NO];
-
- [self.gestureEngine hideLibreOffice];
-
- [self.scroller hideLibreOffice];
-
- [self.selection reset];
-
- [self.keyboard hide];
-
+
+ [self.role hideLibreOffice];
[self.view removeFromSuperview];
[[MLOManager getInstance] hideLibreOffice];
@@ -94,14 +76,12 @@ static const CGFloat
}
-(void)initCanvas{
-
self.view.frame = self.view.bounds =[self getFullFrameForRect:[[MLOManager getInstance] bounds]];
-
- self.canvas = [[UIView alloc]
- initWithFrame:CGRectMake(0,
- TOP_BAR_HEIGHT,
- self.view.frame.size.width,
- self.view.frame.size.height - TOP_BAR_HEIGHT)];
+ CGRect canvasRect = CGRectMake(0,
+ TOP_BAR_HEIGHT,
+ self.view.frame.size.width,
+ self.view.frame.size.height - TOP_BAR_HEIGHT);
+ self.canvas = [[UIView alloc] initWithFrame:canvasRect];
self.canvas.clipsToBounds = YES;
self.canvas.backgroundColor = [UIColor whiteColor];
}
@@ -109,43 +89,33 @@ static const CGFloat
- (id) init{
self = [super init];
if(self){
-
- [self initCanvas];
-
- self.scroller = [[MLOScrollerViewController alloc] initWithMainViewController:self];
- self.selection = [[MLOSelectionViewController alloc] initWithMainViewController: self];
+ self.role = [MLOAppRoleFactory getInstanceWithMainViewController:self];
- self.toolbar = [[MLOToolbarViewController alloc] initWithMainViewController:self];
+ [self initCanvas];
+
+ [self.role initSubviews];
self.topbar = [[MLOTopbarViewController alloc] initWithMainViewController:self];
- self.flasher =[[UIView alloc] initWithFrame:CGRECT_ZERO];
-
- self.keyboard = [[MLOKeyboardManager alloc]initWithMainViewController:self];
-
- _flasher.alpha = 0.0f;
- _flasher.backgroundColor = [UIColor whiteColor];
-
- self.gestureEngine = nil;
[self addSubviews];
[self onStart];
- _focused =NO;
- _topBarHeight = TOP_BAR_HEIGHT;
+ self.focused = NO;
+ self.topBarHeight = TOP_BAR_HEIGHT;
}
return self;
}
-(void) flash{
- _flasher.frame =self.view.frame;
- _flasher.alpha = 1.0f;
+ self.flasher.frame =self.view.frame;
+ self.flasher.alpha = 1.0f;
[self.view addSubview:_flasher];
[UIView animateWithDuration:FLASH_DURATION animations:^{
- _flasher.alpha=0.0f;
+ self.flasher.alpha=0.0f;
} completion:^(BOOL finished) {
- [_flasher removeFromSuperview];
+ [self.flasher removeFromSuperview];
}];
}
@@ -155,91 +125,50 @@ static const CGFloat
[UIView animateWithDuration:EXPAND_DURATION animations:^(void){
- _canvas.frame = CGRectMake(0, targetHeight, mainFrame.size.width, mainFrame.size.height - targetHeight);
- _renderManager.view.alpha= 0.0f;
+ self.canvas.frame = CGRectMake(0, targetHeight, mainFrame.size.width, mainFrame.size.height - targetHeight);
+ self.renderManager.view.alpha= 0.0f;
} completion:^(BOOL completed){
- _topBarHeight = targetHeight;
+ self.topBarHeight = targetHeight;
[self rotate];
- [_toolbar expandDidToggle];
+ [self.toolbar expandDidToggle];
}];
}
-(void)resize{
CGRect mainViewRect = [self getFullFrameForRect:self.view.bounds];
-
LOG_RECT(mainViewRect, @"MLO Resize: main view");
self.view.bounds = self.view.frame = mainViewRect;
CGFloat width = self.view.frame.size.width;
- CGFloat height = self.view.frame.size.height - _topBarHeight;
+ CGFloat height = self.view.frame.size.height - self.topBarHeight;
CGRect canvasRect =CGRectMake(0, _topBarHeight, width, height);
-
- _canvas.frame = canvasRect;
-
- [_renderManager setWidth:width height:height];
+ self.canvas.frame = canvasRect;
+ [self.role setWidth:width height:height];
LOG_RECT(canvasRect, @"MLO Resize: canvas");
-
-
}
-(void) addSubviews{
- [_topbar addToMainViewController];
-
- [self.view addSubview:_canvas];
-
+ [self.topbar addToMainViewController];
+ [self.view addSubview:self.canvas];
self.view.backgroundColor = [UIColor whiteColor];
- self.renderManager = [MLORenderManager getInstance];
-
- [self resize];
-
- [self.canvas addSubview: _renderManager.view];
-
- self.gestureEngine = [[MLOGestureEngine alloc] initWithMainViewController:self];
- [_toolbar addToMainViewController];
- [_scroller addToMainViewController];
- [_selection addToMainViewController];
- [_keyboard addToMainViewController];
+ [self.role addSubviews];
}
-(void)rotate{
- if(_focused){
-
- NSLog(@"MLO rotate");
-
- _renderManager.view.alpha= 0.0f;
-
- [self resize];
-
- [_gestureEngine onRotate];
-
- [_topbar onRotate];
-
- [_scroller reset];
-
- [_scroller showLibreOffice];
-
- [_selection onRotate];
-
- [_toolbar onRotate];
-
-
- [UIView animateWithDuration:ROTATE_FLASH_DURATION animations:^(void){
- _renderManager.view.alpha=1.0f;
- }];
-
+ if(self.focused){
+ [self.role rotate];
}
}
-
-
-(void)resetSubviews{
+
[_gestureEngine reset];
[_scroller reset];
[_selection reset];