This repository has been archived by the owner on Nov 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
Scan: Implemented the txIndexPage's mobile layout #2310
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
df03ff3
:lipstick: Implemented the txIndexPage's mobile layout
6ef8e8d
:loud_sound: Updated the changelog file
b8c1393
:recycle: Refactor by following comments
fc0e927
:recycle: Re-write the nothing case
45e8150
Merge branch 'master' into mobile-tx-index
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
let addressWidth = 160; | ||
let renderMuitisendList = (tx: TxSub.Msg.MultiSend.t) => | ||
InfoMobileCard.[("INPUTS", Nothing)] | ||
->Belt.List.concat( | ||
{ | ||
let%IterList {address, coins} = tx.inputs; | ||
[ | ||
("FROM", InfoMobileCard.Address(address, addressWidth, false)), | ||
("AMOUNT", Coin({value: coins, hasDenom: false})), | ||
]; | ||
}, | ||
) | ||
->Belt.List.concat([("OUTPUT", Nothing)]) | ||
->Belt.List.concat( | ||
{ | ||
let%IterList {address, coins} = tx.outputs; | ||
[ | ||
("TO", InfoMobileCard.Address(address, addressWidth, false)), | ||
("AMOUNT", Coin({value: coins, hasDenom: false})), | ||
]; | ||
}, | ||
); | ||
|
||
let renderDetailMobile = | ||
//TODO: implement Guan Yu's message later | ||
fun | ||
| TxSub.Msg.SendMsg({fromAddress, toAddress, amount}) => | ||
InfoMobileCard.[ | ||
("FROM", Address(fromAddress, addressWidth, false)), | ||
("TO", Address(toAddress, addressWidth, false)), | ||
("AMOUNT", Coin({value: amount, hasDenom: true})), | ||
] | ||
| DelegateMsg({validatorAddress, delegatorAddress, amount}) => [ | ||
("DELEGATOR ADDRESS", Address(delegatorAddress, addressWidth, false)), | ||
("VALIDATOR ADDRESS", Address(validatorAddress, addressWidth, true)), | ||
("AMOUNT", Coin({value: [amount], hasDenom: true})), | ||
] | ||
| UndelegateMsg({validatorAddress, delegatorAddress, amount}) => [ | ||
("DELEGATOR ADDRESS", Address(delegatorAddress, addressWidth, false)), | ||
("VALIDATOR ADDRESS", Address(validatorAddress, addressWidth, true)), | ||
("AMOUNT", Coin({value: [amount], hasDenom: true})), | ||
] | ||
| MultiSendMsg(tx) => renderMuitisendList(tx) | ||
| WithdrawRewardMsg({validatorAddress, delegatorAddress, amount}) => [ | ||
("DELEGATOR ADDRESS", Address(delegatorAddress, addressWidth, false)), | ||
("VALIDATOR ADDRESS", Address(validatorAddress, addressWidth, true)), | ||
("AMOUNT", Coin({value: amount, hasDenom: true})), | ||
] | ||
| RedelegateMsg({validatorSourceAddress, validatorDestinationAddress, delegatorAddress, amount}) => [ | ||
("DELEGATOR ADDRESS", Address(delegatorAddress, addressWidth, false)), | ||
("SOURCE ADDRESS", Address(validatorSourceAddress, addressWidth, true)), | ||
("DESTINATION ADDRESS", Address(validatorDestinationAddress, addressWidth, true)), | ||
("AMOUNT", Coin({value: [amount], hasDenom: true})), | ||
] | ||
| SetWithdrawAddressMsg({delegatorAddress, withdrawAddress}) => [ | ||
("DELEGATOR ADDRESS", Address(delegatorAddress, addressWidth, false)), | ||
("WITHDRAW ADDRESS", Address(withdrawAddress, addressWidth, false)), | ||
] | ||
| CreateValidatorMsg({ | ||
moniker, | ||
identity, | ||
website, | ||
details, | ||
commissionRate, | ||
commissionMaxRate, | ||
commissionMaxChange, | ||
delegatorAddress, | ||
validatorAddress, | ||
publicKey, | ||
minSelfDelegation, | ||
selfDelegation, | ||
}) => [ | ||
("MONIKER", Text(moniker)), | ||
("IDENTITY", Text(identity)), | ||
("WEBSITE", Text(website)), | ||
("DETAIL", Text(details)), | ||
("COMMISSION RATE", Percentage(commissionRate, Some(4))), | ||
("COMMISSION MAX RATE", Percentage(commissionMaxRate, Some(4))), | ||
("COMMISSION MAX CHANGE", Percentage(commissionMaxChange, Some(4))), | ||
("DELEGATOR ADDRESS", Address(delegatorAddress, addressWidth, false)), | ||
("VALIDATOR ADDRESS", Address(validatorAddress, addressWidth, true)), | ||
("PUBLIC KEY", PubKey(publicKey)), | ||
("MIN SELF DELEGATION", Coin({value: [minSelfDelegation], hasDenom: true})), | ||
("SELF DELEGATION", Coin({value: [selfDelegation], hasDenom: true})), | ||
] | ||
| EditValidatorMsg({ | ||
moniker, | ||
identity, | ||
website, | ||
details, | ||
commissionRate, | ||
sender, | ||
minSelfDelegation, | ||
}) => [ | ||
("MONIKER", moniker == Config.doNotModify ? Text("Unchanged") : Text(moniker)), | ||
("IDENTITY", identity == Config.doNotModify ? Text("Unchanged") : Text(identity)), | ||
("WEBSITE", website == Config.doNotModify ? Text("Unchanged") : Text(website)), | ||
("DETAIL", details == Config.doNotModify ? Text("Unchanged") : Text(details)), | ||
( | ||
"COMMISSION RATE", | ||
switch (commissionRate) { | ||
| Some(rate) => Percentage(rate, Some(4)) | ||
| None => Text("Unchanged") | ||
}, | ||
), | ||
("VALIDATOR ADDRESS", Address(sender, addressWidth, true)), | ||
( | ||
"MIN SELF DELEGATION", | ||
switch (minSelfDelegation) { | ||
| Some(amount) => Coin({value: [amount], hasDenom: true}) | ||
| None => Text("Unchanged") | ||
}, | ||
), | ||
] | ||
| WithdrawCommissionMsg({validatorAddress, amount}) => [ | ||
("VALIDATOR ADDRESS", Address(validatorAddress, addressWidth, true)), | ||
("AMOUNT", Coin({value: amount, hasDenom: true})), | ||
] | ||
| UnjailMsg({address}) => [("VALIDATOR ADDRESS", Address(address, addressWidth, true))] | ||
| _ => []; | ||
pzshine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
[@react.component] | ||
let make = (~messages: list(TxSub.Msg.t)) => { | ||
<> | ||
//TODO: Change index to be uniqe something | ||
{messages | ||
->Belt.List.mapWithIndex((index, msg) => { | ||
let renderList = msg |> renderDetailMobile; | ||
let theme = msg |> TxSub.Msg.getBadgeTheme; | ||
let creator = msg |> TxSub.Msg.getCreator; | ||
<MobileCard | ||
values={ | ||
InfoMobileCard.[ | ||
("MESSAGE\nTYPE", Badge(theme)), | ||
("CREATOR", Address(creator, addressWidth, false)), | ||
] | ||
->Belt.List.concat(renderList) | ||
} | ||
key={index |> string_of_int} | ||
idx={index |> string_of_int} | ||
/>; | ||
}) | ||
->Array.of_list | ||
->React.array} | ||
</>; | ||
}; | ||
|
||
module Loading = { | ||
[@react.component] | ||
let make = () => { | ||
<MobileCard | ||
values=InfoMobileCard.[ | ||
("MESSAGE\nTYPE", Loading(80)), | ||
("CREATOR", Loading(80)), | ||
("Detail", Loading(80)), | ||
] | ||
idx="1" | ||
/>; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
nit: typo