Commit 6ef167a5 authored by Kiridena I.T.K_IT19981840's avatar Kiridena I.T.K_IT19981840

Merge branch 'UI-changes' into 'master'

progress bars

See merge request !49
parents a249a58e 3031d1e0
This source diff could not be displayed because it is too large. You can view the blob instead.
import React, { useState } from "react"; import React, { useState } from "react";
import { View, Text, Button, StyleSheet, Alert, Clipboard } from "react-native"; import {
View,
Text,
Button,
StyleSheet,
Alert,
Clipboard,
ActivityIndicator,
} from "react-native";
import RadioForm, { import RadioForm, {
RadioButton, RadioButton,
RadioButtonInput, RadioButtonInput,
...@@ -13,6 +21,7 @@ import AsyncStorage from "@react-native-async-storage/async-storage"; ...@@ -13,6 +21,7 @@ import AsyncStorage from "@react-native-async-storage/async-storage";
export default function PatientRegEight({ navigation, route }) { export default function PatientRegEight({ navigation, route }) {
const [educationLevel, setEducationLevel] = useState(""); const [educationLevel, setEducationLevel] = useState("");
const [employedStatus, setEmployedStatus] = useState(""); const [employedStatus, setEmployedStatus] = useState("");
const [isLoading, setIsLoading] = useState(false);
const educationLevelOptions = [ const educationLevelOptions = [
{ label: "Schooling", value: "Schooling" }, { label: "Schooling", value: "Schooling" },
...@@ -28,6 +37,8 @@ export default function PatientRegEight({ navigation, route }) { ...@@ -28,6 +37,8 @@ export default function PatientRegEight({ navigation, route }) {
]; ];
const handleSave = async () => { const handleSave = async () => {
setIsLoading(true);
//encrypt the data //encrypt the data
const encryptedEmail = EncryptWithServerKey(route.params.email); const encryptedEmail = EncryptWithServerKey(route.params.email);
const encryptedUsername = EncryptWithServerKey(route.params.username); const encryptedUsername = EncryptWithServerKey(route.params.username);
...@@ -132,7 +143,7 @@ export default function PatientRegEight({ navigation, route }) { ...@@ -132,7 +143,7 @@ export default function PatientRegEight({ navigation, route }) {
`\nSecret key : ` + `\nSecret key : ` +
decryptedStellarSecretKey + decryptedStellarSecretKey +
`\n Save the keys in a safe place`; `\n Save the keys in a safe place`;
setIsLoading(false);
//Show keys on the alert //Show keys on the alert
Alert.alert("Account keys", alertMessage, [ Alert.alert("Account keys", alertMessage, [
{ {
...@@ -156,84 +167,92 @@ export default function PatientRegEight({ navigation, route }) { ...@@ -156,84 +167,92 @@ export default function PatientRegEight({ navigation, route }) {
//on close send to main UI //on close send to main UI
} catch (errorWhenStoringInAsyncStorage) { } catch (errorWhenStoringInAsyncStorage) {
console.log(errorWhenStoringInAsyncStorage); console.log(errorWhenStoringInAsyncStorage);
setIsLoading(false);
} }
} else { } else {
console.log(responseData); console.log(responseData);
} }
} catch (errorWhenSendingRegObj) { } catch (errorWhenSendingRegObj) {
console.error("Error : ", errorWhenSendingRegObj); console.error("Error : ", errorWhenSendingRegObj);
setIsLoading(false);
} }
}; };
return ( return (
<View style={styles.container}> <View style={styles.container}>
<Text>Highest Education Level:</Text> {isLoading ? (
<RadioForm animation={true}> <ActivityIndicator size="large" color="#560CCE" />
{educationLevelOptions.map((option, index) => ( ) : (
<RadioButton <>
labelHorizontal={true} <Text>Highest Education Level:</Text>
key={index} <RadioForm animation={true}>
labelWrapStyle={{ flexDirection: "row", alignItems: "center" }} {educationLevelOptions.map((option, index) => (
> <RadioButton
<RadioButtonInput labelHorizontal={true}
obj={option} key={index}
index={index} labelWrapStyle={{ flexDirection: "row", alignItems: "center" }}
isSelected={educationLevel === option.value} >
onPress={() => setEducationLevel(option.value)} <RadioButtonInput
buttonInnerColor={"#2196f3"} obj={option}
buttonOuterColor={ index={index}
educationLevel === option.value ? "#2196f3" : "#000" isSelected={educationLevel === option.value}
} onPress={() => setEducationLevel(option.value)}
buttonSize={15} buttonInnerColor={"#2196f3"}
buttonOuterSize={25} buttonOuterColor={
buttonStyle={{}} educationLevel === option.value ? "#2196f3" : "#000"
buttonWrapStyle={{ marginLeft: 10 }} }
/> buttonSize={15}
<RadioButtonLabel buttonOuterSize={25}
obj={option} buttonStyle={{}}
index={index} buttonWrapStyle={{ marginLeft: 10 }}
labelHorizontal={true} />
onPress={() => setEducationLevel(option.value)} <RadioButtonLabel
labelStyle={{ fontSize: 16, marginRight: 10 }} obj={option}
/> index={index}
</RadioButton> labelHorizontal={true}
))} onPress={() => setEducationLevel(option.value)}
</RadioForm> labelStyle={{ fontSize: 16, marginRight: 10 }}
/>
<Text>Employed:</Text> </RadioButton>
<RadioForm animation={true}> ))}
{employedOptions.map((option, index) => ( </RadioForm>
<RadioButton
labelHorizontal={true} <Text>Employed:</Text>
key={index} <RadioForm animation={true}>
labelWrapStyle={{ flexDirection: "row", alignItems: "center" }} {employedOptions.map((option, index) => (
> <RadioButton
<RadioButtonInput labelHorizontal={true}
obj={option} key={index}
index={index} labelWrapStyle={{ flexDirection: "row", alignItems: "center" }}
isSelected={employedStatus === option.value} >
onPress={() => setEmployedStatus(option.value)} <RadioButtonInput
buttonInnerColor={"#2196f3"} obj={option}
buttonOuterColor={ index={index}
employedStatus === option.value ? "#2196f3" : "#000" isSelected={employedStatus === option.value}
} onPress={() => setEmployedStatus(option.value)}
buttonSize={15} buttonInnerColor={"#2196f3"}
buttonOuterSize={25} buttonOuterColor={
buttonStyle={{}} employedStatus === option.value ? "#2196f3" : "#000"
buttonWrapStyle={{ marginLeft: 10 }} }
/> buttonSize={15}
<RadioButtonLabel buttonOuterSize={25}
obj={option} buttonStyle={{}}
index={index} buttonWrapStyle={{ marginLeft: 10 }}
labelHorizontal={true} />
onPress={() => setEmployedStatus(option.value)} <RadioButtonLabel
labelStyle={{ fontSize: 16, marginRight: 10 }} obj={option}
/> index={index}
</RadioButton> labelHorizontal={true}
))} onPress={() => setEmployedStatus(option.value)}
</RadioForm> labelStyle={{ fontSize: 16, marginRight: 10 }}
/>
<Button title="All Done" onPress={handleSave} /> </RadioButton>
))}
</RadioForm>
<Button title="All Done" onPress={handleSave} />
</>
)}
</View> </View>
); );
} }
......
import { useNavigation } from "@react-navigation/core"; import { useNavigation } from "@react-navigation/core";
import { View, TextInput, Button, StyleSheet, Alert } from "react-native"; import {
View,
TextInput,
Button,
StyleSheet,
Alert,
ActivityIndicator,
} from "react-native";
import React, { useState } from "react"; import React, { useState } from "react";
import EncryptWithServerKey from "../../services/encryptByServerKey"; import EncryptWithServerKey from "../../services/encryptByServerKey";
import { LOCALBACKEND } from "../../env"; import { LOCALBACKEND } from "../../env";
...@@ -13,8 +20,11 @@ export default function PractitionerRegistration() { ...@@ -13,8 +20,11 @@ export default function PractitionerRegistration() {
const [email, setEmail] = useState(""); const [email, setEmail] = useState("");
const [fullName, setFullName] = useState(""); const [fullName, setFullName] = useState("");
const [workspace, setWorkspace] = useState(""); const [workspace, setWorkspace] = useState("");
const [isLoading, setIsLoading] = useState(false);
const handleNext = async () => { const handleNext = async () => {
setIsLoading(true);
//encrypt the data //encrypt the data
const encryptedUsername = EncryptWithServerKey(username); const encryptedUsername = EncryptWithServerKey(username);
const encryptedPassword = EncryptWithServerKey(password); const encryptedPassword = EncryptWithServerKey(password);
...@@ -75,6 +85,7 @@ export default function PractitionerRegistration() { ...@@ -75,6 +85,7 @@ export default function PractitionerRegistration() {
`\nSecret key : ` + `\nSecret key : ` +
decryptedStellarSecretKey + decryptedStellarSecretKey +
`\n Save the keys in a safe place`; `\n Save the keys in a safe place`;
setIsLoading(false);
Alert.alert("Account keys", alertMessage, [ Alert.alert("Account keys", alertMessage, [
{ {
...@@ -94,49 +105,57 @@ export default function PractitionerRegistration() { ...@@ -94,49 +105,57 @@ export default function PractitionerRegistration() {
"Error when saving details in the async storage : ", "Error when saving details in the async storage : ",
errorWhenStoringInTheAsyncStorage errorWhenStoringInTheAsyncStorage
); );
setIsLoading(false);
} }
} catch (errorWhenRegisteringPractitioner) { } catch (errorWhenRegisteringPractitioner) {
console.log( console.log(
"Error when registering practitioner : ", "Error when registering practitioner : ",
errorWhenRegisteringPractitioner errorWhenRegisteringPractitioner
); );
setIsLoading(false);
} }
}; };
return ( return (
<View style={styles.container}> <View style={styles.container}>
<TextInput {isLoading ? (
style={styles.input} <ActivityIndicator size="large" color="#560CCE" />
placeholder="User name" ) : (
value={username} <>
onChangeText={(text) => setUsername(text)} <TextInput
/> style={styles.input}
<TextInput placeholder="User name"
style={styles.input} value={username}
placeholder="Password" onChangeText={(text) => setUsername(text)}
value={password} />
onChangeText={(text) => setPassword(text)} <TextInput
secureTextEntry={true} style={styles.input}
/> placeholder="Password"
<TextInput value={password}
style={styles.input} onChangeText={(text) => setPassword(text)}
placeholder="Full Name" secureTextEntry={true}
value={fullName} />
onChangeText={(text) => setFullName(text)} <TextInput
/> style={styles.input}
<TextInput placeholder="Full Name"
style={styles.input} value={fullName}
placeholder="Workspace" onChangeText={(text) => setFullName(text)}
value={workspace} />
onChangeText={(text) => setWorkspace(text)} <TextInput
/> style={styles.input}
<TextInput placeholder="Workspace"
style={styles.input} value={workspace}
placeholder="Email" onChangeText={(text) => setWorkspace(text)}
value={email} />
onChangeText={(text) => setEmail(text)} <TextInput
/> style={styles.input}
<Button title="Register" onPress={handleNext} /> placeholder="Email"
value={email}
onChangeText={(text) => setEmail(text)}
/>
<Button title="Register" onPress={handleNext} />
</>
)}
</View> </View>
); );
} }
......
This diff is collapsed.
...@@ -23,10 +23,10 @@ ...@@ -23,10 +23,10 @@
"react-native-base64": "^0.2.1", "react-native-base64": "^0.2.1",
"react-native-crypto-js": "^1.0.0", "react-native-crypto-js": "^1.0.0",
"react-native-datepicker": "^1.7.2", "react-native-datepicker": "^1.7.2",
"react-native-gesture-handler": "^2.10.0", "react-native-gesture-handler": "~2.9.0",
"react-native-render-html": "^6.3.4", "react-native-render-html": "^6.3.4",
"react-native-rsa-native": "^2.0.5", "react-native-rsa-native": "^2.0.5",
"react-native-safe-area-context": "^4.5.3", "react-native-safe-area-context": "4.5.0",
"react-native-simple-radio-button": "^2.7.4", "react-native-simple-radio-button": "^2.7.4",
"react-native-toast-message": "^2.1.6", "react-native-toast-message": "^2.1.6",
"react-native-webview": "11.26.0" "react-native-webview": "11.26.0"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment