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

feat: Added Skeleton UI to chats #8042

Merged
merged 59 commits into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
8bddc65
feat: Added react-content-loader dependency
mananjadhav Feb 6, 2022
416bc77
feat: Basic setup of content loader added
mananjadhav Feb 6, 2022
851952b
feat: Added content loaders with svgs
mananjadhav Feb 7, 2022
d98a67c
feat: Updated chat ghost ui with dynamic loaders
mananjadhav Feb 7, 2022
92dd9a1
feat: Added native files for content loading elements
mananjadhav Feb 7, 2022
4060abc
feat: Added isLoadingReportData flag for loader on Report
mananjadhav Feb 7, 2022
01af67a
Merge branch 'main' of https://github.com/mananjadhav/App into feat/g…
mananjadhav Feb 21, 2022
afaac18
Merge branch 'main' of https://github.com/mananjadhav/App into feat/g…
mananjadhav Mar 7, 2022
2004e68
Merge branch 'main' of https://github.com/mananjadhav/App into feat/g…
mananjadhav Mar 8, 2022
cb9b0eb
fix: added state variable for ghostscreen
mananjadhav Mar 8, 2022
b96aa5b
fix: added derivedstatefromprops function to update state one time
mananjadhav Mar 8, 2022
0c60227
fix: removed props check from loader
mananjadhav Mar 8, 2022
8665824
fix: changed width for native devices
mananjadhav Mar 8, 2022
95d1130
fix: code cleanup with style guidelines
mananjadhav Mar 8, 2022
7229d3d
fix: added _.map for _.keys
mananjadhav Mar 8, 2022
ed69116
Merge branch 'main' of https://github.com/mananjadhav/App into feat/g…
mananjadhav Mar 24, 2022
8fce186
fix: reusing shapes from rn-svg and replacing content-loader wrapper
mananjadhav Mar 25, 2022
6bb0c36
fix: moved setstate to componentDidUpdate
mananjadhav Mar 25, 2022
f9d02b2
fix: remove full screen loader
mananjadhav Mar 25, 2022
c2270ff
fix: add delay in render
mananjadhav Mar 25, 2022
8b7d569
Merge branch 'main' of https://github.com/mananjadhav/App into feat/g…
mananjadhav Apr 12, 2022
3ae559c
fix: added flag check to function
mananjadhav Apr 12, 2022
17177d6
Merge branch 'main' of https://github.com/mananjadhav/App into feat/g…
mananjadhav May 1, 2022
a6128c0
Merge branch 'main' of https://github.com/mananjadhav/App into feat/g…
mananjadhav May 2, 2022
0bfe1ba
feat: updated component structure for skeleton views
mananjadhav May 2, 2022
9140ea1
fix: removed old code
mananjadhav May 2, 2022
abdb0a9
fix: updated conditions for showing loader
mananjadhav May 2, 2022
2052ba0
fix: removed "ghost" word references
mananjadhav May 2, 2022
428e545
fix: cleanup skeleton ui logic
mananjadhav May 2, 2022
22ba08d
fix: change condition for loader screen
mananjadhav May 2, 2022
fcabd27
fix: added alias to webpack for react-content-loader
mananjadhav May 2, 2022
14e230c
fix: moved heights to const and cleanup code
mananjadhav May 2, 2022
a021c5e
fix: updated num row logic
mananjadhav May 2, 2022
a277fc2
style: fixed linting and added jsdoc
mananjadhav May 2, 2022
bb5b935
fix: wrapped render component with fragment
mananjadhav May 8, 2022
ddd0def
fix: switched to container height from window height to set the heigh…
mananjadhav May 8, 2022
9417fee
Merge branch 'main' of https://github.com/mananjadhav/App into feat/g…
mananjadhav May 12, 2022
6431e4b
Merge branch 'main' of https://github.com/mananjadhav/App into feat/g…
mananjadhav Jun 14, 2022
d0f52f2
feat: merge report fetch action methods
mananjadhav Jun 14, 2022
6567615
feat: update loader logic for skeleton view
mananjadhav Jun 14, 2022
662409e
feat: update references for isloading flags
mananjadhav Jun 14, 2022
5a8c3e5
fix: report actions loader
mananjadhav Jun 14, 2022
b5c10e6
fix: split functions for initial load and pagination
mananjadhav Jun 14, 2022
479e056
fix: alignment of skeleton view
mananjadhav Jun 14, 2022
e468cbc
fix: update checks for shouldComponentUpdate
mananjadhav Jun 14, 2022
8d9e5bb
feat: added animation transition to skeleton ui
mananjadhav Jun 14, 2022
7f8d26f
Merge branch 'main' of github.com:mananjadhav/App into feat/ghost-screen
mananjadhav Jul 22, 2022
cc66043
refactor: chnged the latest version of skeleton ui code
mananjadhav Jul 22, 2022
aaa6806
chore: package-lock changes
mananjadhav Jul 22, 2022
fb56647
refactor: retain the latest changes ReportScreen
mananjadhav Jul 22, 2022
2c35e7a
refactor: change the flags for isLoadingMoreActions
mananjadhav Jul 22, 2022
2efc337
feat: changed flags for loading actions with new format
mananjadhav Jul 22, 2022
d4cbe16
style: lint fixes
mananjadhav Jul 22, 2022
8f09ac6
fix: updated the flag with reportId
mananjadhav Jul 22, 2022
80671e6
Merge branch 'main' of github.com:mananjadhav/App into feat/ghost-screen
mananjadhav Jul 26, 2022
719a477
Merge branch 'main' of github.com:mananjadhav/App into feat/ghost-screen
mananjadhav Jul 28, 2022
0352b63
refactor: remove unwanted pagination method
mananjadhav Jul 28, 2022
862557b
Merge branch 'main' of github.com:mananjadhav/App into feat/ghost-screen
mananjadhav Jul 29, 2022
ab2189f
style: corrected comment
mananjadhav Jul 29, 2022
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
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"pusher-js": "^7.0.0",
"react": "^17.0.2",
"react-collapse": "^5.1.0",
"react-content-loader": "^6.1.0",
"react-dom": "^17.0.2",
"react-native": "0.66.4",
"react-native-collapsible": "^1.6.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import ContentLoader from 'react-content-loader';

