<commit_before>import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { Platform } from 'react-native';

import {
    EMPTY_METRIC,
    AVG_VELOCITY_METRIC,
    RPE_METRIC,
    DURATION_METRIC,
    ROM_METRIC,
    PKH_METRIC,
    PKV_METRIC,
    EMPTY_QUANTIFIER,
    AVG_QUANTIFIER,
    BEST_EVER_QUANTIFIER,
    ABS_LOSS_QUANTIFIER,
} from 'app/constants/CollapsedMetricTypes';

import PickerModal from 'app/shared_features/picker/PickerModal';
import * as Actions from './SettingsEditMetricsActions';
import * as CollapsedSettingsSelectors from 'app/redux/selectors/CollapsedSettingsSelectors';
import * as CollapsedMetricsUtility from 'app/utility/transforms/CollapsedMetrics';

const pickerItem = (metric) => ({
    label: Platform.OS === 'ios' ? CollapsedMetricsUtility.metricString(metric) : CollapsedMetricsUtility.metricAbbreviation(metric),
    value: metric,
});

const generateItems = (quantifier) => {
    switch (quantifier) {
        case BEST_EVER_QUANTIFIER:
            return [
                pickerItem(EMPTY_METRIC),
                pickerItem(AVG_VELOCITY_METRIC),
                pickerItem(PKV_METRIC),
                pickerItem(DURATION_METRIC),
                pickerItem(RPE_METRIC),
            ];
        case AVG_QUANTIFIER:
        case ABS_LOSS_QUANTIFIER:
            return [
                pickerItem(EMPTY_METRIC),
                pickerItem(AVG_VELOCITY_METRIC),
                pickerItem(PKV_METRIC),
                pickerItem(ROM_METRIC),
                pickerItem(DURATION_METRIC),
                pickerItem(RPE_METRIC),
            ];
        default:
            return [
                pickerItem(EMPTY_METRIC),
                pickerItem(AVG_VELOCITY_METRIC),
                pickerItem(PKV_METRIC),
                pickerItem(PKH_METRIC),
                pickerItem(ROM_METRIC),
                pickerItem(DURATION_METRIC),
                pickerItem(RPE_METRIC),
            ];
    };
};

const mapStateToProps = (state, ownProps) => {
    if (Platform.OS === 'ios') {
        return {
            isModalShowing: CollapsedSettingsSelectors.getIsEditingMetric(state),
            items: generateItems(CollapsedSettingsSelectors.getCurrentQuantifier(state)),
            selectedValue: CollapsedSettingsSelectors.getCurrentMetric(state),
        };
    } else {
        switch (ownProps.rank) {
            case 1:
                return {
                    items: generateItems(CollapsedSettingsSelectors.getQuantifier1(state)),
                    selectedValue: CollapsedSettingsSelectors.getMetric1(state),
                };<commit_msg>Switch order of metrics in picker to get around android bug<commit_after>import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { Platform } from 'react-native';

import {
    EMPTY_METRIC,
    AVG_VELOCITY_METRIC,
    RPE_METRIC,
    DURATION_METRIC,
    ROM_METRIC,
    PKH_METRIC,
    PKV_METRIC,
    EMPTY_QUANTIFIER,
    AVG_QUANTIFIER,
    BEST_EVER_QUANTIFIER,
    ABS_LOSS_QUANTIFIER,
} from 'app/constants/CollapsedMetricTypes';

import PickerModal from 'app/shared_features/picker/PickerModal';
import * as Actions from './SettingsEditMetricsActions';
import * as CollapsedSettingsSelectors from 'app/redux/selectors/CollapsedSettingsSelectors';
import * as CollapsedMetricsUtility from 'app/utility/transforms/CollapsedMetrics';

const pickerItem = (metric) => ({
    label: Platform.OS === 'ios' ? CollapsedMetricsUtility.metricString(metric) : CollapsedMetricsUtility.metricAbbreviation(metric),
    value: metric,
});

const generateItems = (quantifier) => {
    switch (quantifier) {
        case BEST_EVER_QUANTIFIER:
            return [
                pickerItem(EMPTY_METRIC),
                pickerItem(PKV_METRIC),
                pickerItem(AVG_VELOCITY_METRIC),
                pickerItem(DURATION_METRIC),
                pickerItem(RPE_METRIC),
            ];
        case AVG_QUANTIFIER:
        case ABS_LOSS_QUANTIFIER:
            return [
                pickerItem(EMPTY_METRIC),
                pickerItem(ROM_METRIC),
                pickerItem(PKV_METRIC),
                pickerItem(AVG_VELOCITY_METRIC),
                pickerItem(DURATION_METRIC),
                pickerItem(RPE_METRIC),
            ];
        default:
            return [
                pickerItem(EMPTY_METRIC),
                pickerItem(PKH_METRIC),
                pickerItem(ROM_METRIC),
                pickerItem(PKV_METRIC),
                pickerItem(AVG_VELOCITY_METRIC),
                pickerItem(DURATION_METRIC),
                pickerItem(RPE_METRIC),
            ];
    };
};

const mapStateToProps = (state, ownProps) => {
    if (Platform.OS === 'ios') {
        return {
            isModalShowing: CollapsedSettingsSelectors.getIsEditingMetric(state),
            items: generateItems(CollapsedSettingsSelectors.getCurrentQuantifier(state)),
            selectedValue: CollapsedSettingsSelectors.getCurrentMetric(state),
        };
    } else {
        switch (ownProps.rank) {
            case 1:
                return {
                    items: generateItems(CollapsedSettingsSelectors.getQuantifier1(state)),
                    selectedValue: CollapsedSettingsSelectors.getMetric1(state),
                };
{'fraction_non_alphanumeric': 0.08666164280331574, 'fraction_numerical': 0.0011303692539562924, 'mean_word_length': 2.349526813880126, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '7249501', 'n_tokens_mistral': 1672, 'n_tokens_neox': 1583, 'n_words': 234}