1
0
mirror of https://github.com/danog/Telegram.git synced 2024-12-12 09:29:55 +01:00
Telegram/Telegraph/TGOverlayControllerWindow.m

71 lines
1.9 KiB
Mathematica
Raw Normal View History

2014-07-10 16:11:09 +02:00
/*
* This is the source code of Telegram for iOS v. 1.1
* It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE).
*
* Copyright Peter Iakovlev, 2013.
*/
#import "TGOverlayControllerWindow.h"
#import "TGViewController.h"
#import "TGOverlayController.h"
2015-10-01 18:19:52 +02:00
#import "TGAppDelegate.h"
2014-07-10 16:11:09 +02:00
@interface TGOverlayControllerWindow ()
{
__weak TGViewController *_parentController;
}
@end
@implementation TGOverlayControllerWindow
2015-10-01 18:19:52 +02:00
- (instancetype)initWithParentController:(TGViewController *)parentController contentController:(TGOverlayController *)contentController {
return [self initWithParentController:parentController contentController:contentController keepKeyboard:false];
}
- (instancetype)initWithParentController:(TGViewController *)parentController contentController:(TGOverlayController *)contentController keepKeyboard:(bool)keepKeyboard
2014-07-10 16:11:09 +02:00
{
2015-10-01 18:19:52 +02:00
if (self != nil) {
_keepKeyboard = keepKeyboard;
}
self = [super initWithFrame:TGAppDelegateInstance.rootController.view.bounds];
2014-07-10 16:11:09 +02:00
if (self != nil)
{
2015-10-01 18:19:52 +02:00
_keepKeyboard = keepKeyboard;
self.windowLevel = UIWindowLevelStatusBar - 0.001f;
2014-07-10 16:11:09 +02:00
_parentController = parentController;
[parentController.associatedWindowStack addObject:self];
contentController.overlayWindow = self;
self.rootViewController = contentController;
}
return self;
}
- (void)dealloc
{
[self.rootViewController viewWillDisappear:false];
[self.rootViewController viewDidDisappear:false];
}
- (void)dismiss
{
TGViewController *parentController = _parentController;
[parentController.associatedWindowStack removeObject:self];
2015-10-01 18:19:52 +02:00
self.hidden = true;
}
- (void)setHidden:(BOOL)hidden {
[super setHidden:hidden];
if (!hidden && !_keepKeyboard) {
[TGAppDelegateInstance.window endEditing:true];
}
2014-07-10 16:11:09 +02:00
}
@end