// Tabs component custom
//
// Props:
// tabs: array
// selectedTab: object
// onSelectTab: function
//
import React from 'react'
import { StyleSheet, View, TouchableOpacity } from 'react-native'
import { colors, spacing } from '../theme'
import Text from './Text'

const Tabs = ({ tabs, selectedTab, onSelectTab }) => {
  return (
    <View style={styles.container}>
      {tabs.map((tab) => (
        <TouchableOpacity
          key={tab.id}
          style={styles.tab}
          onPress={() => onSelectTab(tab)}
        >
          <Text
            style={[
              styles.text,
              selectedTab.id === tab.id ? styles.selectedText : null,
            ]}
          >
            {tab.name}
          </Text>
        </TouchableOpacity>
      ))}
    </View>
  )
}

const styles = StyleSheet.create({
  container: {
    flexDirection: 'row',
    justifyContent: 'space-around',
    alignItems: 'center',
    backgroundColor: '#f8f4f4',
    // paddingVertical: 10,
  },
  tab: {
    flex: 1,
    alignItems: 'center',
  },
  text: {
    fontSize: 18,
    fontWeight: '500',
  },
  selectedText: {
    color: colors.primary,

    paddingVertical: spacing.s_2,
  },
})

export default Tabs
