import React, { useState } from 'react';
import { StyleSheet, View } from 'react-native';
import { Counter } from '@proximus/react-native-common-ui/lib/inputs/Counter';
import { useFonts } from 'expo-font';

export default function App() {
  const [value, setValue] = useState(0);
  const loaded = useFonts({
    'Proximus-Bold': require('@proximus/react-native-font-icons/lib/assets/fonts/Proximus-Bold.ttf'),
    'Proximus-Regular': require('@proximus/react-native-font-icons/lib/assets/fonts/Proximus-Regular.ttf'),
    Proximus: require('@proximus/react-native-font-icons/lib/assets/fonts/Proximus-Regular.ttf'),
    Nucleo: require('@proximus/react-native-font-icons/lib/assets/fonts/Nucleo.ttf'),
  });

  if (!loaded) {
    return <View />;
  }

  return (
    <View style={styles.container}>
      <View style={styles.viewRow}>
        <Counter value={value} onValueChange={setValue} label={'Default'} />
      </View>
      <View style={styles.viewRow}>
        <Counter
          value={value}
          onValueChange={setValue}
          hasError
          errorHelper={'Helper text'}
          label={'Error'}
        />
      </View>
      <View style={styles.viewRow}>
        <Counter
          value={value}
          onValueChange={setValue}
          successHelper={'Helper text'}
          label={'Success'}
        />
      </View>
      <View style={styles.viewRow}>
        <Counter
          value={value}
          onValueChange={setValue}
          textFieldWidth={200}
          label={'Custom width'}
        />
      </View>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
    padding: 20,
  },
  viewRow: {
    marginBottom: 10,
  },
});
