import React , {useState}from 'react';
 
import C from 'rn-class'
import i18n from  "i18n-js";
import _ from 'lodash'

export default (props)=>{
    const initData  = [
        { title : i18n.t("ServiceAlarm.NewContentsUpload") , subtitle : "New Contents Upload" , switch : {value :  true , } , icon : {type:"antdesign" , name:"user" } },
        { title : i18n.t("ServiceAlarm.TodaysWords") , subtitle : "Today’s Words" , switch : {value : false,  } , icon : {type:"antdesign" , name:"user" }},
        { title : i18n.t("ServiceAlarm.TimeSchedule") , subtitle : "Time Schedule" , switch : {value : false,  } , icon : {type:"antdesign" , name:"user" }},
    ] 
    let [datas , setDatas]= useState(initData);
    
    return (
        <C.View cls="flx1 bgc-color-white"> 
            <C.EL.Header 
                    ccls="bgc-color-transparent" 
                    leftComponent={<C.EL.Icon type="antdesign" name="close" onPress={()=>props.navigation.goBack()}/>}  
                >
                </C.EL.Header>
                <C.View cls="flx1 jc-sa ai-c">
                    <C.View  >
                        <C.Text cls="f3 fw-b"> 
                            컨텐츠 알람
                        </C.Text>
                        <C.Text cls="f2"> 
                        Contents Alarm
                        </C.Text>
                    </C.View>
                    <C.View cls="mb10"> 
                        {
                            datas.map((obj, idx) =>{
                                
                                let onoffEvent = (o)=>{
                                    obj.switch.value = !obj.switch.value ;
                                    setDatas(_.map(datas , (o)=>{return o ;})); 
                                }
                                return (
                                    <C.EL.ListItem
                                        key={`item_${idx}`}
                                        ccls="w100"
                                        leftIcon={obj.icon}
                                        title={obj.title} 
                                        subtitle={obj.subtitle}  
                                        rightElement={<C.Switch {...obj.switch}   onValueChange ={onoffEvent} />}
                                        />
                                )
                            })
                        }
                        
                        {/* <C.EL.Button ccls="w90%"  btncls="br10" title="다붓컨설팅 홈페이지"></C.EL.Button> */}
                    </C.View>
                </C.View>
        </C.View>
    )  


}

