Skip to content

Commit a9ead79

Browse files
authored
Merge pull request #519 from huqiaoli/dev
fix(DatePicker):修改时分秒值
2 parents a64f4ac + 0962e55 commit a9ead79

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

packages/core/src/DatePicker/component/PickerView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export interface PickerViewProps extends PickerProps {
2727
}
2828

2929
const PickerView = (props: PickerViewProps) => {
30-
const { title, showTitle, titleStyle, renderTitle, getTypeDate, value, ...other } = props;
30+
const { title, showTitle, titleStyle, renderTitle, getTypeDate, value, onScrollEnd, ...other } = props;
3131
const textStyle = StyleSheet.flatten([styles.textStyle, titleStyle]);
3232
const [state, setState] = useState<number>(0);
3333
useEffect(() => {

packages/core/src/DatePicker/pure-function.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ export function getHours(initial: number = 0, type: 'star' | 'end' = 'star'): Pi
159159
return arr;
160160
}
161161
/** 得到分钟或者秒 */
162-
export function getMinutesOrSeconds(initial: number = 1, type: 'star' | 'end' = 'star'): PickerData[] {
163-
const star = type === 'star' ? initial : 1;
162+
export function getMinutesOrSeconds(initial: number = 0, type: 'star' | 'end' = 'star'): PickerData[] {
163+
const star = type === 'star' ? initial : 0;
164164
const end = type === 'end' ? initial : 59;
165165
const arr: PickerData[] = createDate(star, end);
166166
return arr;

packages/core/src/Picker/index.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export interface PickerProps {
4848
readonly?: boolean;
4949
/** value 改变时触发 */
5050
onChange?: (value: number) => unknown;
51+
onScrollEnd?: () => void;
5152
}
5253

5354
const Picker = (props: PickerProps) => {
@@ -60,6 +61,7 @@ const Picker = (props: PickerProps) => {
6061
value = 0,
6162
onChange,
6263
readonly = false,
64+
onScrollEnd,
6365
} = props;
6466
const Y = useRef(new Animated.Value(0)).current;
6567
const scrollView = useRef<ScrollView>();
@@ -171,6 +173,10 @@ const Picker = (props: PickerProps) => {
171173
};
172174
}, [lines]);
173175

176+
const onMomentumScrollEnd = () => {
177+
onScrollEnd?.();
178+
};
179+
174180
return (
175181
<View style={{ paddingVertical: 0, height: (style.containerHeight as number) * lines }}>
176182
<ScrollView
@@ -183,6 +189,7 @@ const Picker = (props: PickerProps) => {
183189
useNativeDriver: false,
184190
})}
185191
scrollEnabled={!readonly}
192+
onMomentumScrollEnd={onMomentumScrollEnd}
186193
>
187194
{
188195
<Pressable

packages/core/src/TextArea/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export interface TextAreaProps extends ViewProps {
3333
/** 是否禁用 */
3434
editable?: boolean;
3535
/** 文本域内容变化时触发 */
36-
onChangeText?: (val: string) => void;
36+
onChange?: (val: string) => void;
3737
/** 文本框中的文字内容 */
3838
value?: string;
3939
/** 是否展示字数 */
@@ -50,7 +50,7 @@ function TextArea(props: TextAreaProps) {
5050
placeholder = '',
5151
placeholderTextColor = '#989FB2',
5252
numberOfLines = 30,
53-
onChangeText = () => {},
53+
onChange = () => {},
5454
maxLength = 50,
5555
value = '',
5656
editable = true,
@@ -64,7 +64,7 @@ function TextArea(props: TextAreaProps) {
6464
const [defaultText, setDefaultText] = useState<string>('');
6565
const [height = 0, setHeight] = useState<number>(0);
6666

67-
const onChange = (event: NativeSyntheticEvent<TextInputChangeEventData>) => {
67+
const onChangeValue = (event: NativeSyntheticEvent<TextInputChangeEventData>) => {
6868
if (autoSize) {
6969
setDefaultText(event.nativeEvent.text);
7070
}
@@ -87,8 +87,8 @@ function TextArea(props: TextAreaProps) {
8787
placeholderTextColor={placeholderTextColor}
8888
numberOfLines={numberOfLines}
8989
maxLength={maxLength}
90-
onChangeText={onChangeText}
91-
onChange={onChange}
90+
onChangeText={onChange}
91+
onChange={onChangeValue}
9292
onContentSizeChange={onContentSizeChange}
9393
editable={editable}
9494
value={value}

0 commit comments

Comments
 (0)