forked from ZyntariHQ/Invoisio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOnlineStatusIndicator.tsx
More file actions
48 lines (43 loc) · 1.15 KB
/
Copy pathOnlineStatusIndicator.tsx
File metadata and controls
48 lines (43 loc) · 1.15 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
import React from "react";
import { View, Text, StyleSheet } from "react-native";
import { useConnectivity } from "../hooks/use-connectivity";
export function OnlineStatusIndicator() {
const { isConnected, isInternetReachable, isDegraded } = useConnectivity();
let statusColor = "#22C55E"; // green
let statusText = "Online";
if (!isConnected) {
statusColor = "#DC2626"; // red
statusText = "Offline";
} else if (isDegraded || isInternetReachable === false) {
statusColor = "#F59E0B"; // yellow
statusText = "Degraded";
}
return (
<View style={[styles.container, { backgroundColor: statusColor }]}>
<View style={styles.indicator} />
<Text style={styles.text}>{statusText}</Text>
</View>
);
}
const styles = StyleSheet.create({
container: {
flexDirection: "row",
alignItems: "center",
paddingHorizontal: 8,
paddingVertical: 4,
borderRadius: 12,
backgroundColor: "#22C55E",
},
indicator: {
width: 6,
height: 6,
borderRadius: 3,
backgroundColor: "#FFFFFF",
marginRight: 6,
},
text: {
color: "#FFFFFF",
fontSize: 10,
fontFamily: "Inter_600SemiBold",
},
});