import React from 'react';
import { View, TouchableOpacity, StyleSheet, Text } from 'react-native';

type ViewMode = 'stack' | 'grid';

interface ViewToggleProps {
  mode: ViewMode;
  onToggle: (mode: ViewMode) => void;
}

export function ViewToggle({ mode, onToggle }: ViewToggleProps) {
  return (
    <View style={styles.container}>
      <TouchableOpacity
        style={[styles.button, mode === 'stack' && styles.buttonActive]}
        onPress={() => onToggle('stack')}
      >
        <Text style={[styles.buttonText, mode === 'stack' && styles.buttonTextActive]}>
          Stack
        </Text>
      </TouchableOpacity>
      <TouchableOpacity
        style={[styles.button, mode === 'grid' && styles.buttonActive]}
        onPress={() => onToggle('grid')}
      >
        <Text style={[styles.buttonText, mode === 'grid' && styles.buttonTextActive]}>
          Grid
        </Text>
      </TouchableOpacity>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flexDirection: 'row',
    backgroundColor: '#f0f0f0',
    borderRadius: 8,
    padding: 4,
    gap: 4,
  },
  button: {
    flex: 1,
    paddingVertical: 8,
    paddingHorizontal: 16,
    borderRadius: 6,
    alignItems: 'center',
  },
  buttonActive: {
    backgroundColor: '#fff',
    shadowColor: '#000',
    shadowOffset: { width: 0, height: 1 },
    shadowOpacity: 0.1,
    shadowRadius: 2,
    elevation: 2,
  },
  buttonText: {
    fontSize: 14,
    fontWeight: '500',
    color: '#666',
  },
  buttonTextActive: {
    color: '#333',
    fontWeight: '600',
  },
});
