@zulfio/react-native-alarm-kit 1.0.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/Alarmkit.podspec +35 -0
- package/LICENSE +20 -0
- package/README.md +163 -0
- package/android/CMakeLists.txt +24 -0
- package/android/build.gradle +129 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/alarmkit/AlarmkitPackage.kt +22 -0
- package/android/src/main/java/com/margelo/nitro/alarmkit/Alarmkit.kt +7 -0
- package/ios/AlarmKit.swift +296 -0
- package/lib/module/AlarmKit.nitro.js +4 -0
- package/lib/module/AlarmKit.nitro.js.map +1 -0
- package/lib/module/index.js +40 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/AlarmKit.nitro.d.ts +24 -0
- package/lib/typescript/src/AlarmKit.nitro.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +11 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/nitro.json +17 -0
- package/nitrogen/generated/android/alarmkit+autolinking.cmake +78 -0
- package/nitrogen/generated/android/alarmkit+autolinking.gradle +27 -0
- package/nitrogen/generated/android/alarmkitOnLoad.cpp +46 -0
- package/nitrogen/generated/android/alarmkitOnLoad.hpp +25 -0
- package/nitrogen/generated/android/c++/JAlarmCountdown.hpp +57 -0
- package/nitrogen/generated/android/c++/JAlarmWeekday.hpp +74 -0
- package/nitrogen/generated/android/c++/JCustomizableAlarmButton.hpp +61 -0
- package/nitrogen/generated/android/c++/JHybridAlarmKitSpec.cpp +180 -0
- package/nitrogen/generated/android/c++/JHybridAlarmKitSpec.hpp +68 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/alarmkit/AlarmCountdown.kt +27 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/alarmkit/AlarmWeekday.kt +30 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/alarmkit/CustomizableAlarmButton.kt +28 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/alarmkit/HybridAlarmKitSpec.kt +76 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/alarmkit/alarmkitOnLoad.kt +35 -0
- package/nitrogen/generated/ios/AlarmKit+autolinking.rb +60 -0
- package/nitrogen/generated/ios/AlarmKit-Swift-Cxx-Bridge.cpp +72 -0
- package/nitrogen/generated/ios/AlarmKit-Swift-Cxx-Bridge.hpp +309 -0
- package/nitrogen/generated/ios/AlarmKit-Swift-Cxx-Umbrella.hpp +56 -0
- package/nitrogen/generated/ios/AlarmKitAutolinking.mm +33 -0
- package/nitrogen/generated/ios/AlarmKitAutolinking.swift +25 -0
- package/nitrogen/generated/ios/c++/HybridAlarmKitSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridAlarmKitSpecSwift.hpp +130 -0
- package/nitrogen/generated/ios/swift/AlarmCountdown.swift +70 -0
- package/nitrogen/generated/ios/swift/AlarmWeekday.swift +60 -0
- package/nitrogen/generated/ios/swift/CustomizableAlarmButton.swift +57 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__optional_std__string_.swift +52 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_std__string_.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridAlarmKitSpec.swift +54 -0
- package/nitrogen/generated/ios/swift/HybridAlarmKitSpec_cxx.swift +271 -0
- package/nitrogen/generated/shared/c++/AlarmCountdown.hpp +73 -0
- package/nitrogen/generated/shared/c++/AlarmWeekday.hpp +98 -0
- package/nitrogen/generated/shared/c++/CustomizableAlarmButton.hpp +77 -0
- package/nitrogen/generated/shared/c++/HybridAlarmKitSpec.cpp +27 -0
- package/nitrogen/generated/shared/c++/HybridAlarmKitSpec.hpp +79 -0
- package/package.json +168 -0
- package/src/AlarmKit.nitro.ts +48 -0
- package/src/index.tsx +96 -0
package/package.json
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zulfio/react-native-alarm-kit",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "This library provides a simple and modern interface for working with alarms in your React Native app using Apple’s latest AlarmKit framework.",
|
|
5
|
+
"main": "./lib/module/index.js",
|
|
6
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"source": "./src/index.tsx",
|
|
10
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
11
|
+
"default": "./lib/module/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"src",
|
|
17
|
+
"lib",
|
|
18
|
+
"android",
|
|
19
|
+
"ios",
|
|
20
|
+
"cpp",
|
|
21
|
+
"nitrogen",
|
|
22
|
+
"nitro.json",
|
|
23
|
+
"*.podspec",
|
|
24
|
+
"react-native.config.js",
|
|
25
|
+
"!ios/build",
|
|
26
|
+
"!android/build",
|
|
27
|
+
"!android/gradle",
|
|
28
|
+
"!android/gradlew",
|
|
29
|
+
"!android/gradlew.bat",
|
|
30
|
+
"!android/local.properties",
|
|
31
|
+
"!**/__tests__",
|
|
32
|
+
"!**/__fixtures__",
|
|
33
|
+
"!**/__mocks__",
|
|
34
|
+
"!**/.*"
|
|
35
|
+
],
|
|
36
|
+
"scripts": {
|
|
37
|
+
"example": "yarn workspace react-native-alarm-kit-example",
|
|
38
|
+
"test": "jest",
|
|
39
|
+
"typecheck": "tsc",
|
|
40
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
41
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
42
|
+
"prepare": "bob build",
|
|
43
|
+
"nitrogen": "nitro-codegen",
|
|
44
|
+
"release": "release-it --only-version"
|
|
45
|
+
},
|
|
46
|
+
"keywords": [
|
|
47
|
+
"react-native",
|
|
48
|
+
"ios",
|
|
49
|
+
"android"
|
|
50
|
+
],
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "git+https://github.com/raphckrman/react-native-alarm-kit.git"
|
|
54
|
+
},
|
|
55
|
+
"author": "raphckrman <raphckrman@proton.me> (https://github.com/raphckrman)",
|
|
56
|
+
"license": "MIT",
|
|
57
|
+
"bugs": {
|
|
58
|
+
"url": "https://github.com/raphckrman/react-native-alarm-kit/issues"
|
|
59
|
+
},
|
|
60
|
+
"homepage": "https://github.com/raphckrman/react-native-alarm-kit#readme",
|
|
61
|
+
"publishConfig": {
|
|
62
|
+
"registry": "https://registry.npmjs.org/"
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"@commitlint/config-conventional": "^19.6.0",
|
|
66
|
+
"@eslint/compat": "^1.2.7",
|
|
67
|
+
"@eslint/eslintrc": "^3.3.0",
|
|
68
|
+
"@eslint/js": "^9.22.0",
|
|
69
|
+
"@evilmartians/lefthook": "^1.5.0",
|
|
70
|
+
"@react-native/babel-preset": "0.79.2",
|
|
71
|
+
"@react-native/eslint-config": "^0.78.0",
|
|
72
|
+
"@release-it/conventional-changelog": "^9.0.2",
|
|
73
|
+
"@types/jest": "^29.5.5",
|
|
74
|
+
"@types/react": "^19.0.0",
|
|
75
|
+
"commitlint": "^19.6.1",
|
|
76
|
+
"del-cli": "^5.1.0",
|
|
77
|
+
"eslint": "^9.22.0",
|
|
78
|
+
"eslint-config-prettier": "^10.1.1",
|
|
79
|
+
"eslint-plugin-prettier": "^5.2.3",
|
|
80
|
+
"jest": "^29.7.0",
|
|
81
|
+
"nitro-codegen": "^0.26.3",
|
|
82
|
+
"prettier": "^3.0.3",
|
|
83
|
+
"react": "19.0.0",
|
|
84
|
+
"react-native": "0.79.2",
|
|
85
|
+
"react-native-builder-bob": "^0.40.12",
|
|
86
|
+
"react-native-nitro-modules": "^0.26.3",
|
|
87
|
+
"release-it": "^17.10.0",
|
|
88
|
+
"turbo": "^1.10.7",
|
|
89
|
+
"typescript": "^5.8.3"
|
|
90
|
+
},
|
|
91
|
+
"peerDependencies": {
|
|
92
|
+
"react": "*",
|
|
93
|
+
"react-native": "*",
|
|
94
|
+
"react-native-nitro-modules": "^0.26.3"
|
|
95
|
+
},
|
|
96
|
+
"workspaces": [
|
|
97
|
+
"example"
|
|
98
|
+
],
|
|
99
|
+
"packageManager": "yarn@3.6.1",
|
|
100
|
+
"jest": {
|
|
101
|
+
"preset": "react-native",
|
|
102
|
+
"modulePathIgnorePatterns": [
|
|
103
|
+
"<rootDir>/example/node_modules",
|
|
104
|
+
"<rootDir>/lib/"
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
"commitlint": {
|
|
108
|
+
"extends": [
|
|
109
|
+
"@commitlint/config-conventional"
|
|
110
|
+
]
|
|
111
|
+
},
|
|
112
|
+
"release-it": {
|
|
113
|
+
"git": {
|
|
114
|
+
"commitMessage": "chore: release ${version}",
|
|
115
|
+
"tagName": "v${version}"
|
|
116
|
+
},
|
|
117
|
+
"npm": {
|
|
118
|
+
"publish": true
|
|
119
|
+
},
|
|
120
|
+
"github": {
|
|
121
|
+
"release": true
|
|
122
|
+
},
|
|
123
|
+
"plugins": {
|
|
124
|
+
"@release-it/conventional-changelog": {
|
|
125
|
+
"preset": {
|
|
126
|
+
"name": "angular"
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
"prettier": {
|
|
132
|
+
"quoteProps": "consistent",
|
|
133
|
+
"singleQuote": true,
|
|
134
|
+
"tabWidth": 2,
|
|
135
|
+
"trailingComma": "es5",
|
|
136
|
+
"useTabs": false
|
|
137
|
+
},
|
|
138
|
+
"react-native-builder-bob": {
|
|
139
|
+
"source": "src",
|
|
140
|
+
"output": "lib",
|
|
141
|
+
"targets": [
|
|
142
|
+
[
|
|
143
|
+
"custom",
|
|
144
|
+
{
|
|
145
|
+
"script": "nitrogen",
|
|
146
|
+
"clean": "nitrogen/"
|
|
147
|
+
}
|
|
148
|
+
],
|
|
149
|
+
[
|
|
150
|
+
"module",
|
|
151
|
+
{
|
|
152
|
+
"esm": true
|
|
153
|
+
}
|
|
154
|
+
],
|
|
155
|
+
[
|
|
156
|
+
"typescript",
|
|
157
|
+
{
|
|
158
|
+
"project": "tsconfig.build.json"
|
|
159
|
+
}
|
|
160
|
+
]
|
|
161
|
+
]
|
|
162
|
+
},
|
|
163
|
+
"create-react-native-library": {
|
|
164
|
+
"languages": "kotlin-swift",
|
|
165
|
+
"type": "nitro-module",
|
|
166
|
+
"version": "0.51.1"
|
|
167
|
+
}
|
|
168
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
|
+
|
|
3
|
+
export interface AlarmKit
|
|
4
|
+
extends HybridObject<{ ios: 'swift'; android: 'kotlin' }> {
|
|
5
|
+
requestAlarmPermission(): Promise<boolean>;
|
|
6
|
+
scheduleFixedAlarm(
|
|
7
|
+
title: string,
|
|
8
|
+
stopBtn: CustomizableAlarmButton,
|
|
9
|
+
tintColor: string,
|
|
10
|
+
secondaryBtn?: CustomizableAlarmButton,
|
|
11
|
+
timestamp?: number,
|
|
12
|
+
countdown?: AlarmCountdown
|
|
13
|
+
): Promise<string>;
|
|
14
|
+
scheduleRelativeAlarm(
|
|
15
|
+
title: string,
|
|
16
|
+
stopBtn: CustomizableAlarmButton,
|
|
17
|
+
tintColor: string,
|
|
18
|
+
hour: number,
|
|
19
|
+
minute: number,
|
|
20
|
+
repeats: AlarmWeekday[],
|
|
21
|
+
secondaryBtn?: CustomizableAlarmButton,
|
|
22
|
+
countdown?: AlarmCountdown
|
|
23
|
+
): Promise<string>;
|
|
24
|
+
cancelAlarm(id: string): Promise<boolean>;
|
|
25
|
+
cancelAllAlarms(): Promise<boolean>;
|
|
26
|
+
getAlarm(id: string): Promise<string | null>;
|
|
27
|
+
getAllAlarms(): Promise<string[]>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface CustomizableAlarmButton {
|
|
31
|
+
text: string;
|
|
32
|
+
textColor: string;
|
|
33
|
+
icon: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface AlarmCountdown {
|
|
37
|
+
preAlert?: number | null;
|
|
38
|
+
postAlert?: number | null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type AlarmWeekday =
|
|
42
|
+
| 'monday'
|
|
43
|
+
| 'tuesday'
|
|
44
|
+
| 'wednesday'
|
|
45
|
+
| 'thursday'
|
|
46
|
+
| 'friday'
|
|
47
|
+
| 'saturday'
|
|
48
|
+
| 'sunday';
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { NitroModules } from 'react-native-nitro-modules';
|
|
2
|
+
import type {
|
|
3
|
+
AlarmCountdown,
|
|
4
|
+
AlarmKit,
|
|
5
|
+
AlarmWeekday,
|
|
6
|
+
CustomizableAlarmButton,
|
|
7
|
+
} from './AlarmKit.nitro';
|
|
8
|
+
|
|
9
|
+
const AlarmKitHybridObject =
|
|
10
|
+
NitroModules.createHybridObject<AlarmKit>('AlarmKit');
|
|
11
|
+
|
|
12
|
+
export async function requestAlarmPermission(): Promise<boolean> {
|
|
13
|
+
return AlarmKitHybridObject.requestAlarmPermission();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export async function scheduleFixedAlarm(
|
|
17
|
+
title: string,
|
|
18
|
+
stopBtn: CustomizableAlarmButton,
|
|
19
|
+
tintColor: string,
|
|
20
|
+
secondaryBtn?: CustomizableAlarmButton,
|
|
21
|
+
timestamp?: number,
|
|
22
|
+
countdown?: AlarmCountdown
|
|
23
|
+
): Promise<string> {
|
|
24
|
+
if (!timestamp && !countdown)
|
|
25
|
+
throw new Error(
|
|
26
|
+
'You need to specify when the alarm will trigger, use countdown for a timer and timestamp for an alarm.'
|
|
27
|
+
);
|
|
28
|
+
return AlarmKitHybridObject.scheduleFixedAlarm(
|
|
29
|
+
title,
|
|
30
|
+
stopBtn,
|
|
31
|
+
tintColor,
|
|
32
|
+
secondaryBtn,
|
|
33
|
+
timestamp,
|
|
34
|
+
countdown
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export async function scheduleRelativeAlarm(
|
|
39
|
+
title: string,
|
|
40
|
+
stopBtn: CustomizableAlarmButton,
|
|
41
|
+
tintColor: string,
|
|
42
|
+
hour: number,
|
|
43
|
+
minute: number,
|
|
44
|
+
repeats: AlarmWeekday[],
|
|
45
|
+
secondaryBtn?: CustomizableAlarmButton,
|
|
46
|
+
countdown?: AlarmCountdown
|
|
47
|
+
): Promise<string> {
|
|
48
|
+
return AlarmKitHybridObject.scheduleRelativeAlarm(
|
|
49
|
+
title,
|
|
50
|
+
stopBtn,
|
|
51
|
+
tintColor,
|
|
52
|
+
hour,
|
|
53
|
+
minute,
|
|
54
|
+
repeats,
|
|
55
|
+
secondaryBtn,
|
|
56
|
+
countdown
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export async function cancelAlarm(id: string): Promise<boolean> {
|
|
61
|
+
return AlarmKitHybridObject.cancelAlarm(id);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export async function cancelAllAlarms(): Promise<boolean> {
|
|
65
|
+
return AlarmKitHybridObject.cancelAllAlarms();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export async function getAlarm(id: string): Promise<string | null> {
|
|
69
|
+
return AlarmKitHybridObject.getAlarm(id);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export async function getAllAlarms(): Promise<string[]> {
|
|
73
|
+
return AlarmKitHybridObject.getAllAlarms();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export async function createAlarmButton(
|
|
77
|
+
text: string,
|
|
78
|
+
textColor: string,
|
|
79
|
+
icon: string
|
|
80
|
+
): Promise<CustomizableAlarmButton> {
|
|
81
|
+
return {
|
|
82
|
+
text,
|
|
83
|
+
textColor,
|
|
84
|
+
icon,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export async function createAlarmCountdown(
|
|
89
|
+
preAlert: number | null,
|
|
90
|
+
postAlert: number | null
|
|
91
|
+
): Promise<AlarmCountdown> {
|
|
92
|
+
return {
|
|
93
|
+
preAlert,
|
|
94
|
+
postAlert,
|
|
95
|
+
};
|
|
96
|
+
}
|