-
Notifications
You must be signed in to change notification settings - Fork 4
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: improve proposal details visualization #260
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3fdba0f
feat: show the proposal messages without a flatlist
manu0466 4cd075f
feat: improved MsgUpdateParams visualization
manu0466 d02438a
feat: add proposal summary visualization
manu0466 fe789c2
feat: display the proposer profile
manu0466 45f54a8
chore: fix lint errors
manu0466 2cd96f5
feat: handle null and undefined and improved the handling of coins
manu0466 2a27edc
fix: tokenfactory params conversion
manu0466 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"signer": "Signer", | ||
"user": "User", | ||
"update params": "Update params" | ||
"update params": "Update params", | ||
"update module params": "Update {{ module }} module params", | ||
} |
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,90 @@ | ||
import { useNavigation } from '@react-navigation/native'; | ||
import { StackNavigationProp } from '@react-navigation/stack'; | ||
import TypographyContentLoaders from 'components/ContentLoaders/Typography'; | ||
import CopiableAddress from 'components/CopiableAddress'; | ||
import ProfileImage from 'components/ProfileImage'; | ||
import Spacer from 'components/Spacer'; | ||
import Typography from 'components/Typography'; | ||
import { makeStyle } from 'config/theme'; | ||
import useGetProfile from 'hooks/profile/useGetProfile'; | ||
import { getProfileDisplayName } from 'lib/ProfileUtils'; | ||
import { RootNavigatorParamList } from 'navigation/RootNavigator'; | ||
import ROUTES from 'navigation/routes'; | ||
import React from 'react'; | ||
import { View } from 'react-native'; | ||
import { TouchableOpacity } from 'react-native-gesture-handler'; | ||
import { DesmosProfile } from 'types/desmos'; | ||
|
||
interface InlineProfileProps { | ||
/** | ||
* Address of the profile to display. | ||
*/ | ||
readonly address: string; | ||
/** | ||
* Optional prefetched profile. | ||
*/ | ||
readonly profile?: DesmosProfile; | ||
} | ||
|
||
/** | ||
* Components that displays an user profile and if clicked opens the | ||
* profile screen. | ||
*/ | ||
const InlineProfile: React.FC<InlineProfileProps> = ({ address, profile }) => { | ||
const styles = useStyles(); | ||
const [toDisplayProfile, setToDisplayProfile] = React.useState(profile); | ||
const [profileLoading, setProfileLoading] = React.useState(profile === undefined); | ||
|
||
const navigation = useNavigation<StackNavigationProp<RootNavigatorParamList>>(); | ||
const getProfile = useGetProfile(); | ||
const showProfile = React.useCallback(() => { | ||
navigation.navigate(ROUTES.PROFILE, { | ||
visitingProfile: address, | ||
}); | ||
}, [address, navigation]); | ||
|
||
React.useEffect(() => { | ||
(async () => { | ||
if (profile === undefined) { | ||
setProfileLoading(true); | ||
const fetchedProfile = await getProfile(address); | ||
if (fetchedProfile.isOk()) { | ||
setToDisplayProfile(fetchedProfile.value); | ||
} | ||
setProfileLoading(false); | ||
} | ||
})(); | ||
}, [address, getProfile, profile]); | ||
|
||
if (toDisplayProfile === undefined && profileLoading === false) { | ||
return ( | ||
<View style={styles.root}> | ||
<CopiableAddress address={address} /> | ||
</View> | ||
); | ||
} | ||
|
||
return ( | ||
<TouchableOpacity onPress={showProfile}> | ||
<View style={styles.root}> | ||
<ProfileImage profile={toDisplayProfile} loading={profileLoading} size={32} /> | ||
<Spacer paddingLeft={8} /> | ||
{profileLoading ? ( | ||
<TypographyContentLoaders.Regular16 width={180} /> | ||
) : ( | ||
<Typography.Regular16>{getProfileDisplayName(toDisplayProfile!)}</Typography.Regular16> | ||
)} | ||
</View> | ||
</TouchableOpacity> | ||
); | ||
}; | ||
|
||
export default InlineProfile; | ||
|
||
const useStyles = makeStyle(() => ({ | ||
root: { | ||
display: 'flex', | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
}, | ||
})); |
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
52 changes: 52 additions & 0 deletions
52
src/components/Messages/common/MsgUpdateParamsDetails/index.tsx
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,52 @@ | ||
import { EncodeObject } from '@desmoslabs/desmjs'; | ||
import { MessageDetailsComponent } from 'components/Messages/BaseMessage'; | ||
import BaseMessageDetails, { | ||
MessageDetailsField, | ||
} from 'components/Messages/BaseMessage/BaseMessageDetails'; | ||
import Typography from 'components/Typography'; | ||
import { formatCoin } from 'lib/FormatUtils'; | ||
import React from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
const MsgUpdateParamsDetails: MessageDetailsComponent<EncodeObject> = ({ message }) => { | ||
const { t } = useTranslation('messages.common'); | ||
const moduleName = React.useMemo(() => { | ||
const [, name] = message.typeUrl.split('.'); | ||
return `${name[0].toUpperCase()}${name.substring(1)}`; | ||
}, [message.typeUrl]); | ||
|
||
const fields = React.useMemo<MessageDetailsField[]>(() => { | ||
const result: MessageDetailsField[] = []; | ||
Object.keys(message.value.params).forEach((key) => { | ||
const objectValue = message.value.params[key]; | ||
let serializedValue: string; | ||
|
||
if (typeof objectValue === 'object') { | ||
// Special case for the coin object. | ||
if (typeof objectValue.denom === 'string' && typeof objectValue.amount === 'string') { | ||
serializedValue = formatCoin(objectValue); | ||
} else { | ||
serializedValue = JSON.stringify(objectValue, undefined, 4); | ||
} | ||
} else { | ||
serializedValue = objectValue.toString(); | ||
} | ||
|
||
result.push({ | ||
label: key, | ||
value: serializedValue, | ||
}); | ||
}); | ||
return result; | ||
}, [message.value]); | ||
|
||
return ( | ||
<BaseMessageDetails message={message} fields={fields}> | ||
<Typography.Regular14> | ||
{t('update module params', { module: moduleName })} | ||
</Typography.Regular14> | ||
</BaseMessageDetails> | ||
); | ||
}; | ||
|
||
export default MsgUpdateParamsDetails; |
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 was deleted.
Oops, something went wrong.
54 changes: 0 additions & 54 deletions
54
src/components/Messages/tokenfactory/MsgUpdateParamsDetails/index.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.
Does this work on boolean values as well? I saw in your preview Gif that the
send_enabled
parameter was rendered as a white square box for some reason.Also, would it be better to check if the
objectValue
is eitherundefined
ornull
and render it asnull
in both cases?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.
@RiccardoM I have handled the case where
objectValue
isundefined
ornull
.About the boolean there was an error in the conversion of the
/desmos.tokenfactory.v1.MsgUpdateParams
.I have update it to matche the proto definition.