This commit is contained in:
Yamozha
2021-04-02 02:24:13 +03:00
parent c23950b545
commit 7256d79e2c
31493 changed files with 3036630 additions and 0 deletions

23
node_modules/expo-keep-awake/ios/EXKeepAwake.podspec generated vendored Normal file
View File

@ -0,0 +1,23 @@
require 'json'
package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))
Pod::Spec.new do |s|
s.name = 'EXKeepAwake'
s.version = package['version']
s.summary = package['description']
s.description = package['description']
s.license = package['license']
s.author = package['author']
s.homepage = package['homepage']
s.platform = :ios, '10.0'
s.source = { git: 'https://github.com/expo/expo.git' }
s.source_files = 'EXKeepAwake/**/*.{h,m}'
s.preserve_paths = 'EXKeepAwake/**/*.{h,m}'
s.requires_arc = true
s.dependency 'UMCore'
end

View File

@ -0,0 +1,7 @@
// Copyright 2018-present 650 Industries. All rights reserved.
#import <UMCore/UMExportedModule.h>
#import <UMCore/UMModuleRegistryConsumer.h>
@interface EXKeepAwake : UMExportedModule <UMModuleRegistryConsumer>
@end

View File

@ -0,0 +1,92 @@
// Copyright 2018-present 650 Industries. All rights reserved.
#import <UMCore/UMModuleRegistry.h>
#import <EXKeepAwake/EXKeepAwake.h>
#import <UMCore/UMAppLifecycleService.h>
#import <UMCore/UMUtilities.h>
@interface EXKeepAwake () <UMAppLifecycleListener>
@property (nonatomic, weak) id<UMAppLifecycleService> lifecycleManager;
@property (nonatomic, weak) UMModuleRegistry *moduleRegistry;
@end
@implementation EXKeepAwake {
NSMutableSet *_activeTags;
}
- (instancetype)init {
self = [super init];
_activeTags = [NSMutableSet set];
return self;
}
UM_EXPORT_MODULE(ExpoKeepAwake);
# pragma mark - UMModuleRegistryConsumer
- (void)setModuleRegistry:(UMModuleRegistry *)moduleRegistry
{
if (_moduleRegistry) {
[_lifecycleManager unregisterAppLifecycleListener:self];
}
_lifecycleManager = nil;
if (moduleRegistry) {
_lifecycleManager = [moduleRegistry getModuleImplementingProtocol:@protocol(UMAppLifecycleService)];
}
if (_lifecycleManager) {
[_lifecycleManager registerAppLifecycleListener:self];
}
}
UM_EXPORT_METHOD_AS(activate, activate:(NSString *)tag
resolve:(UMPromiseResolveBlock)resolve
reject:(UMPromiseRejectBlock)reject)
{
if(![self shouldBeActive]) {
[UMUtilities performSynchronouslyOnMainThread:^{
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
}];
}
[_activeTags addObject:tag];
resolve(@YES);
}
UM_EXPORT_METHOD_AS(deactivate, deactivate:(NSString *)tag
resolve:(UMPromiseResolveBlock)resolve
reject:(UMPromiseRejectBlock)reject)
{
[_activeTags removeObject:tag];
if (![self shouldBeActive]) {
[UMUtilities performSynchronouslyOnMainThread:^{
[[UIApplication sharedApplication] setIdleTimerDisabled:NO];
}];
}
resolve(@YES);
}
# pragma mark - UMAppLifecycleListener
- (void)onAppBackgrounded {
[UMUtilities performSynchronouslyOnMainThread:^{
[[UIApplication sharedApplication] setIdleTimerDisabled:NO];
}];
}
- (void)onAppForegrounded {
if ([self shouldBeActive]) {
[UMUtilities performSynchronouslyOnMainThread:^{
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
}];
}
}
- (BOOL)shouldBeActive {
return [_activeTags count] > 0;
}
@end