AlarmConfig.js
6.61 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
163
164
165
166
167
168
169
170
171
172
173
import React, { Component } from 'react';
import { View, Text, StyleSheet,TouchableOpacity,Image } from 'react-native';
import MapView from 'react-native-daummap';
import Postcode from '../Postcode'
import AlarmItem from '../AlarmItem'
import { ScrollView } from 'react-native-gesture-handler';
import Heart from '../../assets/heart_.svg'
import Chat from '../../assets/chat_.svg'
import Home from '../../assets/home.svg'
import QR from '../../assets/qr.svg'
import Alarm from '../../assets/alarm.svg'
import AsyncStorage from '@react-native-community/async-storage'
import { TabRouter } from 'react-navigation';
import {put } from 'axios'
export default class AddTab extends Component {
static navigationOptions = {
headerShown: false
}
state = {
mapLoading:false,
alarmList:[],
notice:true,
allAlarm:false,
}
componentDidMount = () => {
AsyncStorage.getItem("AlarmList",(err,res) => {
if(res) {
this.setState({
alarmList:JSON.parse(res)
})
}
})
AsyncStorage.getItem("NoticeAlarm",(err,res) => {
if(res) {
this.setState({
notice:JSON.parse(res)
})
}
})
}
setItem = (e,i) => {
this.setState((prev) => ({
alarmList:[...prev.alarmList.slice(0,i),e,...prev.alarmList.slice(i+1,prev.alarmList.length)]
}))
}
HandleAllAlarmOff = () => {
if(this.state.allAlarm == false) {
this.setState({
allAlarm:true
})
var tem = this.state.alarmList
if(tem.filter((el,i) => {
el.alarm = true
return true
}).length > 0) {
AsyncStorage.setItem("AlarmList",JSON.stringify(tem))
}
this.state.alarmList.filter((e,i) => {
var temp = e
temp.alarm = true
this.setItem(temp,i)
})
}
else {
this.setState({
allAlarm:false
})
var tem = this.state.alarmList
if(tem.filter((el,i) => {
el.alarm = false
return true
}).length > 0) {
AsyncStorage.setItem("AlarmList",JSON.stringify(tem))
}
this.state.alarmList.filter((e,i) => {
var temp = e
temp.alarm = false
this.setItem(temp,i)
})
}
}
handleNoticeAlarmOff = () => {
this.setState((prev) => ({
notice:!prev.notice
}),() => {
AsyncStorage.setItem("NoticeAlarm",JSON.stringify(this.state.notice))
})
}
render() {
return (
<View style={{backgroundColor:"#BDBCBC",width:"100%",height:"100%"}}>
<View style={{width:"100%",flexDirection:"row",paddingTop:16,paddingBottom:16,paddingLeft:16,backgroundColor:"#615F5F"}}>
<TouchableOpacity onPress={() => this.props.navigation.goBack(null)}>
<Image source={require('../../assets/back.png')}/>
</TouchableOpacity>
<Text style={{color:"white",fontSize:16,marginLeft:16}}>
알림 설정
</Text>
</View>
<View style={{marginBottom:8}}>
<View style={{flexDirection:"row" }}>
<TouchableOpacity onPress={() => this.handleNoticeAlarmOff()} style={{width:"50%",backgroundColor:"white",paddingTop:8.9, paddingBottom:12,}}>
<Text style={[{textAlign:"center",borderRightColor:"#615F5F",borderRightWidth:1,color:"#615F5F"}]}>
공지사항 알림
{this.state.notice==false?
<Text style={{fontSize:15,fontWeight:"bold",color:"#615F5F"}}>
{" "}off
</Text>
:
<Text style={{fontSize:15,fontWeight:"bold",color:"#FFD63A"}}>
{" "}on
</Text>}
</Text>
</TouchableOpacity>
<TouchableOpacity onPress={() => this.HandleAllAlarmOff()} style={{width:"50%",backgroundColor:"white",paddingTop:8.9, paddingBottom:12}}>
<Text style={[{textAlign:"center",color:"#615F5F"}]}>
모든 소식
{this.state.allAlarm==false?
<Text style={{fontSize:15,fontWeight:"bold",color:"#615F5F"}}>
{" "}off
</Text>
:
<Text style={{fontSize:15,fontWeight:"bold",color:"#FFD63A"}}>
{" "}on
</Text>}
</Text>
</TouchableOpacity>
</View>
</View>
<ScrollView>
{this.state.alarmList.map((e,i) => <AlarmItem config={true} item={e} i={i} setItem={this.setItem}/> )}
</ScrollView>
<View style={{
shadowColor: "#000",
shadowOffset: {
width: 0,
height: 6,
},
shadowOpacity: 0.39,
shadowRadius: 8.30,
elevation: 13,
flexDirection:"row",justifyContent:"space-between",paddingLeft:24,paddingRight:24,paddingTop:19,paddingBottom:19,width:"100%",position:"absolute",backgroundColor:"white",bottom:0}}>
<Home onPress={() => this.props.navigation.navigate("Main_")}/>
<Chat onPress={() => this.props.navigation.navigate("ChatTab")}/>
<QR onPress={() => this.props.navigation.navigate("QRTab")}/>
<Heart onPress={() => this.props.navigation.navigate("LikeTab")}/>
<Alarm onPress={() => this.props.navigation.navigate("AlarmTab")}/>
</View>
</View>
);
}
}
const style = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
}
});