farhantock
5 months ago
7 changed files with 0 additions and 401 deletions
Before Width: | Height: | Size: 9.8 KiB |
Before Width: | Height: | Size: 119 KiB |
Before Width: | Height: | Size: 100 KiB |
Before Width: | Height: | Size: 41 KiB |
@ -1,87 +0,0 @@
|
||||
import { Box, HStack, Text, VStack } from '@gluestack-ui/themed'; |
||||
import React, { useEffect } from 'react'; |
||||
import { ScrollView, StyleSheet, TouchableOpacity } from 'react-native'; |
||||
import Feather from 'react-native-vector-icons/Feather'; |
||||
import { useDispatch, useSelector } from 'react-redux'; |
||||
import { setChosenLanguage } from '../appredux/actions'; |
||||
import { changeLanguage } from '../utils/i18n'; |
||||
|
||||
const LanguageSettingScreen = () => { |
||||
|
||||
const dispatch = useDispatch() |
||||
const {chosenLanguage} = useSelector(state => state.userReducer) |
||||
|
||||
const SettingItem = ({title, name, onPress}) => { |
||||
return ( |
||||
<Box |
||||
maxWidth="$100" |
||||
borderColor="$borderLight200" |
||||
borderRadius="$lg" |
||||
// borderWidth="$1"
|
||||
borderBottomWidth="$1" |
||||
// my="$1"
|
||||
py="$5" |
||||
overflow="hidden" |
||||
sx={{ |
||||
"@base": { |
||||
mx: "$5", |
||||
}, |
||||
_dark: { |
||||
bg: "$backgroundDark900", |
||||
borderColor: "$borderDark800", |
||||
}, |
||||
}} |
||||
> |
||||
<TouchableOpacity onPress={onPress}> |
||||
<HStack> |
||||
<VStack> |
||||
<Text _dark={{ color: "$textLight200" }} fontSize="$md">{ title ? title : null }</Text> |
||||
</VStack> |
||||
<Box flex={1} alignItems='flex-end'> |
||||
{ name && name === chosenLanguage ?
|
||||
<Feather |
||||
name="check" |
||||
size={25} |
||||
color="green" |
||||
/> |
||||
: null |
||||
}
|
||||
</Box> |
||||
</HStack> |
||||
</TouchableOpacity> |
||||
</Box> |
||||
) |
||||
} |
||||
|
||||
useEffect(() => { |
||||
changeLanguage(chosenLanguage) |
||||
}, [chosenLanguage]) |
||||
|
||||
return ( |
||||
<Box style={styles.container}> |
||||
<Box flex={1}> |
||||
<ScrollView> |
||||
<SettingItem
|
||||
title="Bahasa Indonesia" |
||||
name="id" |
||||
onPress={() => dispatch(setChosenLanguage('id'))} |
||||
/> |
||||
<SettingItem
|
||||
title="English" |
||||
name="en" |
||||
onPress={() => dispatch(setChosenLanguage('en'))} |
||||
/> |
||||
</ScrollView> |
||||
</Box> |
||||
</Box> |
||||
) |
||||
} |
||||
|
||||
const styles = StyleSheet.create({ |
||||
container: { |
||||
flex: 1, |
||||
backgroundColor: '#FAFAFA' |
||||
}, |
||||
}) |
||||
|
||||
export default LanguageSettingScreen |
@ -1,173 +0,0 @@
|
||||
|
||||
import React, { createContext, useEffect, useReducer } from 'react'; |
||||
import { WebView } from 'react-native-webview'; |
||||
import { StyleSheet, Text, View } from 'react-native'; |
||||
import { BASE_URL_API_V1, ERROR_LOGIN, LOGIN_STATE_CHANGED } from 'config/ApiConst'; |
||||
import axios from 'axios'; |
||||
|
||||
// const |
||||
// const initialState = { |
||||
// isLoggedIn: false, |
||||
// isInitialized: true, |
||||
// user: null, |
||||
// loginError: false, |
||||
// loginErrorMessage: { type: '', message: '' } |
||||
// }; |
||||
|
||||
// // reducer - state management |
||||
// const reducer = (state = initialState, action) => { |
||||
// switch (action.type) { |
||||
// case LOGIN_STATE_CHANGED: { |
||||
// const { isLoggedIn, user } = action.payload; |
||||
// return { |
||||
// ...state, |
||||
// isLoggedIn, |
||||
// isInitialized: true, |
||||
// user |
||||
// }; |
||||
// } |
||||
// case ERROR_LOGIN: { |
||||
// const { loginError, loginErrorMessage } = action.payload; |
||||
// return { |
||||
// ...state, |
||||
// loginError, |
||||
// loginErrorMessage |
||||
// }; |
||||
// } |
||||
// default: { |
||||
// return { ...state }; |
||||
// } |
||||
// } |
||||
// }; |
||||
|
||||
|
||||
// const LoginContext = createContext({ |
||||
// ...initialState, |
||||
// usernamePasswordSignIn: (username, password) => { }, |
||||
// usernamePasswordRegister: (payload) => { }, |
||||
// OauthSignIn: payload => { }, |
||||
// handleCloseError: () => { }, |
||||
// logout: () => { } |
||||
// }); |
||||
const LoginScreen = ({ route, navigation }) => { |
||||
// const [state, dispatch] = useReducer(reducer, initialState); |
||||
// const navigate = useNavigate(); |
||||
// const location = useLocation(); |
||||
// const OauthSignIn = async (token) => { |
||||
// try { |
||||
// const response = await axios |
||||
// .get(`${BASE_URL_API_V1}/auth-nawakara/login?token=${token}`) |
||||
// .then((res) => res) |
||||
// .catch((error) => error.response); |
||||
// if (response.status == 200) { |
||||
// const user = JSON.stringify(response.data.data) |
||||
// localStorage.setItem('user_id', response.data.data.id); |
||||
// localStorage.setItem('name', response.data.data.name); |
||||
// localStorage.setItem('token', response.data.data.token); |
||||
// localStorage.setItem('data_user', user); |
||||
// localStorage.setItem('role', response.data.data.role_id); |
||||
// localStorage.setItem('nik', response.data.data.ktp_number); |
||||
// localStorage.setItem('regional', response.data.data.Regional_id); |
||||
// localStorage.setItem('data_menu', JSON.stringify(response.data.data.menu)); |
||||
// dispatch({ |
||||
// type: LOGIN_STATE_CHANGED, |
||||
// payload: { |
||||
// isLoggedIn: true, |
||||
// user: { |
||||
// ...response.data.data, |
||||
// } |
||||
// } |
||||
// }); |
||||
// window.location.reload(); |
||||
// } else { |
||||
// const alert = { |
||||
// type: 'error', |
||||
// message: response.data.message |
||||
// } |
||||
// dispatch({ |
||||
// type: ERROR_LOGIN, |
||||
// payload: { |
||||
// loginError: true, |
||||
// loginErrorMessage: alert |
||||
// } |
||||
// }); |
||||
// } |
||||
// } catch (error) { |
||||
// const alert = { |
||||
// type: 'error', |
||||
// message: 'Tidak Dapat Terhubung Ke server, coba beberapa saat lagi' |
||||
// } |
||||
// dispatch({ |
||||
// type: ERROR_LOGIN, |
||||
// payload: { |
||||
// loginError: true, |
||||
// loginErrorMessage: alert |
||||
// } |
||||
// }); |
||||
// } |
||||
// }; |
||||
|
||||
// const logout = () => { |
||||
// localStorage.clear() |
||||
// dispatch({ |
||||
// type: LOGIN_STATE_CHANGED, |
||||
// payload: { |
||||
// isLoggedIn: false, |
||||
// user: null |
||||
// } |
||||
// }); |
||||
// }; |
||||
|
||||
// const handleCloseError = () => { |
||||
// const alert = { |
||||
// type: '', |
||||
// message: '' |
||||
// } |
||||
// dispatch({ |
||||
// type: ERROR_LOGIN, |
||||
// payload: { |
||||
// loginError: false, |
||||
// loginErrorMessage: alert |
||||
// } |
||||
// }); |
||||
// } |
||||
|
||||
// useEffect(() => { |
||||
// const user_id = localStorage.getItem('user_id'); |
||||
// const data_user = localStorage.getItem('data_user'); |
||||
|
||||
// if (user_id) { |
||||
// dispatch({ |
||||
// type: LOGIN_STATE_CHANGED, |
||||
// payload: { |
||||
// isLoggedIn: true, |
||||
// user: data_user |
||||
// } |
||||
// }); |
||||
// let pathAfterLogin = location.pathname == "/" ? config.defaultPath : location.pathname; |
||||
// navigate(pathAfterLogin, { replace: true }); |
||||
// } |
||||
// }, []); |
||||
|
||||
|
||||
// return ( |
||||
// <LoginContext.Provider |
||||
// value={{ |
||||
// ...state, |
||||
// usernamePasswordSignIn, |
||||
// logout, |
||||
// usernamePasswordRegister, |
||||
// handleCloseError, |
||||
// OauthSignIn |
||||
// }} |
||||
// > |
||||
// {children} |
||||
// </LoginContext.Provider> |
||||
// ); |
||||
|
||||
return ( |
||||
<WebView source={{ uri: 'https://nis.nawakara.com/e-hris/api/index.php/auth/sso?appid=ops_Vk2pzFe0J6XioPwt7' }} style={{ flex: 1 }} /> |
||||
); |
||||
} |
||||
|
||||
export default LoginScreen |
@ -1,141 +0,0 @@
|
||||
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 = (step) => { |
||||
switch (step) { |
||||
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 />; |
||||
} |
||||
}; |
||||
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 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(active)} |
||||
</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