react-native-timezone 2.3.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +44 -25
- package/android/build.gradle +64 -80
- package/android/generated/java/com/samitha/timezone/NativeTimezoneSpec.java +50 -0
- package/android/generated/jni/CMakeLists.txt +36 -0
- package/android/generated/jni/RNTimezoneSpec-generated.cpp +50 -0
- package/android/generated/jni/RNTimezoneSpec.h +31 -0
- package/android/generated/jni/react/renderer/components/RNTimezoneSpec/RNTimezoneSpecJSI-generated.cpp +48 -0
- package/android/generated/jni/react/renderer/components/RNTimezoneSpec/RNTimezoneSpecJSI.h +94 -0
- package/android/src/main/AndroidManifest.xml +1 -2
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/samitha/timezone/TimezoneModule.kt +86 -0
- package/android/src/main/java/com/samitha/timezone/TimezonePackage.kt +34 -0
- package/ios/Timezone.h +1 -7
- package/ios/Timezone.mm +42 -18
- package/ios/generated/RNTimezoneSpec/RNTimezoneSpec-generated.mm +60 -0
- package/ios/generated/RNTimezoneSpec/RNTimezoneSpec.h +62 -0
- package/ios/generated/RNTimezoneSpecJSI-generated.cpp +48 -0
- package/ios/generated/RNTimezoneSpecJSI.h +94 -0
- package/lib/commonjs/NativeTimezone.js +9 -0
- package/lib/commonjs/NativeTimezone.js.map +1 -0
- package/lib/commonjs/index.js +12 -10
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/NativeTimezone.js +5 -0
- package/lib/module/NativeTimezone.js.map +1 -0
- package/lib/module/index.js +14 -10
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/NativeTimezone.d.ts +10 -0
- package/lib/typescript/commonjs/src/NativeTimezone.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +8 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/NativeTimezone.d.ts +10 -0
- package/lib/typescript/module/src/NativeTimezone.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +8 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/package.json +87 -48
- package/react-native-timezone.podspec +23 -16
- package/react-native.config.js +12 -0
- package/src/NativeTimezone.ts +11 -0
- package/src/index.tsx +15 -0
- package/android/src/main/java/com/samitha/rn/timezone/TimezoneModule.java +0 -41
- package/android/src/main/java/com/samitha/rn/timezone/TimezonePackage.java +0 -28
- package/ios/Timezone.xcodeproj/project.pbxproj +0 -274
- package/ios/Timezone.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -4
- package/ios/Timezone.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/Timezone.xcodeproj/project.xcworkspace/xcuserdata/samitha.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/Timezone.xcodeproj/xcuserdata/samitha.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- package/lib/commonjs/index.d.js +0 -6
- package/lib/commonjs/index.d.js.map +0 -1
- package/lib/module/index.d.js +0 -2
- package/lib/module/index.d.js.map +0 -1
- package/lib/typescript/index.test.d.ts +0 -1
- package/lib/typescript/index.test.d.ts.map +0 -1
- package/src/index.d.ts +0 -5
- package/src/index.js +0 -20
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
package com.samitha.timezone
|
|
2
|
+
|
|
3
|
+
import android.content.ContentResolver
|
|
4
|
+
import android.os.Build
|
|
5
|
+
import android.provider.Settings
|
|
6
|
+
import android.telephony.TelephonyManager
|
|
7
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
8
|
+
import com.facebook.react.bridge.ReactMethod
|
|
9
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
10
|
+
import java.util.TimeZone
|
|
11
|
+
|
|
12
|
+
@ReactModule(name = TimezoneModule.NAME)
|
|
13
|
+
class TimezoneModule(reactContext: ReactApplicationContext) :
|
|
14
|
+
NativeTimezoneSpec(reactContext) {
|
|
15
|
+
|
|
16
|
+
override fun getName(): String = NAME
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* This is a Synchronous method.
|
|
20
|
+
* Checks if the device is set to automatically detect the time zone.
|
|
21
|
+
*/
|
|
22
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
23
|
+
override fun isAutoTimeZoneEnabled(): Boolean? {
|
|
24
|
+
return try {
|
|
25
|
+
val resolver: ContentResolver = reactApplicationContext.contentResolver
|
|
26
|
+
val isLaterThanJelly = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1
|
|
27
|
+
if (isLaterThanJelly) {
|
|
28
|
+
Settings.Global.getInt(resolver, Settings.Global.AUTO_TIME_ZONE, 0) != 0
|
|
29
|
+
} else {
|
|
30
|
+
Settings.System.getInt(resolver, Settings.System.AUTO_TIME_ZONE, 0) != 0
|
|
31
|
+
}
|
|
32
|
+
} catch (e: Exception) {
|
|
33
|
+
null
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* This is a Synchronous method.
|
|
39
|
+
* Retrieves the current time zone ID.
|
|
40
|
+
*/
|
|
41
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
42
|
+
override fun getTimeZone(): String? {
|
|
43
|
+
return try {
|
|
44
|
+
TimeZone.getDefault().id
|
|
45
|
+
} catch (e: Exception) {
|
|
46
|
+
null
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Synchronous method.
|
|
52
|
+
* Gets the region based on the telephony manager's network country ISO.
|
|
53
|
+
*/
|
|
54
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
55
|
+
override fun getRegionByTelephony(): String? {
|
|
56
|
+
return try {
|
|
57
|
+
val telephonyService = reactApplicationContext.getSystemService(ReactApplicationContext.TELEPHONY_SERVICE) as? TelephonyManager
|
|
58
|
+
telephonyService?.networkCountryIso
|
|
59
|
+
} catch (e: Exception) {
|
|
60
|
+
null
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Synchronous method.
|
|
66
|
+
* Retrieves the region based on the device's locale.
|
|
67
|
+
*/
|
|
68
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
69
|
+
override fun getRegionByLocale(): String? {
|
|
70
|
+
return try {
|
|
71
|
+
val configuration = reactApplicationContext.resources.configuration
|
|
72
|
+
val locale = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
|
73
|
+
configuration.locales.get(0)
|
|
74
|
+
} else {
|
|
75
|
+
configuration.locale
|
|
76
|
+
}
|
|
77
|
+
locale.country
|
|
78
|
+
} catch (e: Exception) {
|
|
79
|
+
null
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
companion object {
|
|
84
|
+
const val NAME = "Timezone"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
package com.samitha.timezone
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.BaseReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
7
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
8
|
+
import java.util.HashMap
|
|
9
|
+
|
|
10
|
+
class TimezonePackage : BaseReactPackage() {
|
|
11
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
12
|
+
return if (name == TimezoneModule.NAME) {
|
|
13
|
+
TimezoneModule(reactContext)
|
|
14
|
+
} else {
|
|
15
|
+
null
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
20
|
+
return ReactModuleInfoProvider {
|
|
21
|
+
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
|
|
22
|
+
moduleInfos[TimezoneModule.NAME] = ReactModuleInfo(
|
|
23
|
+
TimezoneModule.NAME,
|
|
24
|
+
TimezoneModule.NAME,
|
|
25
|
+
false, // canOverrideExistingModule
|
|
26
|
+
false, // needsEagerInit
|
|
27
|
+
true, // hasConstants
|
|
28
|
+
false, // isCxxModule
|
|
29
|
+
true // isTurboModule
|
|
30
|
+
)
|
|
31
|
+
moduleInfos
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
package/ios/Timezone.h
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
#
|
|
3
|
-
#import "RNTimezoneSpec.h"
|
|
2
|
+
#import "generated/RNTimezoneSpec/RNTimezoneSpec.h"
|
|
4
3
|
|
|
5
4
|
@interface Timezone : NSObject <NativeTimezoneSpec>
|
|
6
|
-
#else
|
|
7
|
-
#import <React/RCTBridgeModule.h>
|
|
8
|
-
|
|
9
|
-
@interface Timezone : NSObject <RCTBridgeModule>
|
|
10
|
-
#endif
|
|
11
5
|
|
|
12
6
|
@end
|
package/ios/Timezone.mm
CHANGED
|
@@ -1,25 +1,49 @@
|
|
|
1
|
+
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
|
|
2
|
+
#import <CoreTelephony/CTCarrier.h>
|
|
1
3
|
#import "Timezone.h"
|
|
2
4
|
|
|
3
5
|
@implementation Timezone
|
|
4
|
-
RCT_EXPORT_MODULE()
|
|
6
|
+
RCT_EXPORT_MODULE('Timezone');
|
|
7
|
+
/**
|
|
8
|
+
* This is a Synchronous method.
|
|
9
|
+
* Retrieves the current time zone name.
|
|
10
|
+
*/
|
|
11
|
+
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(getTimeZone)
|
|
12
|
+
{
|
|
13
|
+
NSTimeZone *timeZone = [NSTimeZone localTimeZone];
|
|
14
|
+
return timeZone.name;
|
|
15
|
+
}
|
|
5
16
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
{
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Synchronous method.
|
|
19
|
+
* Gets the region based on the telephony manager's network country ISO.
|
|
20
|
+
*/
|
|
21
|
+
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(getRegionByTelephony)
|
|
22
|
+
{
|
|
23
|
+
CTTelephonyNetworkInfo *networkInfo = [[CTTelephonyNetworkInfo alloc] init];
|
|
24
|
+
CTCarrier *carrier = [networkInfo subscriberCellularProvider];
|
|
25
|
+
NSString *isoCountryCode = [carrier isoCountryCode];
|
|
26
|
+
if (isoCountryCode == nil || [isoCountryCode isEqualToString:@""]) {
|
|
27
|
+
return nil;
|
|
28
|
+
}
|
|
29
|
+
return isoCountryCode;
|
|
30
|
+
}
|
|
15
31
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Synchronous method.
|
|
34
|
+
* Retrieves the region based on the device's locale.
|
|
35
|
+
*/
|
|
36
|
+
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(getRegionByLocale)
|
|
37
|
+
{
|
|
38
|
+
NSLocale *locale = [NSLocale currentLocale];
|
|
39
|
+
NSString *countryCode = [locale objectForKey:NSLocaleCountryCode];
|
|
40
|
+
return countryCode;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
44
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
45
|
+
{
|
|
46
|
+
return std::make_shared<facebook::react::NativeTimezoneSpecJSI>(params);
|
|
47
|
+
}
|
|
24
48
|
|
|
25
49
|
@end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleObjCpp
|
|
8
|
+
*
|
|
9
|
+
* We create an umbrella header (and corresponding implementation) here since
|
|
10
|
+
* Cxx compilation in BUCK has a limitation: source-code producing genrule()s
|
|
11
|
+
* must have a single output. More files => more genrule()s => slower builds.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
#import "RNTimezoneSpec.h"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@implementation NativeTimezoneSpecBase
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
- (void)setEventEmitterCallback:(EventEmitterCallbackWrapper *)eventEmitterCallbackWrapper
|
|
21
|
+
{
|
|
22
|
+
_eventEmitterCallback = std::move(eventEmitterCallbackWrapper->_eventEmitterCallback);
|
|
23
|
+
}
|
|
24
|
+
@end
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
namespace facebook::react {
|
|
28
|
+
|
|
29
|
+
static facebook::jsi::Value __hostFunction_NativeTimezoneSpecJSI_getTimeZone(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
30
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, StringKind, "getTimeZone", @selector(getTimeZone), args, count);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static facebook::jsi::Value __hostFunction_NativeTimezoneSpecJSI_getRegionByLocale(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
34
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, StringKind, "getRegionByLocale", @selector(getRegionByLocale), args, count);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static facebook::jsi::Value __hostFunction_NativeTimezoneSpecJSI_getRegionByTelephony(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
38
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, StringKind, "getRegionByTelephony", @selector(getRegionByTelephony), args, count);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static facebook::jsi::Value __hostFunction_NativeTimezoneSpecJSI_isAutoTimeZoneEnabled(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
42
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, BooleanKind, "isAutoTimeZoneEnabled", @selector(isAutoTimeZoneEnabled), args, count);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
NativeTimezoneSpecJSI::NativeTimezoneSpecJSI(const ObjCTurboModule::InitParams ¶ms)
|
|
46
|
+
: ObjCTurboModule(params) {
|
|
47
|
+
|
|
48
|
+
methodMap_["getTimeZone"] = MethodMetadata {0, __hostFunction_NativeTimezoneSpecJSI_getTimeZone};
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
methodMap_["getRegionByLocale"] = MethodMetadata {0, __hostFunction_NativeTimezoneSpecJSI_getRegionByLocale};
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
methodMap_["getRegionByTelephony"] = MethodMetadata {0, __hostFunction_NativeTimezoneSpecJSI_getRegionByTelephony};
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
methodMap_["isAutoTimeZoneEnabled"] = MethodMetadata {0, __hostFunction_NativeTimezoneSpecJSI_isAutoTimeZoneEnabled};
|
|
58
|
+
|
|
59
|
+
}
|
|
60
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleObjCpp
|
|
8
|
+
*
|
|
9
|
+
* We create an umbrella header (and corresponding implementation) here since
|
|
10
|
+
* Cxx compilation in BUCK has a limitation: source-code producing genrule()s
|
|
11
|
+
* must have a single output. More files => more genrule()s => slower builds.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
#ifndef __cplusplus
|
|
15
|
+
#error This file must be compiled as Obj-C++. If you are importing it, you must change your file extension to .mm.
|
|
16
|
+
#endif
|
|
17
|
+
|
|
18
|
+
// Avoid multiple includes of RNTimezoneSpec symbols
|
|
19
|
+
#ifndef RNTimezoneSpec_H
|
|
20
|
+
#define RNTimezoneSpec_H
|
|
21
|
+
|
|
22
|
+
#import <Foundation/Foundation.h>
|
|
23
|
+
#import <RCTRequired/RCTRequired.h>
|
|
24
|
+
#import <RCTTypeSafety/RCTConvertHelpers.h>
|
|
25
|
+
#import <RCTTypeSafety/RCTTypedModuleConstants.h>
|
|
26
|
+
#import <React/RCTBridgeModule.h>
|
|
27
|
+
#import <React/RCTCxxConvert.h>
|
|
28
|
+
#import <React/RCTManagedPointer.h>
|
|
29
|
+
#import <ReactCommon/RCTTurboModule.h>
|
|
30
|
+
#import <optional>
|
|
31
|
+
#import <vector>
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@protocol NativeTimezoneSpec <RCTBridgeModule, RCTTurboModule>
|
|
35
|
+
|
|
36
|
+
- (NSString * _Nullable)getTimeZone;
|
|
37
|
+
- (NSString * _Nullable)getRegionByLocale;
|
|
38
|
+
- (NSString * _Nullable)getRegionByTelephony;
|
|
39
|
+
- (NSNumber * _Nullable)isAutoTimeZoneEnabled;
|
|
40
|
+
|
|
41
|
+
@end
|
|
42
|
+
|
|
43
|
+
@interface NativeTimezoneSpecBase : NSObject {
|
|
44
|
+
@protected
|
|
45
|
+
facebook::react::EventEmitterCallback _eventEmitterCallback;
|
|
46
|
+
}
|
|
47
|
+
- (void)setEventEmitterCallback:(EventEmitterCallbackWrapper *)eventEmitterCallbackWrapper;
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@end
|
|
51
|
+
|
|
52
|
+
namespace facebook::react {
|
|
53
|
+
/**
|
|
54
|
+
* ObjC++ class for module 'NativeTimezone'
|
|
55
|
+
*/
|
|
56
|
+
class JSI_EXPORT NativeTimezoneSpecJSI : public ObjCTurboModule {
|
|
57
|
+
public:
|
|
58
|
+
NativeTimezoneSpecJSI(const ObjCTurboModule::InitParams ¶ms);
|
|
59
|
+
};
|
|
60
|
+
} // namespace facebook::react
|
|
61
|
+
|
|
62
|
+
#endif // RNTimezoneSpec_H
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleCpp.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#include "RNTimezoneSpecJSI.h"
|
|
11
|
+
|
|
12
|
+
namespace facebook::react {
|
|
13
|
+
|
|
14
|
+
static jsi::Value __hostFunction_NativeTimezoneCxxSpecJSI_getTimeZone(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
15
|
+
auto result = static_cast<NativeTimezoneCxxSpecJSI *>(&turboModule)->getTimeZone(
|
|
16
|
+
rt
|
|
17
|
+
);
|
|
18
|
+
return result ? jsi::Value(std::move(*result)) : jsi::Value::null();
|
|
19
|
+
}
|
|
20
|
+
static jsi::Value __hostFunction_NativeTimezoneCxxSpecJSI_getRegionByLocale(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
21
|
+
auto result = static_cast<NativeTimezoneCxxSpecJSI *>(&turboModule)->getRegionByLocale(
|
|
22
|
+
rt
|
|
23
|
+
);
|
|
24
|
+
return result ? jsi::Value(std::move(*result)) : jsi::Value::null();
|
|
25
|
+
}
|
|
26
|
+
static jsi::Value __hostFunction_NativeTimezoneCxxSpecJSI_getRegionByTelephony(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
27
|
+
auto result = static_cast<NativeTimezoneCxxSpecJSI *>(&turboModule)->getRegionByTelephony(
|
|
28
|
+
rt
|
|
29
|
+
);
|
|
30
|
+
return result ? jsi::Value(std::move(*result)) : jsi::Value::null();
|
|
31
|
+
}
|
|
32
|
+
static jsi::Value __hostFunction_NativeTimezoneCxxSpecJSI_isAutoTimeZoneEnabled(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
33
|
+
auto result = static_cast<NativeTimezoneCxxSpecJSI *>(&turboModule)->isAutoTimeZoneEnabled(
|
|
34
|
+
rt
|
|
35
|
+
);
|
|
36
|
+
return result ? jsi::Value(std::move(*result)) : jsi::Value::null();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
NativeTimezoneCxxSpecJSI::NativeTimezoneCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
|
|
40
|
+
: TurboModule("Timezone", jsInvoker) {
|
|
41
|
+
methodMap_["getTimeZone"] = MethodMetadata {0, __hostFunction_NativeTimezoneCxxSpecJSI_getTimeZone};
|
|
42
|
+
methodMap_["getRegionByLocale"] = MethodMetadata {0, __hostFunction_NativeTimezoneCxxSpecJSI_getRegionByLocale};
|
|
43
|
+
methodMap_["getRegionByTelephony"] = MethodMetadata {0, __hostFunction_NativeTimezoneCxxSpecJSI_getRegionByTelephony};
|
|
44
|
+
methodMap_["isAutoTimeZoneEnabled"] = MethodMetadata {0, __hostFunction_NativeTimezoneCxxSpecJSI_isAutoTimeZoneEnabled};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleH.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
#include <ReactCommon/TurboModule.h>
|
|
13
|
+
#include <react/bridging/Bridging.h>
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class JSI_EXPORT NativeTimezoneCxxSpecJSI : public TurboModule {
|
|
19
|
+
protected:
|
|
20
|
+
NativeTimezoneCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
|
|
21
|
+
|
|
22
|
+
public:
|
|
23
|
+
virtual std::optional<jsi::String> getTimeZone(jsi::Runtime &rt) = 0;
|
|
24
|
+
virtual std::optional<jsi::String> getRegionByLocale(jsi::Runtime &rt) = 0;
|
|
25
|
+
virtual std::optional<jsi::String> getRegionByTelephony(jsi::Runtime &rt) = 0;
|
|
26
|
+
virtual std::optional<bool> isAutoTimeZoneEnabled(jsi::Runtime &rt) = 0;
|
|
27
|
+
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
template <typename T>
|
|
31
|
+
class JSI_EXPORT NativeTimezoneCxxSpec : public TurboModule {
|
|
32
|
+
public:
|
|
33
|
+
jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
|
|
34
|
+
return delegate_.get(rt, propName);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static constexpr std::string_view kModuleName = "Timezone";
|
|
38
|
+
|
|
39
|
+
protected:
|
|
40
|
+
NativeTimezoneCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
|
|
41
|
+
: TurboModule(std::string{NativeTimezoneCxxSpec::kModuleName}, jsInvoker),
|
|
42
|
+
delegate_(reinterpret_cast<T*>(this), jsInvoker) {}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
private:
|
|
46
|
+
class Delegate : public NativeTimezoneCxxSpecJSI {
|
|
47
|
+
public:
|
|
48
|
+
Delegate(T *instance, std::shared_ptr<CallInvoker> jsInvoker) :
|
|
49
|
+
NativeTimezoneCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
std::optional<jsi::String> getTimeZone(jsi::Runtime &rt) override {
|
|
54
|
+
static_assert(
|
|
55
|
+
bridging::getParameterCount(&T::getTimeZone) == 1,
|
|
56
|
+
"Expected getTimeZone(...) to have 1 parameters");
|
|
57
|
+
|
|
58
|
+
return bridging::callFromJs<std::optional<jsi::String>>(
|
|
59
|
+
rt, &T::getTimeZone, jsInvoker_, instance_);
|
|
60
|
+
}
|
|
61
|
+
std::optional<jsi::String> getRegionByLocale(jsi::Runtime &rt) override {
|
|
62
|
+
static_assert(
|
|
63
|
+
bridging::getParameterCount(&T::getRegionByLocale) == 1,
|
|
64
|
+
"Expected getRegionByLocale(...) to have 1 parameters");
|
|
65
|
+
|
|
66
|
+
return bridging::callFromJs<std::optional<jsi::String>>(
|
|
67
|
+
rt, &T::getRegionByLocale, jsInvoker_, instance_);
|
|
68
|
+
}
|
|
69
|
+
std::optional<jsi::String> getRegionByTelephony(jsi::Runtime &rt) override {
|
|
70
|
+
static_assert(
|
|
71
|
+
bridging::getParameterCount(&T::getRegionByTelephony) == 1,
|
|
72
|
+
"Expected getRegionByTelephony(...) to have 1 parameters");
|
|
73
|
+
|
|
74
|
+
return bridging::callFromJs<std::optional<jsi::String>>(
|
|
75
|
+
rt, &T::getRegionByTelephony, jsInvoker_, instance_);
|
|
76
|
+
}
|
|
77
|
+
std::optional<bool> isAutoTimeZoneEnabled(jsi::Runtime &rt) override {
|
|
78
|
+
static_assert(
|
|
79
|
+
bridging::getParameterCount(&T::isAutoTimeZoneEnabled) == 1,
|
|
80
|
+
"Expected isAutoTimeZoneEnabled(...) to have 1 parameters");
|
|
81
|
+
|
|
82
|
+
return bridging::callFromJs<std::optional<bool>>(
|
|
83
|
+
rt, &T::isAutoTimeZoneEnabled, jsInvoker_, instance_);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
private:
|
|
87
|
+
friend class NativeTimezoneCxxSpec;
|
|
88
|
+
T *instance_;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
Delegate delegate_;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
var _default = exports.default = _reactNative.TurboModuleRegistry.getEnforcing('Timezone');
|
|
9
|
+
//# sourceMappingURL=NativeTimezone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeTimezone.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAAmD,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GASpCC,gCAAmB,CAACC,YAAY,CAAO,UAAU,CAAC","ignoreList":[]}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -5,15 +5,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _reactNative = require("react-native");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
var _NativeTimezone = _interopRequireDefault(require("./NativeTimezone.js"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
var _default = exports.default = {
|
|
11
|
+
getTimeZone: () => _NativeTimezone.default.getTimeZone(),
|
|
12
|
+
getRegionByLocale: () => _NativeTimezone.default.getRegionByLocale(),
|
|
13
|
+
getRegionByTelephony: () => _NativeTimezone.default.getRegionByTelephony(),
|
|
14
|
+
isAutoTimeZoneEnabled: () => {
|
|
15
|
+
if (_reactNative.Platform.OS === 'android') {
|
|
16
|
+
return _NativeTimezone.default.isAutoTimeZoneEnabled();
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
15
19
|
}
|
|
16
|
-
}
|
|
17
|
-
var _default = Timezone;
|
|
18
|
-
exports.default = _default;
|
|
20
|
+
};
|
|
19
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_NativeTimezone","_interopRequireDefault","e","__esModule","default","_default","exports","getTimeZone","Timezone","getRegionByLocale","getRegionByTelephony","isAutoTimeZoneEnabled","Platform","OS"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAwC,SAAAE,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAF,OAAA,GAEzB;EACbG,WAAW,EAAEA,CAAA,KAAMC,uBAAQ,CAACD,WAAW,CAAC,CAAC;EACzCE,iBAAiB,EAAEA,CAAA,KAAMD,uBAAQ,CAACC,iBAAiB,CAAC,CAAC;EACrDC,oBAAoB,EAAEA,CAAA,KAAMF,uBAAQ,CAACE,oBAAoB,CAAC,CAAC;EAC3DC,qBAAqB,EAAEA,CAAA,KAAM;IAC3B,IAAIC,qBAAQ,CAACC,EAAE,KAAK,SAAS,EAAE;MAC7B,OAAOL,uBAAQ,CAACG,qBAAqB,CAAC,CAAC;IACzC;IACA,OAAO,IAAI;EACb;AACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeTimezone.ts"],"mappings":";;AACA,SAASA,mBAAmB,QAAQ,cAAc;AASlD,eAAeA,mBAAmB,CAACC,YAAY,CAAO,UAAU,CAAC","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { Platform } from 'react-native';
|
|
4
|
+
import Timezone from "./NativeTimezone.js";
|
|
5
|
+
export default {
|
|
6
|
+
getTimeZone: () => Timezone.getTimeZone(),
|
|
7
|
+
getRegionByLocale: () => Timezone.getRegionByLocale(),
|
|
8
|
+
getRegionByTelephony: () => Timezone.getRegionByTelephony(),
|
|
9
|
+
isAutoTimeZoneEnabled: () => {
|
|
10
|
+
if (Platform.OS === 'android') {
|
|
11
|
+
return Timezone.isAutoTimeZoneEnabled();
|
|
12
|
+
}
|
|
13
|
+
return null;
|
|
9
14
|
}
|
|
10
|
-
}
|
|
11
|
-
export default Timezone;
|
|
15
|
+
};
|
|
12
16
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["Platform","Timezone","getTimeZone","getRegionByLocale","getRegionByTelephony","isAutoTimeZoneEnabled","OS"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,OAAOC,QAAQ,MAAM,qBAAkB;AAEvC,eAAe;EACbC,WAAW,EAAEA,CAAA,KAAMD,QAAQ,CAACC,WAAW,CAAC,CAAC;EACzCC,iBAAiB,EAAEA,CAAA,KAAMF,QAAQ,CAACE,iBAAiB,CAAC,CAAC;EACrDC,oBAAoB,EAAEA,CAAA,KAAMH,QAAQ,CAACG,oBAAoB,CAAC,CAAC;EAC3DC,qBAAqB,EAAEA,CAAA,KAAM;IAC3B,IAAIL,QAAQ,CAACM,EAAE,KAAK,SAAS,EAAE;MAC7B,OAAOL,QAAQ,CAACI,qBAAqB,CAAC,CAAC;IACzC;IACA,OAAO,IAAI;EACb;AACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
export interface Spec extends TurboModule {
|
|
3
|
+
getTimeZone(): string | null;
|
|
4
|
+
getRegionByLocale(): string | null;
|
|
5
|
+
getRegionByTelephony(): string | null;
|
|
6
|
+
isAutoTimeZoneEnabled(): boolean | null;
|
|
7
|
+
}
|
|
8
|
+
declare const _default: Spec;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=NativeTimezone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeTimezone.d.ts","sourceRoot":"","sources":["../../../../src/NativeTimezone.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,WAAW,IAAI,MAAM,GAAG,IAAI,CAAC;IAC7B,iBAAiB,IAAI,MAAM,GAAG,IAAI,CAAC;IACnC,oBAAoB,IAAI,MAAM,GAAG,IAAI,CAAC;IACtC,qBAAqB,IAAI,OAAO,GAAG,IAAI,CAAC;CACzC;;AAED,wBAAkE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":";;;;;;AAIA,wBAUE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
export interface Spec extends TurboModule {
|
|
3
|
+
getTimeZone(): string | null;
|
|
4
|
+
getRegionByLocale(): string | null;
|
|
5
|
+
getRegionByTelephony(): string | null;
|
|
6
|
+
isAutoTimeZoneEnabled(): boolean | null;
|
|
7
|
+
}
|
|
8
|
+
declare const _default: Spec;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=NativeTimezone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeTimezone.d.ts","sourceRoot":"","sources":["../../../../src/NativeTimezone.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,WAAW,IAAI,MAAM,GAAG,IAAI,CAAC;IAC7B,iBAAiB,IAAI,MAAM,GAAG,IAAI,CAAC;IACnC,oBAAoB,IAAI,MAAM,GAAG,IAAI,CAAC;IACtC,qBAAqB,IAAI,OAAO,GAAG,IAAI,CAAC;CACzC;;AAED,wBAAkE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":";;;;;;AAIA,wBAUE"}
|