[3739ec]: / mobile / ElderCare / ConnectDeviceScreen.js

Download this file

163 lines (158 with data), 5.1 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
import React, { useState } from 'react';
import {
StyleSheet,
Text,
View,
Image,
TouchableOpacity,
ActivityIndicator,
Alert,
} from 'react-native';
export default function ConnectDeviceScreen() {
const [loading, setLoading] = useState(false);
const handleConnect = () => {
setLoading(true);
// Simulate searching process with a delay
setTimeout(() => {
setLoading(false);
Alert.alert(
'Device Not Found',
'No accelerometer device was found. Please ensure the device is turned on, in range, and try again.',
[
{ text: 'Retry', onPress: () => handleConnect() },
{ text: 'Cancel' },
],
{ cancelable: false }
);
}, 3000); // Simulate a 3-second search process
};
return (
<View style={styles.container}>
<View style={styles.header}>
<Image
source={require('./assets/logo.png')} // Replace with your logo path
style={styles.logo}
/>
<Text style={styles.appName}>ElderCare+</Text>
<Text style={styles.slogan}>Connect Your Accelerometer</Text>
</View>
<View style={styles.content}>
<Text style={styles.description}>
Connect to an actual accelerometer device to monitor real
elder person activity. Ensure the device is powered on and
within range.
</Text>
<View style={styles.instructionContainer}>
<Text style={styles.instructionText}>
To connect your accelerometer:
</Text>
<Text style={styles.instructionItem}>
1. Make sure your device is turned on.
</Text>
<Text style={styles.instructionItem}>
2. Ensure your device is Bluetooth or WiFi enabled.
</Text>
<Text style={styles.instructionItem}>
3. Place the accelerometer close to your phone.
</Text>
<Text style={styles.instructionItem}>
4. Press the "Connect" button to start.
</Text>
</View>
{loading ? (
<ActivityIndicator
size="large"
color="#2D328C"
style={styles.spinner}
/>
) : (
<TouchableOpacity
style={styles.connectButton}
onPress={handleConnect}>
<Text style={styles.buttonText}>Connect</Text>
</TouchableOpacity>
)}
</View>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#F2F4F9', // Light gray background for the entire screen
},
header: {
flex: 0.3, // Occupies 30% of the screen height
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#2D328C', // Blue background for the header
padding: 20,
borderBottomRightRadius: 30, // Rounded corners for a better look
borderBottomLeftRadius: 30,
},
logo: {
width: 100,
height: 100,
resizeMode: 'contain',
},
appName: {
fontSize: 24,
color: '#fff',
fontWeight: 'bold',
marginTop: 10,
},
slogan: {
fontSize: 16,
color: '#fff',
marginTop: 5,
},
content: {
flex: 0.7, // Occupies the remaining space
justifyContent: 'center',
alignItems: 'center',
padding: 20,
},
description: {
fontSize: 18,
color: '#000',
textAlign: 'center',
marginBottom: 20,
},
instructionContainer: {
width: '100%',
padding: 20,
backgroundColor: '#fff',
borderRadius: 10,
borderColor: '#2D328C',
borderWidth: 1,
marginBottom: 20,
},
instructionText: {
fontSize: 18,
color: '#2D328C',
fontWeight: 'bold',
marginBottom: 10,
textAlign: 'center',
},
instructionItem: {
fontSize: 16,
color: '#555',
marginBottom: 10,
},
connectButton: {
width: '100%',
height: 50,
backgroundColor: '#FF1B08', // Red background for the button
justifyContent: 'center',
alignItems: 'center',
borderRadius: 5,
},
buttonText: {
color: '#fff',
fontSize: 18,
fontWeight: 'bold',
},
spinner: {
marginVertical: 20,
},
});