Skip to content
Open
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
22 changes: 14 additions & 8 deletions src/components/charts/BalanceHistoryChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ export type BalanceHistoryChartProps = {
preChartContent?: React.ReactNode;
preChartContentTopMargin?: number;
postChartContent?: React.ReactNode;
/** Rendered below the timeframe selector and fades together with it. */
postTimeframeContent?: React.ReactNode;
changeRowStyle?: StyleProp<ViewStyle>;
showChangeRow?: boolean;
showTimeframeSelector?: boolean;
Expand Down Expand Up @@ -133,6 +135,7 @@ const BalanceHistoryChart = ({
preChartContent,
preChartContentTopMargin = 22,
postChartContent,
postTimeframeContent,
changeRowStyle,
showChangeRow = true,
showTimeframeSelector = true,
Expand Down Expand Up @@ -415,15 +418,18 @@ const BalanceHistoryChart = ({

{postChartContent}

{showTimeframeSelector ? (
{showTimeframeSelector || postTimeframeContent ? (
<Animated.View style={timeframeSelectorAnimatedStyle}>
<TimeframeSelector
options={getFiatChartTimeframeOptions(t)}
selected={displayModel.selectedTimeframe}
width={timeframeSelectorWidth}
horizontalInset={timeframeSelectorHorizontalInset}
onSelect={displayModel.onTimeframeSelect}
/>
{showTimeframeSelector ? (
<TimeframeSelector
options={getFiatChartTimeframeOptions(t)}
selected={displayModel.selectedTimeframe}
width={timeframeSelectorWidth}
horizontalInset={timeframeSelectorHorizontalInset}
onSelect={displayModel.onTimeframeSelect}
/>
) : null}
{postTimeframeContent}
</Animated.View>
) : null}
</>
Expand Down
1 change: 1 addition & 0 deletions src/components/charts/ChartChangeRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const ChartChangeRow = ({
priceChange={displayedDelta}
rangeLabel={rangeLabel}
fractionDigits={2}
maxFontSizeMultiplier={1.2}
/>
</Animated.View>
);
Expand Down
6 changes: 6 additions & 0 deletions src/components/percentage/Percentage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const styles = StyleSheet.create({
flexDirection: 'row',
alignItems: 'center',
flexWrap: 'wrap',
justifyContent: 'center',
flexShrink: 1,
},
rangeLabel: {
Expand All @@ -40,6 +41,7 @@ export interface PercentageProps {
suffix?: string;
textStyle?: any;
fractionDigits?: number;
maxFontSizeMultiplier?: number;
}

export const getDifferenceColor = (isPositive: boolean, isDarkMode: boolean) =>
Expand All @@ -65,6 +67,7 @@ const Percentage = ({
suffix,
textStyle,
fractionDigits,
maxFontSizeMultiplier,
}: PercentageProps) => {
const theme = useTheme();
const isDarkMode = theme.dark;
Expand Down Expand Up @@ -114,6 +117,7 @@ const Percentage = ({
) : null}
{shouldShowPriceChange ? (
<BaseText
maxFontSizeMultiplier={maxFontSizeMultiplier}
style={[
styles.percentageContainer,
{color: percentageColor},
Expand All @@ -124,6 +128,7 @@ const Percentage = ({
</BaseText>
) : null}
<BaseText
maxFontSizeMultiplier={maxFontSizeMultiplier}
style={[
styles.percentageContainer,
{color: percentageColor},
Expand All @@ -134,6 +139,7 @@ const Percentage = ({
</BaseText>
{rangeLabel ? (
<BaseText
maxFontSizeMultiplier={maxFontSizeMultiplier}
style={[
styles.rangeLabel,
{color: getNeutralChangeColor(theme.dark)},
Expand Down
47 changes: 37 additions & 10 deletions src/navigation/tabs/home/components/PortfolioBalance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,13 @@
unchartedNote: {
flexDirection: 'row',
alignItems: 'center',
marginLeft: 8,
alignSelf: 'flex-end',
marginTop: 4,
paddingRight: 12,
},
unchartedNoteText: {
fontSize: 13,
lineHeight: 18,
fontSize: 11,
lineHeight: 14,
marginRight: 3,
},
});
Expand Down Expand Up @@ -200,6 +202,9 @@
return (
<BaseText
maxFontSizeMultiplier={1.5}
numberOfLines={1}
adjustsFontSizeToFit
minimumFontScale={0.5}
style={[
headerStyles.portfolioBalanceText,
{
Expand Down Expand Up @@ -261,7 +266,7 @@
]}>
{t('Some assets not charted')}
</BaseText>
<InfoSvg width={13} height={13} />
<InfoSvg width={11} height={11} />
</TouchableOpacity>
);
};
Expand Down Expand Up @@ -295,6 +300,7 @@
priceChange={displayedDelta}
rangeLabel={rangeLabel}
fractionDigits={2}
maxFontSizeMultiplier={1.2}
/>
{trailing}
</PortfolioBalanceChangeRowContainer>
Expand Down Expand Up @@ -476,6 +482,18 @@
(collapseButtonLayout.x + collapseButtonLayout.width),
)
: 12;
// Width the mini chart occupies next to the balance once collapsed, minus the
// top section's own gutter, so a long amount shrinks instead of running
// under (or being cut by) the chart.
const collapsedChartReservedWidth = chartStageWidth
? Math.max(
0,
chartStageWidth * collapsedScale +
targetChartRightInset +
8 -
parseInt(ScreenGutter, 10),
)
: 0;
const collapsedTranslateX =
chartStageWidth > 0
? chartStageWidth * ((1 - collapsedScale) / 2) - targetChartRightInset
Expand Down Expand Up @@ -810,7 +828,14 @@
<BalanceVisibilityButton
testID="portfolio-balance-toggle"
style={
shouldLeftAlignTopSection ? {alignItems: 'flex-start'} : undefined
shouldLeftAlignTopSection
? {
alignItems: 'flex-start',
marginRight: isChartCollapsed
? collapsedChartReservedWidth
: 0,
}
: undefined
}
hidden={hideAllBalances}
onToggle={() => {
Expand All @@ -836,12 +861,7 @@
percent={displayedChangeRowData?.percent ?? 0}
deltaFiatFormatted={displayedChangeRowData?.deltaFiatFormatted}
rangeLabel={displayedChangeRowData?.rangeLabel}
visible={!!displayedChangeRowData}

Check warning on line 864 in src/navigation/tabs/home/components/PortfolioBalance.tsx

View workflow job for this annotation

GitHub Actions / Lint

[eslint] reported by reviewdog 🐶 Error: Cannot access refs during render React refs are values that are not needed for rendering. Refs should only be accessed outside of render, such as in event handlers or effects. Accessing a ref value (the `current` property) during render can cause your component not to update as expected (https://react.dev/reference/react/useRef). /home/runner/work/bitpay-app/bitpay-app/src/navigation/tabs/home/components/PortfolioBalance.tsx:864:22 862 | deltaFiatFormatted={displayedChangeRowData?.deltaFiatFormatted} 863 | rangeLabel={displayedChangeRowData?.rangeLabel} > 864 | visible={!!displayedChangeRowData} | ^^^^^^^^^^^^^^^^^^^^^^ Cannot access ref value during render 865 | style={{ 866 | width: '100%', 867 | justifyContent: shouldLeftAlignTopSection ? 'flex-start' : 'center', To initialize a ref only once, check that the ref is null with the pattern `if (ref.current == null) { ref.current = ... }` Raw Output: {"ruleId":"react-hooks/refs","severity":1,"message":"Error: Cannot access refs during render\n\nReact refs are values that are not needed for rendering. Refs should only be accessed outside of render, such as in event handlers or effects. Accessing a ref value (the `current` property) during render can cause your component not to update as expected (https://react.dev/reference/react/useRef).\n\n/home/runner/work/bitpay-app/bitpay-app/src/navigation/tabs/home/components/PortfolioBalance.tsx:864:22\n 862 | deltaFiatFormatted={displayedChangeRowData?.deltaFiatFormatted}\n 863 | rangeLabel={displayedChangeRowData?.rangeLabel}\n> 864 | visible={!!displayedChangeRowData}\n | ^^^^^^^^^^^^^^^^^^^^^^ Cannot access ref value during render\n 865 | style={{\n 866 | width: '100%',\n 867 | justifyContent: shouldLeftAlignTopSection ? 'flex-start' : 'center',\n\nTo initialize a ref only once, check that the ref is null with the pattern `if (ref.current == null) { ref.current = ... }`","line":864,"column":22,"nodeType":null,"endLine":864,"endColumn":44}

Check warning on line 864 in src/navigation/tabs/home/components/PortfolioBalance.tsx

View workflow job for this annotation

GitHub Actions / Lint

[eslint] reported by reviewdog 🐶 Error: Cannot access refs during render React refs are values that are not needed for rendering. Refs should only be accessed outside of render, such as in event handlers or effects. Accessing a ref value (the `current` property) during render can cause your component not to update as expected (https://react.dev/reference/react/useRef). /home/runner/work/bitpay-app/bitpay-app/src/navigation/tabs/home/components/PortfolioBalance.tsx:864:21 862 | deltaFiatFormatted={displayedChangeRowData?.deltaFiatFormatted} 863 | rangeLabel={displayedChangeRowData?.rangeLabel} > 864 | visible={!!displayedChangeRowData} | ^^^^^^^^^^^^^^^^^^^^^^^ Cannot access ref value during render 865 | style={{ 866 | width: '100%', 867 | justifyContent: shouldLeftAlignTopSection ? 'flex-start' : 'center', Raw Output: {"ruleId":"react-hooks/refs","severity":1,"message":"Error: Cannot access refs during render\n\nReact refs are values that are not needed for rendering. Refs should only be accessed outside of render, such as in event handlers or effects. Accessing a ref value (the `current` property) during render can cause your component not to update as expected (https://react.dev/reference/react/useRef).\n\n/home/runner/work/bitpay-app/bitpay-app/src/navigation/tabs/home/components/PortfolioBalance.tsx:864:21\n 862 | deltaFiatFormatted={displayedChangeRowData?.deltaFiatFormatted}\n 863 | rangeLabel={displayedChangeRowData?.rangeLabel}\n> 864 | visible={!!displayedChangeRowData}\n | ^^^^^^^^^^^^^^^^^^^^^^^ Cannot access ref value during render\n 865 | style={{\n 866 | width: '100%',\n 867 | justifyContent: shouldLeftAlignTopSection ? 'flex-start' : 'center',","line":864,"column":21,"nodeType":null,"endLine":864,"endColumn":44}
trailing={
unchartedWallets.length && displayedChangeRowData ? (
<UnchartedAssetsNote onPress={showUnchartedAssetsModal} />
) : null
}
style={{
width: '100%',
justifyContent: shouldLeftAlignTopSection ? 'flex-start' : 'center',
Expand Down Expand Up @@ -892,6 +912,13 @@
showChangeRow={false}
timeframeSelectorOpacity={timeframeSelectorOpacity}
disablePanGesture={isChartCollapsed}
postTimeframeContent={
unchartedWallets.length &&
displayedChangeRowData &&
!isChartCollapsed ? (
<UnchartedAssetsNote onPress={showUnchartedAssetsModal} />
) : null
}
/>
{isChartCollapsed && canCollapseChart ? (
<TouchableOpacity
Expand Down
Loading