-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
1,812 additions
and
85 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react'; | ||
import {Text, View, StyleSheet} from 'react-native'; | ||
import {Icon} from 'react-native-elements'; | ||
import {RecordOperationProps} from '../screens/RecordList'; | ||
|
||
export type BooleanRecordOperationProps = RecordOperationProps; | ||
|
||
const BooleanRecordOperation = ({onComplete}: BooleanRecordOperationProps) => { | ||
const onSubmit = (value: boolean) => { | ||
onComplete({ | ||
value: value ? 1 : 0, | ||
}); | ||
}; | ||
return ( | ||
<View style={styles.body}> | ||
<Icon name={'thumb-down-alt'} onPress={() => onSubmit(false)} /> | ||
<Icon name={'thumb-up-alt'} onPress={() => onSubmit(true)} /> | ||
</View> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
body: { | ||
display: 'flex', | ||
flexDirection: 'row', | ||
justifyContent: 'space-around', | ||
alignContent: 'center', | ||
}, | ||
}); | ||
|
||
export default BooleanRecordOperation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react'; | ||
import {Text, View, StyleSheet} from 'react-native'; | ||
import {RecordOperationProps} from '../screens/RecordList'; | ||
import {Button, Icon} from "react-native-elements"; | ||
|
||
export type Props = { | ||
value?: number; | ||
} & RecordOperationProps; | ||
|
||
const CountingRecordOperation = ({onComplete, value}: Props) => { | ||
const onConfirm = () => { | ||
onComplete && onComplete({value: value ? value + 1 : 1}); | ||
}; | ||
return ( | ||
<View style={styles.body}> | ||
<Text>添加记录项</Text> | ||
<Icon name={'add-task'} onPress={onConfirm} /> | ||
</View> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
body: { | ||
display: 'flex', | ||
flexDirection: 'row', | ||
justifyContent: 'space-around', | ||
alignContent: 'center', | ||
}, | ||
}); | ||
|
||
export default CountingRecordOperation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import React, {createRef, useRef, useState} from 'react'; | ||
import {Text, View, StyleSheet, TextInput} from 'react-native'; | ||
import {RecordOperationProps} from '../screens/RecordList'; | ||
import {Icon, Input} from 'react-native-elements'; | ||
import Toast from 'react-native-simple-toast'; | ||
|
||
export type InputtingRecordOperationProps = RecordOperationProps; | ||
|
||
const InputtingRecordOperation = ({ | ||
onComplete, | ||
}: InputtingRecordOperationProps) => { | ||
const [value, setValue] = useState(''); | ||
const inputRef = createRef<TextInput>(); | ||
const onValueChange = (text: string) => { | ||
setValue(text); | ||
}; | ||
const onSubmit = () => { | ||
if (value.length === 0) { | ||
Toast.show('请先输入后提交'); | ||
return; | ||
} | ||
try { | ||
const floatValue = parseFloat(value); | ||
onComplete({ | ||
value: floatValue, | ||
}).then(() => { | ||
inputRef.current && inputRef.current.clear(); | ||
setValue(''); | ||
}); | ||
} catch (e) { | ||
console.error('parseFloat error', e); | ||
Toast.show('请输入合法的数值'); | ||
} | ||
}; | ||
return ( | ||
<View style={styles.body}> | ||
<Input | ||
ref={inputRef} | ||
placeholder={'请输入合法数值'} | ||
keyboardType={'numeric'} | ||
onChangeText={onValueChange} | ||
leftIcon={<Icon name={'keyboard'} />} | ||
rightIcon={<Icon name={'done'} onPress={onSubmit} />} | ||
/> | ||
</View> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
body: { | ||
display: 'flex', | ||
flexDirection: 'row', | ||
justifyContent: 'space-around', | ||
alignItems: 'center', | ||
}, | ||
}); | ||
|
||
export default InputtingRecordOperation; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import React, {useState} from 'react'; | ||
import {Text, View, StyleSheet} from 'react-native'; | ||
import {RecordOperationProps} from "../screens/RecordList"; | ||
import {Icon} from "react-native-elements"; | ||
import Toast from "react-native-simple-toast"; | ||
|
||
export type TimingRecordOperationProps = {} & RecordOperationProps; | ||
|
||
const TimingRecordOperation = ({onComplete}: TimingRecordOperationProps) => { | ||
const [step, setStep] = useState(1); | ||
const [startTime, setStartTime] = useState(0); | ||
const onStart = () => { | ||
setStep(2); | ||
setStartTime(new Date().getTime()); | ||
Toast.show('记录开始时间'); | ||
}; | ||
const onEnd = () => { | ||
if (startTime > 0) { | ||
Toast.show('记录结束时间'); | ||
onComplete({ | ||
value: new Date().getTime() - startTime, | ||
}).then(() => { | ||
setStartTime(0); | ||
setStep(1); | ||
}); | ||
} else { | ||
Toast.show('请先记录开始时间'); | ||
} | ||
}; | ||
return ( | ||
<View style={styles.body}> | ||
<View style={styles.startContainer}> | ||
<Icon name={step === 1 ? 'play-arrow' : 'sync'} onPress={onStart} /> | ||
</View> | ||
<View style={styles.endContainer}> | ||
<Icon name={'stop'} onPress={onEnd} /> | ||
</View> | ||
</View> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
body: { | ||
display: 'flex', | ||
flexDirection: 'row', | ||
justifyContent: 'space-around', | ||
alignItems: 'center', | ||
}, | ||
startContainer: {}, | ||
endContainer: {}, | ||
}); | ||
|
||
export default TimingRecordOperation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.