@izonnet-web-solution/react-native-date-time-picker-kit 0.0.0-stage → 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/DateTimePickerKit.podspec +22 -0
- package/LICENSE +20 -0
- package/README.md +532 -2
- package/android/build.gradle +36 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/datetimepickerkit/DatePickerHelper.kt +185 -0
- package/android/src/main/java/com/datetimepickerkit/DateTimePickerHelper.kt +214 -0
- package/android/src/main/java/com/datetimepickerkit/DateTimePickerKitModule.kt +258 -0
- package/android/src/main/java/com/datetimepickerkit/DateTimePickerKitPackage.kt +30 -0
- package/android/src/main/java/com/datetimepickerkit/TimePickerHelper.kt +208 -0
- package/ios/DateTimePickerKit.h +11 -0
- package/ios/DateTimePickerKit.mm +84 -0
- package/ios/DateTimePickerModule.swift +474 -0
- package/lib/module/NativeDateTimePickerKit.js +5 -0
- package/lib/module/NativeDateTimePickerKit.js.map +1 -0
- package/lib/module/components/CalendarPicker.js +414 -0
- package/lib/module/components/CalendarPicker.js.map +1 -0
- package/lib/module/components/ClockPicker.js +273 -0
- package/lib/module/components/ClockPicker.js.map +1 -0
- package/lib/module/components/DatePicker.js +174 -0
- package/lib/module/components/DatePicker.js.map +1 -0
- package/lib/module/components/DateRangePicker.js +154 -0
- package/lib/module/components/DateRangePicker.js.map +1 -0
- package/lib/module/components/DateTimePicker.js +598 -0
- package/lib/module/components/DateTimePicker.js.map +1 -0
- package/lib/module/components/MonthPicker.js +145 -0
- package/lib/module/components/MonthPicker.js.map +1 -0
- package/lib/module/components/TimePicker.js +140 -0
- package/lib/module/components/TimePicker.js.map +1 -0
- package/lib/module/components/TimeSlotPicker.js +118 -0
- package/lib/module/components/TimeSlotPicker.js.map +1 -0
- package/lib/module/components/WheelPicker.js +138 -0
- package/lib/module/components/WheelPicker.js.map +1 -0
- package/lib/module/components/YearPicker.js +151 -0
- package/lib/module/components/YearPicker.js.map +1 -0
- package/lib/module/components/common/ModalWrapper.js +130 -0
- package/lib/module/components/common/ModalWrapper.js.map +1 -0
- package/lib/module/components/common/PickerHeader.js +82 -0
- package/lib/module/components/common/PickerHeader.js.map +1 -0
- package/lib/module/components/common/PresetsBar.js +66 -0
- package/lib/module/components/common/PresetsBar.js.map +1 -0
- package/lib/module/errors/DateTimePickerError.js +12 -0
- package/lib/module/errors/DateTimePickerError.js.map +1 -0
- package/lib/module/hooks/useDateTimePicker.js +73 -0
- package/lib/module/hooks/useDateTimePicker.js.map +1 -0
- package/lib/module/index.js +40 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/localization/index.js +6 -0
- package/lib/module/localization/index.js.map +1 -0
- package/lib/module/localization/locales.js +186 -0
- package/lib/module/localization/locales.js.map +1 -0
- package/lib/module/localization/types.js +2 -0
- package/lib/module/localization/types.js.map +1 -0
- package/lib/module/localization/useLocale.js +126 -0
- package/lib/module/localization/useLocale.js.map +1 -0
- package/lib/module/native/NativeDateTimePicker.js +110 -0
- package/lib/module/native/NativeDateTimePicker.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/presets/datePresets.js +75 -0
- package/lib/module/presets/datePresets.js.map +1 -0
- package/lib/module/presets/index.js +4 -0
- package/lib/module/presets/index.js.map +1 -0
- package/lib/module/slots/index.js +4 -0
- package/lib/module/slots/index.js.map +1 -0
- package/lib/module/slots/timeSlots.js +59 -0
- package/lib/module/slots/timeSlots.js.map +1 -0
- package/lib/module/theme/defaultTheme.js +91 -0
- package/lib/module/theme/defaultTheme.js.map +1 -0
- package/lib/module/theme/index.js +6 -0
- package/lib/module/theme/index.js.map +1 -0
- package/lib/module/theme/types.js +2 -0
- package/lib/module/theme/types.js.map +1 -0
- package/lib/module/theme/useTheme.js +59 -0
- package/lib/module/theme/useTheme.js.map +1 -0
- package/lib/module/types/events.js +4 -0
- package/lib/module/types/events.js.map +1 -0
- package/lib/module/types/index.js +7 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/types/native.js +2 -0
- package/lib/module/types/native.js.map +1 -0
- package/lib/module/types/presentation.js +2 -0
- package/lib/module/types/presentation.js.map +1 -0
- package/lib/module/types/props.js +4 -0
- package/lib/module/types/props.js.map +1 -0
- package/lib/module/utils/constants.js +14 -0
- package/lib/module/utils/constants.js.map +1 -0
- package/lib/module/utils/dateConversion.js +115 -0
- package/lib/module/utils/dateConversion.js.map +1 -0
- package/lib/module/utils/dateFormatting.js +102 -0
- package/lib/module/utils/dateFormatting.js.map +1 -0
- package/lib/module/utils/dateValidation.js +161 -0
- package/lib/module/utils/dateValidation.js.map +1 -0
- package/lib/module/utils/index.js +7 -0
- package/lib/module/utils/index.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/NativeDateTimePickerKit.d.ts +17 -0
- package/lib/typescript/src/NativeDateTimePickerKit.d.ts.map +1 -0
- package/lib/typescript/src/components/CalendarPicker.d.ts +35 -0
- package/lib/typescript/src/components/CalendarPicker.d.ts.map +1 -0
- package/lib/typescript/src/components/ClockPicker.d.ts +22 -0
- package/lib/typescript/src/components/ClockPicker.d.ts.map +1 -0
- package/lib/typescript/src/components/DatePicker.d.ts +32 -0
- package/lib/typescript/src/components/DatePicker.d.ts.map +1 -0
- package/lib/typescript/src/components/DateRangePicker.d.ts +41 -0
- package/lib/typescript/src/components/DateRangePicker.d.ts.map +1 -0
- package/lib/typescript/src/components/DateTimePicker.d.ts +7 -0
- package/lib/typescript/src/components/DateTimePicker.d.ts.map +1 -0
- package/lib/typescript/src/components/MonthPicker.d.ts +21 -0
- package/lib/typescript/src/components/MonthPicker.d.ts.map +1 -0
- package/lib/typescript/src/components/TimePicker.d.ts +25 -0
- package/lib/typescript/src/components/TimePicker.d.ts.map +1 -0
- package/lib/typescript/src/components/TimeSlotPicker.d.ts +18 -0
- package/lib/typescript/src/components/TimeSlotPicker.d.ts.map +1 -0
- package/lib/typescript/src/components/WheelPicker.d.ts +17 -0
- package/lib/typescript/src/components/WheelPicker.d.ts.map +1 -0
- package/lib/typescript/src/components/YearPicker.d.ts +14 -0
- package/lib/typescript/src/components/YearPicker.d.ts.map +1 -0
- package/lib/typescript/src/components/common/ModalWrapper.d.ts +10 -0
- package/lib/typescript/src/components/common/ModalWrapper.d.ts.map +1 -0
- package/lib/typescript/src/components/common/PickerHeader.d.ts +13 -0
- package/lib/typescript/src/components/common/PickerHeader.d.ts.map +1 -0
- package/lib/typescript/src/components/common/PresetsBar.d.ts +12 -0
- package/lib/typescript/src/components/common/PresetsBar.d.ts.map +1 -0
- package/lib/typescript/src/errors/DateTimePickerError.d.ts +7 -0
- package/lib/typescript/src/errors/DateTimePickerError.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useDateTimePicker.d.ts +17 -0
- package/lib/typescript/src/hooks/useDateTimePicker.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +23 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/localization/index.d.ts +4 -0
- package/lib/typescript/src/localization/index.d.ts.map +1 -0
- package/lib/typescript/src/localization/locales.d.ts +12 -0
- package/lib/typescript/src/localization/locales.d.ts.map +1 -0
- package/lib/typescript/src/localization/types.d.ts +23 -0
- package/lib/typescript/src/localization/types.d.ts.map +1 -0
- package/lib/typescript/src/localization/useLocale.d.ts +31 -0
- package/lib/typescript/src/localization/useLocale.d.ts.map +1 -0
- package/lib/typescript/src/native/NativeDateTimePicker.d.ts +14 -0
- package/lib/typescript/src/native/NativeDateTimePicker.d.ts.map +1 -0
- package/lib/typescript/src/presets/datePresets.d.ts +8 -0
- package/lib/typescript/src/presets/datePresets.d.ts.map +1 -0
- package/lib/typescript/src/presets/index.d.ts +2 -0
- package/lib/typescript/src/presets/index.d.ts.map +1 -0
- package/lib/typescript/src/slots/index.d.ts +2 -0
- package/lib/typescript/src/slots/index.d.ts.map +1 -0
- package/lib/typescript/src/slots/timeSlots.d.ts +18 -0
- package/lib/typescript/src/slots/timeSlots.d.ts.map +1 -0
- package/lib/typescript/src/theme/defaultTheme.d.ts +9 -0
- package/lib/typescript/src/theme/defaultTheme.d.ts.map +1 -0
- package/lib/typescript/src/theme/index.d.ts +4 -0
- package/lib/typescript/src/theme/index.d.ts.map +1 -0
- package/lib/typescript/src/theme/types.d.ts +65 -0
- package/lib/typescript/src/theme/types.d.ts.map +1 -0
- package/lib/typescript/src/theme/useTheme.d.ts +4 -0
- package/lib/typescript/src/theme/useTheme.d.ts.map +1 -0
- package/lib/typescript/src/types/events.d.ts +8 -0
- package/lib/typescript/src/types/events.d.ts.map +1 -0
- package/lib/typescript/src/types/index.d.ts +5 -0
- package/lib/typescript/src/types/index.d.ts.map +1 -0
- package/lib/typescript/src/types/native.d.ts +26 -0
- package/lib/typescript/src/types/native.d.ts.map +1 -0
- package/lib/typescript/src/types/presentation.d.ts +19 -0
- package/lib/typescript/src/types/presentation.d.ts.map +1 -0
- package/lib/typescript/src/types/props.d.ts +68 -0
- package/lib/typescript/src/types/props.d.ts.map +1 -0
- package/lib/typescript/src/utils/constants.d.ts +12 -0
- package/lib/typescript/src/utils/constants.d.ts.map +1 -0
- package/lib/typescript/src/utils/dateConversion.d.ts +27 -0
- package/lib/typescript/src/utils/dateConversion.d.ts.map +1 -0
- package/lib/typescript/src/utils/dateFormatting.d.ts +8 -0
- package/lib/typescript/src/utils/dateFormatting.d.ts.map +1 -0
- package/lib/typescript/src/utils/dateValidation.d.ts +46 -0
- package/lib/typescript/src/utils/dateValidation.d.ts.map +1 -0
- package/lib/typescript/src/utils/index.d.ts +5 -0
- package/lib/typescript/src/utils/index.d.ts.map +1 -0
- package/package.json +183 -4
- package/src/NativeDateTimePickerKit.ts +19 -0
- package/src/components/CalendarPicker.tsx +593 -0
- package/src/components/ClockPicker.tsx +403 -0
- package/src/components/DatePicker.tsx +246 -0
- package/src/components/DateRangePicker.tsx +226 -0
- package/src/components/DateTimePicker.tsx +862 -0
- package/src/components/MonthPicker.tsx +216 -0
- package/src/components/TimePicker.tsx +190 -0
- package/src/components/TimeSlotPicker.tsx +163 -0
- package/src/components/WheelPicker.tsx +199 -0
- package/src/components/YearPicker.tsx +228 -0
- package/src/components/common/ModalWrapper.tsx +184 -0
- package/src/components/common/PickerHeader.tsx +121 -0
- package/src/components/common/PresetsBar.tsx +104 -0
- package/src/errors/DateTimePickerError.ts +29 -0
- package/src/hooks/useDateTimePicker.ts +100 -0
- package/src/index.tsx +92 -0
- package/src/localization/index.ts +3 -0
- package/src/localization/locales.ts +499 -0
- package/src/localization/types.ts +21 -0
- package/src/localization/useLocale.ts +137 -0
- package/src/native/NativeDateTimePicker.ts +154 -0
- package/src/presets/datePresets.ts +97 -0
- package/src/presets/index.ts +1 -0
- package/src/slots/index.ts +1 -0
- package/src/slots/timeSlots.ts +89 -0
- package/src/theme/defaultTheme.ts +102 -0
- package/src/theme/index.ts +3 -0
- package/src/theme/types.ts +70 -0
- package/src/theme/useTheme.ts +75 -0
- package/src/types/events.ts +8 -0
- package/src/types/index.ts +4 -0
- package/src/types/native.ts +28 -0
- package/src/types/presentation.ts +21 -0
- package/src/types/props.ts +104 -0
- package/src/utils/constants.ts +15 -0
- package/src/utils/dateConversion.ts +127 -0
- package/src/utils/dateFormatting.ts +166 -0
- package/src/utils/dateValidation.ts +178 -0
- package/src/utils/index.ts +4 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
package com.datetimepickerkit
|
|
2
|
+
|
|
3
|
+
import android.app.TimePickerDialog
|
|
4
|
+
import android.content.Context
|
|
5
|
+
import android.text.format.DateFormat
|
|
6
|
+
import android.widget.TimePicker
|
|
7
|
+
import com.facebook.react.bridge.Arguments
|
|
8
|
+
import com.facebook.react.bridge.Promise
|
|
9
|
+
import com.facebook.react.bridge.ReadableMap
|
|
10
|
+
import com.facebook.react.bridge.WritableMap
|
|
11
|
+
import java.util.Calendar
|
|
12
|
+
import java.util.Locale
|
|
13
|
+
import java.util.TimeZone
|
|
14
|
+
|
|
15
|
+
class TimePickerHelper(
|
|
16
|
+
private val context: Context,
|
|
17
|
+
private val options: ReadableMap,
|
|
18
|
+
private val promise: Promise,
|
|
19
|
+
private val onDismissCallback: () -> Unit
|
|
20
|
+
) {
|
|
21
|
+
private var isHandled = false
|
|
22
|
+
private var timePickerDialog: TimePickerDialog? = null
|
|
23
|
+
private val calendar = Calendar.getInstance()
|
|
24
|
+
private var currentHour = 0
|
|
25
|
+
private var currentMinute = 0
|
|
26
|
+
|
|
27
|
+
fun show(): TimePickerDialog {
|
|
28
|
+
val initialTimestamp = if (options.hasKey("value") && !options.isNull("value")) {
|
|
29
|
+
options.getDouble("value").toLong()
|
|
30
|
+
} else {
|
|
31
|
+
System.currentTimeMillis()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (options.hasKey("timeZoneOffsetInMinutes") && !options.isNull("timeZoneOffsetInMinutes")) {
|
|
35
|
+
val offsetMinutes = options.getInt("timeZoneOffsetInMinutes")
|
|
36
|
+
val sign = if (offsetMinutes < 0) "-" else "+"
|
|
37
|
+
val absOffset = Math.abs(offsetMinutes)
|
|
38
|
+
val hours = absOffset / 60
|
|
39
|
+
val minutes = absOffset % 60
|
|
40
|
+
val tz = TimeZone.getTimeZone(String.format(Locale.US, "GMT%s%02d:%02d", sign, hours, minutes))
|
|
41
|
+
calendar.timeZone = tz
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
calendar.timeInMillis = initialTimestamp
|
|
45
|
+
|
|
46
|
+
currentHour = calendar.get(Calendar.HOUR_OF_DAY)
|
|
47
|
+
currentMinute = calendar.get(Calendar.MINUTE)
|
|
48
|
+
|
|
49
|
+
// Minute interval snapping
|
|
50
|
+
val minuteInterval = if (options.hasKey("minuteInterval") && !options.isNull("minuteInterval")) {
|
|
51
|
+
options.getInt("minuteInterval")
|
|
52
|
+
} else {
|
|
53
|
+
1
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (minuteInterval > 1) {
|
|
57
|
+
val remainder = currentMinute % minuteInterval
|
|
58
|
+
if (remainder != 0) {
|
|
59
|
+
currentMinute = if (remainder >= minuteInterval / 2) {
|
|
60
|
+
(currentMinute + (minuteInterval - remainder)).coerceAtMost(59)
|
|
61
|
+
} else {
|
|
62
|
+
currentMinute - remainder
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
val is24Hour = if (options.hasKey("is24Hour") && !options.isNull("is24Hour")) {
|
|
68
|
+
options.getBoolean("is24Hour")
|
|
69
|
+
} else {
|
|
70
|
+
DateFormat.is24HourFormat(context)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
val display = if (options.hasKey("display") && !options.isNull("display")) {
|
|
74
|
+
options.getString("display")
|
|
75
|
+
} else {
|
|
76
|
+
"default"
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
val themeId = when (display) {
|
|
80
|
+
"spinner" -> android.R.style.Theme_DeviceDefault_Dialog_Alert
|
|
81
|
+
else -> 0
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
val dialog = if (themeId != 0) {
|
|
85
|
+
TimePickerDialog(context, themeId, { _: TimePicker, hourOfDay: Int, minute: Int ->
|
|
86
|
+
if (!isHandled) {
|
|
87
|
+
isHandled = true
|
|
88
|
+
currentHour = hourOfDay
|
|
89
|
+
currentMinute = snapMinute(minute, minuteInterval)
|
|
90
|
+
calendar.set(Calendar.HOUR_OF_DAY, currentHour)
|
|
91
|
+
calendar.set(Calendar.MINUTE, currentMinute)
|
|
92
|
+
calendar.set(Calendar.SECOND, 0)
|
|
93
|
+
calendar.set(Calendar.MILLISECOND, 0)
|
|
94
|
+
resolveSuccess("confirmed", calendar.timeInMillis)
|
|
95
|
+
}
|
|
96
|
+
}, currentHour, currentMinute, is24Hour)
|
|
97
|
+
} else {
|
|
98
|
+
TimePickerDialog(context, { _: TimePicker, hourOfDay: Int, minute: Int ->
|
|
99
|
+
if (!isHandled) {
|
|
100
|
+
isHandled = true
|
|
101
|
+
currentHour = hourOfDay
|
|
102
|
+
currentMinute = snapMinute(minute, minuteInterval)
|
|
103
|
+
calendar.set(Calendar.HOUR_OF_DAY, currentHour)
|
|
104
|
+
calendar.set(Calendar.MINUTE, currentMinute)
|
|
105
|
+
calendar.set(Calendar.SECOND, 0)
|
|
106
|
+
calendar.set(Calendar.MILLISECOND, 0)
|
|
107
|
+
resolveSuccess("confirmed", calendar.timeInMillis)
|
|
108
|
+
}
|
|
109
|
+
}, currentHour, currentMinute, is24Hour)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Custom title
|
|
113
|
+
if (options.hasKey("title") && !options.isNull("title")) {
|
|
114
|
+
val title = options.getString("title")
|
|
115
|
+
if (!title.isNullOrEmpty()) {
|
|
116
|
+
dialog.setTitle(title)
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Custom buttons
|
|
121
|
+
if (options.hasKey("confirmText") && !options.isNull("confirmText")) {
|
|
122
|
+
val confirmText = options.getString("confirmText")
|
|
123
|
+
if (!confirmText.isNullOrEmpty()) {
|
|
124
|
+
dialog.setButton(TimePickerDialog.BUTTON_POSITIVE, confirmText, dialog)
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (options.hasKey("cancelText") && !options.isNull("cancelText")) {
|
|
129
|
+
val cancelText = options.getString("cancelText")
|
|
130
|
+
if (!cancelText.isNullOrEmpty()) {
|
|
131
|
+
dialog.setButton(TimePickerDialog.BUTTON_NEGATIVE, cancelText, dialog)
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
dialog.setOnCancelListener {
|
|
136
|
+
if (!isHandled) {
|
|
137
|
+
isHandled = true
|
|
138
|
+
resolveSuccess("cancelled", initialTimestamp)
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
dialog.setOnDismissListener {
|
|
143
|
+
onDismissCallback()
|
|
144
|
+
if (!isHandled) {
|
|
145
|
+
isHandled = true
|
|
146
|
+
resolveSuccess("dismissed", initialTimestamp)
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
timePickerDialog = dialog
|
|
151
|
+
dialog.show()
|
|
152
|
+
return dialog
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
fun updateSelectedTime(timestamp: Long) {
|
|
156
|
+
calendar.timeInMillis = timestamp
|
|
157
|
+
currentHour = calendar.get(Calendar.HOUR_OF_DAY)
|
|
158
|
+
currentMinute = calendar.get(Calendar.MINUTE)
|
|
159
|
+
timePickerDialog?.updateTime(currentHour, currentMinute)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
fun confirmAndDismiss(): Long {
|
|
163
|
+
val ts = getSelectedTimestamp()
|
|
164
|
+
if (!isHandled) {
|
|
165
|
+
isHandled = true
|
|
166
|
+
timePickerDialog?.dismiss()
|
|
167
|
+
resolveSuccess("confirmed", ts)
|
|
168
|
+
} else {
|
|
169
|
+
timePickerDialog?.dismiss()
|
|
170
|
+
}
|
|
171
|
+
return ts
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
fun cancelAndDismiss() {
|
|
175
|
+
if (!isHandled) {
|
|
176
|
+
isHandled = true
|
|
177
|
+
timePickerDialog?.cancel()
|
|
178
|
+
resolveSuccess("cancelled", initialTimestamp)
|
|
179
|
+
} else {
|
|
180
|
+
timePickerDialog?.cancel()
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
fun getSelectedTimestamp(): Long {
|
|
185
|
+
calendar.set(Calendar.HOUR_OF_DAY, currentHour)
|
|
186
|
+
calendar.set(Calendar.MINUTE, currentMinute)
|
|
187
|
+
return calendar.timeInMillis
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
private fun snapMinute(minute: Int, interval: Int): Int {
|
|
191
|
+
if (interval <= 1) return minute
|
|
192
|
+
val remainder = minute % interval
|
|
193
|
+
return if (remainder == 0) {
|
|
194
|
+
minute
|
|
195
|
+
} else if (remainder >= interval / 2) {
|
|
196
|
+
(minute + (interval - remainder)).coerceAtMost(59)
|
|
197
|
+
} else {
|
|
198
|
+
minute - remainder
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
private fun resolveSuccess(action: String, timestamp: Long) {
|
|
203
|
+
val map: WritableMap = Arguments.createMap()
|
|
204
|
+
map.putString("action", action)
|
|
205
|
+
map.putDouble("timestamp", timestamp.toDouble())
|
|
206
|
+
promise.resolve(map)
|
|
207
|
+
}
|
|
208
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#if __has_include(<DateTimePickerKitSpec/DateTimePickerKitSpec.h>)
|
|
2
|
+
#import <DateTimePickerKitSpec/DateTimePickerKitSpec.h>
|
|
3
|
+
#elif __has_include(<ReactCodegen/DateTimePickerKitSpec/DateTimePickerKitSpec.h>)
|
|
4
|
+
#import <ReactCodegen/DateTimePickerKitSpec/DateTimePickerKitSpec.h>
|
|
5
|
+
#else
|
|
6
|
+
#import "DateTimePickerKitSpec.h"
|
|
7
|
+
#endif
|
|
8
|
+
|
|
9
|
+
@interface DateTimePickerKit : NSObject <NativeDateTimePickerKitSpec>
|
|
10
|
+
|
|
11
|
+
@end
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
#import "DateTimePickerKit.h"
|
|
2
|
+
|
|
3
|
+
#if __has_include(<DateTimePickerKit/DateTimePickerKit-Swift.h>)
|
|
4
|
+
#import <DateTimePickerKit/DateTimePickerKit-Swift.h>
|
|
5
|
+
#elif __has_include("DateTimePickerKit-Swift.h")
|
|
6
|
+
#import "DateTimePickerKit-Swift.h"
|
|
7
|
+
#endif
|
|
8
|
+
|
|
9
|
+
@implementation DateTimePickerKit
|
|
10
|
+
|
|
11
|
+
RCT_EXPORT_MODULE(DateTimePickerKit)
|
|
12
|
+
|
|
13
|
+
- (void)openDatePicker:(NSDictionary *)options
|
|
14
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
15
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
16
|
+
{
|
|
17
|
+
[[DateTimePickerKitImpl shared] openDatePickerWithOptions:options resolve:resolve reject:reject];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
- (void)openTimePicker:(NSDictionary *)options
|
|
21
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
22
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
23
|
+
{
|
|
24
|
+
[[DateTimePickerKitImpl shared] openTimePickerWithOptions:options resolve:resolve reject:reject];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
- (void)openDateTimePicker:(NSDictionary *)options
|
|
28
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
29
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
30
|
+
{
|
|
31
|
+
[[DateTimePickerKitImpl shared] openDateTimePickerWithOptions:options resolve:resolve reject:reject];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
- (void)openCountdownPicker:(NSDictionary *)options
|
|
35
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
36
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
37
|
+
{
|
|
38
|
+
[[DateTimePickerKitImpl shared] openCountdownPickerWithOptions:options resolve:resolve reject:reject];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
- (void)closePicker:(RCTPromiseResolveBlock)resolve
|
|
42
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
43
|
+
{
|
|
44
|
+
[[DateTimePickerKitImpl shared] closePickerWithResolve:resolve reject:reject];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
- (void)confirmPicker:(RCTPromiseResolveBlock)resolve
|
|
48
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
49
|
+
{
|
|
50
|
+
[[DateTimePickerKitImpl shared] confirmPickerWithResolve:resolve reject:reject];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
- (void)cancelPicker:(RCTPromiseResolveBlock)resolve
|
|
54
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
55
|
+
{
|
|
56
|
+
[[DateTimePickerKitImpl shared] cancelPickerWithResolve:resolve reject:reject];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
- (void)setSelectedDate:(double)timestamp
|
|
60
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
61
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
62
|
+
{
|
|
63
|
+
[[DateTimePickerKitImpl shared] setSelectedDate:timestamp resolve:resolve reject:reject];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
- (void)getSelectedDate:(RCTPromiseResolveBlock)resolve
|
|
67
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
68
|
+
{
|
|
69
|
+
[[DateTimePickerKitImpl shared] getSelectedDateWithResolve:resolve reject:reject];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
- (void)resetPicker:(RCTPromiseResolveBlock)resolve
|
|
73
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
74
|
+
{
|
|
75
|
+
[[DateTimePickerKitImpl shared] resetPickerWithResolve:resolve reject:reject];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
79
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
80
|
+
{
|
|
81
|
+
return std::make_shared<facebook::react::NativeDateTimePickerKitSpecJSI>(params);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@end
|