1
0
mirror of https://github.com/danog/Telegram.git synced 2024-12-03 09:57:46 +01:00
Telegram/Telegraph/TGModernConversationControllerDynamicTypeSignals.m
2015-10-01 19:19:52 +03:00

31 lines
1.0 KiB
Objective-C

#import "TGModernConversationControllerDynamicTypeSignals.h"
@implementation TGModernConversationControllerDynamicTypeSignals
+ (SSignal *)dynamicTypeBaseFontPointSize
{
return [[SSignal alloc] initWithGenerator:^(SSubscriber *subscriber)
{
CGFloat pointSize = [UIFont preferredFontForTextStyle:UIFontTextStyleBody].pointSize;
[subscriber putNext:@(pointSize)];
id observer = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillEnterForegroundNotification object:nil queue:nil usingBlock:^(__unused NSNotification *notification)
{
TGDispatchOnMainThread(^
{
[subscriber putNext:@([UIFont preferredFontForTextStyle:UIFontTextStyleBody].pointSize)];
});
}];
return [[SBlockDisposable alloc] initWithBlock:^
{
TGDispatchOnMainThread(^
{
[[NSNotificationCenter defaultCenter] removeObserver:observer];
});
}];
}];
}
@end