farhantock
7 months ago
2 changed files with 225 additions and 42 deletions
@ -0,0 +1,145 @@ |
|||||||
|
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 Manpower from './stepComponent/manPower' |
||||||
|
import InformationReport from './stepComponent/informationReport'; |
||||||
|
import SpesialRequest from './stepComponent/spesialRequest'; |
||||||
|
import Training from './stepComponent/training'; |
||||||
|
import Visit from './stepComponent/visit'; |
||||||
|
import PatroliDRScreen from './stepComponent/patroli' |
||||||
|
|
||||||
|
|
||||||
|
export default function DialogForm({ route, navigation }) { |
||||||
|
const [active, setActive] = useState(0); |
||||||
|
const labels = ["Manpower", "Kunjungan", "Spesial Request", "Pelatihan", "Laporan Informasi", "Patroli"]; |
||||||
|
|
||||||
|
const renderStepContent = useMemo(() => { |
||||||
|
switch (active) { |
||||||
|
case 0: |
||||||
|
return <Manpower navigation={navigation} />; |
||||||
|
case 1: |
||||||
|
return <Visit />; |
||||||
|
case 2: |
||||||
|
return <SpesialRequest />; |
||||||
|
case 3: |
||||||
|
return <Training />; |
||||||
|
case 4: |
||||||
|
return <InformationReport navigation={navigation} />; |
||||||
|
case 5: |
||||||
|
return <PatroliDRScreen navigation={navigation} />; |
||||||
|
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.pureWhite} barStyle="dark-content" /> |
||||||
|
<Appbar.Header mode='center-aligned' style={{ backgroundColor: colors.pureWhite }}> |
||||||
|
<Appbar.BackAction color={colors.blue} onPress={() => { navigation.goBack() }} /> |
||||||
|
<Appbar.Content titleStyle={{ fontWeight: 'bold' }} color={colors.blue} title={strings('dailyReport.add')} /> |
||||||
|
</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.blue }]} onPress={() => console.log('Handle Saved')}> |
||||||
|
Simpan |
||||||
|
</Button> |
||||||
|
) |
||||||
|
: ( |
||||||
|
<Button mode="contained" style={[styles.button, { backgroundColor: colors.blue }]} 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.blue, |
||||||
|
stepStrokeCurrentColor: colors.blue, |
||||||
|
stepStrokeWidth: 1, |
||||||
|
stepStrokeFinishedColor: colors.blue, |
||||||
|
stepStrokeUnFinishedColor: colors.semiBlue, |
||||||
|
separatorFinishedColor: colors.blue, |
||||||
|
separatorUnFinishedColor: colors.semiBlue, |
||||||
|
stepIndicatorFinishedColor: colors.blue, |
||||||
|
stepIndicatorUnFinishedColor: colors.semiBlue, |
||||||
|
stepIndicatorCurrentColor: colors.blue, |
||||||
|
stepIndicatorLabelFontSize: 12, |
||||||
|
currentStepIndicatorLabelFontSize: 12, |
||||||
|
stepIndicatorLabelCurrentColor: colors.pureWhite, |
||||||
|
stepIndicatorLabelFinishedColor: colors.pureWhite, |
||||||
|
stepIndicatorLabelUnFinishedColor: colors.blue, |
||||||
|
labelColor: colors.semiBlue, |
||||||
|
labelSize: 12, |
||||||
|
currentStepLabelColor: colors.blue |
||||||
|
} |
Loading…
Reference in new issue