farhantock
5 months ago
7 changed files with 180 additions and 49 deletions
@ -0,0 +1,144 @@ |
|||||||
|
import React, { useEffect, useCallback, useMemo, useState, useRef } from 'react'; |
||||||
|
import { StatusBar } from 'react-native'; |
||||||
|
import { Button, Text, Appbar, } from 'react-native-paper'; |
||||||
|
import { StyleSheet, View, } from 'react-native'; |
||||||
|
import { colors } from '../../utils/color'; |
||||||
|
import { strings } from '../../utils/i18n'; |
||||||
|
import StepIndicator from 'react-native-step-indicator'; |
||||||
|
import TimeComponent from './stepComponent/time' |
||||||
|
import LocationScreen from './stepComponent/location'; |
||||||
|
import ReportScreen from './stepComponent/report'; |
||||||
|
import IncidentScreen from './stepComponent/incident'; |
||||||
|
import ChronologyScreen from './stepComponent/chronology'; |
||||||
|
import MediaScreen from './stepComponent/media'; |
||||||
|
|
||||||
|
export default function DialogForm({ route, navigation }) { |
||||||
|
const [active, setActive] = useState(0); |
||||||
|
const labels = ["Waktu", "Lokasi", "Pelapor", "Kejadian", "Kronologis", "Media"]; |
||||||
|
|
||||||
|
const renderStepContent = useMemo(() => { |
||||||
|
switch (active) { |
||||||
|
case 0: |
||||||
|
return <TimeComponent />; |
||||||
|
case 1: |
||||||
|
return <LocationScreen />; |
||||||
|
case 2: |
||||||
|
return <ReportScreen />; |
||||||
|
case 3: |
||||||
|
return <IncidentScreen />; |
||||||
|
case 4: |
||||||
|
return <ChronologyScreen navigation={navigation} />; |
||||||
|
case 5: |
||||||
|
return <MediaScreen />; |
||||||
|
default: |
||||||
|
return null; |
||||||
|
} |
||||||
|
}, [active]); |
||||||
|
|
||||||
|
const handleBack = () => { |
||||||
|
if (active > 0) { |
||||||
|
setActive(active - 1); |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
const handleNext = () => { |
||||||
|
if (active < labels.length - 1) { |
||||||
|
setActive(active + 1); |
||||||
|
} |
||||||
|
}; |
||||||
|
return ( |
||||||
|
<View style={styles.container}> |
||||||
|
<StatusBar backgroundColor={colors.beanRed} barStyle="light-content" /> |
||||||
|
<Appbar.Header mode='center-aligned' style={{ backgroundColor: colors.beanRed }}> |
||||||
|
<Appbar.BackAction color={colors.pureWhite} onPress={() => { navigation.goBack() }} /> |
||||||
|
<Appbar.Content titleStyle={{ fontWeight: 'bold' }} color={colors.pureWhite} title={strings('incidentReport.title')} /> |
||||||
|
</Appbar.Header> |
||||||
|
<View style={{ width: '100%', marginTop: 15, marginBottom: 2, backgroundColor: colors.pureWhite }}> |
||||||
|
<StepIndicator |
||||||
|
stepCount={labels.length} |
||||||
|
customStyles={stepIndicatorStyles} |
||||||
|
currentPosition={active} |
||||||
|
labels={labels} |
||||||
|
onPress={(position) => setActive(position)} |
||||||
|
/> |
||||||
|
</View> |
||||||
|
<View style={styles.contentContainer}> |
||||||
|
{renderStepContent} |
||||||
|
</View> |
||||||
|
<View style={styles.buttonContainer}> |
||||||
|
<Button mode="outlined" style={styles.button} textColor={colors.mistBlue} onPress={handleBack} disabled={active === 0}> |
||||||
|
Kembali |
||||||
|
</Button> |
||||||
|
{active === labels.length - 1 ? |
||||||
|
( |
||||||
|
<Button mode="contained" style={[styles.button, { backgroundColor: colors.beanRed }]} onPress={() => console.log('Handle Saved')}> |
||||||
|
Simpan |
||||||
|
</Button> |
||||||
|
) |
||||||
|
: ( |
||||||
|
<Button mode="contained" style={[styles.button, { backgroundColor: colors.beanRed }]} onPress={handleNext}> |
||||||
|
Lanjut |
||||||
|
</Button> |
||||||
|
)} |
||||||
|
|
||||||
|
</View> |
||||||
|
</View > |
||||||
|
) |
||||||
|
} |
||||||
|
|
||||||
|
const styles = StyleSheet.create({ |
||||||
|
container: { |
||||||
|
flex: 1, |
||||||
|
marginTop: 20, |
||||||
|
backgroundColor: colors.pureWhite |
||||||
|
}, |
||||||
|
cardView: { |
||||||
|
marginTop: 10, |
||||||
|
}, |
||||||
|
card: { |
||||||
|
marginTop: 10, |
||||||
|
marginHorizontal: 10, |
||||||
|
backgroundColor: '#1C1B40', |
||||||
|
}, |
||||||
|
button: { |
||||||
|
flex: 1, |
||||||
|
margin: 5, |
||||||
|
borderRadius: 5 |
||||||
|
}, |
||||||
|
contentContainer: { |
||||||
|
flex: 1, |
||||||
|
}, |
||||||
|
buttonContainer: { |
||||||
|
flexDirection: 'row', |
||||||
|
justifyContent: 'space-between', |
||||||
|
padding: 10, |
||||||
|
paddingBottom: 20, |
||||||
|
}, |
||||||
|
|
||||||
|
}) |
||||||
|
|
||||||
|
const stepIndicatorStyles = { |
||||||
|
|
||||||
|
stepIndicatorSize: 25, |
||||||
|
currentStepIndicatorSize: 30, |
||||||
|
separatorStrokeWidth: 2, |
||||||
|
currentStepStrokeWidth: 2, |
||||||
|
stepIndicatorCurrentColor: colors.beanRed, |
||||||
|
stepStrokeCurrentColor: colors.beanRed, |
||||||
|
stepStrokeWidth: 1, |
||||||
|
stepStrokeFinishedColor: colors.beanRed, |
||||||
|
stepStrokeUnFinishedColor: colors.semiRed, |
||||||
|
separatorFinishedColor: colors.beanRed, |
||||||
|
separatorUnFinishedColor: colors.semiRed, |
||||||
|
stepIndicatorFinishedColor: colors.beanRed, |
||||||
|
stepIndicatorUnFinishedColor: colors.semiRed, |
||||||
|
stepIndicatorCurrentColor: colors.beanRed, |
||||||
|
stepIndicatorLabelFontSize: 12, |
||||||
|
currentStepIndicatorLabelFontSize: 12, |
||||||
|
stepIndicatorLabelCurrentColor: colors.pureWhite, |
||||||
|
stepIndicatorLabelFinishedColor: colors.pureWhite, |
||||||
|
stepIndicatorLabelUnFinishedColor: colors.beanRed, |
||||||
|
labelColor: colors.semiRed, |
||||||
|
labelSize: 12, |
||||||
|
currentStepLabelColor: colors.beanRed |
||||||
|
} |
Loading…
Reference in new issue