Skip to content
Closed
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
31 changes: 2 additions & 29 deletions src/components/token-dashboard/token-dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,12 @@ import { openBottomSheet } from '../../redux/ui/bottomSheet/actions';
import { smartConnect } from '../../core/utils/smart-connect';
import { connect } from 'react-redux';
import { NavigationService } from '../../navigation/navigation-service';
import { QuickDelegateBanner } from '../quick-delegate-banner/quick-delegate-banner';
import { AccountSummary } from '../account-summary/account-summary';
import { getBlockchain } from '../../core/blockchain/blockchain-factory';
import { AffiliateBanner } from '../affiliate-banner/affiliate-banner';
import { AffiliateBannerType } from '../affiliate-banner/types';
import { IReduxState } from '../../redux/state';
import { AccountStats } from '../../core/blockchain/types/stats';
import { fetchAccountDelegateStats } from '../../redux/ui/stats/actions';
import { getAccountStats } from '../../redux/ui/stats/selectors';
import { Widgets } from '../widgets/widgets';

interface IExternalProps {
blockchain: Blockchain;
Expand Down Expand Up @@ -163,31 +160,7 @@ export class TokenDashboardComponent extends React.Component<
{ paddingBottom: this.props.showBottomPadding ? normalize(70) : 0 }
]}
>
<AffiliateBanner
type={AffiliateBannerType.LEDGER_NANO_X}
style={styles.affiliateBanner}
/>

<AccountSummary
isLoading={this.state.loadingAccountStats}
style={styles.accountSummary}
data={{
accountStats: this.props.accountStats,
blockchain: this.props.blockchain,
token: this.state.token,
extraToken: this.props.account?.tokens[this.props.chainId].gZIL
}}
enableExpand={true}
/>

<QuickDelegateBanner
blockchain={this.props.blockchain}
account={this.props.account}
chainId={this.props.chainId}
style={styles.quickDelegateBannerContainer}
accountStats={this.props.accountStats}
/>

<Widgets />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to implement SmartScreen and do something

// Class SmartScreen
//    - Component Widgets (response API), typeof IScreenResponse
//              | '3-lines-cta'
//              | 'static-text-columns-top-header'
//              | 'static-text-columns-bottom-header'
//              | 'balances-grid-icons'
//              | 'single-balance-icon'
//              | 'image-banner'
//              | '2-lines-text-banner'
//              | 'separator';

