generated from VeeamCommunity/veeamcommunity-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ActiveAlarmsScreen.js
123 lines (117 loc) · 3.08 KB
/
ActiveAlarmsScreen.js
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
import React from 'react';
import { SafeAreaView, StyleSheet, Text, View, FlatList, TouchableOpacity } from 'react-native';
import { useNavigation, useRoute } from '@react-navigation/native';
const ActiveAlarmsScreen = () => {
const navigation = useNavigation();
const route = useRoute();
const { alarms } = route.params;
const renderAlarmItem = ({ item }) => (
<TouchableOpacity
style={styles.alarmItem}
onPress={() => handleViewAlarmDetails(item)}
>
<View style={styles.alarmInfo}>
<Text style={styles.alarmName}>{item.object?.objectName || 'Unknown Object'}</Text>
<Text style={styles.alarmMessage}>{item.lastActivation?.message || 'No message'}</Text>
</View>
<View style={[styles.alarmStatus, styles[item.lastActivation?.status?.toLowerCase() || 'unknown']]} >
<Text style={styles.alarmStatusText}>{item.lastActivation?.status || 'Unknown'}</Text>
</View>
</TouchableOpacity>
);
const handleViewAlarmDetails = (alarm) => {
alert(`Alarm Details:\n\nObject: ${alarm.object?.objectName || 'Unknown'}\nStatus: ${alarm.lastActivation?.status || 'Unknown'}\nMessage: ${alarm.lastActivation?.message || 'No message'}`);
};
return (
<SafeAreaView style={styles.container}>
<View style={styles.header}>
<TouchableOpacity onPress={() => navigation.goBack()}>
<Text style={styles.backButton}>← Back</Text>
</TouchableOpacity>
<Text style={styles.title}>Active Alarms</Text>
</View>
<FlatList
data={alarms}
renderItem={renderAlarmItem}
keyExtractor={(item, index) => item.id?.toString() || index.toString()}
contentContainerStyle={styles.listContent}
/>
</SafeAreaView>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#F5F5F5',
},
header: {
flexDirection: 'row',
alignItems: 'center',
padding: 16,
backgroundColor: '#004D40',
},
backButton: {
fontSize: 18,
color: '#FFFFFF',
marginRight: 16,
},
title: {
fontSize: 20,
fontWeight: 'bold',
color: '#FFFFFF',
},
listContent: {
padding: 16,
},
alarmItem: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
backgroundColor: '#FFFFFF',
borderRadius: 8,
padding: 16,
marginBottom: 12,
shadowColor: '#000',
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.1,
shadowRadius: 4,
elevation: 3,
},
alarmInfo: {
flex: 1,
marginRight: 16,
},
alarmName: {
fontSize: 16,
fontWeight: 'bold',
color: '#333',
marginBottom: 4,
},
alarmMessage: {
fontSize: 14,
color: '#666',
},
alarmStatus: {
paddingHorizontal: 8,
paddingVertical: 4,
borderRadius: 4,
},
alarmStatusText: {
fontSize: 12,
fontWeight: 'bold',
color: '#FFFFFF',
},
error: {
backgroundColor: '#FF5252',
},
warning: {
backgroundColor: '#FFA000',
},
info: {
backgroundColor: '#2196F3',
},
resolved: {
backgroundColor: '#4CAF50',
},
});
export default ActiveAlarmsScreen;