Skip to content

Commit 6880c1f

Browse files
authored
Merge pull request #18 from ThiBsc/bug/fix-scroll-in-currencies-and-drag-drop-order-bug
Fix drag drop bug + scrolling in currencies
2 parents 206b9ad + ab03924 commit 6880c1f

File tree

10 files changed

+18
-25
lines changed

10 files changed

+18
-25
lines changed

android/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ android {
8484
applicationId "com.unitstool"
8585
minSdkVersion rootProject.ext.minSdkVersion
8686
targetSdkVersion rootProject.ext.targetSdkVersion
87-
versionCode 9060
88-
versionName "1.0.15"
87+
versionCode 9070
88+
versionName "1.0.16"
8989
}
9090
signingConfigs {
9191
debug {

src/components/EmptyDataComponent.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import { Text } from '@rneui/themed';
32

43

src/components/ListCategoryItem.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import { Icon } from "@rneui/themed";
32
import { ListItem, Text, useTheme } from "@rneui/themed";
43
import { useTranslation } from 'react-i18next';

src/components/ListUnitItem.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import Icon from 'react-native-vector-icons/FontAwesome5';
32
import { ListItem, useTheme } from "@rneui/themed";
43
import { Button } from '@rneui/base';

src/components/MainMenu.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import Icon from 'react-native-vector-icons/FontAwesome5';
32
import translation from '../utils/translation.json';
43
import { FlatList, View } from 'react-native';

src/components/UnitValue.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import Icon from 'react-native-vector-icons/FontAwesome5';
32
import { Button, Input, useTheme } from '@rneui/themed';
43
import { Text, View } from 'react-native';

src/containers/ConvertCurrencyScreen.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
import React, { useEffect, useRef, useState } from 'react';
1+
import { useEffect, useRef, useState } from 'react';
2+
import Icon from 'react-native-vector-icons/FontAwesome5';
23
import AsyncStorage from '@react-native-async-storage/async-storage';
34
import DraggableFlatList, { OpacityDecorator } from 'react-native-draggable-flatlist';
45
import UnitValue from '../components/UnitValue';
56
import ListUnitItem from '../components/ListUnitItem';
67
import Snackbar from 'react-native-snackbar';
7-
import { RefreshControl } from 'react-native-gesture-handler';
88
import { StyleSheet, TouchableOpacity, View } from 'react-native';
99
import { Text, useTheme } from '@rneui/themed';
1010
import { convertCurrency, getEuropeanCentralBankRates } from '../utils/currencies';
1111
import { useTranslation } from 'react-i18next';
1212
import { fractionToNumber } from '../utils/conversion';
13+
import { Button } from '@rneui/base';
14+
import { ActivityIndicator } from 'react-native';
1315

1416

1517
const ConvertCurrencyScreen = ({ navigation }) => {
@@ -19,7 +21,6 @@ const ConvertCurrencyScreen = ({ navigation }) => {
1921
const { t } = useTranslation();
2022
const isInitialized = useRef(false);
2123
const [isRefreshing, setIsRefreshing] = useState(false);
22-
const [isDragging, setIsDragging] = useState(false);
2324
const [refUnit, setRefUnit] = useState(defaultUnit);
2425
const [value, setValue] = useState(0);
2526
const [fxRate, setFxRate] = useState({});
@@ -35,10 +36,9 @@ const ConvertCurrencyScreen = ({ navigation }) => {
3536

3637
setFxRate(newFxRate);
3738
saveCurrencyOrder(data);
38-
setIsDragging(false);
3939
}
4040

41-
const keyExtractor = (item, index) => item + index;
41+
const keyExtractor = (item, _index) => item.iso;
4242

4343
const renderItem = ({ item, drag }) => {
4444
const isReferenceUnit = item.iso == refUnit.iso;
@@ -205,20 +205,19 @@ const ConvertCurrencyScreen = ({ navigation }) => {
205205
setValue={setValue}
206206
unit={refUnit}
207207
/>
208-
<Text>{t('update')}: {fxRate.day} ({t('sourceECB')})</Text>
208+
<View style={{display: 'flex', flexDirection: 'row', alignItems: 'center'}}>
209+
<Text>{t('update')}: {fxRate.day} ({t('sourceECB')})</Text>
210+
<Button size='sm' type='clear' color={theme.colors.white} onPress={fetchFxRate} disabled={isRefreshing}>
211+
<Icon name="sync" solid={false} size={24} color={theme.colors.primary}/>
212+
</Button>
213+
</View>
214+
{isRefreshing && <ActivityIndicator size="large" />}
209215
<View style={{flex: 1, width: '100%'}}>
210216
<DraggableFlatList
211217
data={fxRate.rates ?? []}
212-
refreshControl={
213-
<RefreshControl
214-
enabled={!isDragging}
215-
onRefresh={fetchFxRate}
216-
refreshing={isRefreshing}
217-
/>
218-
}
218+
refreshing={isRefreshing}
219219
renderItem={renderItem}
220220
keyExtractor={keyExtractor}
221-
onDragBegin={() => setIsDragging(true)}
222221
onDragEnd={onDragEnd}
223222
/>
224223
</View>

src/containers/ConvertScreen.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useRef, useState } from 'react';
1+
import { useEffect, useRef, useState } from 'react';
22
import AsyncStorage from '@react-native-async-storage/async-storage';
33
import DraggableFlatList, { OpacityDecorator } from 'react-native-draggable-flatlist';
44
import UnitValue from '../components/UnitValue';
@@ -27,7 +27,7 @@ const ConvertScreen = ({ navigation, conversionData }) => {
2727
saveCategoryOrder(data);
2828
}
2929

30-
const keyExtractor = (item, index) => item + index;
30+
const keyExtractor = (item, _index) => item.name;
3131

3232
const renderItem = ({ item, drag }) => {
3333
const isReferenceUnit = (item.name == refUnit.name);

src/containers/HomeScreen.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React, { useState } from 'react';
21
import ListCategoryItem from '../components/ListCategoryItem';
32
import EmptyDataComponent from '../components/EmptyDataComponent';
43
import { FlatList, StyleSheet, View } from 'react-native';

src/containers/RootNavigation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useRef, useState } from 'react';
1+
import { useEffect, useRef } from 'react';
22
import Icon from 'react-native-vector-icons/FontAwesome5';
33
import AsyncStorage from '@react-native-async-storage/async-storage';
44
import ConvertScreen from './ConvertScreen';

0 commit comments

Comments
 (0)