Skip to content

Commit

Permalink
refactor usless code away
Browse files Browse the repository at this point in the history
  • Loading branch information
Norfeldt committed Sep 28, 2020
1 parent e49e440 commit 0134104
Showing 1 changed file with 71 additions and 80 deletions.
151 changes: 71 additions & 80 deletions screens/PatientScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,99 +20,90 @@ import { ContextConsumer } from '../Context'
import SourceCodeLink from '../components/SourceCodeLink'

export default function HomeScreen(props) {
const scanned = false;
const [ scanning, setScanned ] = useState(false);
const [scanning, setScanning] = useState(false)

const RenderView = props => {
if (scanning) {
return (
<ContextConsumer>
{({ checkOUT }) => (
<View style={{ flex: 1 }}>
<BarCodeScanner
style={{ flex: 1 }}
onBarCodeScanned={
scanned
? undefined
: ({ type, data }) => {
setScanned(false)
const RenderView = (props) => {
if (scanning) {
return (
<ContextConsumer>
{({ checkOUT }) => (
<View style={{ flex: 1 }}>
<BarCodeScanner
style={{ flex: 1 }}
onBarCodeScanned={({ data }) => {
setScanning(false)

Alert.alert('PRODUCT DATA', data, [
{
text: 'Cancel',
onPress: () => console.log('Cancel Pressed'),
},
{
text: 'CHECK OUT',
onPress: () => checkOUT({ ...JSON.parse(data) }),
},
])
}
}
/>
<View
style={{
backgroundColor: Colors.passiveBG,
justifyContent: 'center',
}}
>
<TouchableOpacity
onPress={() => setScanned(false)}
Alert.alert('PRODUCT DATA', data, [
{
text: 'Cancel',
onPress: () => console.log('Cancel Pressed'),
},
{
text: 'CHECK OUT',
onPress: () => checkOUT({ ...JSON.parse(data) }),
},
])
}}
/>
<View
style={{
backgroundColor: Colors.passiveBG,
justifyContent: 'center',
}}
>
<TouchableOpacity onPress={() => setScanning(false)}>
<Text
style={{
color: Colors.passive,
textAlign: 'center',
paddingVertical: 15,
}}
>
<Text
style={{
color: Colors.passive,
textAlign: 'center',
paddingVertical: 15,
}}
>
Cancel
</Text>
</TouchableOpacity>
</View>
Cancel
</Text>
</TouchableOpacity>
</View>
)}
</ContextConsumer>
)
} else {
return (
<ScrollView style={blockStyles.container}>
<SectionTitle name="CHECK OUT" />
</View>
)}
</ContextConsumer>
)
} else {
return (
<ScrollView style={blockStyles.container}>
<SectionTitle name="CHECK OUT" />

<ScrollView horizontal={true}>
<GenuineDrugs style={{ flexDirection: 'row' }} />
<View style={{ borderLeftWidth: 1 }} />
<FalsifiedDrugs />
</ScrollView>
<ScrollView horizontal={true}>
<GenuineDrugs style={{ flexDirection: 'row' }} />
<View style={{ borderLeftWidth: 1 }} />
<FalsifiedDrugs />
</ScrollView>

<Button
title="SCAN PRODUCT"
iconName="QR_Code"
onPress={async () => {
const { status } = await Permissions.askAsync(
Permissions.CAMERA
)
setScanned(status == 'granted')
}}
/>
<Button
title="SCAN PRODUCT"
iconName="QR_Code"
onPress={async () => {
const { status } = await Permissions.askAsync(Permissions.CAMERA)
setScanning(status == 'granted')
}}
/>

<SectionTitle name="MEDICATION HISTORY" />
<SectionTitle name="MEDICATION HISTORY" />

<DrugHistory />
<DrugHistory />

<SourceCodeLink />
<View style={{ height: 30 }} />
</ScrollView>
)
}
<SourceCodeLink />
<View style={{ height: 30 }} />
</ScrollView>
)
}
}

return <RenderView />
return <RenderView />
}

HomeScreen['navigationOptions'] = screenprops => ({
header: () => <Header title="Patient" />
});
HomeScreen['navigationOptions'] = (screenprops) => ({
header: () => <Header title="Patient" />,
})

const blockStyles = StyleSheet.create({
container: {
Expand Down

0 comments on commit 0134104

Please sign in to comment.