mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
68 lines
1.2 KiB
Objective-C
68 lines
1.2 KiB
Objective-C
#import "NavigationBarProxy.h"
|
|
|
|
@interface NavigationBarProxy ()
|
|
{
|
|
NSArray *_items;
|
|
}
|
|
|
|
@end
|
|
|
|
@implementation NavigationBarProxy
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
{
|
|
self = [super initWithFrame:frame];
|
|
if (self != nil)
|
|
{
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)pushNavigationItem:(UINavigationItem *)item animated:(BOOL)animated
|
|
{
|
|
[self setItems:[[self items] arrayByAddingObject:item] animated:animated];
|
|
}
|
|
|
|
- (UINavigationItem *)popNavigationItemAnimated:(BOOL)animated
|
|
{
|
|
NSMutableArray *items = [[NSMutableArray alloc] initWithArray:[self items]];
|
|
UINavigationItem *lastItem = [items lastObject];
|
|
[items removeLastObject];
|
|
[self setItems:items animated:animated];
|
|
return lastItem;
|
|
}
|
|
|
|
- (UINavigationItem *)topItem
|
|
{
|
|
return [[self items] lastObject];
|
|
}
|
|
|
|
- (UINavigationItem *)backItem
|
|
{
|
|
NSLog(@"backItem");
|
|
return nil;
|
|
}
|
|
|
|
- (NSArray *)items
|
|
{
|
|
if (_items == nil)
|
|
return @[];
|
|
return _items;
|
|
}
|
|
|
|
- (void)setItems:(NSArray *)items
|
|
{
|
|
[self setItems:items animated:false];
|
|
}
|
|
|
|
- (void)setItems:(NSArray *)items animated:(BOOL)animated
|
|
{
|
|
NSArray *previousItems = _items;
|
|
_items = items;
|
|
|
|
if (_setItemsProxy)
|
|
_setItemsProxy(previousItems, items, animated);
|
|
}
|
|
|
|
@end
|