/**
 * React Native Full App (https://store.enappd.com/product/react-native-full-app)
 *
 * Copyright © 2019-present Enappd. All rights reserved.
 *
 * This source code is licensed as per the terms found in the
 * LICENSE.md file in the root directory of this source tree.
 */
import React from 'react';
import { View, ListItem, Left, Text, Right, Radio } from 'native-base';
import { TouchableOpacity } from 'react-native';

interface ScheduleListProps {
  selectedIndex: number;
  scheduleTimeJson: any;
  container: any;
  gotoSelectRadio: (index: number) => void;
}

const ScheduleList = (props: ScheduleListProps) => {
  const { selectedIndex, scheduleTimeJson, container } = props;
  return (
    <View style={container}>
      {scheduleTimeJson.map((data: any, index: number) => {
        return (
          <View key={index}>
            <TouchableOpacity onPress={() => props.gotoSelectRadio(index)}>
              <ListItem>
                <Left>
                  <Text>{data.time}</Text>
                </Left>
                <Right>
                  <Radio selected={selectedIndex === index ? true : false} />
                </Right>
              </ListItem>
            </TouchableOpacity>
          </View>
        );
      })}
    </View>
  );
};
export default ScheduleList;
