added powering down info

This commit is contained in:
Sadaqat Ali 2022-04-20 22:07:22 +05:00
parent 860498be47
commit fbe6e9cb46
4 changed files with 118 additions and 4 deletions

View File

@ -641,7 +641,11 @@
"power_down": "Power Down",
"power_down_amount_head": "Withdraw Amount",
"power_down_amount_subhead": "Power Down info here",
"amount_hp": "Amount (HP)"
"amount_hp": "Amount (HP)",
"powering_down": "Powering Down",
"powering_down_subheading": "You are currently powering down.",
"powering_down_info": "Next power down is in {days} days, {hp} HIVE"
},
"boost": {
"title": "Get Points",

View File

@ -27,7 +27,7 @@ import WithdrawAccountModal from './withdrawAccountModal';
import parseToken from '../../../utils/parseToken';
import parseDate from '../../../utils/parseDate';
import { hpToVests, vestsToHp } from '../../../utils/conversions';
import { isEmptyDate } from '../../../utils/time';
import { isEmptyDate, daysTillDate } from '../../../utils/time';
import styles from './transferStyles';
import { OptionsModal } from '../../../components/atoms';
@ -387,6 +387,24 @@ class PowerDownView extends Component {
);
};
const _renderPowerDownInfo = () => {
const days = daysTillDate(nextPowerDown);
return (
<View style={styles.powerDownInfoContainer}>
<Text style={styles.sectionHeading}>
{intl.formatMessage({ id: 'transfer.powering_down' })}
</Text>
<Text style={styles.sectionSubheading}>
{intl.formatMessage({ id: 'transfer.powering_down_subheading' }) +
'\n\n' +
intl.formatMessage(
{ id: 'transfer.powering_down_info' },
{ days: days, hp: poweringDownFund },
)}
</Text>
</View>
);
};
return (
<Fragment>
<BasicHeader title={intl.formatMessage({ id: `transfer.${transferType}` })} />
@ -396,11 +414,89 @@ class PowerDownView extends Component {
keyboardShouldPersistTaps
>
<ScrollView style={styles.scroll} contentContainerStyle={styles.scrollContentContainer}>
{this._renderBeneficiarySelectionContent()}
{_renderMiddleContent()}
{!poweringDown && this._renderBeneficiarySelectionContent()}
{!poweringDown && _renderMiddleContent()}
{poweringDown && _renderPowerDownInfo()}
{/*
<View style={styles.middleContent}>
<TransferFormItem
label={intl.formatMessage({ id: 'transfer.from' })}
rightComponent={() => this._renderDropdown(accounts, currentAccountName)}
/>
<TransferFormItem
label={intl.formatMessage({ id: 'transfer.destination_accounts' })}
rightComponent={this._renderDestinationAccountItems}
/>
{!poweringDown && (
<Fragment>
<TransferFormItem
label={intl.formatMessage({ id: 'transfer.amount' })}
rightComponent={() => this._renderInformationText(`${amount.toFixed(6)} VESTS`)}
/>
<Slider
style={styles.slider}
trackStyle={styles.track}
thumbStyle={styles.thumb}
minimumTrackTintColor="#357ce6"
thumbTintColor="#007ee5"
maximumValue={availableVestingShares}
value={amount}
onValueChange={(value) => {
this.setState({ amount: value });
}}
/>
<Text style={styles.informationText}>
{intl.formatMessage({ id: 'transfer.amount_information' })}
</Text>
</Fragment>
)}
{poweringDown && (
<Fragment>
<TransferFormItem
label={intl.formatMessage({ id: 'transfer.incoming_funds' })}
rightComponent={() =>
this._renderIncomingFunds(
poweringDownFund,
poweringDownVests,
nextPowerDown.toLocaleString(),
)
}
/>
</Fragment>
)}
</View>
*/}
<View style={styles.bottomContent}>
{!poweringDown && (
<Fragment>
{/*
<View style={styles.informationView}>
<InformationBox
style={styles.spInformation}
text={`- ${spCalculated.toFixed(3)} HP`}
/>
<InformationBox
style={styles.vestsInformation}
text={`- ${amount.toFixed(0)} VESTS`}
/>
</View>
<Icon
style={styles.icon}
size={40}
iconType="MaterialIcons"
name="arrow-downward"
/>
<InformationBox
style={styles.steemInformation}
text={`+ ${fundPerWeek.toFixed(3)} HIVE`}
/>
<Text style={styles.informationText}>
{intl.formatMessage({ id: 'transfer.estimated_weekly' })}
</Text>
*/}
<MainButton
style={styles.button}
isDisable={amount <= 0}

View File

@ -352,4 +352,12 @@ export default EStyleSheet.create({
flex: 1,
backgroundColor: '$primaryBackgroundColor',
},
powerDownInfoContainer: {
marginTop: 16,
paddingHorizontal: 12,
zIndex: 2,
paddingVertical: 16,
borderRadius: 12,
backgroundColor: '$primaryLightBackground',
},
});

View File

@ -134,3 +134,9 @@ export const isEmptyContentDate = (value) => {
};
export const isEmptyDate = (s) => parseInt(s.split('-')[0], 10) < 1980;
export const daysTillDate = (date) => {
var given = moment(new Date(date), 'YYYY-MM-DD');
var current = moment().startOf('day');
return Math.round(moment.duration(given.diff(current)).asDays());
};