{this.props.account?.tokens &&
this.props.chainId &&
Object.values(this.props.account.tokens[this.props.chainId]).map(
Expand Down
26 changes: 26 additions & 0 deletions src/components/widgets/components/image-banner/image-banner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react';
import { TouchableOpacity, Image } from 'react-native';
import { smartConnect } from '../../../../core/utils/smart-connect';
import { withTheme } from '../../../../core/theme/with-theme';
import stylesProvider from './styles';

interface IExternalProps {
imageUrl: string;
urlToOpen: string;
}

interface Props {
styles: ReturnType<typeof stylesProvider>;
}

const ImageBannerComponent: React.FC<Props & IExternalProps> = ({ imageUrl, styles }) => {
return (
<TouchableOpacity style={styles.container}>
<Image style={styles.image} source={{ uri: imageUrl }} />
</TouchableOpacity>
);
};

export const ImageBanner = smartConnect<IExternalProps>(ImageBannerComponent, [
withTheme(stylesProvider)
]);
15 changes: 15 additions & 0 deletions src/components/widgets/components/image-banner/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { StyleSheet } from 'react-native';
import { ITheme } from '../../../../core/theme/itheme';
import { BORDER_RADIUS, normalize } from '../../../../styles/dimensions';

export default (theme: ITheme) =>
StyleSheet.create({
container: {
flex: 1
},
image: {
height: normalize(60),
width: '100%',
borderRadius: BORDER_RADIUS
}
});
16 changes: 16 additions & 0 deletions src/components/widgets/components/separator/sepratator.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import { View } from 'react-native';
import { smartConnect } from '../../../../core/utils/smart-connect';
import { IExternalProps } from '../../../../library';
import { withTheme, IThemeProps } from '../../../../core/theme/with-theme';
import stylesProvider from './styles';

export const SeparatorComponent: React.FC<IThemeProps<ReturnType<typeof stylesProvider>>> = ({
styles
}) => {
return <View style={styles.separator} />;
};

export const Separator = smartConnect<IExternalProps>(SeparatorComponent, [
withTheme(stylesProvider)
]);
13 changes: 13 additions & 0 deletions src/components/widgets/components/separator/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { StyleSheet } from 'react-native';
import { ITheme } from '../../../../core/theme/itheme';
import { BASE_DIMENSION } from '../../../../styles/dimensions';

export default (theme: ITheme) =>
StyleSheet.create({
separator: {
height: 1,
flex: 1,
backgroundColor: theme.colors.inputBackground,
marginVertical: BASE_DIMENSION * 2
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';
import { View, Text, Image } from 'react-native';
import { smartConnect } from '../../../../core/utils/smart-connect';
import { withTheme, IThemeProps } from '../../../../core/theme/with-theme';
import stylesProvider from './styles';

interface IExternalProps {
data;
}

const SingleBalanceIconComponent: React.FC<IThemeProps<ReturnType<typeof stylesProvider>> &
IExternalProps> = ({ data, styles }) => {
return (
<View style={styles.container}>
{data.map(item => (
<View style={styles.container}>
<View style={styles.imageContainer}>
<Image
source={{ uri: item.icon.value }}
style={[{ tintColor: item.icon.color }]}
/>
</View>
<Text style={styles.labelText}>
{item.balance.value + ' ' + item.balance.symbol}
</Text>
</View>
))}
</View>
);
};

export const SingleBalanceIcon = smartConnect<IExternalProps>(SingleBalanceIconComponent, [
withTheme(stylesProvider)
]);
34 changes: 34 additions & 0 deletions src/components/widgets/components/single-balance-icon/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { StyleSheet } from 'react-native';
import { ITheme } from '../../../../core/theme/itheme';
import {
BASE_DIMENSION,
normalizeFontAndLineHeight,
normalize,
BORDER_RADIUS
} from '../../../../styles/dimensions';

export default (theme: ITheme) =>
StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
flexDirection: 'row',
marginBottom: BASE_DIMENSION
},
imageContainer: {
width: normalize(38),
height: normalize(38),
marginRight: BASE_DIMENSION,
backgroundColor: theme.colors.black + '40', // 25% opacity
borderRadius: BORDER_RADIUS,
justifyContent: 'center',
alignItems: 'center'
},
labelText: {
fontWeight: '400',
fontSize: normalizeFontAndLineHeight(23),
lineHeight: normalizeFontAndLineHeight(34),
color: theme.colors.white
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import React, { useContext } from 'react';
import { View, Text } from 'react-native';
import { smartConnect } from '../../../../core/utils/smart-connect';
import { withTheme, IThemeProps } from '../../../../core/theme/with-theme';
import { ThemeContext } from '../../../../core/theme/theme-contex';
import stylesProvider from './styles';
import { IStaticTextColHeaderData } from '../../types';

interface ExternalProps {
data: IStaticTextColHeaderData[];
inverted?: boolean;
}

const StaticTextColumnComponent: React.FC<IThemeProps<ReturnType<typeof stylesProvider>> &
ExternalProps> = ({ data, styles, inverted = false }) => {
const theme = useContext(ThemeContext);
return (
<View style={styles.container}>
{data.map(item => {
if (inverted)
return (
<View style={styles.itemContainer}>
<Text
style={[
{
color: item.secondaryColor
? item.secondaryColor
: theme.colors.text
},
styles.secondaryValueText,
styles.text
]}
>
{item.secondaryValue}
</Text>
<Text style={[styles.headerValueText, styles.textColor, styles.text]}>
{item.headerValue}
</Text>
</View>
);
else
return (
<View style={styles.itemContainer}>
<Text style={[styles.headerValueText, styles.textColor, styles.text]}>
{item.headerValue}
</Text>
<Text
style={[
{
color: item.secondaryColor
? item.secondaryColor
: theme.colors.text
},
styles.secondaryValueText,
styles.text
]}
>
{item.secondaryValue}
</Text>
</View>
);
})}
</View>
);
};

export const StaticTextColumn = smartConnect<ExternalProps>(StaticTextColumnComponent, [
withTheme(stylesProvider)
]);
31 changes: 31 additions & 0 deletions src/components/widgets/components/static-text-columns/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { StyleSheet } from 'react-native';
import { ITheme } from '../../../../core/theme/itheme';
import { normalizeFontAndLineHeight, BASE_DIMENSION } from '../../../../styles/dimensions';

export default (theme: ITheme) =>
StyleSheet.create({
container: {
flexDirection: 'row',
justifyContent: 'space-between'
},
itemContainer: {
flex: 1,
justifyContent: 'center',
alignItems: 'flex-start'
},
text: {
lineHeight: normalizeFontAndLineHeight(21),
textAlign: 'center',
fontSize: normalizeFontAndLineHeight(16),
fontWeight: '400'
},
textColor: {
color: theme.colors.textSecondary
},
headerValueText: {
marginBottom: BASE_DIMENSION * 2
},
secondaryValueText: {
marginBottom: BASE_DIMENSION / 2
}
});
47 changes: 47 additions & 0 deletions src/components/widgets/components/summary/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { StyleSheet } from 'react-native';
import { ITheme } from '../../../../core/theme/itheme';
import {
BASE_DIMENSION,
normalizeFontAndLineHeight,
normalize,
BORDER_RADIUS
} from '../../../../styles/dimensions';

export default (theme: ITheme) =>
StyleSheet.create({
container: {
flexDirection: 'row',
justifyContent: 'space-between'
},
itemContainer: {
flex: 1,
flexDirection: 'row',
justifyContent: 'space-between',
marginBottom: BASE_DIMENSION,
marginRight: BASE_DIMENSION
},
iconContainer: {
width: normalize(36),
height: normalize(36),
backgroundColor: theme.colors.black + '40', // 25% opacity
borderRadius: BORDER_RADIUS,
justifyContent: 'center',
marginRight: BASE_DIMENSION,
alignSelf: 'center'
},
labelValuesContainer: {
flex: 1
},
valueLabel: {
fontWeight: '400',
fontSize: normalizeFontAndLineHeight(16),
lineHeight: normalizeFontAndLineHeight(21),
color: theme.colors.text
},
labelText: {
fontSize: normalizeFontAndLineHeight(15),
fontWeight: '400',
lineHeight: normalizeFontAndLineHeight(20),
color: theme.colors.textTertiary
}
});
54 changes: 54 additions & 0 deletions src/components/widgets/components/summary/summary.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import React from 'react';
import { View, Text } from 'react-native';
import stylesProvider from './styles';
import { smartConnect } from '../../../../core/utils/smart-connect';
import { withTheme, IThemeProps } from '../../../../core/theme/with-theme';
import { IconValues } from '../../../icon/values';
import { normalize } from '../../../../styles/dimensions';
import Icon from '../../../icon/icon';
import { formatNumber } from '../../../../core/utils/format-number';

interface ExternalProps {
data;
}

const SummaryComponent: React.FC<IThemeProps<ReturnType<typeof stylesProvider>> &
ExternalProps> = ({ styles, data }) => {
// Might need a better imp
const returnIconName = (iconName: string) => {
switch (iconName) {
case 'claim-reward':
return IconValues.CLAIM_REWARD;
case 'vote':
return IconValues.VOTE;
case 'money-wallet':
return IconValues.MONEY_WALLET;
case 'key-lock':
return IconValues.KEY_LOCK;
}
};

return (
<View style={styles.container}>
{data.map(item => (
<View style={styles.itemContainer}>
<View style={styles.iconContainer}>
<Icon
name={returnIconName(item.icon.value)}
size={normalize(28)}
style={{ color: item.icon.color, alignSelf: 'center' }}
/>
</View>
<View style={styles.labelValuesContainer}>
<Text style={styles.valueLabel}>
{formatNumber(item.balance.value) + ' ' + item.balance.symbol}
</Text>
<Text style={styles.labelText}>{item.label}</Text>
</View>
</View>
))}
</View>
);
};

export const Summary = smartConnect<ExternalProps>(SummaryComponent, [withTheme(stylesProvider)]);
Loading