2020-03-23 17:32:51 +01:00
|
|
|
|
/* global alert */
|
|
|
|
|
import React, { Component } from 'react';
|
2020-07-20 15:38:46 +02:00
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
import { Icon } from 'react-native-elements';
|
2020-03-23 17:32:51 +01:00
|
|
|
|
import {
|
2020-06-15 20:47:54 +02:00
|
|
|
|
ActivityIndicator,
|
2020-11-17 09:43:38 +01:00
|
|
|
|
Dimensions,
|
2020-03-23 17:32:51 +01:00
|
|
|
|
FlatList,
|
2020-06-15 20:47:54 +02:00
|
|
|
|
Image,
|
2020-03-23 17:32:51 +01:00
|
|
|
|
Keyboard,
|
|
|
|
|
KeyboardAvoidingView,
|
2020-06-15 20:47:54 +02:00
|
|
|
|
Linking,
|
2020-03-23 17:32:51 +01:00
|
|
|
|
Platform,
|
2020-06-15 20:47:54 +02:00
|
|
|
|
SectionList,
|
2020-11-17 09:43:38 +01:00
|
|
|
|
StatusBar,
|
2020-06-15 20:47:54 +02:00
|
|
|
|
StyleSheet,
|
|
|
|
|
Text,
|
2020-03-23 17:32:51 +01:00
|
|
|
|
TextInput,
|
2020-06-15 20:47:54 +02:00
|
|
|
|
TouchableHighlight,
|
|
|
|
|
TouchableOpacity,
|
|
|
|
|
View,
|
2020-03-23 17:32:51 +01:00
|
|
|
|
} from 'react-native';
|
2020-11-17 09:43:38 +01:00
|
|
|
|
import Geolocation from '@react-native-community/geolocation';
|
|
|
|
|
|
2020-12-25 17:09:53 +01:00
|
|
|
|
import { BlueButtonLink, SafeBlueArea } from '../../BlueComponents';
|
|
|
|
|
import navigationStyle from '../../components/navigationStyle';
|
2020-03-23 17:32:51 +01:00
|
|
|
|
import { HodlHodlApi } from '../../class/hodl-hodl-api';
|
2020-06-19 02:24:26 +02:00
|
|
|
|
import * as NavigationService from '../../NavigationService';
|
2020-07-15 19:32:59 +02:00
|
|
|
|
import { BlueCurrentTheme } from '../../components/themes';
|
2020-11-17 09:43:38 +01:00
|
|
|
|
import BottomModal from '../../components/BottomModal';
|
2020-07-20 15:38:46 +02:00
|
|
|
|
import loc from '../../loc';
|
2020-10-24 19:20:59 +02:00
|
|
|
|
import { BlueStorageContext } from '../../blue_modules/storage-context';
|
2020-07-01 13:56:52 +02:00
|
|
|
|
const A = require('../../blue_modules/analytics');
|
2020-03-23 17:32:51 +01:00
|
|
|
|
|
|
|
|
|
const CURRENCY_CODE_ANY = '_any';
|
|
|
|
|
const METHOD_ANY = '_any';
|
|
|
|
|
|
2020-06-15 20:47:54 +02:00
|
|
|
|
const HodlHodlListSections = { OFFERS: 'OFFERS' };
|
2020-08-08 04:22:51 +02:00
|
|
|
|
const windowHeight = Dimensions.get('window').height;
|
2020-08-27 02:20:13 +02:00
|
|
|
|
Geolocation.setRNConfiguration({ authorizationLevel: 'whenInUse' });
|
2020-11-17 09:43:38 +01:00
|
|
|
|
|
2020-03-23 17:32:51 +01:00
|
|
|
|
export default class HodlHodl extends Component {
|
2020-10-24 19:20:59 +02:00
|
|
|
|
static contextType = BlueStorageContext;
|
2020-03-23 17:32:51 +01:00
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
|
|
this.state = {
|
2020-06-15 20:47:54 +02:00
|
|
|
|
HodlApi: false,
|
2020-03-23 17:32:51 +01:00
|
|
|
|
isLoading: true,
|
2020-06-15 20:47:54 +02:00
|
|
|
|
isRenderOfferVisible: false,
|
2020-03-23 17:32:51 +01:00
|
|
|
|
isChooseSideModalVisible: false,
|
|
|
|
|
isChooseCountryModalVisible: false,
|
|
|
|
|
isFiltersModalVisible: false,
|
|
|
|
|
isChooseCurrencyVisible: false,
|
|
|
|
|
isChooseMethodVisible: false,
|
2020-08-10 18:10:35 +02:00
|
|
|
|
showShowFlatListRefreshControl: false,
|
2020-03-23 17:32:51 +01:00
|
|
|
|
currency: false, // means no currency filtering is enabled by default
|
|
|
|
|
method: false, // means no payment method filtering is enabled by default
|
|
|
|
|
side: HodlHodlApi.FILTERS_SIDE_VALUE_SELL, // means 'show me sell offers as Im buying'
|
|
|
|
|
offers: [],
|
|
|
|
|
countries: [], // list of hodlhodl supported countries. filled later via api
|
|
|
|
|
currencies: [], // list of hodlhodl supported currencies. filled later via api
|
|
|
|
|
methods: [], // list of hodlhodl payment methods. filled later via api
|
|
|
|
|
country: HodlHodlApi.FILTERS_COUNTRY_VALUE_GLOBAL, // country currently selected by user to display orders on screen. this is country code
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-15 20:47:54 +02:00
|
|
|
|
handleLoginPress = () => {
|
|
|
|
|
const handleLoginCallback = (hodlApiKey, hodlHodlSignatureKey) => {
|
2020-10-24 19:20:59 +02:00
|
|
|
|
this.context.setHodlHodlApiKey(hodlApiKey, hodlHodlSignatureKey);
|
2020-06-15 20:47:54 +02:00
|
|
|
|
const displayLoginButton = !hodlApiKey;
|
|
|
|
|
const HodlApi = new HodlHodlApi(hodlApiKey);
|
|
|
|
|
this.setState({ HodlApi, hodlApiKey });
|
|
|
|
|
this.props.navigation.setParams({ displayLoginButton });
|
|
|
|
|
};
|
2020-07-15 19:32:59 +02:00
|
|
|
|
NavigationService.navigate('HodlHodlLoginRoot', { params: { cb: handleLoginCallback }, screen: 'HodlHodlLogin' });
|
2020-06-15 20:47:54 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
handleMyContractsPress = () => {
|
|
|
|
|
NavigationService.navigate('HodlHodlMyContracts');
|
|
|
|
|
};
|
|
|
|
|
|
2020-03-23 17:32:51 +01:00
|
|
|
|
/**
|
|
|
|
|
* Fetch offers and set those offers into state
|
|
|
|
|
*
|
|
|
|
|
* @returns {Promise<void>}
|
|
|
|
|
*/
|
|
|
|
|
async fetchOffers() {
|
2020-06-01 14:54:23 +02:00
|
|
|
|
const pagination = {
|
2020-03-23 17:32:51 +01:00
|
|
|
|
[HodlHodlApi.PAGINATION_LIMIT]: 200,
|
|
|
|
|
};
|
2020-06-01 14:54:23 +02:00
|
|
|
|
const filters = {
|
2020-03-23 17:32:51 +01:00
|
|
|
|
[HodlHodlApi.FILTERS_SIDE]: this.state.side,
|
|
|
|
|
[HodlHodlApi.FILTERS_ASSET_CODE]: HodlHodlApi.FILTERS_ASSET_CODE_VALUE_BTC,
|
|
|
|
|
[HodlHodlApi.FILTERS_INCLUDE_GLOBAL]: this.state.country === HodlHodlApi.FILTERS_COUNTRY_VALUE_GLOBAL,
|
|
|
|
|
[HodlHodlApi.FILTERS_ONLY_WORKING_NOW]: true, // so there wont be any offers which user tries to open website says 'offer not found'
|
|
|
|
|
};
|
|
|
|
|
|
2020-06-15 20:47:54 +02:00
|
|
|
|
if (this.state.country !== HodlHodlApi.FILTERS_COUNTRY_VALUE_GLOBAL) {
|
|
|
|
|
filters[HodlHodlApi.FILTERS_COUNTRY] = this.state.country;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-23 17:32:51 +01:00
|
|
|
|
if (this.state.currency) {
|
|
|
|
|
filters[HodlHodlApi.FILTERS_CURRENCY_CODE] = this.state.currency;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.state.method) {
|
|
|
|
|
filters[HodlHodlApi.FILTERS_PAYMENT_METHOD_ID] = this.state.method;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-01 14:54:23 +02:00
|
|
|
|
const sort = {
|
2020-03-23 17:32:51 +01:00
|
|
|
|
[HodlHodlApi.SORT_BY]: HodlHodlApi.SORT_BY_VALUE_PRICE,
|
2020-06-25 18:37:50 +02:00
|
|
|
|
[HodlHodlApi.SORT_DIRECTION]:
|
|
|
|
|
this.state.side === HodlHodlApi.FILTERS_SIDE_VALUE_SELL
|
|
|
|
|
? HodlHodlApi.SORT_DIRECTION_VALUE_ASC
|
|
|
|
|
: HodlHodlApi.SORT_DIRECTION_VALUE_DESC,
|
2020-03-23 17:32:51 +01:00
|
|
|
|
};
|
2020-06-15 20:47:54 +02:00
|
|
|
|
const offers = await this.state.HodlApi.getOffers(pagination, filters, sort);
|
2020-03-23 17:32:51 +01:00
|
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
offers,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* fetches all countries from API and sets them to state
|
|
|
|
|
*
|
|
|
|
|
* @returns {Promise<void>}
|
|
|
|
|
**/
|
|
|
|
|
async fetchListOfCountries() {
|
2020-06-15 20:47:54 +02:00
|
|
|
|
const countries = await this.state.HodlApi.getCountries();
|
2020-03-23 17:32:51 +01:00
|
|
|
|
this.setState({ countries });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* fetches all currencies from API and sets them to state
|
|
|
|
|
*
|
|
|
|
|
* @returns {Promise<void>}
|
|
|
|
|
**/
|
|
|
|
|
async fetchListOfCurrencies() {
|
2020-06-15 20:47:54 +02:00
|
|
|
|
const currencies = await this.state.HodlApi.getCurrencies();
|
2020-03-23 17:32:51 +01:00
|
|
|
|
this.setState({ currencies });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* fetches all payment methods from API and sets them to state
|
|
|
|
|
*
|
|
|
|
|
* @returns {Promise<void>}
|
|
|
|
|
**/
|
|
|
|
|
async fetchListOfMethods() {
|
2020-06-15 20:47:54 +02:00
|
|
|
|
const methods = await this.state.HodlApi.getPaymentMethods(this.state.country || HodlHodlApi.FILTERS_COUNTRY_VALUE_GLOBAL);
|
2020-03-23 17:32:51 +01:00
|
|
|
|
this.setState({ methods });
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-25 18:37:50 +02:00
|
|
|
|
onFocus = async () => {
|
2020-10-24 19:20:59 +02:00
|
|
|
|
const hodlApiKey = await this.context.getHodlHodlApiKey();
|
2020-06-25 18:37:50 +02:00
|
|
|
|
const displayLoginButton = !hodlApiKey;
|
|
|
|
|
|
|
|
|
|
if (hodlApiKey && !this.state.hodlApiKey) {
|
|
|
|
|
// only if we had no key, and now we do, we update state
|
|
|
|
|
// (means user logged in)
|
|
|
|
|
this.setState({ hodlApiKey });
|
|
|
|
|
this.props.navigation.setParams({ displayLoginButton });
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
|
this._unsubscribeFocus();
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-23 17:32:51 +01:00
|
|
|
|
async componentDidMount() {
|
|
|
|
|
console.log('wallets/hodlHodl - componentDidMount');
|
2020-06-25 18:37:50 +02:00
|
|
|
|
this._unsubscribeFocus = this.props.navigation.addListener('focus', this.onFocus);
|
2020-03-26 18:26:13 +01:00
|
|
|
|
A(A.ENUM.NAVIGATED_TO_WALLETS_HODLHODL);
|
2020-03-23 17:32:51 +01:00
|
|
|
|
|
2020-10-24 19:20:59 +02:00
|
|
|
|
const hodlApiKey = await this.context.getHodlHodlApiKey();
|
2020-06-15 20:47:54 +02:00
|
|
|
|
const displayLoginButton = !hodlApiKey;
|
|
|
|
|
|
|
|
|
|
const HodlApi = new HodlHodlApi(hodlApiKey);
|
|
|
|
|
this.setState({ HodlApi, hodlApiKey });
|
2020-07-15 19:32:59 +02:00
|
|
|
|
this.props.navigation.setParams({
|
|
|
|
|
handleLoginPress: this.handleLoginPress,
|
|
|
|
|
displayLoginButton: displayLoginButton,
|
|
|
|
|
handleMyContractsPress: this.handleMyContractsPress,
|
|
|
|
|
});
|
2020-06-15 20:47:54 +02:00
|
|
|
|
|
2020-03-23 17:32:51 +01:00
|
|
|
|
try {
|
|
|
|
|
await this.fetchOffers();
|
|
|
|
|
} catch (Error) {
|
|
|
|
|
alert(Error.message);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
isLoading: false,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.fetchListOfCountries();
|
|
|
|
|
this.fetchListOfCurrencies();
|
|
|
|
|
this.fetchListOfMethods();
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-15 19:32:59 +02:00
|
|
|
|
_onPress = item => {
|
2020-06-15 20:47:54 +02:00
|
|
|
|
const offers = this.state.offers.filter(value => value.id === item.id);
|
|
|
|
|
if (offers && offers[0]) {
|
2020-07-15 19:32:59 +02:00
|
|
|
|
this.props.navigation.navigate('HodlHodlViewOffer', { offerToDisplay: offers[0] });
|
2020-06-15 20:47:54 +02:00
|
|
|
|
} else {
|
|
|
|
|
Linking.openURL('https://hodlhodl.com/offers/' + item.id);
|
|
|
|
|
}
|
2020-07-15 19:32:59 +02:00
|
|
|
|
};
|
2020-03-23 17:32:51 +01:00
|
|
|
|
|
|
|
|
|
_onCountryPress(item) {
|
|
|
|
|
this.setState(
|
|
|
|
|
{
|
|
|
|
|
country: item.code,
|
|
|
|
|
method: false, // invalidate currently selected payment method, as it is probably not valid for the new country
|
|
|
|
|
currency: false, // invalidate currently selected currency, as it is probably not valid for the new country
|
|
|
|
|
isChooseCountryModalVisible: false,
|
|
|
|
|
isLoading: true,
|
|
|
|
|
},
|
|
|
|
|
async () => {
|
|
|
|
|
await this.fetchOffers();
|
|
|
|
|
this.setState({
|
|
|
|
|
isLoading: false,
|
|
|
|
|
});
|
|
|
|
|
this.fetchListOfMethods(); // once selected country changed we fetch payment methods for this country
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_onCurrencyPress(item) {
|
|
|
|
|
this.setState(
|
|
|
|
|
{
|
|
|
|
|
currency: item.code === CURRENCY_CODE_ANY ? false : item.code,
|
|
|
|
|
isLoading: true,
|
|
|
|
|
isChooseCurrencyVisible: false,
|
|
|
|
|
},
|
|
|
|
|
async () => {
|
|
|
|
|
await this.fetchOffers();
|
|
|
|
|
this.setState({
|
|
|
|
|
isLoading: false,
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_onMethodPress(item) {
|
|
|
|
|
this.setState(
|
|
|
|
|
{
|
|
|
|
|
method: item.id === METHOD_ANY ? false : item.id,
|
|
|
|
|
isLoading: true,
|
|
|
|
|
isChooseMethodVisible: false,
|
|
|
|
|
},
|
|
|
|
|
async () => {
|
|
|
|
|
await this.fetchOffers();
|
|
|
|
|
this.setState({
|
|
|
|
|
isLoading: false,
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_onSidePress(item) {
|
|
|
|
|
this.setState(
|
|
|
|
|
{
|
|
|
|
|
isChooseSideModalVisible: false,
|
|
|
|
|
isLoading: true,
|
|
|
|
|
side: item.code,
|
|
|
|
|
},
|
|
|
|
|
async () => {
|
|
|
|
|
await this.fetchOffers();
|
|
|
|
|
this.setState({
|
|
|
|
|
isLoading: false,
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getItemText(item) {
|
|
|
|
|
let { title, description } = item;
|
|
|
|
|
title = title || '';
|
|
|
|
|
let ret = title;
|
|
|
|
|
if (description) {
|
|
|
|
|
if (description.startsWith(title)) title = '';
|
2020-06-01 14:54:23 +02:00
|
|
|
|
ret = title + '\n' + description.split('\n').slice(0, 2).join('\n');
|
2020-03-23 17:32:51 +01:00
|
|
|
|
}
|
|
|
|
|
if (ret.length >= 200) ret = ret.substr(0, 200) + '...';
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getMethodName(id) {
|
2020-06-01 14:54:23 +02:00
|
|
|
|
for (const m of this.state.methods) {
|
2020-03-23 17:32:51 +01:00
|
|
|
|
if (m.id === id) return m.name;
|
|
|
|
|
}
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getItemPrice(item) {
|
|
|
|
|
let price = item.price.toString();
|
|
|
|
|
if (price.length > 8) price = Math.round(item.price).toString();
|
|
|
|
|
|
|
|
|
|
switch (item.currency_code) {
|
|
|
|
|
case 'USD':
|
|
|
|
|
return '$ ' + price;
|
|
|
|
|
case 'GBP':
|
|
|
|
|
return '£ ' + price;
|
|
|
|
|
case 'RUB':
|
|
|
|
|
return '₽ ' + price;
|
|
|
|
|
case 'EUR':
|
|
|
|
|
return '€ ' + price;
|
|
|
|
|
case 'UAH':
|
|
|
|
|
return '₴ ' + price;
|
|
|
|
|
default:
|
|
|
|
|
return price + (price.length >= 9 ? '' : ' ' + item.currency_code); // too lengthy prices dont render currency code
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getNativeCountryName() {
|
2020-06-01 14:54:23 +02:00
|
|
|
|
for (const c of this.state.countries) {
|
2020-03-23 17:32:51 +01:00
|
|
|
|
if (c.code === this.state.country) return c.native_name;
|
|
|
|
|
}
|
2020-07-20 15:38:46 +02:00
|
|
|
|
return loc.hodl.filter_country_global;
|
2020-03-23 17:32:51 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-11 17:59:03 +01:00
|
|
|
|
hideChooseSideModal = () => {
|
|
|
|
|
Keyboard.dismiss();
|
|
|
|
|
this.setState({ isChooseSideModalVisible: false });
|
|
|
|
|
};
|
|
|
|
|
|
2020-03-23 17:32:51 +01:00
|
|
|
|
renderChooseSideModal = () => {
|
|
|
|
|
return (
|
2020-11-17 09:43:38 +01:00
|
|
|
|
<BottomModal isVisible={this.state.isChooseSideModalVisible} onClose={this.hideChooseSideModal}>
|
2020-03-23 17:32:51 +01:00
|
|
|
|
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'position' : null}>
|
|
|
|
|
<View style={styles.modalContentShort}>
|
|
|
|
|
<FlatList
|
2020-03-26 00:13:14 +01:00
|
|
|
|
scrollEnabled={false}
|
2020-06-15 20:47:54 +02:00
|
|
|
|
style={styles.modalFlatList}
|
|
|
|
|
ItemSeparatorComponent={() => <View style={styles.itemSeparator} />}
|
2020-03-23 17:32:51 +01:00
|
|
|
|
data={[
|
2020-07-20 15:38:46 +02:00
|
|
|
|
{ code: HodlHodlApi.FILTERS_SIDE_VALUE_SELL, name: loc.hodl.filter_iambuying },
|
|
|
|
|
{ code: HodlHodlApi.FILTERS_SIDE_VALUE_BUY, name: loc.hodl.filter_iamselling },
|
2020-03-23 17:32:51 +01:00
|
|
|
|
]}
|
|
|
|
|
keyExtractor={(item, index) => item.code}
|
|
|
|
|
renderItem={({ item, index, separators }) => (
|
|
|
|
|
<TouchableHighlight
|
|
|
|
|
onShowUnderlay={separators.highlight}
|
|
|
|
|
onHideUnderlay={separators.unhighlight}
|
|
|
|
|
onPress={() => this._onSidePress(item)}
|
|
|
|
|
>
|
2020-06-15 20:47:54 +02:00
|
|
|
|
<View style={styles.itemNameWrapper}>
|
|
|
|
|
<Text style={this.state.side === item.code ? styles.itemNameBold : styles.itemNameNormal}>{item.name}</Text>
|
2020-03-23 17:32:51 +01:00
|
|
|
|
</View>
|
|
|
|
|
</TouchableHighlight>
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
</View>
|
|
|
|
|
</KeyboardAvoidingView>
|
2020-11-17 09:43:38 +01:00
|
|
|
|
</BottomModal>
|
2020-03-23 17:32:51 +01:00
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2020-11-11 17:59:03 +01:00
|
|
|
|
hideFiltersModal = () => {
|
|
|
|
|
Keyboard.dismiss();
|
|
|
|
|
this.setState({ isFiltersModalVisible: false });
|
|
|
|
|
};
|
|
|
|
|
|
2020-03-23 17:32:51 +01:00
|
|
|
|
renderFiltersModal = () => {
|
|
|
|
|
return (
|
2020-11-17 09:43:38 +01:00
|
|
|
|
<BottomModal
|
2020-03-23 17:32:51 +01:00
|
|
|
|
isVisible={this.state.isFiltersModalVisible}
|
2020-11-17 09:43:38 +01:00
|
|
|
|
onClose={this.hideFiltersModal}
|
2020-03-23 17:32:51 +01:00
|
|
|
|
onModalHide={() => {
|
|
|
|
|
if (this.state.openNextModal) {
|
|
|
|
|
const openNextModal = this.state.openNextModal;
|
|
|
|
|
this.setState({
|
|
|
|
|
openNextModal: false,
|
|
|
|
|
[openNextModal]: true,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'position' : null}>
|
|
|
|
|
<View style={styles.modalContentShort}>
|
|
|
|
|
<FlatList
|
2020-03-26 00:13:14 +01:00
|
|
|
|
scrollEnabled={false}
|
2020-06-15 20:47:54 +02:00
|
|
|
|
style={styles.modalFlatList}
|
|
|
|
|
ItemSeparatorComponent={() => <View style={styles.itemSeparator} />}
|
2020-03-23 17:32:51 +01:00
|
|
|
|
data={[
|
2020-07-20 15:38:46 +02:00
|
|
|
|
{ code: 'currency', native_name: loc.hodl.filter_currency },
|
|
|
|
|
{ code: 'method', native_name: loc.hodl.filter_method },
|
2020-03-23 17:32:51 +01:00
|
|
|
|
]}
|
|
|
|
|
keyExtractor={(item, index) => item.code}
|
|
|
|
|
renderItem={({ item, index, separators }) => (
|
|
|
|
|
<TouchableHighlight
|
|
|
|
|
onShowUnderlay={separators.highlight}
|
|
|
|
|
onHideUnderlay={separators.unhighlight}
|
|
|
|
|
onPress={() => {
|
|
|
|
|
if (item.code === 'currency') this.setState({ isFiltersModalVisible: false, openNextModal: 'isChooseCurrencyVisible' });
|
|
|
|
|
if (item.code === 'method') this.setState({ isFiltersModalVisible: false, openNextModal: 'isChooseMethodVisible' });
|
|
|
|
|
}}
|
|
|
|
|
>
|
2020-06-15 20:47:54 +02:00
|
|
|
|
<View style={styles.whiteBackground}>
|
|
|
|
|
<View style={styles.itemNameWrapper}>
|
|
|
|
|
<View style={styles.currencyWrapper}>
|
|
|
|
|
<Text style={styles.currencyNativeName}>{item.native_name}</Text>
|
|
|
|
|
<View style={styles.filteCurrencyTextWrapper}>
|
2020-03-23 17:32:51 +01:00
|
|
|
|
{item.code === 'currency' && (
|
2020-06-15 20:47:54 +02:00
|
|
|
|
<Text style={styles.filterCurrencyText}>
|
|
|
|
|
{' '}
|
2020-07-20 15:38:46 +02:00
|
|
|
|
{this.state.currency ? this.state.currency : loc.hodl.filter_detail}
|
|
|
|
|
{' ❯'}
|
2020-06-15 20:47:54 +02:00
|
|
|
|
</Text>
|
2020-03-23 17:32:51 +01:00
|
|
|
|
)}
|
|
|
|
|
{item.code === 'method' && (
|
2020-06-15 20:47:54 +02:00
|
|
|
|
<Text style={styles.methodNameText}>
|
2020-03-23 17:32:51 +01:00
|
|
|
|
{' '}
|
2020-07-20 15:38:46 +02:00
|
|
|
|
{this.state.method ? this.getMethodName(this.state.method) : loc.hodl.filter_detail}
|
|
|
|
|
{' ❯'}
|
2020-03-23 17:32:51 +01:00
|
|
|
|
</Text>
|
|
|
|
|
)}
|
|
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
</TouchableHighlight>
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
</View>
|
|
|
|
|
</KeyboardAvoidingView>
|
2020-11-17 09:43:38 +01:00
|
|
|
|
</BottomModal>
|
2020-03-23 17:32:51 +01:00
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2020-11-11 17:59:03 +01:00
|
|
|
|
hideChooseCountryModal = () => {
|
|
|
|
|
Keyboard.dismiss();
|
|
|
|
|
this.setState({ isChooseCountryModalVisible: false });
|
|
|
|
|
};
|
|
|
|
|
|
2020-03-23 17:32:51 +01:00
|
|
|
|
renderChooseContryModal = () => {
|
2020-06-01 14:54:23 +02:00
|
|
|
|
const countries2render = [];
|
2020-03-23 17:32:51 +01:00
|
|
|
|
|
|
|
|
|
// first, we include in the list current country
|
2020-06-01 14:54:23 +02:00
|
|
|
|
for (const country of this.state.countries) {
|
2020-03-23 17:32:51 +01:00
|
|
|
|
if (country.code === this.state.country) {
|
|
|
|
|
countries2render.push(country);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// next, we include option for user to set GLOBAL for offers
|
|
|
|
|
countries2render.push({
|
|
|
|
|
code: HodlHodlApi.FILTERS_COUNTRY_VALUE_GLOBAL,
|
|
|
|
|
name: 'Global offers',
|
2020-07-20 15:38:46 +02:00
|
|
|
|
native_name: loc.hodl.filter_country_global,
|
2020-03-23 17:32:51 +01:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// lastly, we include other countries
|
2020-06-01 14:54:23 +02:00
|
|
|
|
for (const country of this.state.countries) {
|
2020-03-23 17:32:51 +01:00
|
|
|
|
if (country.code !== this.state.country) {
|
|
|
|
|
// except currently selected one
|
|
|
|
|
if (this.state.countrySearchInput) {
|
|
|
|
|
// if user typed something in search box we apply that filter
|
|
|
|
|
if (
|
|
|
|
|
country.name.toLocaleLowerCase().includes(this.state.countrySearchInput.toLocaleLowerCase()) ||
|
|
|
|
|
country.native_name.toLocaleLowerCase().includes(this.state.countrySearchInput.toLocaleLowerCase())
|
|
|
|
|
) {
|
|
|
|
|
countries2render.push(country);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// otherwise just put the country in the list
|
|
|
|
|
countries2render.push(country);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
2020-11-17 09:43:38 +01:00
|
|
|
|
<BottomModal isVisible={this.state.isChooseCountryModalVisible} onClose={this.hideChooseCountryModal}>
|
2020-03-23 17:32:51 +01:00
|
|
|
|
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'position' : null}>
|
|
|
|
|
<View style={styles.modalContent}>
|
2020-06-15 20:47:54 +02:00
|
|
|
|
<View style={styles.searchInputContainer}>
|
2020-03-23 17:32:51 +01:00
|
|
|
|
<TextInput
|
|
|
|
|
onChangeText={text => this.setState({ countrySearchInput: text })}
|
2020-07-20 15:38:46 +02:00
|
|
|
|
placeholder={loc.hodl.filter_search + '..'}
|
2020-03-26 21:03:27 +01:00
|
|
|
|
placeholderTextColor="#9AA0AA"
|
2020-03-23 17:32:51 +01:00
|
|
|
|
value={this.state.countrySearchInput || ''}
|
|
|
|
|
numberOfLines={1}
|
2020-06-15 20:47:54 +02:00
|
|
|
|
style={styles.searchTextInput}
|
2020-03-23 17:32:51 +01:00
|
|
|
|
/>
|
2020-06-15 20:47:54 +02:00
|
|
|
|
<Icon name="search" type="material" size={20} color="gray" containerStyle={styles.iconWithOffset} />
|
2020-03-23 17:32:51 +01:00
|
|
|
|
</View>
|
|
|
|
|
<FlatList
|
2020-06-15 20:47:54 +02:00
|
|
|
|
style={styles.modalFlatList}
|
|
|
|
|
ItemSeparatorComponent={() => <View style={styles.itemSeparator} />}
|
2020-03-23 17:32:51 +01:00
|
|
|
|
data={countries2render}
|
|
|
|
|
keyExtractor={(item, index) => item.code}
|
|
|
|
|
renderItem={({ item, index, separators }) => (
|
|
|
|
|
<TouchableHighlight
|
|
|
|
|
onPress={() => this._onCountryPress(item)}
|
|
|
|
|
onShowUnderlay={separators.highlight}
|
|
|
|
|
onHideUnderlay={separators.unhighlight}
|
|
|
|
|
>
|
2020-06-15 20:47:54 +02:00
|
|
|
|
<View style={styles.whiteBackground}>
|
|
|
|
|
<View style={styles.itemNameWrapper}>
|
|
|
|
|
<View style={styles.paddingLeft10}>
|
|
|
|
|
<Text style={item.code === this.state.country ? styles.countryNativeNameBold : styles.countryNativeNameNormal}>
|
2020-03-23 17:32:51 +01:00
|
|
|
|
{item.native_name}
|
|
|
|
|
</Text>
|
|
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
</TouchableHighlight>
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
</View>
|
|
|
|
|
</KeyboardAvoidingView>
|
2020-11-17 09:43:38 +01:00
|
|
|
|
</BottomModal>
|
2020-03-23 17:32:51 +01:00
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2020-11-11 17:59:03 +01:00
|
|
|
|
hideChooseCurrencyModal = () => {
|
|
|
|
|
Keyboard.dismiss();
|
|
|
|
|
this.setState({ isChooseCurrencyVisible: false });
|
|
|
|
|
};
|
|
|
|
|
|
2020-03-23 17:32:51 +01:00
|
|
|
|
renderChooseCurrencyModal = () => {
|
2020-06-01 14:54:23 +02:00
|
|
|
|
const currencies2render = [];
|
2020-03-23 17:32:51 +01:00
|
|
|
|
|
|
|
|
|
// first, option to choose any currency
|
|
|
|
|
currencies2render.push({
|
|
|
|
|
code: CURRENCY_CODE_ANY,
|
2020-07-20 15:38:46 +02:00
|
|
|
|
name: loc.hodl.filter_any,
|
2020-03-23 17:32:51 +01:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// lastly, we include other countries
|
2020-06-01 14:54:23 +02:00
|
|
|
|
for (const curr of this.state.currencies) {
|
2020-03-23 17:32:51 +01:00
|
|
|
|
if (this.state.currencySearchInput) {
|
|
|
|
|
// if user typed something in search box we apply that filter
|
|
|
|
|
if (
|
|
|
|
|
curr.name.toLocaleLowerCase().includes(this.state.currencySearchInput.toLocaleLowerCase()) ||
|
|
|
|
|
curr.code.toLocaleLowerCase().includes(this.state.currencySearchInput.toLocaleLowerCase())
|
|
|
|
|
) {
|
|
|
|
|
currencies2render.push(curr);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// otherwise just put the country in the list
|
|
|
|
|
currencies2render.push(curr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
2020-11-17 09:43:38 +01:00
|
|
|
|
<BottomModal isVisible={this.state.isChooseCurrencyVisible} onClose={this.hideChooseCurrencyModal}>
|
2020-03-23 17:32:51 +01:00
|
|
|
|
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'position' : null}>
|
|
|
|
|
<View style={styles.modalContent}>
|
2020-06-15 20:47:54 +02:00
|
|
|
|
<View style={styles.searchInputContainer}>
|
2020-03-23 17:32:51 +01:00
|
|
|
|
<TextInput
|
|
|
|
|
onChangeText={text => this.setState({ currencySearchInput: text })}
|
2020-07-20 15:38:46 +02:00
|
|
|
|
placeholder={loc.hodl.filter_search + '..'}
|
2020-03-26 00:13:14 +01:00
|
|
|
|
placeholderTextColor="#9AA0AA"
|
2020-03-23 17:32:51 +01:00
|
|
|
|
value={this.state.currencySearchInput || ''}
|
|
|
|
|
numberOfLines={1}
|
2020-06-15 20:47:54 +02:00
|
|
|
|
style={styles.curSearchInput}
|
2020-03-23 17:32:51 +01:00
|
|
|
|
/>
|
2020-06-15 20:47:54 +02:00
|
|
|
|
<Icon name="search" type="material" size={20} color="gray" containerStyle={styles.iconWithOffset} />
|
2020-03-23 17:32:51 +01:00
|
|
|
|
</View>
|
|
|
|
|
<FlatList
|
2020-06-15 20:47:54 +02:00
|
|
|
|
style={styles.modalFlatList}
|
|
|
|
|
ItemSeparatorComponent={() => <View style={styles.itemSeparator} />}
|
2020-03-23 17:32:51 +01:00
|
|
|
|
data={currencies2render}
|
|
|
|
|
keyExtractor={(item, index) => item.code}
|
|
|
|
|
renderItem={({ item, index, separators }) => (
|
|
|
|
|
<TouchableHighlight
|
|
|
|
|
onPress={() => this._onCurrencyPress(item)}
|
|
|
|
|
onShowUnderlay={separators.highlight}
|
|
|
|
|
onHideUnderlay={separators.unhighlight}
|
|
|
|
|
>
|
2020-06-15 20:47:54 +02:00
|
|
|
|
<View style={styles.whiteBackground}>
|
|
|
|
|
<View style={styles.itemNameWrapper}>
|
|
|
|
|
<View style={styles.paddingLeft10}>
|
|
|
|
|
<Text style={styles.currencyText}>
|
2020-03-23 17:32:51 +01:00
|
|
|
|
{item.name} {item.code !== CURRENCY_CODE_ANY && '[' + item.code + ']'}
|
|
|
|
|
</Text>
|
|
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
</TouchableHighlight>
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
</View>
|
|
|
|
|
</KeyboardAvoidingView>
|
2020-11-17 09:43:38 +01:00
|
|
|
|
</BottomModal>
|
2020-03-23 17:32:51 +01:00
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2020-11-11 17:59:03 +01:00
|
|
|
|
hideChooseMethodModal = () => {
|
|
|
|
|
Keyboard.dismiss();
|
|
|
|
|
this.setState({ isChooseMethodVisible: false });
|
|
|
|
|
};
|
|
|
|
|
|
2020-03-23 17:32:51 +01:00
|
|
|
|
renderChooseMethodModal = () => {
|
2020-06-01 14:54:23 +02:00
|
|
|
|
const methods2render = [];
|
2020-03-23 17:32:51 +01:00
|
|
|
|
|
|
|
|
|
// first, option to choose any currency
|
|
|
|
|
methods2render.push({
|
|
|
|
|
id: METHOD_ANY,
|
2020-07-20 15:38:46 +02:00
|
|
|
|
name: loc.hodl.filter_any,
|
2020-03-23 17:32:51 +01:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// lastly, we include other countries
|
2020-06-01 14:54:23 +02:00
|
|
|
|
for (const curr of this.state.methods) {
|
2020-03-23 17:32:51 +01:00
|
|
|
|
if (this.state.methodSearchInput) {
|
|
|
|
|
// if user typed something in search box we apply that filter
|
|
|
|
|
if (
|
|
|
|
|
curr.name.toLocaleLowerCase().includes(this.state.methodSearchInput.toLocaleLowerCase()) ||
|
|
|
|
|
curr.type.toLocaleLowerCase().includes(this.state.methodSearchInput.toLocaleLowerCase())
|
|
|
|
|
) {
|
|
|
|
|
methods2render.push(curr);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// otherwise just put the country in the list
|
|
|
|
|
methods2render.push(curr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
2020-11-17 09:43:38 +01:00
|
|
|
|
<BottomModal isVisible={this.state.isChooseMethodVisible} deviceHeight={windowHeight} onClose={this.hideChooseMethodModal}>
|
2020-03-23 17:32:51 +01:00
|
|
|
|
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'position' : null}>
|
|
|
|
|
<View style={styles.modalContent}>
|
2020-06-15 20:47:54 +02:00
|
|
|
|
<View style={styles.searchInputContainer}>
|
2020-03-23 17:32:51 +01:00
|
|
|
|
<TextInput
|
|
|
|
|
onChangeText={text => this.setState({ methodSearchInput: text })}
|
2020-07-20 15:38:46 +02:00
|
|
|
|
placeholder={loc.hodl.filter_search + '..'}
|
2020-03-26 00:13:14 +01:00
|
|
|
|
placeholderTextColor="#9AA0AA"
|
2020-03-23 17:32:51 +01:00
|
|
|
|
value={this.state.methodSearchInput || ''}
|
|
|
|
|
numberOfLines={1}
|
2020-06-15 20:47:54 +02:00
|
|
|
|
style={styles.mthdSearchInput}
|
2020-03-23 17:32:51 +01:00
|
|
|
|
/>
|
2020-06-15 20:47:54 +02:00
|
|
|
|
<Icon name="search" type="material" size={20} color="gray" containerStyle={styles.iconWithOffset} />
|
2020-03-23 17:32:51 +01:00
|
|
|
|
</View>
|
|
|
|
|
<FlatList
|
2020-06-15 20:47:54 +02:00
|
|
|
|
style={styles.modalFlatList}
|
|
|
|
|
ItemSeparatorComponent={() => <View style={styles.itemSeparator} />}
|
2020-03-23 17:32:51 +01:00
|
|
|
|
data={methods2render}
|
|
|
|
|
keyExtractor={(item, index) => item.id}
|
|
|
|
|
renderItem={({ item, index, separators }) => (
|
|
|
|
|
<TouchableHighlight
|
|
|
|
|
onPress={() => this._onMethodPress(item)}
|
|
|
|
|
onShowUnderlay={separators.highlight}
|
|
|
|
|
onHideUnderlay={separators.unhighlight}
|
|
|
|
|
>
|
2020-06-15 20:47:54 +02:00
|
|
|
|
<View style={styles.whiteBackground}>
|
|
|
|
|
<View style={styles.itemNameWrapper}>
|
|
|
|
|
<View style={styles.paddingLeft10}>
|
2020-03-23 17:32:51 +01:00
|
|
|
|
<Text
|
2020-06-15 20:47:54 +02:00
|
|
|
|
style={
|
2020-05-24 11:17:26 +02:00
|
|
|
|
item.id === this.state.method || (item.id === METHOD_ANY && this.state.method === false)
|
2020-06-15 20:47:54 +02:00
|
|
|
|
? styles.currencyTextBold
|
|
|
|
|
: styles.currencyTextNormal
|
|
|
|
|
}
|
2020-03-23 17:32:51 +01:00
|
|
|
|
>
|
|
|
|
|
{item.name} {item.id !== METHOD_ANY && '[' + item.type + ']'}
|
|
|
|
|
</Text>
|
|
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
</TouchableHighlight>
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
</View>
|
|
|
|
|
</KeyboardAvoidingView>
|
2020-11-17 09:43:38 +01:00
|
|
|
|
</BottomModal>
|
2020-03-23 17:32:51 +01:00
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2020-06-15 20:47:54 +02:00
|
|
|
|
_onRefreshOffers = async () => {
|
|
|
|
|
this.setState({
|
|
|
|
|
showShowFlatListRefreshControl: true,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
await this.fetchOffers();
|
|
|
|
|
} catch (_) {}
|
|
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
showShowFlatListRefreshControl: false,
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
renderHeader = () => {
|
2020-03-23 17:32:51 +01:00
|
|
|
|
return (
|
2020-06-15 20:47:54 +02:00
|
|
|
|
<View style={styles.whiteBackground}>
|
|
|
|
|
<View style={styles.headerWrapper}>
|
|
|
|
|
<Text style={styles.BottomLine}>Powered by HodlHodl®</Text>
|
|
|
|
|
<View style={styles.flexRow}>
|
2020-12-21 19:27:49 +01:00
|
|
|
|
<Text style={styles.Title}>{loc.hodl.local_trader} </Text>
|
2020-03-23 17:32:51 +01:00
|
|
|
|
<TouchableOpacity
|
2020-06-15 20:47:54 +02:00
|
|
|
|
style={styles.grayDropdownTextContainer}
|
2020-03-23 17:32:51 +01:00
|
|
|
|
onPress={() => {
|
|
|
|
|
this.setState({ isChooseSideModalVisible: true });
|
|
|
|
|
}}
|
|
|
|
|
>
|
2020-07-20 15:38:46 +02:00
|
|
|
|
<Text style={styles.grayDropdownText}>
|
|
|
|
|
{this.state.side === HodlHodlApi.FILTERS_SIDE_VALUE_SELL ? loc.hodl.filter_buying : loc.hodl.filter_selling}
|
|
|
|
|
</Text>
|
2020-06-15 20:47:54 +02:00
|
|
|
|
<Icon name="expand-more" type="material" size={22} color="#9AA0AA" containerStyle={styles.noPaddingLeftOrRight} />
|
2020-03-23 17:32:51 +01:00
|
|
|
|
</TouchableOpacity>
|
|
|
|
|
</View>
|
|
|
|
|
|
2020-06-15 20:47:54 +02:00
|
|
|
|
<View style={styles.grayTextContainerContainer}>
|
|
|
|
|
<View style={styles.grayTextContainer}>
|
2020-07-15 19:32:59 +02:00
|
|
|
|
<Icon
|
|
|
|
|
name="place"
|
|
|
|
|
type="material"
|
|
|
|
|
size={20}
|
|
|
|
|
color={BlueCurrentTheme.colors.foregroundColor}
|
|
|
|
|
containerStyle={styles.paddingLeft10}
|
|
|
|
|
/>
|
2020-06-15 20:47:54 +02:00
|
|
|
|
{this.state.isLoading ? (
|
|
|
|
|
<ActivityIndicator />
|
|
|
|
|
) : (
|
|
|
|
|
<TouchableOpacity onPress={() => this.setState({ isChooseCountryModalVisible: true })}>
|
|
|
|
|
<Text style={styles.locationText}>{this.getNativeCountryName()}</Text>
|
|
|
|
|
</TouchableOpacity>
|
|
|
|
|
)}
|
2020-03-23 17:32:51 +01:00
|
|
|
|
<TouchableOpacity
|
2020-06-15 20:47:54 +02:00
|
|
|
|
style={styles.blueTextContainer}
|
2020-03-23 17:32:51 +01:00
|
|
|
|
onPress={() => {
|
|
|
|
|
this.setState({ isFiltersModalVisible: true });
|
|
|
|
|
}}
|
|
|
|
|
>
|
2020-07-20 15:38:46 +02:00
|
|
|
|
<Text style={styles.blueText}>{loc.hodl.filter_filters}</Text>
|
2020-03-23 17:32:51 +01:00
|
|
|
|
|
2020-07-15 19:32:59 +02:00
|
|
|
|
<Icon
|
|
|
|
|
name="filter-list"
|
|
|
|
|
type="material"
|
|
|
|
|
size={24}
|
|
|
|
|
color={BlueCurrentTheme.colors.foregroundColor}
|
|
|
|
|
containerStyle={styles.paddingLeft10}
|
|
|
|
|
/>
|
2020-03-23 17:32:51 +01:00
|
|
|
|
</TouchableOpacity>
|
|
|
|
|
</View>
|
|
|
|
|
</View>
|
2020-06-15 20:47:54 +02:00
|
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
);
|
|
|
|
|
};
|
2020-03-23 17:32:51 +01:00
|
|
|
|
|
2020-06-15 20:47:54 +02:00
|
|
|
|
renderItem = ({ item, index, separators }) => {
|
|
|
|
|
return (
|
|
|
|
|
<View style={styles.marginHorizontal20}>
|
|
|
|
|
<TouchableHighlight
|
|
|
|
|
onPress={() => this._onPress(item)}
|
|
|
|
|
onShowUnderlay={separators.highlight}
|
|
|
|
|
onHideUnderlay={separators.unhighlight}
|
|
|
|
|
>
|
|
|
|
|
<View style={styles.avatarWrapperWrapper}>
|
|
|
|
|
<View style={styles.avatarWrapper}>
|
|
|
|
|
<View>
|
|
|
|
|
<Image
|
|
|
|
|
style={styles.avatarImage}
|
|
|
|
|
source={
|
|
|
|
|
item.trader.avatar_url.endsWith('.svg')
|
|
|
|
|
? require('../../img/hodlhodl-default-avatar.png')
|
|
|
|
|
: {
|
|
|
|
|
uri: item.trader.avatar_url,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
{item.trader.online_status === 'online' && (
|
|
|
|
|
<View style={styles.circleWhite}>
|
|
|
|
|
<View style={styles.circleGreen} />
|
|
|
|
|
</View>
|
|
|
|
|
)}
|
|
|
|
|
</View>
|
|
|
|
|
<View style={styles.paddingLeft10}>
|
|
|
|
|
<View style={styles.flexRow}>
|
|
|
|
|
{item.trader.strong_hodler && (
|
|
|
|
|
<Icon name="verified-user" type="material" size={14} color="#0071fc" containerStyle={styles.verifiedIcon} />
|
|
|
|
|
)}
|
|
|
|
|
<Text style={styles.nicknameText}>{item.trader.login}</Text>
|
|
|
|
|
</View>
|
|
|
|
|
<Text style={styles.traderRatingText2}>
|
|
|
|
|
{item.trader.trades_count > 0
|
2020-07-20 15:38:46 +02:00
|
|
|
|
? loc.formatString(loc.hodl.item_rating, {
|
|
|
|
|
rating: Math.round(item.trader.rating * 100) + '% / ' + item.trader.trades_count,
|
|
|
|
|
})
|
|
|
|
|
: loc.hodl.item_rating_no}
|
2020-06-15 20:47:54 +02:00
|
|
|
|
</Text>
|
|
|
|
|
</View>
|
|
|
|
|
</View>
|
2020-05-24 11:17:26 +02:00
|
|
|
|
|
2020-06-15 20:47:54 +02:00
|
|
|
|
<Text style={styles.itemText}>{this.getItemText(item)}</Text>
|
2020-03-23 17:32:51 +01:00
|
|
|
|
|
2020-06-15 20:47:54 +02:00
|
|
|
|
<View style={styles.itemPriceWrapperWrapper}>
|
|
|
|
|
<View style={styles.itemPriceWrapper}>
|
|
|
|
|
<Text style={styles.itemPrice}>{this.getItemPrice(item)}</Text>
|
|
|
|
|
</View>
|
2020-03-23 17:32:51 +01:00
|
|
|
|
|
2020-06-15 20:47:54 +02:00
|
|
|
|
<Text style={styles.minmax}>
|
2020-07-20 15:38:46 +02:00
|
|
|
|
{loc.hodl.item_minmax}: {item.min_amount.replace('.00', '')} - {item.max_amount.replace('.00', '')} {item.currency_code}
|
2020-06-15 20:47:54 +02:00
|
|
|
|
</Text>
|
|
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
</TouchableHighlight>
|
|
|
|
|
</View>
|
|
|
|
|
);
|
|
|
|
|
};
|
2020-03-23 17:32:51 +01:00
|
|
|
|
|
2020-06-15 20:47:54 +02:00
|
|
|
|
sectionListKeyExtractor = (item, index) => {
|
|
|
|
|
return `${item}${index}}`;
|
|
|
|
|
};
|
2020-03-23 17:32:51 +01:00
|
|
|
|
|
2020-06-15 20:47:54 +02:00
|
|
|
|
renderSectionFooter = () => {
|
|
|
|
|
return this.state.offers.length <= 0 ? (
|
|
|
|
|
<View style={styles.noOffersWrapper}>
|
2020-07-20 15:38:46 +02:00
|
|
|
|
<Text style={styles.noOffersText}>{loc.hodl.item_nooffers}</Text>
|
2020-06-15 20:47:54 +02:00
|
|
|
|
</View>
|
|
|
|
|
) : undefined;
|
|
|
|
|
};
|
2020-03-23 17:32:51 +01:00
|
|
|
|
|
2020-06-15 20:47:54 +02:00
|
|
|
|
render() {
|
|
|
|
|
return (
|
|
|
|
|
<SafeBlueArea>
|
2020-07-15 19:32:59 +02:00
|
|
|
|
<StatusBar barStyle="default" />
|
2020-06-15 20:47:54 +02:00
|
|
|
|
<SectionList
|
2020-08-10 18:10:35 +02:00
|
|
|
|
onRefresh={this._onRefreshOffers}
|
|
|
|
|
refreshing={this.state.showShowFlatListRefreshControl}
|
2020-06-15 20:47:54 +02:00
|
|
|
|
renderItem={this.renderItem}
|
|
|
|
|
keyExtractor={this.sectionListKeyExtractor}
|
|
|
|
|
renderSectionHeader={this.renderHeader}
|
|
|
|
|
contentInset={{ top: 0, left: 0, bottom: 60, right: 0 }}
|
|
|
|
|
sections={[{ key: HodlHodlListSections.OFFERS, data: this.state.offers }]}
|
|
|
|
|
style={styles.offersSectionList}
|
|
|
|
|
ItemSeparatorComponent={() => <View style={styles.itemSeparator} />}
|
|
|
|
|
renderSectionFooter={this.renderSectionFooter}
|
|
|
|
|
/>
|
|
|
|
|
{this.renderChooseSideModal()}
|
|
|
|
|
{this.renderChooseContryModal()}
|
|
|
|
|
{this.renderFiltersModal()}
|
2020-03-23 17:32:51 +01:00
|
|
|
|
{this.renderChooseCurrencyModal()}
|
|
|
|
|
{this.renderChooseMethodModal()}
|
2020-03-26 21:03:27 +01:00
|
|
|
|
</SafeBlueArea>
|
2020-03-23 17:32:51 +01:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HodlHodl.propTypes = {
|
2020-06-15 20:47:54 +02:00
|
|
|
|
navigation: PropTypes.shape({
|
2020-06-25 18:37:50 +02:00
|
|
|
|
addListener: PropTypes.func,
|
2020-06-15 20:47:54 +02:00
|
|
|
|
navigate: PropTypes.func,
|
|
|
|
|
setParams: PropTypes.func,
|
2020-08-27 02:20:13 +02:00
|
|
|
|
goBack: PropTypes.func,
|
2020-03-23 17:32:51 +01:00
|
|
|
|
}),
|
|
|
|
|
};
|
2020-06-15 20:47:54 +02:00
|
|
|
|
|
2020-12-25 17:09:53 +01:00
|
|
|
|
HodlHodl.navigationOptions = navigationStyle(
|
|
|
|
|
{
|
|
|
|
|
title: '',
|
2020-07-15 19:32:59 +02:00
|
|
|
|
},
|
2020-12-25 17:09:53 +01:00
|
|
|
|
(options, { theme, navigation, route }) => ({
|
|
|
|
|
...options,
|
|
|
|
|
headerStyle: {
|
|
|
|
|
...options.headerStyle,
|
|
|
|
|
backgroundColor: theme.colors.customHeader,
|
|
|
|
|
},
|
|
|
|
|
headerRight: () => {
|
|
|
|
|
return route.params.displayLoginButton ? (
|
|
|
|
|
<BlueButtonLink title={loc.hodl.login} onPress={route.params.handleLoginPress} style={styles.marginHorizontal20} />
|
|
|
|
|
) : (
|
|
|
|
|
<BlueButtonLink title={loc.hodl.mycont} onPress={route.params.handleMyContractsPress} style={styles.marginHorizontal20} />
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
);
|
2020-06-15 20:47:54 +02:00
|
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
|
grayDropdownText: {
|
|
|
|
|
fontSize: 15,
|
|
|
|
|
fontWeight: '600',
|
|
|
|
|
color: '#9AA0AA',
|
|
|
|
|
},
|
|
|
|
|
modalContent: {
|
2020-07-15 19:32:59 +02:00
|
|
|
|
backgroundColor: BlueCurrentTheme.colors.elevated,
|
2020-06-15 20:47:54 +02:00
|
|
|
|
padding: 22,
|
|
|
|
|
justifyContent: 'center',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
borderTopLeftRadius: 16,
|
|
|
|
|
borderTopRightRadius: 16,
|
|
|
|
|
borderColor: 'rgba(0, 0, 0, 0.1)',
|
|
|
|
|
minHeight: 400,
|
|
|
|
|
height: 400,
|
|
|
|
|
},
|
|
|
|
|
modalContentShort: {
|
2020-07-15 19:32:59 +02:00
|
|
|
|
backgroundColor: BlueCurrentTheme.colors.elevated,
|
2020-06-15 20:47:54 +02:00
|
|
|
|
padding: 22,
|
|
|
|
|
justifyContent: 'center',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
borderTopLeftRadius: 16,
|
|
|
|
|
borderTopRightRadius: 16,
|
|
|
|
|
borderColor: 'rgba(0, 0, 0, 0.1)',
|
|
|
|
|
minHeight: 200,
|
|
|
|
|
height: 200,
|
|
|
|
|
},
|
|
|
|
|
Title: {
|
|
|
|
|
fontWeight: 'bold',
|
|
|
|
|
fontSize: 30,
|
2020-07-15 19:32:59 +02:00
|
|
|
|
color: BlueCurrentTheme.colors.foregroundColor,
|
2020-06-15 20:47:54 +02:00
|
|
|
|
},
|
|
|
|
|
BottomLine: {
|
|
|
|
|
fontSize: 10,
|
2020-07-15 19:32:59 +02:00
|
|
|
|
color: BlueCurrentTheme.colors.foregroundColor,
|
2020-06-15 20:47:54 +02:00
|
|
|
|
},
|
|
|
|
|
grayDropdownTextContainer: {
|
2020-07-15 19:32:59 +02:00
|
|
|
|
backgroundColor: BlueCurrentTheme.colors.inputBackgroundColor,
|
2020-06-15 20:47:54 +02:00
|
|
|
|
borderRadius: 20,
|
|
|
|
|
height: 35,
|
|
|
|
|
top: 3,
|
|
|
|
|
paddingLeft: 16,
|
|
|
|
|
paddingRight: 8,
|
|
|
|
|
paddingVertical: 6,
|
|
|
|
|
justifyContent: 'center',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
flexDirection: 'row',
|
|
|
|
|
},
|
|
|
|
|
grayTextContainerContainer: {
|
2020-07-15 19:32:59 +02:00
|
|
|
|
backgroundColor: BlueCurrentTheme.colors.inputBackgroundColor,
|
2020-06-15 20:47:54 +02:00
|
|
|
|
borderRadius: 20,
|
|
|
|
|
height: 44,
|
|
|
|
|
justifyContent: 'center',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
marginTop: 15,
|
|
|
|
|
},
|
|
|
|
|
grayTextContainer: {
|
|
|
|
|
width: '100%',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
flex: 1,
|
|
|
|
|
flexDirection: 'row',
|
|
|
|
|
},
|
|
|
|
|
blueText: {
|
2020-07-15 19:32:59 +02:00
|
|
|
|
color: BlueCurrentTheme.colors.foregroundColor,
|
2020-06-15 20:47:54 +02:00
|
|
|
|
fontSize: 15,
|
|
|
|
|
fontWeight: '600',
|
|
|
|
|
},
|
|
|
|
|
allOffersText: {
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
color: '#9AA0AA',
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
top: 0,
|
|
|
|
|
left: 15,
|
|
|
|
|
},
|
|
|
|
|
locationText: {
|
|
|
|
|
top: 0,
|
|
|
|
|
left: 5,
|
2020-07-15 19:32:59 +02:00
|
|
|
|
color: BlueCurrentTheme.colors.foregroundColor,
|
2020-06-15 20:47:54 +02:00
|
|
|
|
fontSize: 20,
|
|
|
|
|
fontWeight: '500',
|
|
|
|
|
},
|
|
|
|
|
nicknameText: {
|
2020-07-15 19:32:59 +02:00
|
|
|
|
color: BlueCurrentTheme.colors.foregroundColor,
|
2020-06-15 20:47:54 +02:00
|
|
|
|
fontSize: 18,
|
|
|
|
|
fontWeight: '600',
|
|
|
|
|
},
|
|
|
|
|
blueTextContainer: {
|
2020-07-15 19:32:59 +02:00
|
|
|
|
backgroundColor: BlueCurrentTheme.colors.mainColor,
|
2020-06-15 20:47:54 +02:00
|
|
|
|
borderRadius: 20,
|
|
|
|
|
width: 110,
|
|
|
|
|
flex: 1,
|
|
|
|
|
flexDirection: 'row',
|
|
|
|
|
height: 36,
|
|
|
|
|
paddingLeft: 8,
|
|
|
|
|
justifyContent: 'center',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
right: 4,
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
},
|
|
|
|
|
searchInputContainer: {
|
|
|
|
|
flexDirection: 'row',
|
2020-07-15 19:32:59 +02:00
|
|
|
|
borderColor: BlueCurrentTheme.colors.inputBackgroundColor,
|
|
|
|
|
borderBottomColor: BlueCurrentTheme.colors.inputBackgroundColor,
|
2020-06-15 20:47:54 +02:00
|
|
|
|
borderWidth: 1.0,
|
|
|
|
|
borderBottomWidth: 0.5,
|
2020-07-15 19:32:59 +02:00
|
|
|
|
backgroundColor: BlueCurrentTheme.colors.inputBackgroundColor,
|
2020-06-15 20:47:54 +02:00
|
|
|
|
minHeight: 48,
|
|
|
|
|
height: 48,
|
|
|
|
|
marginHorizontal: 20,
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
marginVertical: 8,
|
|
|
|
|
borderRadius: 26,
|
|
|
|
|
width: '100%',
|
|
|
|
|
},
|
|
|
|
|
circleWhite: {
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
bottom: 4,
|
|
|
|
|
right: 3,
|
|
|
|
|
backgroundColor: 'white',
|
|
|
|
|
width: 9,
|
|
|
|
|
height: 9,
|
|
|
|
|
borderRadius: 4,
|
|
|
|
|
},
|
|
|
|
|
circleGreen: {
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
bottom: 1,
|
|
|
|
|
right: 1,
|
|
|
|
|
backgroundColor: '#00d327',
|
|
|
|
|
width: 7,
|
|
|
|
|
height: 7,
|
|
|
|
|
borderRadius: 4,
|
|
|
|
|
},
|
|
|
|
|
itemPrice: { fontWeight: '600', fontSize: 14, color: '#9AA0AA' },
|
|
|
|
|
minmax: { color: '#9AA0AA', fontSize: 12, paddingLeft: 10 },
|
|
|
|
|
noOffersWrapper: { height: '100%', justifyContent: 'center' },
|
2020-07-15 19:32:59 +02:00
|
|
|
|
noOffersText: { textAlign: 'center', color: BlueCurrentTheme.colors.feeText, paddingHorizontal: 16 },
|
2020-06-15 20:47:54 +02:00
|
|
|
|
modalFlatList: { width: '100%' },
|
2020-07-15 19:32:59 +02:00
|
|
|
|
itemSeparator: { height: 0.5, width: '100%', backgroundColor: BlueCurrentTheme.colors.lightBorder },
|
|
|
|
|
itemNameWrapper: { backgroundColor: BlueCurrentTheme.colors.elevated, flex: 1, flexDirection: 'row', paddingTop: 20, paddingBottom: 20 },
|
|
|
|
|
itemNameBold: { fontSize: 20, color: BlueCurrentTheme.colors.foregroundColor, fontWeight: 'bold' },
|
|
|
|
|
itemNameNormal: { fontSize: 20, color: BlueCurrentTheme.colors.foregroundColor, fontWeight: 'normal' },
|
|
|
|
|
whiteBackground: { backgroundColor: BlueCurrentTheme.colors.background },
|
|
|
|
|
filterCurrencyText: { fontSize: 16, color: BlueCurrentTheme.colors.foregroundColor },
|
|
|
|
|
filteCurrencyTextWrapper: { color: BlueCurrentTheme.colors.foregroundColor, right: 0, position: 'absolute' },
|
|
|
|
|
currencyNativeName: { fontSize: 20, color: BlueCurrentTheme.colors.foregroundColor },
|
2020-06-15 20:47:54 +02:00
|
|
|
|
currencyWrapper: { paddingLeft: 10, flex: 1, flexDirection: 'row' },
|
2020-07-15 19:32:59 +02:00
|
|
|
|
methodNameText: { fontSize: 16, color: BlueCurrentTheme.colors.foregroundColor },
|
2020-06-16 13:48:29 +02:00
|
|
|
|
searchTextInput: { fontSize: 17, flex: 1, marginHorizontal: 8, minHeight: 33, paddingLeft: 6, paddingRight: 6, color: '#81868e' },
|
2020-06-15 20:47:54 +02:00
|
|
|
|
iconWithOffset: { left: -10 },
|
|
|
|
|
paddingLeft10: { paddingLeft: 10 },
|
2020-07-15 19:32:59 +02:00
|
|
|
|
countryNativeNameBold: { fontSize: 20, color: BlueCurrentTheme.colors.foregroundColor, fontWeight: 'bold' },
|
|
|
|
|
countryNativeNameNormal: { fontSize: 20, color: BlueCurrentTheme.colors.foregroundColor, fontWeight: 'normal' },
|
2020-06-16 13:48:29 +02:00
|
|
|
|
curSearchInput: { flex: 1, marginHorizontal: 8, minHeight: 33, paddingLeft: 6, paddingRight: 6, color: '#81868e' },
|
|
|
|
|
mthdSearchInput: { flex: 1, marginHorizontal: 8, minHeight: 33, paddingLeft: 6, paddingRight: 6, color: '#81868e' },
|
2020-06-15 20:47:54 +02:00
|
|
|
|
currencyTextBold: {
|
|
|
|
|
fontSize: 20,
|
2020-07-15 19:32:59 +02:00
|
|
|
|
color: BlueCurrentTheme.colors.foregroundColor,
|
2020-06-15 20:47:54 +02:00
|
|
|
|
fontWeight: 'bold',
|
|
|
|
|
},
|
|
|
|
|
currencyTextNormal: {
|
|
|
|
|
fontSize: 20,
|
2020-07-15 19:32:59 +02:00
|
|
|
|
color: BlueCurrentTheme.colors.foregroundColor,
|
2020-06-15 20:47:54 +02:00
|
|
|
|
fontWeight: 'normal',
|
|
|
|
|
},
|
2020-07-15 19:32:59 +02:00
|
|
|
|
currencyText: {
|
|
|
|
|
fontSize: 20,
|
|
|
|
|
color: BlueCurrentTheme.colors.foregroundColor,
|
|
|
|
|
},
|
2020-06-15 20:47:54 +02:00
|
|
|
|
noPaddingLeftOrRight: { paddingLeft: 0, paddingRight: 0 },
|
|
|
|
|
flexRow: { flexDirection: 'row' },
|
|
|
|
|
traderRatingText2: { color: '#9AA0AA' },
|
|
|
|
|
itemPriceWrapper: {
|
2020-07-15 19:32:59 +02:00
|
|
|
|
backgroundColor: BlueCurrentTheme.colors.lightButton,
|
2020-06-15 20:47:54 +02:00
|
|
|
|
borderRadius: 20,
|
|
|
|
|
paddingLeft: 8,
|
|
|
|
|
paddingRight: 8,
|
|
|
|
|
height: 26,
|
|
|
|
|
justifyContent: 'center',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
},
|
|
|
|
|
itemText: { color: '#9AA0AA', paddingTop: 10 },
|
|
|
|
|
itemPriceWrapperWrapper: { flex: 1, flexDirection: 'row', paddingTop: 10, paddingBottom: 10, alignItems: 'center' },
|
|
|
|
|
offersSectionList: { marginTop: 24, flex: 1 },
|
|
|
|
|
marginHorizontal20: { marginHorizontal: 20 },
|
|
|
|
|
avatarImage: { width: 40, height: 40, borderRadius: 40 },
|
2020-07-15 19:32:59 +02:00
|
|
|
|
avatarWrapper: { backgroundColor: BlueCurrentTheme.colors.background, flex: 1, flexDirection: 'row' },
|
|
|
|
|
avatarWrapperWrapper: { backgroundColor: BlueCurrentTheme.colors.background, paddingTop: 16, paddingBottom: 16 },
|
|
|
|
|
headerWrapper: { backgroundColor: BlueCurrentTheme.colors.background, marginHorizontal: 20, marginBottom: 8 },
|
2020-06-15 20:47:54 +02:00
|
|
|
|
verifiedIcon: { marginTop: 5, marginRight: 5 },
|
|
|
|
|
});
|