@xhsreds/reds-rn-next 0.10.1-beta202512041155 → 0.10.1-feat-sheets-anim202512041203
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/coverage/.tmp/coverage-0.json +1 -1
- package/coverage/.tmp/coverage-1.json +1 -1
- package/coverage/.tmp/coverage-11.json +1 -1
- package/coverage/.tmp/coverage-12.json +1 -1
- package/coverage/.tmp/coverage-13.json +1 -1
- package/coverage/.tmp/coverage-14.json +1 -1
- package/coverage/.tmp/coverage-17.json +1 -1
- package/coverage/.tmp/coverage-19.json +1 -1
- package/coverage/.tmp/coverage-2.json +1 -1
- package/coverage/.tmp/coverage-20.json +1 -1
- package/coverage/.tmp/coverage-21.json +1 -1
- package/coverage/.tmp/coverage-22.json +1 -1
- package/coverage/.tmp/coverage-23.json +1 -1
- package/coverage/.tmp/coverage-24.json +1 -1
- package/coverage/.tmp/coverage-25.json +1 -1
- package/coverage/.tmp/coverage-26.json +1 -1
- package/coverage/.tmp/coverage-27.json +1 -1
- package/coverage/.tmp/coverage-30.json +1 -1
- package/coverage/.tmp/coverage-31.json +1 -1
- package/coverage/.tmp/coverage-32.json +1 -1
- package/coverage/.tmp/coverage-34.json +1 -1
- package/coverage/.tmp/coverage-35.json +1 -1
- package/coverage/.tmp/coverage-36.json +1 -1
- package/coverage/.tmp/coverage-37.json +1 -1
- package/coverage/.tmp/coverage-38.json +1 -1
- package/coverage/.tmp/coverage-42.json +1 -1
- package/coverage/.tmp/coverage-5.json +1 -1
- package/coverage/.tmp/coverage-7.json +1 -1
- package/coverage/.tmp/coverage-8.json +1 -1
- package/coverage/.tmp/coverage-9.json +1 -1
- package/lib/cjs/_chunks/{DVfoVjpR.js → 47jfgoRG.js} +4 -2
- package/lib/cjs/_chunks/47jfgoRG.js.map +1 -0
- package/lib/cjs/_chunks/hA3qoGpS.js.map +1 -1
- package/lib/cjs/components/ActionSheets/ActionSheets.js +1 -1
- package/lib/cjs/components/ActionSheets/api.js +1 -1
- package/lib/cjs/components/ActionSheets/hooks.js +1 -1
- package/lib/cjs/components/ActionSheets/index.js +1 -1
- package/lib/cjs/components/ActionablePopover/ActionablePopover.js +2 -2
- package/lib/cjs/components/ActionablePopover/ActionablePopover.js.map +1 -1
- package/lib/cjs/components/Avatar/styles.js +5 -5
- package/lib/cjs/components/Avatar/styles.js.map +1 -1
- package/lib/cjs/components/AvatarGroup/AvatarGroup.js +1 -1
- package/lib/cjs/components/BottomBar/styles.js +1 -1
- package/lib/cjs/components/BottomBar/styles.js.map +1 -1
- package/lib/cjs/components/DatePicker/DatePicker.js +1 -1
- package/lib/cjs/components/DatePicker/api.js +1 -1
- package/lib/cjs/components/DatePicker/index.js +1 -1
- package/lib/cjs/components/Divider/Divider.js +12 -33
- package/lib/cjs/components/Divider/Divider.js.map +1 -1
- package/lib/cjs/components/Divider/index.js +3 -3
- package/lib/cjs/components/Divider/styles.js +30 -36
- package/lib/cjs/components/Divider/styles.js.map +1 -1
- package/lib/cjs/components/Image/Image.js +13 -13
- package/lib/cjs/components/Image/Image.js.map +1 -1
- package/lib/cjs/components/List/ListItem/ListItem.js +2 -4
- package/lib/cjs/components/List/ListItem/ListItem.js.map +1 -1
- package/lib/cjs/components/NoticeBar/NoticeBar.js +1 -2
- package/lib/cjs/components/NoticeBar/NoticeBar.js.map +1 -1
- package/lib/cjs/components/Picker/Picker.js +1 -1
- package/lib/cjs/components/Picker/api.js +1 -1
- package/lib/cjs/components/Picker/index.js +1 -1
- package/lib/cjs/components/PickerView/Wheel.js +5 -52
- package/lib/cjs/components/PickerView/Wheel.js.map +1 -1
- package/lib/cjs/components/Portal/core/PortalHost.js +1 -3
- package/lib/cjs/components/Portal/core/PortalHost.js.map +1 -1
- package/lib/cjs/components/Radio/Radio.js +4 -4
- package/lib/cjs/components/Radio/Radio.js.map +1 -1
- package/lib/cjs/components/Radio/index.js +1 -1
- package/lib/cjs/components/Radio/styles.js +7 -5
- package/lib/cjs/components/Radio/styles.js.map +1 -1
- package/lib/cjs/components/Sheets/AnimatedSheets.js +14 -8
- package/lib/cjs/components/Sheets/AnimatedSheets.js.map +1 -1
- package/lib/cjs/components/Sheets/Sheets.js +1 -1
- package/lib/cjs/components/Sheets/api.js +1 -1
- package/lib/cjs/components/Sheets/index.js +1 -1
- package/lib/cjs/components/Sheets/interface/index.js +1 -1
- package/lib/cjs/components/Slider/Slider.js +34 -74
- package/lib/cjs/components/Slider/Slider.js.map +1 -1
- package/lib/cjs/components/Stepper/Stepper.js +1 -1
- package/lib/cjs/components/Stepper/Stepper.js.map +1 -1
- package/lib/cjs/components/Stepper/styles.js +2 -2
- package/lib/cjs/components/Stepper/styles.js.map +1 -1
- package/lib/cjs/components/TextView/TextView.js +3 -6
- package/lib/cjs/components/TextView/TextView.js.map +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/esm/_chunks/C0MWVrjO.js.map +1 -1
- package/lib/esm/_chunks/{C4jyXYEi.js → DMjPllnU.js} +4 -2
- package/lib/esm/_chunks/DMjPllnU.js.map +1 -0
- package/lib/esm/components/ActionSheets/ActionSheets.js +1 -1
- package/lib/esm/components/ActionSheets/api.js +1 -1
- package/lib/esm/components/ActionSheets/hooks.js +1 -1
- package/lib/esm/components/ActionSheets/index.js +1 -1
- package/lib/esm/components/ActionablePopover/ActionablePopover.js +1 -1
- package/lib/esm/components/ActionablePopover/ActionablePopover.js.map +1 -1
- package/lib/esm/components/Avatar/styles.js +5 -5
- package/lib/esm/components/Avatar/styles.js.map +1 -1
- package/lib/esm/components/AvatarGroup/AvatarGroup.js +1 -1
- package/lib/esm/components/BottomBar/styles.js +1 -1
- package/lib/esm/components/BottomBar/styles.js.map +1 -1
- package/lib/esm/components/DatePicker/DatePicker.js +1 -1
- package/lib/esm/components/DatePicker/api.js +1 -1
- package/lib/esm/components/DatePicker/index.js +1 -1
- package/lib/esm/components/Divider/Divider.js +14 -35
- package/lib/esm/components/Divider/Divider.js.map +1 -1
- package/lib/esm/components/Divider/index.js +3 -3
- package/lib/esm/components/Divider/styles.js +30 -36
- package/lib/esm/components/Divider/styles.js.map +1 -1
- package/lib/esm/components/Image/Image.js +13 -13
- package/lib/esm/components/Image/Image.js.map +1 -1
- package/lib/esm/components/List/ListItem/ListItem.js +3 -5
- package/lib/esm/components/List/ListItem/ListItem.js.map +1 -1
- package/lib/esm/components/NoticeBar/NoticeBar.js +1 -2
- package/lib/esm/components/NoticeBar/NoticeBar.js.map +1 -1
- package/lib/esm/components/Picker/Picker.js +1 -1
- package/lib/esm/components/Picker/api.js +1 -1
- package/lib/esm/components/Picker/index.js +1 -1
- package/lib/esm/components/PickerView/Wheel.js +5 -52
- package/lib/esm/components/PickerView/Wheel.js.map +1 -1
- package/lib/esm/components/Portal/core/PortalHost.js +1 -3
- package/lib/esm/components/Portal/core/PortalHost.js.map +1 -1
- package/lib/esm/components/Radio/Radio.js +4 -4
- package/lib/esm/components/Radio/Radio.js.map +1 -1
- package/lib/esm/components/Radio/index.js +1 -1
- package/lib/esm/components/Radio/styles.js +7 -5
- package/lib/esm/components/Radio/styles.js.map +1 -1
- package/lib/esm/components/Sheets/AnimatedSheets.js +14 -8
- package/lib/esm/components/Sheets/AnimatedSheets.js.map +1 -1
- package/lib/esm/components/Sheets/Sheets.js +1 -1
- package/lib/esm/components/Sheets/api.js +1 -1
- package/lib/esm/components/Sheets/index.js +1 -1
- package/lib/esm/components/Sheets/interface/index.js +1 -1
- package/lib/esm/components/Slider/Slider.js +36 -76
- package/lib/esm/components/Slider/Slider.js.map +1 -1
- package/lib/esm/components/Stepper/Stepper.js +1 -1
- package/lib/esm/components/Stepper/Stepper.js.map +1 -1
- package/lib/esm/components/Stepper/styles.js +2 -2
- package/lib/esm/components/Stepper/styles.js.map +1 -1
- package/lib/esm/components/TextView/TextView.js +3 -6
- package/lib/esm/components/TextView/TextView.js.map +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/src/components/BottomBar/styles.d.ts +1 -1
- package/lib/src/components/Divider/styles.d.ts +2 -3
- package/lib/src/components/List/ListItem/ListItem.d.ts +0 -2
- package/lib/src/components/Sheets/Sheets.d.ts +3 -3
- package/lib/src/components/Sheets/interface/index.d.ts +12 -0
- package/lib/src/components/Slider/Slider.d.ts +1 -1
- package/lib/src/components/Stepper/interface/index.d.ts +0 -1
- package/lib/src/components/Stepper/styles.d.ts +2 -2
- package/lib/types/components/BottomBar/styles.d.ts +1 -1
- package/lib/types/components/Divider/styles.d.ts +2 -3
- package/lib/types/components/List/ListItem/ListItem.d.ts +0 -2
- package/lib/types/components/Sheets/Sheets.d.ts +3 -3
- package/lib/types/components/Sheets/interface/index.d.ts +12 -0
- package/lib/types/components/Slider/Slider.d.ts +1 -1
- package/lib/types/components/Stepper/interface/index.d.ts +0 -1
- package/lib/types/components/Stepper/styles.d.ts +2 -2
- package/package.json +2 -2
- package/src/components/ActionablePopover/ActionablePopover.tsx +1 -10
- package/src/components/Avatar/styles.ts +4 -5
- package/src/components/BottomBar/styles.ts +1 -1
- package/src/components/DatePicker/demo/index.tsx +0 -26
- package/src/components/Divider/Divider.tsx +9 -29
- package/src/components/Divider/demo/index.tsx +6 -12
- package/src/components/Divider/styles.ts +30 -33
- package/src/components/Image/Image.tsx +9 -14
- package/src/components/Image/demo/index.tsx +5 -4
- package/src/components/List/ListItem/ListItem.tsx +1 -12
- package/src/components/List/demo/index.tsx +0 -2
- package/src/components/NoticeBar/NoticeBar.tsx +1 -3
- package/src/components/PickerView/Wheel.tsx +0 -50
- package/src/components/Portal/core/PortalHost.tsx +1 -4
- package/src/components/Radio/Radio.tsx +3 -3
- package/src/components/Radio/styles.ts +5 -3
- package/src/components/Sheets/AnimatedSheets.tsx +118 -120
- package/src/components/Sheets/doc/index.mdx +8 -0
- package/src/components/Sheets/interface/index.ts +13 -0
- package/src/components/Slider/Slider.tsx +37 -103
- package/src/components/Slider/demo/index.tsx +0 -18
- package/src/components/Stepper/Stepper.tsx +1 -1
- package/src/components/Stepper/demo/index.tsx +1 -1
- package/src/components/Stepper/doc/index.mdx +0 -1
- package/src/components/Stepper/interface/index.ts +0 -1
- package/src/components/Stepper/styles.ts +2 -2
- package/src/components/TextView/TextView.tsx +3 -6
- package/src/components/TextView/demo/index.tsx +1 -1
- package/src/i18n/@types/resources.d.ts +18 -18
- package/src/i18n/index.json +31 -31
- package/lib/cjs/_chunks/DVfoVjpR.js.map +0 -1
- package/lib/esm/_chunks/C4jyXYEi.js.map +0 -1
|
@@ -56,6 +56,8 @@ const AnimatedSheets = forwardRef((props: RedsSheets, ref) => {
|
|
|
56
56
|
close,
|
|
57
57
|
iconType,
|
|
58
58
|
size,
|
|
59
|
+
openAnimation,
|
|
60
|
+
closeAnimation,
|
|
59
61
|
} = props;
|
|
60
62
|
|
|
61
63
|
const themeColor = useThemeColor();
|
|
@@ -181,7 +183,7 @@ const AnimatedSheets = forwardRef((props: RedsSheets, ref) => {
|
|
|
181
183
|
Animated.timing(translateY, {
|
|
182
184
|
toValue: 0, // 移动到目标位置(顶部)
|
|
183
185
|
useNativeDriver: true,
|
|
184
|
-
duration: 150,
|
|
186
|
+
duration: openAnimation?.duration ?? 150,
|
|
185
187
|
easing: Easing.ease,
|
|
186
188
|
}).start();
|
|
187
189
|
};
|
|
@@ -243,7 +245,7 @@ const AnimatedSheets = forwardRef((props: RedsSheets, ref) => {
|
|
|
243
245
|
}
|
|
244
246
|
Animated.timing(opacityValue, {
|
|
245
247
|
toValue: _visible && mask ? 1 : 0,
|
|
246
|
-
duration: 150,
|
|
248
|
+
duration: _visible ? openAnimation?.duration ?? 150 : closeAnimation?.duration ?? 150,
|
|
247
249
|
useNativeDriver: true, // 使用原生驱动
|
|
248
250
|
easing: Easing.linear, // 动画缓动函数
|
|
249
251
|
}).start(() => {
|
|
@@ -351,7 +353,7 @@ const AnimatedSheets = forwardRef((props: RedsSheets, ref) => {
|
|
|
351
353
|
Animated.timing(translateY, {
|
|
352
354
|
toValue: screenHeight || Dimensions.get("screen").height, // 移动到屏幕底部
|
|
353
355
|
useNativeDriver: true,
|
|
354
|
-
duration: 150,
|
|
356
|
+
duration: closeAnimation?.duration ?? 150,
|
|
355
357
|
easing: Easing.ease,
|
|
356
358
|
}).start((data) => {
|
|
357
359
|
if (data.finished) {
|
|
@@ -370,7 +372,7 @@ const AnimatedSheets = forwardRef((props: RedsSheets, ref) => {
|
|
|
370
372
|
Animated.timing(translateY, {
|
|
371
373
|
toValue: screenHeight || Dimensions.get("screen").height, // 移动到屏幕底部
|
|
372
374
|
useNativeDriver: true,
|
|
373
|
-
duration: 150,
|
|
375
|
+
duration: closeAnimation?.duration ?? 150,
|
|
374
376
|
easing: Easing.ease,
|
|
375
377
|
}).start((data) => {
|
|
376
378
|
if (data.finished) {
|
|
@@ -402,127 +404,123 @@ const AnimatedSheets = forwardRef((props: RedsSheets, ref) => {
|
|
|
402
404
|
) : (
|
|
403
405
|
<></>
|
|
404
406
|
)}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
>
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
<Block />
|
|
433
|
-
) : (
|
|
434
|
-
<></>
|
|
435
|
-
)
|
|
436
|
-
) : (
|
|
437
|
-
<TouchableOpacity onPress={handleCancel} activeOpacity={1}>
|
|
438
|
-
{cancelType === SheetsActionType.text ? (
|
|
439
|
-
<Text style={[styles.cancel, { color: themeColor.Title }]} testID="cancel">
|
|
440
|
-
{cancelText || cancelKey}
|
|
441
|
-
</Text>
|
|
442
|
-
) : (
|
|
443
|
-
iconWrapper("cancel")
|
|
444
|
-
)}
|
|
445
|
-
</TouchableOpacity>
|
|
446
|
-
)}
|
|
447
|
-
{label ? (
|
|
448
|
-
<Text style={[styles.label, { color: themeColor.Title }]}>
|
|
449
|
-
{label}
|
|
450
|
-
{showMask}
|
|
451
|
-
</Text>
|
|
407
|
+
<Animated.View
|
|
408
|
+
testID="Sheets"
|
|
409
|
+
style={[
|
|
410
|
+
styles.picker,
|
|
411
|
+
{ backgroundColor: themeColor.Bg2 },
|
|
412
|
+
{
|
|
413
|
+
height: sheetsHeight,
|
|
414
|
+
transform: [{ translateY }],
|
|
415
|
+
},
|
|
416
|
+
{ zIndex: props.zIndex },
|
|
417
|
+
props.sheetsStyle,
|
|
418
|
+
]}
|
|
419
|
+
>
|
|
420
|
+
{props.header ? <View onLayout={handleLabelLayout}>{props.header}</View> : <></>}
|
|
421
|
+
{/** normal */}
|
|
422
|
+
{showLabel && !props.header ? (
|
|
423
|
+
<View
|
|
424
|
+
style={[
|
|
425
|
+
props.headlerLayout === "center" ? styles.labelContainer : styles.leftLabelContainer,
|
|
426
|
+
{ backgroundColor: themeColor.Bg2 },
|
|
427
|
+
props.headerStyle,
|
|
428
|
+
]}
|
|
429
|
+
onLayout={handleLabelLayout}
|
|
430
|
+
>
|
|
431
|
+
{!cancel ? (
|
|
432
|
+
props.headlerLayout === "center" ? (
|
|
433
|
+
<Block />
|
|
452
434
|
) : (
|
|
453
435
|
<></>
|
|
454
|
-
)
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
<></>
|
|
460
|
-
)
|
|
461
|
-
) : (
|
|
462
|
-
<TouchableOpacity onPress={handleConfirm} activeOpacity={1}>
|
|
463
|
-
{closeType === SheetsActionType.text ? (
|
|
464
|
-
<View>
|
|
465
|
-
<Text
|
|
466
|
-
style={[
|
|
467
|
-
styles.confirm,
|
|
468
|
-
{ color: themeColor.Primary },
|
|
469
|
-
{ elevation: 0, shadowColor: "transparent" },
|
|
470
|
-
]}
|
|
471
|
-
testID="close"
|
|
472
|
-
>
|
|
473
|
-
{closeText || sureKey}
|
|
474
|
-
</Text>
|
|
475
|
-
</View>
|
|
476
|
-
) : (
|
|
477
|
-
iconWrapper("confirm")
|
|
478
|
-
)}
|
|
479
|
-
</TouchableOpacity>
|
|
480
|
-
)}
|
|
481
|
-
</View>
|
|
482
|
-
) : (
|
|
483
|
-
<></>
|
|
484
|
-
)}
|
|
485
|
-
|
|
486
|
-
{/** 拖拽按钮 */}
|
|
487
|
-
{sheetsType === SheetsType.dragable && !props.header ? (
|
|
488
|
-
<Animated.View style={[styles.dragableContainer]} {...panResponder.panHandlers} testID={"draggable"}>
|
|
489
|
-
<View style={[styles.dragable, { backgroundColor: themeColor.Fill3 }]} />
|
|
490
|
-
</Animated.View>
|
|
491
|
-
) : (
|
|
492
|
-
<></>
|
|
493
|
-
)}
|
|
494
|
-
|
|
495
|
-
<View onLayout={handleLayout}>{children}</View>
|
|
496
|
-
|
|
497
|
-
{/** action */}
|
|
498
|
-
{showAction ? (
|
|
499
|
-
<View style={[styles.actionContainer]} onLayout={handleActionLayout}>
|
|
500
|
-
{cancel ? (
|
|
501
|
-
<View style={styles.action}>
|
|
502
|
-
<Button block onClick={handleCancel}>
|
|
436
|
+
)
|
|
437
|
+
) : (
|
|
438
|
+
<TouchableOpacity onPress={handleCancel} activeOpacity={1}>
|
|
439
|
+
{cancelType === SheetsActionType.text ? (
|
|
440
|
+
<Text style={[styles.cancel, { color: themeColor.Title }]} testID="cancel">
|
|
503
441
|
{cancelText || cancelKey}
|
|
504
|
-
</
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
442
|
+
</Text>
|
|
443
|
+
) : (
|
|
444
|
+
iconWrapper("cancel")
|
|
445
|
+
)}
|
|
446
|
+
</TouchableOpacity>
|
|
447
|
+
)}
|
|
448
|
+
{label ? (
|
|
449
|
+
<Text style={[styles.label, { color: themeColor.Title }]}>
|
|
450
|
+
{label}
|
|
451
|
+
{showMask}
|
|
452
|
+
</Text>
|
|
453
|
+
) : (
|
|
454
|
+
<></>
|
|
455
|
+
)}
|
|
456
|
+
{!close ? (
|
|
457
|
+
props.headlerLayout === "center" ? (
|
|
458
|
+
<Block />
|
|
515
459
|
) : (
|
|
516
460
|
<></>
|
|
517
|
-
)
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
461
|
+
)
|
|
462
|
+
) : (
|
|
463
|
+
<TouchableOpacity onPress={handleConfirm} activeOpacity={1}>
|
|
464
|
+
{closeType === SheetsActionType.text ? (
|
|
465
|
+
<View>
|
|
466
|
+
<Text
|
|
467
|
+
style={[
|
|
468
|
+
styles.confirm,
|
|
469
|
+
{ color: themeColor.Primary },
|
|
470
|
+
{ elevation: 0, shadowColor: "transparent" },
|
|
471
|
+
]}
|
|
472
|
+
testID="close"
|
|
473
|
+
>
|
|
474
|
+
{closeText || sureKey}
|
|
475
|
+
</Text>
|
|
476
|
+
</View>
|
|
477
|
+
) : (
|
|
478
|
+
iconWrapper("confirm")
|
|
479
|
+
)}
|
|
480
|
+
</TouchableOpacity>
|
|
481
|
+
)}
|
|
482
|
+
</View>
|
|
483
|
+
) : (
|
|
484
|
+
<></>
|
|
485
|
+
)}
|
|
486
|
+
|
|
487
|
+
{/** 拖拽按钮 */}
|
|
488
|
+
{sheetsType === SheetsType.dragable && !props.header ? (
|
|
489
|
+
<Animated.View style={[styles.dragableContainer]} {...panResponder.panHandlers} testID={"draggable"}>
|
|
490
|
+
<View style={[styles.dragable, { backgroundColor: themeColor.Fill3 }]} />
|
|
491
|
+
</Animated.View>
|
|
492
|
+
) : (
|
|
493
|
+
<></>
|
|
494
|
+
)}
|
|
495
|
+
|
|
496
|
+
<View onLayout={handleLayout}>{children}</View>
|
|
497
|
+
|
|
498
|
+
{/** action */}
|
|
499
|
+
{showAction ? (
|
|
500
|
+
<View style={[styles.actionContainer]} onLayout={handleActionLayout}>
|
|
501
|
+
{cancel ? (
|
|
502
|
+
<View style={styles.action}>
|
|
503
|
+
<Button block onClick={handleCancel}>
|
|
504
|
+
{cancelText || cancelKey}
|
|
505
|
+
</Button>
|
|
506
|
+
</View>
|
|
507
|
+
) : (
|
|
508
|
+
<></>
|
|
509
|
+
)}
|
|
510
|
+
{close ? (
|
|
511
|
+
<View style={styles.action}>
|
|
512
|
+
<Button block onClick={handleConfirm} type="primary">
|
|
513
|
+
{closeText || sureKey}
|
|
514
|
+
</Button>
|
|
515
|
+
</View>
|
|
516
|
+
) : (
|
|
517
|
+
<></>
|
|
518
|
+
)}
|
|
519
|
+
</View>
|
|
520
|
+
) : (
|
|
521
|
+
<></>
|
|
522
|
+
)}
|
|
523
|
+
</Animated.View>
|
|
526
524
|
</>
|
|
527
525
|
);
|
|
528
526
|
});
|
|
@@ -38,6 +38,14 @@ import BaseDemo from "!!raw-loader!../demo/index.tsx";
|
|
|
38
38
|
| onImmediateConfirm | 点击确定弹窗立即执行 | () => void | () => {} |
|
|
39
39
|
| avoidSheetsMove | 安卓上是否阻止键盘弹出弹窗位置上移 | boolean | false |
|
|
40
40
|
| headlerLayout | headlerLayout | "center" | "left" | center |
|
|
41
|
+
| openAnimation | openAnimation | { |
|
|
42
|
+
|
|
43
|
+
duration?: number
|
|
44
|
+
|
|
45
|
+
} | `{}` |
|
|
46
|
+
| closeAnimation | openAnimation | {
|
|
47
|
+
duration?: number
|
|
48
|
+
} | `{}` |
|
|
41
49
|
|
|
42
50
|
### Events
|
|
43
51
|
|
|
@@ -33,6 +33,11 @@ export const enum AnimatedSheetsSize {
|
|
|
33
33
|
auto = "auto",
|
|
34
34
|
fixed = "fixed",
|
|
35
35
|
}
|
|
36
|
+
|
|
37
|
+
export interface SheetAnimationConfig {
|
|
38
|
+
/** Duration in milliseconds. Default: 150 */
|
|
39
|
+
duration?: number;
|
|
40
|
+
}
|
|
36
41
|
export interface RedsSheets {
|
|
37
42
|
label?: string;
|
|
38
43
|
mask?: boolean;
|
|
@@ -63,6 +68,12 @@ export interface RedsSheets {
|
|
|
63
68
|
onImmediateConfirm?: () => void;
|
|
64
69
|
avoidSheetsMove?: boolean;
|
|
65
70
|
headlerLayout?: "center" | "left";
|
|
71
|
+
openAnimation?: {
|
|
72
|
+
duration?: number;
|
|
73
|
+
};
|
|
74
|
+
closeAnimation?: {
|
|
75
|
+
duration?: number;
|
|
76
|
+
};
|
|
66
77
|
}
|
|
67
78
|
|
|
68
79
|
export interface RedsSheetsEvent {}
|
|
@@ -91,4 +102,6 @@ export const SheetsDefaultProps = {
|
|
|
91
102
|
onImmediateConfirm: () => {},
|
|
92
103
|
avoidSheetsMove: false,
|
|
93
104
|
headlerLayout: "center",
|
|
105
|
+
openAnimation: {},
|
|
106
|
+
closeAnimation: {},
|
|
94
107
|
};
|
|
@@ -15,17 +15,10 @@ import { RedsSlider, SliderDefaultProps } from "./interface/index";
|
|
|
15
15
|
import styles from "./styles";
|
|
16
16
|
import useMounted from "../../pvCount/useUnmountedProcess";
|
|
17
17
|
|
|
18
|
-
const Slider = ({
|
|
19
|
-
defaultValue,
|
|
20
|
-
min = 0,
|
|
21
|
-
max = 100,
|
|
22
|
-
initalValue = 0,
|
|
23
|
-
onValueChange,
|
|
24
|
-
dotStyle = {},
|
|
25
|
-
step = 1,
|
|
26
|
-
}: RedsSlider) => {
|
|
18
|
+
const Slider = ({ defaultValue, min = 0, max = 100, initalValue = 0, onValueChange, dotStyle = {} }: RedsSlider) => {
|
|
27
19
|
useMounted("Slider");
|
|
28
|
-
const [
|
|
20
|
+
const [panResponder, setPanResponder] = useState(PanResponder.create({}));
|
|
21
|
+
const [sliderWidth, setSliderWidth] = useState(Dimensions.get("window").width * 0.8);
|
|
29
22
|
const [value, setValue] = useState(initalValue);
|
|
30
23
|
|
|
31
24
|
if (max < min) {
|
|
@@ -35,109 +28,51 @@ const Slider = ({
|
|
|
35
28
|
return;
|
|
36
29
|
}
|
|
37
30
|
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
(rawValue: number) => {
|
|
41
|
-
const steppedValue = Math.round((rawValue - min) / step) * step + min;
|
|
42
|
-
return Math.max(min, Math.min(max, steppedValue));
|
|
43
|
-
},
|
|
44
|
-
[min, max, step],
|
|
45
|
-
);
|
|
46
|
-
|
|
31
|
+
const thumbPosition = (value / (max - min)) * sliderWidth;
|
|
32
|
+
const step = 1;
|
|
47
33
|
const animatedValue = useRef(new Animated.Value((initalValue * sliderWidth) / (max - min))).current;
|
|
48
|
-
|
|
49
|
-
const animatedThumbValue = useRef(
|
|
50
|
-
new Animated.Value(
|
|
51
|
-
(initalValue * sliderWidth) / (max - min) > 0
|
|
52
|
-
? (initalValue * sliderWidth) / (max - min) - 8
|
|
53
|
-
: (initalValue * sliderWidth) / (max - min),
|
|
54
|
-
),
|
|
55
|
-
).current;
|
|
56
|
-
|
|
57
34
|
useEffect(() => {
|
|
58
35
|
const handleOrientationChange = () => {
|
|
59
|
-
setSliderWidth(Dimensions.get("window").width);
|
|
36
|
+
setSliderWidth(Dimensions.get("window").width * 0.8);
|
|
60
37
|
};
|
|
61
38
|
|
|
62
39
|
const subscription = Dimensions.addEventListener("change", handleOrientationChange);
|
|
40
|
+
createPanResponder();
|
|
63
41
|
return () => {
|
|
64
42
|
subscription.remove();
|
|
43
|
+
//Dimensions.removeEventListener("change", handleOrientationChange);
|
|
65
44
|
};
|
|
66
45
|
}, []);
|
|
67
46
|
|
|
68
47
|
// 可以根据需要调整的滑块高度
|
|
69
|
-
const hanleValueUpdate =
|
|
70
|
-
(gestureState
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
animatedThumbValue.setValue(
|
|
79
|
-
(steppedValue * sliderWidth) / (max - min) > 0
|
|
80
|
-
? (steppedValue * sliderWidth) / (max - min) - 8
|
|
81
|
-
: (steppedValue * sliderWidth) / (max - min),
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
if (onValueChange) {
|
|
85
|
-
onValueChange(steppedValue);
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
[min, max, sliderWidth, initalValue, step, getSteppedValue, onValueChange],
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
// 添加点击轨道跳转功能(可选)
|
|
92
|
-
const handleTrackPress = useCallback(
|
|
93
|
-
(event: GestureResponderEvent) => {
|
|
94
|
-
const { locationX } = event.nativeEvent;
|
|
95
|
-
const rawValue = (locationX / sliderWidth) * (max - min) + min;
|
|
96
|
-
const steppedValue = getSteppedValue(rawValue);
|
|
97
|
-
|
|
98
|
-
setValue(steppedValue);
|
|
99
|
-
|
|
100
|
-
// 使用动画过渡到新位置
|
|
101
|
-
Animated.timing(animatedValue, {
|
|
102
|
-
toValue: (steppedValue * sliderWidth) / (max - min),
|
|
103
|
-
duration: 200,
|
|
104
|
-
useNativeDriver: false,
|
|
105
|
-
}).start();
|
|
106
|
-
|
|
107
|
-
Animated.timing(animatedThumbValue, {
|
|
108
|
-
toValue:
|
|
109
|
-
(steppedValue * sliderWidth) / (max - min) > 0
|
|
110
|
-
? (steppedValue * sliderWidth) / (max - min) - 8
|
|
111
|
-
: (steppedValue * sliderWidth) / (max - min),
|
|
112
|
-
duration: 200,
|
|
113
|
-
useNativeDriver: false,
|
|
114
|
-
}).start();
|
|
115
|
-
|
|
116
|
-
if (onValueChange) {
|
|
117
|
-
onValueChange(steppedValue);
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
[sliderWidth, min, max, getSteppedValue, onValueChange, animatedValue, animatedThumbValue],
|
|
121
|
-
);
|
|
48
|
+
const hanleValueUpdate = (gestureState: PanResponderGestureState) => {
|
|
49
|
+
const currentValue = Math.max(min, Math.min(max, (gestureState.dx / sliderWidth) * (max - min) + initalValue));
|
|
50
|
+
|
|
51
|
+
setValue(currentValue);
|
|
52
|
+
animatedValue.setValue((currentValue * sliderWidth) / (max - min));
|
|
53
|
+
if (onValueChange) {
|
|
54
|
+
onValueChange(currentValue);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
122
57
|
|
|
123
58
|
const handleLayout = (event: LayoutChangeEvent) => {
|
|
124
59
|
setSliderWidth(event.nativeEvent.layout.width);
|
|
125
60
|
};
|
|
126
61
|
|
|
127
|
-
const
|
|
128
|
-
(
|
|
62
|
+
const createPanResponder = () => {
|
|
63
|
+
setPanResponder(
|
|
129
64
|
PanResponder.create({
|
|
130
65
|
onStartShouldSetPanResponder: () => true,
|
|
131
66
|
onMoveShouldSetPanResponder: () => true,
|
|
132
|
-
onPanResponderGrant: () =>
|
|
133
|
-
onPanResponderRelease: () =>
|
|
67
|
+
onPanResponderGrant: () => {},
|
|
68
|
+
onPanResponderRelease: () => {},
|
|
134
69
|
onPanResponderTerminate: () => {},
|
|
135
70
|
onPanResponderMove: (evt, gestureState) => {
|
|
136
71
|
hanleValueUpdate(gestureState);
|
|
137
72
|
},
|
|
138
73
|
}),
|
|
139
|
-
|
|
140
|
-
|
|
74
|
+
);
|
|
75
|
+
};
|
|
141
76
|
|
|
142
77
|
const styles = StyleSheet.create({
|
|
143
78
|
sliderContainer: {
|
|
@@ -146,7 +81,7 @@ const Slider = ({
|
|
|
146
81
|
justifyContent: "center",
|
|
147
82
|
},
|
|
148
83
|
trackContainer: {
|
|
149
|
-
width: "
|
|
84
|
+
width: "80%",
|
|
150
85
|
height: 4,
|
|
151
86
|
backgroundColor: "rgba(48, 48, 52, 0.20)",
|
|
152
87
|
borderRadius: 2,
|
|
@@ -172,22 +107,21 @@ const Slider = ({
|
|
|
172
107
|
},
|
|
173
108
|
});
|
|
174
109
|
|
|
110
|
+
//<View style={[styles.track, { width: sliderWidth }]}>
|
|
111
|
+
//<View style={[styles.thumb, { left: thumbPosition }]} {...panResponder.panHandlers} />
|
|
112
|
+
//</View>
|
|
175
113
|
return (
|
|
176
|
-
<
|
|
177
|
-
<View style={styles.
|
|
178
|
-
{
|
|
179
|
-
|
|
180
|
-
<View
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
style={[styles.thumbButton, { transform: [{ translateX: animatedThumbValue }] }, dotStyle]}
|
|
186
|
-
{...panResponder.panHandlers}
|
|
187
|
-
hitSlop={{ top: 20, bottom: 20, left: 20, right: 20 }}
|
|
188
|
-
/>
|
|
114
|
+
<TouchableWithoutFeedback onPress={(e) => {}}>
|
|
115
|
+
<View style={styles.sliderContainer} onLayout={handleLayout}>
|
|
116
|
+
<View style={styles.trackContainer}>
|
|
117
|
+
<Animated.View style={[styles.coloredTrack, { width: animatedValue }]} />
|
|
118
|
+
<Animated.View
|
|
119
|
+
style={[styles.thumbButton, { transform: [{ translateX: animatedValue }] }, dotStyle]}
|
|
120
|
+
{...panResponder.panHandlers}
|
|
121
|
+
/>
|
|
122
|
+
</View>
|
|
189
123
|
</View>
|
|
190
|
-
</
|
|
124
|
+
</TouchableWithoutFeedback>
|
|
191
125
|
);
|
|
192
126
|
};
|
|
193
127
|
|
|
@@ -8,7 +8,6 @@ const styles = StyleSheet.create({
|
|
|
8
8
|
justifyContent: "center",
|
|
9
9
|
paddingTop: 100,
|
|
10
10
|
paddingBottom: 100,
|
|
11
|
-
paddingHorizontal: 50,
|
|
12
11
|
},
|
|
13
12
|
scrollView: {
|
|
14
13
|
backgroundColor: "pink",
|
|
@@ -45,23 +44,6 @@ export default function App() {
|
|
|
45
44
|
<Br />
|
|
46
45
|
<Slider min={200} max={100}></Slider>
|
|
47
46
|
<Br />
|
|
48
|
-
<Desc>step使用示例</Desc>
|
|
49
|
-
<Slider
|
|
50
|
-
min={0}
|
|
51
|
-
max={100}
|
|
52
|
-
step={10} // 每次移动10个单位
|
|
53
|
-
initalValue={0}
|
|
54
|
-
onValueChange={(value: any) => console.log("Current value:", value)}
|
|
55
|
-
/>
|
|
56
|
-
<Br />
|
|
57
|
-
<Desc>step使用示例(或者更小的步长)</Desc>
|
|
58
|
-
<Slider
|
|
59
|
-
min={0}
|
|
60
|
-
max={1}
|
|
61
|
-
step={0.1} // 每次移动0.1个单位
|
|
62
|
-
initalValue={0.5}
|
|
63
|
-
onValueChange={(value: any) => console.log("Current value:", value)}
|
|
64
|
-
/>
|
|
65
47
|
</View>
|
|
66
48
|
);
|
|
67
49
|
}
|
|
@@ -84,7 +84,7 @@ const Stepper = (props: RedsStepper) => {
|
|
|
84
84
|
}, [colorMode]);
|
|
85
85
|
|
|
86
86
|
return (
|
|
87
|
-
<View style={
|
|
87
|
+
<View style={styles.container}>
|
|
88
88
|
<TouchableWithoutFeedback onPress={() => handleNumber("min")}>
|
|
89
89
|
<View style={[styles.icon, minus]}>
|
|
90
90
|
<Image source={{ uri: minusImage }} style={[styles.minus]} />
|
|
@@ -21,7 +21,7 @@ export default function App() {
|
|
|
21
21
|
return (
|
|
22
22
|
<View style={styles.container}>
|
|
23
23
|
<Text>基础用法</Text>
|
|
24
|
-
<Stepper value={value} onChange={handleChange}
|
|
24
|
+
<Stepper value={value} onChange={handleChange} />
|
|
25
25
|
|
|
26
26
|
<Text>基础用法(非受控)</Text>
|
|
27
27
|
<Stepper isControl={false} />
|
|
@@ -5,8 +5,7 @@ export const getStyles = (themeColor: any, typography: any) => {
|
|
|
5
5
|
display: "flex",
|
|
6
6
|
flexDirection: "row",
|
|
7
7
|
alignItems: "center",
|
|
8
|
-
justifyContent: "
|
|
9
|
-
width: 72,
|
|
8
|
+
justifyContent: "center",
|
|
10
9
|
},
|
|
11
10
|
opacity: {
|
|
12
11
|
opacity: 0.5,
|
|
@@ -22,6 +21,7 @@ export const getStyles = (themeColor: any, typography: any) => {
|
|
|
22
21
|
lineHeight: 20,
|
|
23
22
|
},
|
|
24
23
|
text: {
|
|
24
|
+
paddingHorizontal: 8,
|
|
25
25
|
fontWeight: typography.B1LooseFontWeight,
|
|
26
26
|
fontSize: typography.T3FontSize,
|
|
27
27
|
color: themeColor.Title,
|
|
@@ -68,8 +68,7 @@ const TextField = forwardRef((props: RedsTextView, ref) => {
|
|
|
68
68
|
|
|
69
69
|
const handleChangeText = useCallback(
|
|
70
70
|
(value: string) => {
|
|
71
|
-
|
|
72
|
-
updateValue(filteredValue);
|
|
71
|
+
updateValue(value);
|
|
73
72
|
// Only apply cursor fix on iOS when text equals maxLength (indicating truncation)
|
|
74
73
|
if (Platform.OS === "ios" && maxLength && value.length >= maxLength && inputRef.current) {
|
|
75
74
|
// Use requestAnimationFrame instead of setTimeout
|
|
@@ -135,10 +134,8 @@ const TextField = forwardRef((props: RedsTextView, ref) => {
|
|
|
135
134
|
}, [layout]);
|
|
136
135
|
|
|
137
136
|
const handleKeyPress = ({ nativeEvent }: any) => {
|
|
138
|
-
if (nativeEvent.key === "Enter") {
|
|
139
|
-
|
|
140
|
-
Keyboard.dismiss();
|
|
141
|
-
}
|
|
137
|
+
if (nativeEvent.key === "Enter" && props.returnKeyType !== "next") {
|
|
138
|
+
Keyboard.dismiss();
|
|
142
139
|
}
|
|
143
140
|
};
|
|
144
141
|
|
|
@@ -26,7 +26,7 @@ export default function App() {
|
|
|
26
26
|
clearable
|
|
27
27
|
actionLayout={"horizontal"}
|
|
28
28
|
autofocus={true}
|
|
29
|
-
returnKeyType={"
|
|
29
|
+
returnKeyType={"search"}
|
|
30
30
|
/>
|
|
31
31
|
<Desc>最大长度</Desc>
|
|
32
32
|
<TextView modelValue={modelValue} maxLength={100} showCount placeholder="占位符" />
|