<commit_before>import { Animated, Easing, TouchableHighlight, View, Text } from 'react-native';
import { Icon } from 'react-native-elements';
import { connect } from 'react-redux';
import Collapsible from 'react-native-collapsible';
import React from 'react';

import { foiRequestsFilterChange } from '../../actions/foiRequests';
import { getFilterableStatus, shortenLabel } from '../../utils';
import { grey, greyDark, primaryColor, greyLight } from '../../globals/colors';
import { styles } from './styles';
import FilterDropDown from '../../components/library/FilterDropDown';
import FilterDropDownButton from '../../components/library/FilterDropDownButton';
import I18n from '../../i18n';
import jurisdictionList from '../../data/jurisdiction.json';
import categoryList from '../../data/category.json';

const DROPDOWN_ANIMATION_DURATION = 300; // ms
const DROPDOWN_ANIMATION_PAUSE_BETWEEN_CHANGE = 100; // ms

const filterPossibilities = ['status', 'jurisdiction', 'category'];
const filterOptionsData = {
  status: getFilterableStatus().map(x => {
    return { param: x.id, label: I18n.t(x.id) };
  }),
  jurisdiction: jurisdictionList.map(x => {
    return { param: x.id, label: x.name };
  }),
  category: categoryList.map(x => {
    return { param: x, label: x };
  }),
};

class FoiRequestsListHeader extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      collapsed: null,
      prevCollapsed: null,
      dropdownAnim: new Animated.Value(0),
    };
  }

  startExpanding() {
    Animated.timing(this.state.dropdownAnim, {
      toValue: 1,
      duration: DROPDOWN_ANIMATION_DURATION,
      easing: Easing.linear,
    }).start();
  }

  startCollapsing() {
    Animated.timing(this.state.dropdownAnim, {
      toValue: 0,
      duration: DROPDOWN_ANIMATION_DURATION,
      easing: Easing.linear,
    }).start();
  }

  styleActiveTab(x) {
    const border = this.state.dropdownAnim.interpolate({
      inputRange: [0, 1],
      outputRange: [0, 3],
    });

    if (
      (this.state.collapsed === null && this.state.prevCollapsed === x) ||
      this.state.collapsed === x
    ) {
      return { borderBottomWidth: border, borderBottomColor: primaryColor };
    }

    return {
      borderBottomWidth: 1,
      borderBottomColor: greyLight,
    };
  }

  _onPress(x) {
    if (this.state.collapsed === x) {
      this.setState(
        {
          prevCollapsed: x,
          collapsed: null,
          dropdownAnim: new Animated.Value(1),
        },
        () => this.startCollapsing()
      );
    } else if (this.state.collapsed === null) {
      this.setState(
        {
          prevCollapsed: null,
          collapsed: x,
          dropdownAnim: new Animated.Value(0),
        },
        () => this.startExpanding()
      );
    } else {<commit_msg>fix bottom border for drop down buttuns<commit_after>import { Animated, Easing, TouchableHighlight, View, Text } from 'react-native';
import { Icon } from 'react-native-elements';
import { connect } from 'react-redux';
import Collapsible from 'react-native-collapsible';
import React from 'react';

import { foiRequestsFilterChange } from '../../actions/foiRequests';
import { getFilterableStatus, shortenLabel } from '../../utils';
import { grey, greyDark, primaryColor, greyLight } from '../../globals/colors';
import { styles } from './styles';
import FilterDropDown from '../../components/library/FilterDropDown';
import FilterDropDownButton from '../../components/library/FilterDropDownButton';
import I18n from '../../i18n';
import jurisdictionList from '../../data/jurisdiction.json';
import categoryList from '../../data/category.json';

const DROPDOWN_ANIMATION_DURATION = 300; // ms
const DROPDOWN_ANIMATION_PAUSE_BETWEEN_CHANGE = 100; // ms

const filterPossibilities = ['status', 'jurisdiction', 'category'];
const filterOptionsData = {
  status: getFilterableStatus().map(x => {
    return { param: x.id, label: I18n.t(x.id) };
  }),
  jurisdiction: jurisdictionList.map(x => {
    return { param: x.id, label: x.name };
  }),
  category: categoryList.map(x => {
    return { param: x, label: x };
  }),
};

class FoiRequestsListHeader extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      collapsed: null,
      prevCollapsed: null,
      dropdownAnim: new Animated.Value(0),
    };
  }

  startExpanding() {
    Animated.timing(this.state.dropdownAnim, {
      toValue: 1,
      duration: DROPDOWN_ANIMATION_DURATION,
      easing: Easing.linear,
    }).start();
  }

  startCollapsing() {
    Animated.timing(this.state.dropdownAnim, {
      toValue: 0,
      duration: DROPDOWN_ANIMATION_DURATION,
      easing: Easing.linear,
    }).start();
  }

  styleActiveTab(x) {
    const { collapsed, prevCollapsed } = this.state;

    if (collapsed === null && prevCollapsed !== x) return {};

    const border = this.state.dropdownAnim.interpolate({
      inputRange: [0, 1],
      outputRange: [0, 3],
    });

    if ((collapsed === null && prevCollapsed === x) || collapsed === x) {
      return { borderBottomWidth: border, borderBottomColor: primaryColor };
    }

    return {
      borderBottomWidth: 1,
      borderBottomColor: greyLight,
    };
  }

  _onPress(x) {
    if (this.state.collapsed === x) {
      this.setState(
        {
          prevCollapsed: x,
          collapsed: null,
          dropdownAnim: new Animated.Value(1),
        },
        () => this.startCollapsing()
      );
    } else if (this.state.collapsed === null) {
      this.setState(
        {
          prevCollapsed: null,
          collapsed: x,
          dropdownAnim: new Animated.Value(0),
        },
        () => this.startExpanding()
      );
    } else {
{'fraction_non_alphanumeric': 0.1455341506129597, 'fraction_numerical': 0.007705779334500876, 'mean_word_length': 2.898293515358362, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7243721', 'n_tokens_mistral': 1800, 'n_tokens_neox': 1759, 'n_words': 388}