const ContentLoadingOneLine = () => (
<ContentLoader
height={60}
width="100%"
title=""
>
<circle cx="50" cy="26" r="20" />
<rect x="90" y="11" width="20%" height="8" />
<rect x="90" y="31" width="90%" height="8" />
</ContentLoader>
);

ContentLoadingOneLine.displayName = 'ContentLoadingOneLine';
export default ContentLoadingOneLine;
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import ContentLoader, {Circle, Rect} from 'react-content-loader/native';

const ContentLoadingOneLine = () => (
<ContentLoader
height={60}
width="100%"
title=""
>
<Circle cx="50" cy="26" r="20" />
<Rect x="90" y="11" width="20%" height="8" />
<Rect x="90" y="31" width="75%" height="8" />
</ContentLoader>
);

ContentLoadingOneLine.displayName = 'ContentLoadingOneLine';
export default ContentLoadingOneLine;
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import ContentLoader from 'react-content-loader';

const ContentLoadingThreeLines = () => (
<ContentLoader
height={100}
width="100%"
title=""
>
<circle cx="50" cy="26" r="20" />
<rect x="90" y="11" width="20%" height="8" />
<rect x="90" y="31" width="90%" height="8" />
<rect x="90" y="51" width="90%" height="8" />
<rect x="90" y="71" width="50%" height="8" />
</ContentLoader>
);

ContentLoadingThreeLines.displayName = 'ContentLoadingThreeLines';
export default ContentLoadingThreeLines;
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import ContentLoader, {Circle, Rect} from 'react-content-loader/native';

const ContentLoadingThreeLines = () => (
<ContentLoader
height={100}
width="100%"
title=""
>
<Circle cx="50" cy="26" r="20" />
<Rect x="90" y="11" width="20%" height="8" />
<Rect x="90" y="31" width="75%" height="8" />
<Rect x="90" y="51" width="75%" height="8" />
<Rect x="90" y="71" width="50%" height="8" />
</ContentLoader>
);

ContentLoadingThreeLines.displayName = 'ContentLoadingThreeLines';
export default ContentLoadingThreeLines;
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import ContentLoader from 'react-content-loader';

const ContentLoadingTwoLines = () => (
<ContentLoader
height={80}
width="100%"
title=""
>
<circle cx="50" cy="26" r="20" />
<rect x="90" y="11" width="20%" height="8" />
<rect x="90" y="31" width="90%" height="8" />
<rect x="90" y="51" width="50%" height="8" />
</ContentLoader>
);

ContentLoadingTwoLines.displayName = 'ContentLoadingTwoLines';
export default ContentLoadingTwoLines;
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import ContentLoader, {Rect, Circle} from 'react-content-loader/native';
mananjadhav marked this conversation as resolved.
Show resolved Hide resolved

const ContentLoadingTwoLines = () => (
<ContentLoader
height={80}
width="100%"
title=""
mananjadhav marked this conversation as resolved.
Show resolved Hide resolved
>
<Circle cx="50" cy="26" r="20" />
<Rect x="90" y="11" width="20%" height="8" />
<Rect x="90" y="31" width="75%" height="8" />
<Rect x="90" y="51" width="50%" height="8" />
</ContentLoader>
);

