AlarmItem.js
4.32 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
import { useState } from 'react';
import {post} from 'axios'
import {Dimensions, View,Text,Image,StyleSheet,TouchableOpacity,TouchableHighlight,Alert} from 'react-native'
import * as React from 'react'
import moment from 'moment'
import Modal from 'react-native-modal';
import TimeAgo from 'react-native-timeago';
import AsyncStorage from '@react-native-community/async-storage'
import Options from '../assets/Options.svg'
let timestamp = "2020-06-01T05:24:44.124Z";
require('moment/locale/ko'); //for import moment local language file during the application build
moment.locale('ko');//set moment local language to zh-cn
export default ({ item, height, handleHeight,index,config,setItem,i }) => {
React.useEffect(() => {
},[])
const HandleAlarm = (e,i) => {
var temp = e
if(e.alarm == true || e.alarm ==false) {
temp.alarm = !e.alarm
}
else {
temp.alarm = true
}
setItem(temp,i)
AsyncStorage.getItem("AlarmList",(err,res) => {
var tem = JSON.parse(res)
if(res) {
if(tem.filter((el,i) => {
if(el.id == e.id) {
tem[i].alarm = !tem[i].alarm
}
return el.id == e.id
}).length > 0) {
AsyncStorage.setItem("AlarmList",JSON.stringify(tem))
}
else {
AsyncStorage.setItem("AlarmList",JSON.stringify(tem.push(e)))
}
}
else {
e.alarm=true
AsyncStorage.setItem("AlarmList",JSON.stringify([e]))
AsyncStorage.getItem("AlarmList",(err,res) => {
})
}
})
}
return (
<View style={{paddingLeft:24,paddingRight:24,backgroundColor:"white"}}>
<View style={{paddingTop:8,paddingBottom:8,backgroundColor:"white",width:"100%",borderBottomColor:"#BDBCBC",borderBottomWidth:1}}>
<View style={{flexDirection:"row"}}>
<Image style={{alignSelf:"center",width:Dimensions.get("screen").width*0.16,height:Dimensions.get("screen").width*0.16}} resizeMode="stretch" source={require('../assets/img.png')} />
{config == true?<View style={{marginLeft:16,width:Dimensions.get("screen").width*0.60}}>
<Text style={{color:"black",fontSize:15,marginBottom:4}}>
{item.name}
</Text>
<View style={{flexDirection:"row",justifyContent:"space-between"}}>
<Text style={{fontSize:12,color:"#615F5F"}}>
{item.category}
</Text>
{item.alarm==false?
<TouchableOpacity onPress={() => HandleAlarm(item,i)}><Text style={{fontSize:15,fontWeight:"bold",color:"#615F5F"}}>
off
</Text></TouchableOpacity>
:
<TouchableOpacity onPress={() => HandleAlarm(item,i)}><Text style={{fontSize:15,fontWeight:"bold",color:"#FFD63A"}}>
on
</Text></TouchableOpacity>}
</View>
<Text style={{fontSize:12,color:"#615F5F",marginTop:6}}>
{item.phone_number}
</Text>
</View>
:
<View style={{marginLeft:16}}>
<Text style={{color:"black",fontSize:15,marginBottom:4}}>
{item.name}
</Text>
<Text style={{fontSize:12,color:"#615F5F"}}>
#이벤트 # 연말치킨파티
</Text>
<Text style={{fontSize:12,color:"#615F5F"}}>
12월 31일 모든 치킨 30% 할인 합니다.
</Text>
<TimeAgo style={{color:"#979292",fontSize:9}} time={timestamp} />
</View>}
</View>
</View>
</View>
)
}
const style = StyleSheet.create({
text:{
color:"#707070",
fontSize:11,
fontWeight:"900"
}
})