@ledvance/base 1.1.72 → 1.1.74
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/package.json +1 -1
- package/src/components/Stepper.tsx +121 -0
- package/src/i18n/strings.ts +12 -12
- package/src/res/ic_minus.png +0 -0
- package/src/res/ic_minus@2x.png +0 -0
- package/src/res/ic_minus@3x.png +0 -0
- package/src/res/ic_plus.png +0 -0
- package/src/res/ic_plus@2x.png +0 -0
- package/src/res/ic_plus@3x.png +0 -0
- package/src/res/index.ts +3 -1
package/package.json
CHANGED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { exchangeNumber, localeNumber } from "@ledvance/base/src/utils/common";
|
|
2
|
+
import res from "@res";
|
|
3
|
+
import { useReactive } from "ahooks";
|
|
4
|
+
import React, { memo, useCallback } from "react";
|
|
5
|
+
import { TouchableOpacity, View, Image, TextInput, StyleSheet, StyleProp, ViewStyle } from "react-native";
|
|
6
|
+
import { Utils } from "tuya-panel-kit";
|
|
7
|
+
|
|
8
|
+
const { add, subtract, inMaxMin} = Utils.NumberUtils
|
|
9
|
+
|
|
10
|
+
const { convertX: cx } = Utils.RatioUtils
|
|
11
|
+
|
|
12
|
+
export interface StepperProps {
|
|
13
|
+
value: number | string
|
|
14
|
+
stepValue?: number // 1
|
|
15
|
+
min?: number // 0
|
|
16
|
+
max?: number // 99
|
|
17
|
+
editable?: boolean
|
|
18
|
+
selectionColor?: string
|
|
19
|
+
onValueChange?: ((value: number) => void)
|
|
20
|
+
disabled?: boolean
|
|
21
|
+
style?: StyleProp<ViewStyle>
|
|
22
|
+
buttonStyle?: StyleProp<ViewStyle>
|
|
23
|
+
inputStyle?: StyleProp<ViewStyle>
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const Stepper = (props: StepperProps) => {
|
|
27
|
+
const state = useReactive({
|
|
28
|
+
value: localeNumber(Number(props.value), 1) ?? 0,
|
|
29
|
+
stepValue: props.stepValue ?? 1,
|
|
30
|
+
min: props.min ?? 0,
|
|
31
|
+
max: props.max ?? 99
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
const handlePress = useCallback((isAdd: boolean) => {
|
|
35
|
+
const v = inMaxMin(state.min, state.max, isAdd ? add(Number(exchangeNumber(state.value)), state.stepValue) : subtract(Number(exchangeNumber(state.value)), state.stepValue))
|
|
36
|
+
state.value = localeNumber(v, 1)
|
|
37
|
+
props.onValueChange && props.onValueChange(v)
|
|
38
|
+
}, [])
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
const handleChangeText = useCallback((v: string) =>{
|
|
42
|
+
const newValue = exchangeNumber(v)
|
|
43
|
+
const idx = newValue.indexOf('.')
|
|
44
|
+
if(newValue[0] === '.' ||
|
|
45
|
+
(newValue.length === 2 && newValue[0] === '0' && newValue[1] !== '.') ||
|
|
46
|
+
newValue.split('').filter(item => item === '.').length > 1 ||
|
|
47
|
+
Number(newValue) > state.max || Number(newValue) < state.min ||
|
|
48
|
+
(idx !== -1 && newValue.length > idx + 2)){
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
state.value = v
|
|
52
|
+
}, [])
|
|
53
|
+
|
|
54
|
+
const handleEndText = useCallback(() =>{
|
|
55
|
+
if (typeof state.value === 'string' && !state.value.length) {
|
|
56
|
+
props.onValueChange && props.onValueChange(state.min)
|
|
57
|
+
state.value = state.min.toString()
|
|
58
|
+
}else{
|
|
59
|
+
props.onValueChange && props.onValueChange(Number(exchangeNumber(state.value)))
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
}, [])
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<View style={[styles.stepperContainer, props.style]}>
|
|
66
|
+
<TouchableOpacity
|
|
67
|
+
style={[styles.stepperButton, props.buttonStyle]}
|
|
68
|
+
onPress={() => handlePress(false)}
|
|
69
|
+
>
|
|
70
|
+
<Image width={cx(16)} height={cx(16)} source={res.ic_minus} />
|
|
71
|
+
</TouchableOpacity>
|
|
72
|
+
<TextInput
|
|
73
|
+
style={[styles.stepperInput, props.inputStyle]}
|
|
74
|
+
value={state.value.toString()}
|
|
75
|
+
keyboardType="numeric"
|
|
76
|
+
onChangeText={handleChangeText}
|
|
77
|
+
maxLength={4}
|
|
78
|
+
enablesReturnKeyAutomatically={true}
|
|
79
|
+
onEndEditing={handleEndText}
|
|
80
|
+
editable={props.editable || props.disabled}
|
|
81
|
+
/>
|
|
82
|
+
<TouchableOpacity
|
|
83
|
+
style={[styles.stepperButton, props.buttonStyle]}
|
|
84
|
+
onPress={() => handlePress(true)}
|
|
85
|
+
>
|
|
86
|
+
<Image style={{ width: cx(20), height: cx(20) }} source={res.ic_plus} />
|
|
87
|
+
</TouchableOpacity>
|
|
88
|
+
</View>
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const styles = StyleSheet.create({
|
|
93
|
+
stepperContainer: {
|
|
94
|
+
flexDirection: 'row',
|
|
95
|
+
alignItems: 'center',
|
|
96
|
+
backgroundColor: '#f5f5f5',
|
|
97
|
+
padding: cx(2),
|
|
98
|
+
borderRadius: cx(12),
|
|
99
|
+
width: cx(150),
|
|
100
|
+
},
|
|
101
|
+
stepperButton: {
|
|
102
|
+
width: cx(52),
|
|
103
|
+
height: cx(28),
|
|
104
|
+
backgroundColor: '#fff',
|
|
105
|
+
borderRadius: cx(10),
|
|
106
|
+
alignItems: 'center',
|
|
107
|
+
justifyContent: 'center',
|
|
108
|
+
},
|
|
109
|
+
stepperInput: {
|
|
110
|
+
width: cx(42),
|
|
111
|
+
height: cx(22),
|
|
112
|
+
color: '#333',
|
|
113
|
+
fontSize: cx(16),
|
|
114
|
+
padding: 0,
|
|
115
|
+
alignItems: 'center',
|
|
116
|
+
justifyContent: 'center',
|
|
117
|
+
textAlign: 'center',
|
|
118
|
+
}
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
export default memo(Stepper)
|
package/src/i18n/strings.ts
CHANGED
|
@@ -231,7 +231,7 @@ export default {
|
|
|
231
231
|
cancel_dialog_delete_item_wakeupschedule_answer_no_text: "لا",
|
|
232
232
|
cancel_dialog_delete_item_wakeupschedule_answer_yes_text: "نعم",
|
|
233
233
|
cancel_dialog_delete_item_wakeupschedule_description: "لاحظ أنه لا يمكنك استردادها.",
|
|
234
|
-
randomtimecycle_empty_bttn_text: "
|
|
234
|
+
randomtimecycle_empty_bttn_text: "إضافة دورة زمنية عشوائية",
|
|
235
235
|
randomtimecycle_empty_information_text: "لم تقم بإضافة دورة زمنية عشوائية حتى الآن.",
|
|
236
236
|
conflict_dialog_save_item_randomtimecycle_tips: "معلومات مهمة",
|
|
237
237
|
conflict_dialog_save_item_randomtimecycle_interval_description: "يجب أن تكون هناك 30 دقيقة على الأقل بين وقتي البدء والانتهاء.",
|
|
@@ -381,7 +381,7 @@ export default {
|
|
|
381
381
|
ceiling_fan_direction_info_headline: "معلومات الاتجاه",
|
|
382
382
|
ceiling_fan_direction_info_option_1_text: "باستخدام هذا الإعداد، تقوم المروحة بنفخ الهواء لأسفل. تخلق حركة الهواء الناتجة شعورًا بالبرودة.",
|
|
383
383
|
ceiling_fan_direction_info_option_2_text: "مع هذا الإعداد، تدور المروحة في الاتجاه المعاكس. تؤدي حركة الهواء الناتجة إلى تدفق الهواء الدافئ المتراكم على السقف نحو الأرض.",
|
|
384
|
-
ceiling_fan_feature_2_fan_text_hour_off: "يتم ايقاف التشغيل خلال{0} h {1} min",
|
|
384
|
+
ceiling_fan_feature_2_fan_text_hour_off: "يتم ايقاف التشغيل خلال {0} h {1} min",
|
|
385
385
|
ceiling_fan_feature_2_fan_text_hour_on: "تشغيل المروحة خلال {0} h {1} min",
|
|
386
386
|
ceiling_fan_feature_2_fan_text_min_off: "يتم ايقاف المروحة خلال {0} min",
|
|
387
387
|
ceiling_fan_feature_2_fan_text_min_on: "تشغيل المروحة خلال {0} min",
|
|
@@ -4502,12 +4502,12 @@ export default {
|
|
|
4502
4502
|
mesh_device_detail_lighting_work: "Travail",
|
|
4503
4503
|
mesh_device_detail_mode: "Ambiance",
|
|
4504
4504
|
mesh_device_seting_delete: "Supprimer",
|
|
4505
|
-
mood_overview_add_mood_text: "
|
|
4506
|
-
mood_overview_add_mood_text2: "
|
|
4507
|
-
mood_overview_field_chip_2: "
|
|
4505
|
+
mood_overview_add_mood_text: "Ajouter une ambiance statique",
|
|
4506
|
+
mood_overview_add_mood_text2: "Ajoutez une ambiance dynamique",
|
|
4507
|
+
mood_overview_field_chip_2: "Dynamique",
|
|
4508
4508
|
mood_overview_field_chip_text: "Statique",
|
|
4509
4509
|
mood_overview_filter_name_text1: "Statique",
|
|
4510
|
-
mood_overview_filter_name_text2: "
|
|
4510
|
+
mood_overview_filter_name_text2: "Dynamique",
|
|
4511
4511
|
mood_overview_headline_text: "Ambiance",
|
|
4512
4512
|
mood_overview_information_text: "The static moods are stored locally on your smartphone. Therefore they can’t be shared with other users.",
|
|
4513
4513
|
motion_detection_add_time_schedule_headline_text: "Ajouter un nouveau calendrier",
|
|
@@ -4515,7 +4515,7 @@ export default {
|
|
|
4515
4515
|
motion_detection_add_time_schedule_system_back_text: "Calendrier",
|
|
4516
4516
|
motion_detection_time_schedule_notifications_field_weekdays_text2: "Une seule fois (aujourd'hui)",
|
|
4517
4517
|
timeschedule_add_schedule_text: "Chaque {0}",
|
|
4518
|
-
motion_detection_time_schedule_notifications_field_weekdays_text4: "
|
|
4518
|
+
motion_detection_time_schedule_notifications_field_weekdays_text4: "Tous les jours",
|
|
4519
4519
|
other_lights_modes_gradient_text: "Fluide",
|
|
4520
4520
|
other_lights_modes_jump_text: "Abrupt",
|
|
4521
4521
|
solar_bt_pp_field_dm: "Ambiance dynamique",
|
|
@@ -4619,8 +4619,8 @@ export default {
|
|
|
4619
4619
|
sleepwakeschedule_warning_max_number_both_text: "Le nombre maximum d'horaires de coucher et d'horaires de réveil a été atteint.",
|
|
4620
4620
|
sleepwakeschedule_warning_max_number_sleep_text: "Le nombre maximum d'horaires de sommeil a été atteint.",
|
|
4621
4621
|
sleepwakeschedule_warning_max_number_wakeup_text: "Le nombre maximum d'horaires de réveil a été atteint.",
|
|
4622
|
-
fixedTimeCycle_information_text: "
|
|
4623
|
-
fixedTimeCycle_bttn_text: "
|
|
4622
|
+
fixedTimeCycle_information_text: "Vous n'avez pas encore ajouté de cycle fixe.",
|
|
4623
|
+
fixedTimeCycle_bttn_text: "Ajouter un cycle à temps fixe",
|
|
4624
4624
|
addTimeCycle_warning_text: "Vos paramètres de temps dépassent le délai disponible",
|
|
4625
4625
|
cancel_dialog_delete_item_timeschedule_description: "Notez que vous ne pouvez pas le récupérer.",
|
|
4626
4626
|
cancel_dialog_delete_item_timeschedule_answer_no_text: "Non",
|
|
@@ -4713,13 +4713,13 @@ export default {
|
|
|
4713
4713
|
sockets_headline_power: "Production d'énergie",
|
|
4714
4714
|
edit_static_mood_button_delete_text: "Supprimer l'ambiance",
|
|
4715
4715
|
edit_static_mood_headline_text: "Modifier l'ambiance",
|
|
4716
|
-
mood_overview_warning_max_number_text: "
|
|
4716
|
+
mood_overview_warning_max_number_text: "Le nombre maximum d'ambiances a été atteint.",
|
|
4717
4717
|
music_reactivate_dialog_text: "Notez qu'il est nécessaire d'activer le micro de votre smartphone.",
|
|
4718
4718
|
add_new_trigger_time_text: "Icône",
|
|
4719
4719
|
feature_summary_frequency_txt_1: "Une seule fois (aujourd'hui)",
|
|
4720
4720
|
feature_summary_frequency_txt_2: "Only once (Tomorrow)",
|
|
4721
4721
|
feature_summary_frequency_txt_3: "Tous les {0}",
|
|
4722
|
-
feature_summary_frequency_txt_4: "
|
|
4722
|
+
feature_summary_frequency_txt_4: "Tous les jours",
|
|
4723
4723
|
add_new_trigger_time_headline_text: "Ajouter une nouvelle heure de déclenchement",
|
|
4724
4724
|
consumption_data_field4_month10_value_text: "Octobre",
|
|
4725
4725
|
consumption_data_field4_month11_value_text: "Novembre",
|
|
@@ -9722,7 +9722,7 @@ export default {
|
|
|
9722
9722
|
motion_detection_time_schedule_notifications_warning_text: "O número máximo de cronogramas foi atingido.",
|
|
9723
9723
|
bio_ryhthm_reset_description_text: "Do you really want to reset your settings of the Biological Rhythm?",
|
|
9724
9724
|
timeschedule_add_schedule_devicestate_sec_warning_text: "Um clima é sempre aplicado à iluminação e ao ventilador. Adicione um ventilador na seção “INSCREVA-SE” para selecionar um clima."
|
|
9725
|
-
},
|
|
9725
|
+
},
|
|
9726
9726
|
ro: {
|
|
9727
9727
|
add_new_dynamic_mood_color_changing_mode_value: "Gradient",
|
|
9728
9728
|
power_off_memory_default_state_title: "Starea implicită",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/res/index.ts
CHANGED
|
@@ -61,5 +61,7 @@ export default {
|
|
|
61
61
|
ic_colorize: require('./ic_colorize.png'),
|
|
62
62
|
ic_mood_del: require('./ic_mood_del.png'),
|
|
63
63
|
ic_paint_bucket: require('./ic_paint_bucket.png'),
|
|
64
|
-
ic_text_field_input_error: require('./ic_text_field_input_error.png')
|
|
64
|
+
ic_text_field_input_error: require('./ic_text_field_input_error.png'),
|
|
65
|
+
ic_minus: require('./ic_minus.png'),
|
|
66
|
+
ic_plus: require('./ic_plus.png')
|
|
65
67
|
}
|