Skip to content

Commit 2db844f

Browse files
authored
Merge pull request zingolabs#877 from Brocter/arrow_button_ui/fix
arrow scroll to top: fix
2 parents 4361c5d + 6d561ac commit 2db844f

File tree

1 file changed

+39
-17
lines changed

1 file changed

+39
-17
lines changed

components/History/History.tsx

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
/* eslint-disable react-native/no-inline-styles */
22
import React, { useContext, useState, useEffect, useCallback, useMemo, useRef } from 'react';
3-
import { View, ScrollView, RefreshControl, TouchableOpacity, ActivityIndicator, Dimensions, Platform } from 'react-native';
3+
import {
4+
View,
5+
ScrollView,
6+
RefreshControl,
7+
TouchableOpacity,
8+
ActivityIndicator,
9+
Dimensions,
10+
Platform,
11+
Pressable,
12+
} from 'react-native';
413
import moment from 'moment';
514
import 'moment/locale/es';
615
import 'moment/locale/pt';
@@ -9,7 +18,7 @@ import 'moment/locale/tr';
918

1019
import { useTheme } from '@react-navigation/native';
1120
import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome';
12-
import { faAnglesUp } from '@fortawesome/free-solid-svg-icons';
21+
import { faAnglesUp, faAngleUp, faArrowCircleUp, faArrowUp } from '@fortawesome/free-solid-svg-icons';
1322

1423
import {
1524
ButtonTypeEnum,
@@ -189,7 +198,7 @@ const History: React.FunctionComponent<HistoryProps> = ({
189198
};
190199

191200
const handleScroll = (_rawEvent: ScrollEvent, _offsetX: number, offsetY: number) => {
192-
const isTop = offsetY === 0;
201+
const isTop = offsetY <= 0;
193202
setIsAtTop(isTop);
194203
setShowFooter(true);
195204
};
@@ -206,7 +215,10 @@ const History: React.FunctionComponent<HistoryProps> = ({
206215
/>
207216
),
208217
// possible problem if scrolling vertically, if so change to `undefined`.
209-
{ swipeDirection: Platform.OS === GlobalConst.platformOSios ? 'right' : undefined, style: { flex: 1, backgroundColor: colors.background } },
218+
{
219+
swipeDirection: Platform.OS === GlobalConst.platformOSios ? 'right' : undefined,
220+
style: { flex: 1, backgroundColor: colors.background },
221+
},
210222
).promise;
211223
};
212224

@@ -223,7 +235,10 @@ const History: React.FunctionComponent<HistoryProps> = ({
223235
/>
224236
),
225237
// possible problem if scrolling vertically, if so change to `undefined`.
226-
{ swipeDirection: Platform.OS === GlobalConst.platformOSios ? 'right' : undefined, style: { flex: 1, backgroundColor: colors.background } },
238+
{
239+
swipeDirection: Platform.OS === GlobalConst.platformOSios ? 'right' : undefined,
240+
style: { flex: 1, backgroundColor: colors.background },
241+
},
227242
).promise;
228243
};
229244

@@ -251,11 +266,7 @@ const History: React.FunctionComponent<HistoryProps> = ({
251266

252267
return (
253268
<ToastProvider>
254-
<Snackbars
255-
snackbars={snackbars}
256-
removeFirstSnackbar={removeFirstSnackbar}
257-
screenName={screenName}
258-
/>
269+
<Snackbars snackbars={snackbars} removeFirstSnackbar={removeFirstSnackbar} screenName={screenName} />
259270

260271
<View
261272
accessible={true}
@@ -430,20 +441,31 @@ const History: React.FunctionComponent<HistoryProps> = ({
430441
justifyContent: 'center',
431442
marginTop: 30,
432443
}}>
433-
<FadeText style={{ color: colors.primary }}>
434-
{translate('history.empty') as string}
435-
</FadeText>
444+
<FadeText style={{ color: colors.primary }}>{translate('history.empty') as string}</FadeText>
436445
</View>
437446
)}
438447
{!isAtTop && (
439-
<TouchableOpacity onPress={handleScrollToTop} style={{ position: 'absolute', bottom: 30, right: 10 }}>
448+
<Pressable
449+
onPress={handleScrollToTop}
450+
style={({ pressed }) => ({
451+
position: 'absolute',
452+
bottom: 30,
453+
right: 10,
454+
paddingHorizontal: 10,
455+
paddingVertical: 15,
456+
backgroundColor: colors.sideMenuBackground,
457+
borderRadius: 50,
458+
transform: [{ scale: pressed ? 0.9 : 1 }],
459+
borderWidth: 1,
460+
borderColor: colors.zingo,
461+
})}>
440462
<FontAwesomeIcon
441463
style={{ marginLeft: 5, marginRight: 5, marginTop: 0 }}
442-
size={50}
443-
icon={faAnglesUp}
464+
size={20}
465+
icon={faAngleUp}
444466
color={colors.zingo}
445467
/>
446-
</TouchableOpacity>
468+
</Pressable>
447469
)}
448470
</>
449471
)}

0 commit comments

Comments
 (0)