Commit 8ab12442 by Tonk

update test read notification

parent 8d82acd1
......@@ -108,7 +108,7 @@ export default class HistoryScreen extends React.Component {
<XAxis
style={{ marginHorizontal: -10, position: 'absolute', left: 40, right: 15, bottom: 0 }}
data={data}
formatLabel={(value, index) => format(data[index].time * 1000, 'hh:mm')}
formatLabel={(value, index) => format(data[index].time * 1000, 'D/M/YY')}
contentInset={{ left: 10, right: 10 }}
svg={{ fontSize: 8, fill: color.grey }}
/>
......
[
{
"time": 1566370057,
"data": 356
},
{
"time": 1564639200,
"data": 345
},
......@@ -12,18 +8,10 @@
"data": 2356
},
{
"time": 1566374629,
"data": 123
},
{
"time": 1566317460,
"data": 45
},
{
"time": 1566438573,
"data": 457
},
{
"time": 1565863930,
"data": 243
},
......
......@@ -10,6 +10,7 @@ import { width, height } from '../../../constants/Layout';
import RNPickerSelect from 'react-native-picker-select';
import CalendarPicker from 'react-native-calendar-picker';
import { TouchableWithoutFeedback } from 'react-native-gesture-handler';
import { withNavigationFocus } from 'react-navigation';
const tabHeader = [
{ type: 'all', label: 'All' },
......@@ -17,7 +18,7 @@ const tabHeader = [
{ type: 'log', label: 'Logging' },
];
const dt2 = require('./notification.json');
export default class NotificationScreen extends React.Component {
class NotificationScreen extends React.Component {
static navigationOptions = ({ navigation }) => ({
title: 'Notifications',
headerLeft: (
......@@ -46,6 +47,17 @@ export default class NotificationScreen extends React.Component {
componentDidMount() {
this.sortDate();
}
componentDidUpdate(prevProps) {
if (prevProps.isFocused !== this.props.isFocused) {
console.log('test read notification');
this.setState(state => {
const readed = state.data.map(item => (item.read = true));
return {
readed,
};
});
}
}
sortDate() {
const sortData = dt2.sort(function(a, b) {
var dateA = new Date(a.time),
......@@ -162,9 +174,8 @@ export default class NotificationScreen extends React.Component {
return (
<View
style={[
theme.rowContainer,
styles.actionContainer,
// { backgroundColor: unread ? 'rgba(238, 84, 84, 0.15)' : color.white },
{ backgroundColor: !data.read ? 'rgba(238, 84, 84, 0.15)' : color.white },
]}
>
{data.type === 'log' ? (
......@@ -409,6 +420,8 @@ export default class NotificationScreen extends React.Component {
}
}
export default withNavigationFocus(NotificationScreen);
// style -------------------------------------------------------
const pickerStyle = {
inputIOS: {
......@@ -451,6 +464,7 @@ const styles = StyleSheet.create({
color: color.grey,
},
actionContainer: {
...theme.rowContainer,
paddingHorizontal: 30,
paddingVertical: 15,
alignItems: 'flex-start',
......
[
{ "type": "log", "user": "Sukanya161", "time": 1566370057, "action": "Switched on", "device": "sub breaker 4" },
{ "type": "log", "user": "Sukanya161", "time": 1564639200, "action": "Switched off", "device": "sub breaker 1" },
{
"type": "log",
"user": "Sukanya161",
"time": 1566370057,
"action": "Switched on",
"device": "sub breaker 4",
"read": true
},
{
"type": "log",
"user": "Sukanya161",
"time": 1564639200,
"action": "Switched off",
"device": "sub breaker 1",
"read": true
},
{
"type": "notification",
"user": "Sukanya161",
"time": 1566370196,
"action": "Switched on",
"device": "sub breaker 2"
"device": "sub breaker 2",
"read": true
},
{
"type": "log",
"user": "Sukanya161",
"time": 1566371305,
"action": "Switched on",
"device": "sub breaker 1",
"read": true
},
{
"type": "log",
"user": "Sukanya161",
"time": 1566374629,
"action": "Switched on",
"device": "sub breaker 3",
"read": true
},
{
"type": "notification",
"user": "Tonk",
"time": 1566317460,
"action": "Set timer",
"device": "mcb link 1",
"read": true
},
{
"type": "notification",
"user": "Tonk",
"time": 1566438573,
"action": "Set timer",
"device": "mcb link 2",
"read": true
},
{
"type": "notification",
"user": "Tonk",
"time": 1565863930,
"action": "???",
"device": "???",
"read": true
},
{
"type": "notification",
"user": "Tonk",
"time": 1565777530,
"action": "???",
"device": "???",
"read": true
},
{
"type": "log",
"user": "Sukanya161",
"time": 1566467247,
"action": "Switched on",
"device": "sub breaker 4",
"read": true
},
{
"type": "log",
"user": "Sukanya161",
"time": 1564639200,
"action": "Switched off",
"device": "sub breaker 1",
"read": true
},
{ "type": "log", "user": "Sukanya161", "time": 1566371305, "action": "Switched on", "device": "sub breaker 1" },
{ "type": "log", "user": "Sukanya161", "time": 1566374629, "action": "Switched on", "device": "sub breaker 3" },
{ "type": "notification", "user": "Tonk", "time": 1566317460, "action": "Set timer", "device": "mcb link 1" },
{ "type": "notification", "user": "Tonk", "time": 1566438573, "action": "Set timer", "device": "mcb link 2" },
{ "type": "notification", "user": "Tonk", "time": 1565863930, "action": "???", "device": "???" },
{ "type": "notification", "user": "Tonk", "time": 1565777530, "action": "???", "device": "???" },
{ "type": "log", "user": "Sukanya161", "time": 1566467247, "action": "Switched on", "device": "sub breaker 4" },
{ "type": "log", "user": "Sukanya161", "time": 1564639200, "action": "Switched off", "device": "sub breaker 1" },
{
"type": "notification",
"user": "Sukanya161",
"time": 1566433810,
"action": "Switched on",
"device": "sub breaker 2"
"device": "sub breaker 2",
"read": true
},
{
"type": "log",
"user": "Sukanya161",
"time": 1566371305,
"action": "Switched on",
"device": "sub breaker 1",
"read": true
},
{
"type": "log",
"user": "Sukanya161",
"time": 1566374629,
"action": "Switched on",
"device": "sub breaker 3",
"read": true
},
{ "type": "log", "user": "Sukanya161", "time": 1566371305, "action": "Switched on", "device": "sub breaker 1" },
{ "type": "log", "user": "Sukanya161", "time": 1566374629, "action": "Switched on", "device": "sub breaker 3" },
{ "type": "notification", "user": "Tonk", "time": 1566317460, "action": "Leaved", "device": "office" },
{ "type": "notification", "user": "Tonk", "time": 1561975930, "action": "Entered", "device": "office" },
{ "type": "notification", "user": "Tonk", "time": 1564481530, "action": "ง่วง", "device": "มากๆ" },
{ "type": "notification", "user": "Tonk", "time": 1563790330, "action": "หิว", "device": "ข้าว" },
{ "type": "notification", "user": "Tonk", "time": 1566528669, "action": "Sleep", "device": "" }
{
"type": "notification",
"user": "Tonk",
"time": 1566317460,
"action": "Leaved",
"device": "office",
"read": true
},
{
"type": "notification",
"user": "Tonk",
"time": 1561975930,
"action": "Entered",
"device": "office",
"read": true
},
{
"type": "notification",
"user": "Tonk",
"time": 1564481530,
"action": "ง่วง",
"device": "มากๆ",
"read": true
},
{
"type": "notification",
"user": "Tonk",
"time": 1563790330,
"action": "หิว",
"device": "ข้าว",
"read": true
},
{
"type": "notification",
"user": "Tonk",
"time": 1566528669,
"action": "Sleep",
"device": "",
"read": false
}
]
import React, { Component } from 'react';
import { Fab, Icon, Text } from 'native-base';
import {
View,
StyleSheet,
FlatList,
ScrollView,
Modal,
TouchableOpacity,
TextInput,
Animated,
Platform,
} from 'react-native';
import { Switch, Button, Col, Row } from 'native-base';
import { Icon, Text } from 'native-base';
import { View, StyleSheet, FlatList, ScrollView, Modal, TouchableOpacity, Platform } from 'react-native';
import { Switch, Button } from 'native-base';
import { HeaderButtons, Item as HeaderItem } from 'react-navigation-header-buttons';
import IoniconsHeaderButton from '../../../components/IoniconsHeaderButton';
import { color, theme } from '../../../constants/Styles';
import RNPickerSelect from 'react-native-picker-select';
import { Badge, CheckBox, SearchBar } from 'react-native-elements';
import { CheckBox, SearchBar } from 'react-native-elements';
import SwipeableRow from '../../../components/SwipeableRow';
import DatePicker from 'react-native-date-picker';
import { width, height } from '../../../constants/Layout';
import InputField from '../../../components/InputField';
import { height } from '../../../constants/Layout'
import { isIphoneX } from '../../../utils/isPhoneX';
import FadeDimBG from '../../../components/FadeDimBG';
import SlideUpModal from '../../../components/SlideUpModal';
......@@ -229,7 +218,11 @@ class TimerScreen extends Component {
</TouchableOpacity>
),
});
this.setState({
subBreakerFilterList: this.props.existedData,
});
console.log('STATE', this.state);
console.log('PROPS', this.props);
};
renderAddAndEditTimerModal = () => {
......@@ -443,7 +436,7 @@ class TimerScreen extends Component {
{this.renderAddAndEditTimerModal()}
{/* Filter Modal */}
{/* <Modal
<Modal
transparent
presentationStyle={'overFullScreen'}
animationType="fade"
......@@ -484,19 +477,19 @@ class TimerScreen extends Component {
]}
>
<RNPickerSelect
items={breaker}
items={this.state.pickerSelectData}
onValueChange={(value, index) => {
this.setState({ selectedBreaker: breaker[index - 1].sub });
this.setState({ selectedBreaker: value });
}}
useNativeAndroidPickerStyle={false}
placeholder={{ label: 'Select Breaker', value: null }}
placeholder={{ label: 'Select...', value: null }}
style={pickerStyle}
Icon={() => <Icon name="ios-arrow-down" style={{ fontSize: 14, color: '#c8c8c8' }} />}
/>
</View>
<FlatList
style={theme.mt2}
data={this.state.selectedBreaker}
data={this.state.subBreakerList}
ListEmptyComponent={() => (
<View>
<Text style={[theme.normalText, theme.mt2]}>No Sub breaker</Text>
......@@ -509,28 +502,31 @@ class TimerScreen extends Component {
fontFamily={'Avenir-Roman'}
textStyle={{ fontWeight: 'normal', color: color.darkGrey }}
title={'Sub breaker ' + item.id}
checked={this.state.selectedBreaker[index].active}
checked={this.state.subBreakerList[index].selected}
checkedIcon={
<Icon name="md-checkbox" style={{ color: color.primary, fontSize: 26 }} />
}
uncheckedIcon={
<Icon name="md-square-outline" style={{ color: color.grey, fontSize: 26 }} />
}
onPress={() =>
onPress={() => {
this.setState(prevState => ({
selectedBreaker: prevState.selectedBreaker.map(el =>
el.id === index + 1
? { ...el, active: !this.state.selectedBreaker[index].active }
: el
subBreakerList: prevState.subBreakerList.map((el, elementIndex) =>
elementIndex === index
? {
...el,
selected: !this.state.subBreakerList[index].selected,
}
: { ...el }
),
}))
}
}));
}}
/>
)}
keyExtractor={(item, index) => `sub${index}`}
/>
</SlideUpModal>
</Modal> */}
</Modal>
</>
);
}
......
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