Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat-mobile: add network status button & view (#5492)
* feat: add profile actions buttons and use it for settings * feat: add network status button * feat: add network status routing and view Co-authored-by: Mark Nardi <mark.nardi@iota.org>
- Loading branch information
1 parent
0bc3d87
commit af5a100
Showing
11 changed files
with
85 additions
and
6 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
packages/mobile/components/buttons/NetworkStatusButton.svelte
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,29 @@ | ||
<script lang="typescript"> | ||
import { localize } from '@core/i18n' | ||
import { | ||
NetworkHealth, | ||
networkStatus, | ||
NETWORK_HEALTH_COLORS, | ||
NETWORK_STATUS_DESCRIPTION, | ||
nodeInfo, | ||
} from '@core/network' | ||
import { Icon as IconTypes } from '@lib/auxiliary/icon' | ||
import { ProfileActionButton } from '../../components/' | ||
export let onClick: () => unknown | ||
let health: NetworkHealth | ||
$: health = $networkStatus.health ?? NetworkHealth.Down | ||
$: healthColor = `${NETWORK_HEALTH_COLORS[health]}-500` | ||
$: description = $networkStatus.description ?? NETWORK_STATUS_DESCRIPTION[NetworkHealth.Disconnected] | ||
</script> | ||
|
||
<ProfileActionButton | ||
primaryText={$nodeInfo?.protocol?.networkName} | ||
secondaryText={localize(`views.dashboard.network.${description}`)} | ||
icon={IconTypes.Network} | ||
iconColor={healthColor} | ||
color={healthColor} | ||
{onClick} | ||
/> |
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 @@ | ||
export { default as AccountActionsButton } from './AccountActionsButton.svelte' | ||
export { default as AccountSwitcherButton } from './AccountSwitcherButton.svelte' | ||
export { default as DashboardProfileButton } from './DashboardProfileButton.svelte' | ||
export { default as NetworkStatusButton } from './NetworkStatusButton.svelte' | ||
export { default as ProfileActionButton } from './ProfileActionButton.svelte' | ||
export { default as ProfileButton } from './ProfileButton.svelte' |
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
5 changes: 3 additions & 2 deletions
5
packages/mobile/lib/routers/enums/dashboard/profile-route.enum.ts
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,7 +1,8 @@ | ||
export enum ProfileRoute { | ||
Actions = 'actions', | ||
Backup = 'backup', | ||
Status = 'status', | ||
Unlock = 'unlock', | ||
NetworkStatus = 'networkStatus', | ||
Settings = 'settings', | ||
// Auxiliary | ||
UnlockStronghold = 'unlockStronghold', | ||
} |
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
4 changes: 3 additions & 1 deletion
4
packages/mobile/views/dashboard/drawers/profile/ProfileRouter.svelte
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,10 +1,12 @@ | ||
<script lang="typescript"> | ||
import { ProfileRoute, profileRoute } from '../../../../lib/routers' | ||
import { ActionsView, SettingsView } from './views' | ||
import { ActionsView, NetworkStatusView, SettingsView } from './views' | ||
</script> | ||
|
||
{#if $profileRoute === ProfileRoute.Actions} | ||
<ActionsView /> | ||
{:else if $profileRoute === ProfileRoute.NetworkStatus} | ||
<NetworkStatusView /> | ||
{:else if $profileRoute === ProfileRoute.Settings} | ||
<SettingsView /> | ||
{/if} |
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
32 changes: 32 additions & 0 deletions
32
packages/mobile/views/dashboard/drawers/profile/views/NetworkStatusView.svelte
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,32 @@ | ||
<script lang="typescript"> | ||
import { localize } from '@core/i18n' | ||
import { NetworkHealth, networkStatus, NETWORK_STATUS_DESCRIPTION, nodeInfo } from '@core/network' | ||
import { KeyValueBox } from 'shared/components' | ||
let health: NetworkHealth | ||
$: health = $networkStatus.health ?? NetworkHealth.Down | ||
$: description = $networkStatus.description ?? NETWORK_STATUS_DESCRIPTION[NetworkHealth.Disconnected] | ||
$: networkStatistics = { | ||
messagesPerSecond: Math.round($networkStatus.messagesPerSecond ?? 0), | ||
referencedRate: Math.round($networkStatus.referencedRate ?? 0) + '%', | ||
} | ||
</script> | ||
|
||
<div class="flex flex-col space-y-2"> | ||
<KeyValueBox keyText={localize('general.network')} valueText={$nodeInfo?.protocol?.networkName} /> | ||
<KeyValueBox | ||
keyText={localize('views.settings.networkStatus.title')} | ||
valueText={localize(`views.dashboard.network.${description}`)} | ||
/> | ||
<KeyValueBox | ||
keyText={localize('popups.node.info.general.latestMilestone')} | ||
valueText={$networkStatus?.currentMilestone?.toString() ?? '-'} | ||
/> | ||
{#each Object.keys(networkStatistics) as networkStatisticKey} | ||
<KeyValueBox | ||
keyText={localize(`views.dashboard.network.${networkStatisticKey}`)} | ||
valueText={networkStatistics[networkStatisticKey]} | ||
/> | ||
{/each} | ||
</div> |
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,3 +1,4 @@ | ||
export { default as ActionsView } from './ActionsView.svelte' | ||
export { default as NetworkStatusView } from './NetworkStatusView.svelte' | ||
|
||
export * from './settings' |