-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[No QA] Empty state modal #45690
[No QA] Empty state modal #45690
Changes from all commits
ca2b8a7
7f994b7
969da50
9e2d46d
f643792
6de8bcc
121dd3f
237ff7f
78a2880
c93ac5f
c09a679
7f372bd
8c91902
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import React from 'react'; | ||
import {Circle, Rect} from 'react-native-svg'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import useWindowDimensions from '@hooks/useWindowDimensions'; | ||
import variables from '@styles/variables'; | ||
import ItemListSkeletonView from './ItemListSkeletonView'; | ||
|
||
type CardRowSkeletonProps = { | ||
shouldAnimate?: boolean; | ||
fixedNumItems?: number; | ||
gradientOpacityEnabled?: boolean; | ||
}; | ||
|
||
const barHeight = 7; | ||
const longBarWidth = 120; | ||
const shortBarWidth = 60; | ||
const leftPaneWidth = variables.sideBarWidth; | ||
const gapWidth = 12; | ||
const rightSideElementWidth = 50; | ||
const centralPanePadding = 50; | ||
const rightButtonWidth = 20; | ||
|
||
function CardRowSkeleton({shouldAnimate = true, fixedNumItems, gradientOpacityEnabled = false}: CardRowSkeletonProps) { | ||
const styles = useThemeStyles(); | ||
const {windowWidth, isSmallScreenWidth} = useWindowDimensions(); | ||
|
||
return ( | ||
<ItemListSkeletonView | ||
shouldAnimate={shouldAnimate} | ||
fixedNumItems={fixedNumItems} | ||
gradientOpacityEnabled={gradientOpacityEnabled} | ||
itemViewStyle={[styles.highlightBG, styles.mb3, styles.br3, styles.mr3, styles.ml3]} | ||
renderSkeletonItem={() => ( | ||
<> | ||
<Circle | ||
cx={36} | ||
cy={32} | ||
r={20} | ||
/> | ||
<Rect | ||
x={66} | ||
y={22} | ||
width={longBarWidth} | ||
height={barHeight} | ||
/> | ||
|
||
<Rect | ||
x={66} | ||
y={36} | ||
width={shortBarWidth} | ||
height={barHeight} | ||
/> | ||
|
||
{!isSmallScreenWidth && ( | ||
<> | ||
<Rect | ||
// We have to calculate this value to make sure the element is aligned to the button on the right side. | ||
x={windowWidth - leftPaneWidth - rightButtonWidth - gapWidth - centralPanePadding - gapWidth - rightSideElementWidth} | ||
y={28} | ||
width={20} | ||
height={barHeight} | ||
/> | ||
|
||
<Rect | ||
// We have to calculate this value to make sure the element is aligned to the right border. | ||
x={windowWidth - leftPaneWidth - rightSideElementWidth - gapWidth - centralPanePadding} | ||
y={28} | ||
width={50} | ||
height={barHeight} | ||
/> | ||
</> | ||
)} | ||
</> | ||
)} | ||
/> | ||
); | ||
} | ||
|
||
CardRowSkeleton.displayName = 'CardRowSkeleton'; | ||
|
||
export default CardRowSkeleton; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React from 'react'; | ||
import {View} from 'react-native'; | ||
import EmptyStateComponent from '@components/EmptyStateComponent'; | ||
import * as Illustrations from '@components/Icon/Illustrations'; | ||
import ScrollView from '@components/ScrollView'; | ||
import CardRowSkeleton from '@components/Skeletons/CardRowSkeleton'; | ||
import Text from '@components/Text'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import useWindowDimensions from '@hooks/useWindowDimensions'; | ||
import CONST from '@src/CONST'; | ||
|
||
const HEADER_HEIGHT = 80; | ||
const BUTTON_HEIGHT = 40; | ||
const BUTTON_MARGIN = 12; | ||
|
||
function EmptyCardView() { | ||
const {translate} = useLocalize(); | ||
const styles = useThemeStyles(); | ||
const {windowHeight, isSmallScreenWidth} = useWindowDimensions(); | ||
|
||
const headerHeight = isSmallScreenWidth ? HEADER_HEIGHT + BUTTON_HEIGHT + BUTTON_MARGIN : HEADER_HEIGHT; | ||
|
||
return ( | ||
<ScrollView> | ||
<View style={{height: windowHeight - headerHeight}}> | ||
<EmptyStateComponent | ||
SkeletonComponent={CardRowSkeleton} | ||
headerMediaType={CONST.EMPTY_STATE_MEDIA.ILLUSTRATION} | ||
headerMedia={Illustrations.EmptyCardState} | ||
headerStyles={[{overflow: 'hidden'}, isSmallScreenWidth && {maxHeight: 300}]} | ||
title={translate('workspace.expensifyCard.issueAndManageCards')} | ||
subtitle={translate('workspace.expensifyCard.getStartedIssuing')} | ||
emptyStateContentStyles={isSmallScreenWidth ? {top: -BUTTON_HEIGHT} : undefined} | ||
/> | ||
</View> | ||
<Text style={[styles.textMicroSupporting, styles.m5]}>{translate('workspace.expensifyCard.disclaimer')}</Text> | ||
</ScrollView> | ||
); | ||
} | ||
|
||
EmptyCardView.displayName = 'EmptyCardView'; | ||
|
||
export default EmptyCardView; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,8 @@ import ONYXKEYS from '@src/ONYXKEYS'; | |
import ROUTES from '@src/ROUTES'; | ||
import type SCREENS from '@src/SCREENS'; | ||
import type {Card, WorkspaceCardsList} from '@src/types/onyx'; | ||
import {isEmptyObject} from '@src/types/utils/EmptyObject'; | ||
import EmptyCardView from './EmptyCardView'; | ||
import WorkspaceCardListHeader from './WorkspaceCardListHeader'; | ||
import WorkspaceCardListRow from './WorkspaceCardListRow'; | ||
|
||
|
@@ -160,14 +162,16 @@ function WorkspaceExpensifyCardListPage({route}: WorkspaceExpensifyCardListPageP | |
> | ||
{!shouldUseNarrowLayout && getHeaderButtons()} | ||
</HeaderWithBackButton> | ||
|
||
{shouldUseNarrowLayout && <View style={[styles.pl5, styles.pr5]}>{getHeaderButtons()}</View>} | ||
|
||
<FlatList | ||
data={sortedCards} | ||
renderItem={renderItem} | ||
ListHeaderComponent={WorkspaceCardListHeader} | ||
/> | ||
{!isEmptyObject(cardsList) ? ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @koko57 Please help to explain this line As I understand, we display EmptyCardView if cardList í empty There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @DylanDylann yes, I did it probably bc I didn't want to remove mockedCard list in this PR. I'll tell Vicky (she's integrating BE with the cardList), to correct this condition There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, she did it in her PR https://github.com/Expensify/App/pull/47064/files |
||
<EmptyCardView /> | ||
) : ( | ||
<FlatList | ||
data={sortedCards} | ||
renderItem={renderItem} | ||
ListHeaderComponent={WorkspaceCardListHeader} | ||
/> | ||
)} | ||
</ScreenWrapper> | ||
); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment to add reviewer