Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: transaction list home screen adaptive to screen size #3241

Merged
merged 2 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions app/screens/home-screen/home-screen.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from "react"
import { useMemo } from "react"
import { RefreshControl, View, Alert } from "react-native"
import { RefreshControl, View, Alert, Dimensions, LayoutChangeEvent } from "react-native"
import {
ScrollView,
TouchableOpacity,
Expand Down Expand Up @@ -239,15 +239,27 @@ export const HomeScreen: React.FC = () => {
}
| undefined = undefined

const TRANSACTIONS_TO_SHOW = 1
const [noOfTransactionsToShow, setTransactionsToShow] = React.useState(1)

const onLayoutTransactionDataWrapper = (e: LayoutChangeEvent) => {
if (loading) return
const layout = e.nativeEvent.layout
const txItemsToShow = Math.floor(
(Dimensions.get("screen").height -
(layout.y + layout.height) -
180) /* Bottom Tab Navigation */ /
80 /* Per Transaction Item */,
)
if (noOfTransactionsToShow < txItemsToShow) setTransactionsToShow(txItemsToShow)
}

if (isAuthed && transactions.length > 0) {
recentTransactionsData = {
title: LL.TransactionScreen.title(),
details: (
<>
{transactions
.slice(0, TRANSACTIONS_TO_SHOW)
.slice(0, noOfTransactionsToShow)
.map(
(tx, index, array) =>
tx && (
Expand Down Expand Up @@ -383,7 +395,9 @@ export const HomeScreen: React.FC = () => {
))}
</View>
<NotificationCard />
<View>
<AppUpdate />

<View onLayout={onLayoutTransactionDataWrapper}>
{recentTransactionsData && (
<>
<TouchableOpacity
Expand All @@ -405,7 +419,6 @@ export const HomeScreen: React.FC = () => {
)}
</View>

<AppUpdate />
<SetDefaultAccountModal
isVisible={setDefaultAccountModalVisible}
toggleModal={() => {
Expand Down
6 changes: 5 additions & 1 deletion app/screens/notification-history-screen/notification.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
StatefulNotification,
StatefulNotificationsDocument,
UnacknowledgedNotificationCountDocument,
useStatefulNotificationAcknowledgeMutation,
} from "@app/graphql/generated"
import { Text, makeStyles } from "@rneui/themed"
Expand Down Expand Up @@ -36,7 +37,10 @@ export const Notification: React.FC<StatefulNotification> = ({

const [ack, _] = useStatefulNotificationAcknowledgeMutation({
variables: { input: { notificationId: id } },
refetchQueries: [StatefulNotificationsDocument],
refetchQueries: [
StatefulNotificationsDocument,
UnacknowledgedNotificationCountDocument,
],
})

const linkTo = useLinkTo()
Expand Down
Loading