1
0
mirror of https://github.com/danog/Telegram.git synced 2024-12-11 08:59:48 +01:00
Telegram/Telegraph/TGModernConversationControllerDynamicTypeSignals.m

31 lines
1.0 KiB
Mathematica
Raw Normal View History

2015-10-01 18:19:52 +02:00
#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