ContentLoadingTwoLines.displayName = 'ContentLoadingTwoLines';
export default ContentLoadingTwoLines;
35 changes: 35 additions & 0 deletions src/components/ChatGhostUI/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react';
import {Dimensions} from 'react-native';
import _ from 'underscore';
import ContentLoadingOneLine from './ContentLoadingElements/ContentLoadingOneLine';
mananjadhav marked this conversation as resolved.
Show resolved Hide resolved
import ContentLoadingTwoLines from './ContentLoadingElements/ContentLoadingTwoLines';
import ContentLoadingThreeLines from './ContentLoadingElements/ContentLoadingThreeLines';
mananjadhav marked this conversation as resolved.
Show resolved Hide resolved


mananjadhav marked this conversation as resolved.
Show resolved Hide resolved
const ChatList = () => {
mananjadhav marked this conversation as resolved.
Show resolved Hide resolved
const windowHeight = Dimensions.get('window').height;
mananjadhav marked this conversation as resolved.
Show resolved Hide resolved

mananjadhav marked this conversation as resolved.
Show resolved Hide resolved
const height = 80;
mananjadhav marked this conversation as resolved.
Show resolved Hide resolved
const numberOfRows = Math.floor(windowHeight / height);
const contentItems = Array.from({length: numberOfRows}, (v, i) => i);
mananjadhav marked this conversation as resolved.
Show resolved Hide resolved

return (
<>
{
_.map(contentItems, (item, index) => {
mananjadhav marked this conversation as resolved.
Show resolved Hide resolved
const iconIndex = (index + 1) % 4;
switch (iconIndex) {
case 2:
return <ContentLoadingTwoLines key={item} />;
mananjadhav marked this conversation as resolved.
Show resolved Hide resolved
case 0:
return <ContentLoadingThreeLines key={item} />;
default:
return <ContentLoadingOneLine key={item} />;
}
})
}

mananjadhav marked this conversation as resolved.
Show resolved Hide resolved
</>
);
};
export default ChatList;
30 changes: 28 additions & 2 deletions src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import KeyboardSpacer from '../../components/KeyboardSpacer';
import SwipeableView from '../../components/SwipeableView';
import CONST from '../../CONST';
import FullScreenLoadingIndicator from '../../components/FullscreenLoadingIndicator';
import ChatGhostUI from '../../components/ChatGhostUI';
import reportActionPropTypes from './report/reportActionPropTypes';

const propTypes = {
Expand Down Expand Up @@ -58,6 +59,8 @@ const propTypes = {

/** Beta features list */
betas: PropTypes.arrayOf(PropTypes.string),

isLoadingReportData: PropTypes.bool,
mananjadhav marked this conversation as resolved.
Show resolved Hide resolved
};

const defaultProps = {
Expand All @@ -72,6 +75,7 @@ const defaultProps = {
hasOutstandingIOU: false,
},
betas: [],
isLoadingReportData: false,
};

/**
Expand All @@ -95,6 +99,7 @@ class ReportScreen extends React.Component {

this.state = {
isLoading: true,
isGhostScreenVisible: true,
};
}

Expand All @@ -116,6 +121,21 @@ class ReportScreen extends React.Component {
clearTimeout(this.loadingTimerId);
}

/**
* When the report data is loaded, hide the ghost screen
*
* @static
* @param {Object} props
* @param {Object} state
* @return {Object|null}
*/
static getDerivedStateFromProps(props, state) {
if (state.isGhostScreenVisible && props.isLoadingReportData === false) {
return {isGhostScreenVisible: false};
}
return null;
}

mananjadhav marked this conversation as resolved.
Show resolved Hide resolved
/**
* @param {String} text
*/
Expand Down Expand Up @@ -174,8 +194,11 @@ class ReportScreen extends React.Component {
nativeID={CONST.REPORT.DROP_NATIVE_ID}
style={[styles.flex1, styles.justifyContentEnd, styles.overflowHidden]}
>
<FullScreenLoadingIndicator visible={this.shouldShowLoader()} />
{!this.shouldShowLoader() && (
{
this.state.isGhostScreenVisible && <ChatGhostUI />
}
<FullScreenLoadingIndicator visible={!this.state.isGhostScreenVisible && this.shouldShowLoader()} />
mananjadhav marked this conversation as resolved.
Show resolved Hide resolved
{!this.state.isGhostScreenVisible && !this.shouldShowLoader() && (
mananjadhav marked this conversation as resolved.
Show resolved Hide resolved
<ReportActionsView
reportID={reportID}
reportActions={this.props.reportActions}
Expand Down Expand Up @@ -220,4 +243,7 @@ export default withOnyx({
betas: {
key: ONYXKEYS.BETAS,
},
isLoadingReportData: {
key: ONYXKEYS.IS_LOADING_REPORT_DATA,
},
})(ReportScreen);