Skip to content
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

Move scene param types to their respective fiat plugin scene files #5287

Merged
merged 3 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- fixed: Fixed obscured "done" button display bug on Sepa info display scene for small-screen devices

## 4.15.0

- added: Add Maya Protocol
Expand Down
9 changes: 3 additions & 6 deletions src/plugins/gui/fiatPlugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@ import { datelog } from '../../util/utils'
import {
FiatDirection,
FiatPaymentType,
FiatPluginAddressFormParams,
FiatPluginListModalParams,
FiatPluginPermissions,
FiatPluginRegionCode,
FiatPluginSepaFormParams,
FiatPluginSepaTransferParams,
FiatPluginStartParams,
FiatPluginUi,
FiatPluginUtils,
Expand Down Expand Up @@ -173,7 +170,7 @@ export const executePlugin = async (params: {
maybeNavigateToCorrectTabScene()
navigation.navigate('guiPluginEnterAmount', params)
},
addressForm: async (params: FiatPluginAddressFormParams) => {
addressForm: async params => {
const { countryCode, headerTitle, headerIconUri, onSubmit } = params
return await new Promise((resolve, reject) => {
maybeNavigateToCorrectTabScene()
Expand Down Expand Up @@ -208,7 +205,7 @@ export const executePlugin = async (params: {
maybeNavigateToCorrectTabScene()
navigation.navigate('rewardsCardWelcome', params)
},
sepaForm: async (params: FiatPluginSepaFormParams) => {
sepaForm: async params => {
const { headerTitle, headerIconUri, doneLabel, onDone } = params
return await new Promise((resolve, reject) => {
maybeNavigateToCorrectTabScene()
Expand All @@ -226,7 +223,7 @@ export const executePlugin = async (params: {
})
})
},
sepaTransferInfo: async (params: FiatPluginSepaTransferParams) => {
sepaTransferInfo: async params => {
return await new Promise((resolve, reject) => {
const { headerTitle, headerIconUri, promptMessage, transferInfo, onDone } = params
maybeNavigateToCorrectTabScene()
Expand Down
26 changes: 3 additions & 23 deletions src/plugins/gui/fiatPluginTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ import { GuiPlugin } from '../../types/GuiPluginTypes'
import { AppParamList } from '../../types/routerTypes'
import { EdgeAsset } from '../../types/types'
import { BuyConversionValues, SellConversionValues, TrackingEventName } from '../../util/tracking'
import { FiatPluginAddressFormParams } from './scenes/AddressFormScene'
import { FiatPluginOpenWebViewParams } from './scenes/FiatPluginWebView'
import { FiatPluginSepaTransferParams } from './scenes/InfoDisplayScene'
import { RewardsCardDashboardParams } from './scenes/RewardsCardDashboardScene'
import { RewardsCardWelcomeParams } from './scenes/RewardsCardWelcomeScene'
import { FiatPluginSepaFormParams } from './scenes/SepaFormScene'

export const asFiatDirection = asValue('buy', 'sell')
export type FiatDirection = ReturnType<typeof asFiatDirection>
Expand Down Expand Up @@ -46,22 +49,7 @@ export const asFiatPaymentType = asValue(
)
export type FiatPaymentType = ReturnType<typeof asFiatPaymentType>

export interface FiatPluginAddressFormParams {
countryCode: string
headerTitle: string
headerIconUri?: string
onSubmit: (homeAddress: HomeAddress) => Promise<void>
onClose: () => void
}

export type LinkHandler = (url: FiatProviderLink) => void
export interface FiatPluginSepaFormParams {
headerTitle: string
doneLabel: string
headerIconUri?: string
onDone: (sepaInfo: SepaInfo) => Promise<void>
onClose: () => void
}

export interface FiatPluginSepaTransferInfo {
input: {
Expand All @@ -82,14 +70,6 @@ export interface FiatPluginSepaTransferInfo {
}
}

export interface FiatPluginSepaTransferParams {
headerTitle: string
promptMessage: string
transferInfo: FiatPluginSepaTransferInfo
headerIconUri?: string
onDone: () => Promise<void>
}

export interface FiatPluginListModalParams {
title: string
items: Array<{ icon: string | number | React.ReactNode; name: string; text?: string }> // Icon strings are image uri, numbers are local files
Expand Down
8 changes: 8 additions & 0 deletions src/plugins/gui/scenes/AddressFormScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ import { getDiskletFormData, setDiskletForm } from '../../../util/formUtils'
import { makePeriodicTask } from '../../../util/PeriodicTask'
import { GuiFormField } from '../components/GuiFormField'

export interface FiatPluginAddressFormParams {
countryCode: string
headerTitle: string
headerIconUri?: string
onSubmit: (homeAddress: HomeAddress) => Promise<void>
onClose: () => void
}

interface Props extends EdgeSceneProps<'guiPluginAddressForm'> {}

const FUZZY_SEARCH_INTERVAL = 2000
Expand Down
11 changes: 10 additions & 1 deletion src/plugins/gui/scenes/InfoDisplayScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ import { SceneHeader } from '../../../components/themed/SceneHeader'
import { useHandler } from '../../../hooks/useHandler'
import { lstrings } from '../../../locales/strings'
import { EdgeSceneProps } from '../../../types/routerTypes'
import { FiatPluginSepaTransferInfo } from '../fiatPluginTypes'

export interface FiatPluginSepaTransferParams {
headerTitle: string
promptMessage: string
transferInfo: FiatPluginSepaTransferInfo
headerIconUri?: string
onDone: () => Promise<void>
}

interface InfoDisplayGroup {
groupTitle: string
Expand Down Expand Up @@ -123,7 +132,7 @@ export const InfoDisplayScene = React.memo((props: Props) => {
))

return (
<SceneWrapper scroll hasNotifications>
<SceneWrapper hasTabs scroll hasNotifications>
Copy link
Collaborator

@Jon-edge Jon-edge Oct 3, 2024

Choose a reason for hiding this comment

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

While we're at it, fix the InfoDisplayScene using deprecated components like MainButton to use SceneButtons. This should be a primary button (which SceneButtons and all button group components enforce automatically)

Copy link
Collaborator

Choose a reason for hiding this comment

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

We need to have screenshots in visual PRs so reviewers can catch these mistakes easier.

<SceneHeader title={headerTitle} underline withTopMargin />
<View style={styles.promptContainer}>
<EdgeText numberOfLines={12}>{promptMessage}</EdgeText>
Expand Down
8 changes: 8 additions & 0 deletions src/plugins/gui/scenes/SepaFormScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ import { EdgeSceneProps } from '../../../types/routerTypes'
import { getDiskletFormData, setDiskletForm } from '../../../util/formUtils'
import { GuiFormField } from '../components/GuiFormField'

export interface FiatPluginSepaFormParams {
headerTitle: string
doneLabel: string
headerIconUri?: string
onDone: (sepaInfo: SepaInfo) => Promise<void>
onClose: () => void
}

interface Props extends EdgeSceneProps<'guiPluginSepaForm'> {}

export const SepaFormScene = React.memo((props: Props) => {
Expand Down
4 changes: 3 additions & 1 deletion src/types/routerTypes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ import type { WcConnectionsParams } from '../components/scenes/WcConnectionsScen
import type { WcConnectParams } from '../components/scenes/WcConnectScene'
import type { WcDisconnectParams } from '../components/scenes/WcDisconnectScene'
import type { WebViewSceneParams } from '../components/scenes/WebViewScene'
import type { FiatPluginAddressFormParams, FiatPluginSepaFormParams, FiatPluginSepaTransferParams } from '../plugins/gui/fiatPluginTypes'
import type { FiatPluginAddressFormParams } from '../plugins/gui/scenes/AddressFormScene'
import type { FiatPluginEnterAmountParams } from '../plugins/gui/scenes/FiatPluginEnterAmountScene'
import type { FiatPluginOpenWebViewParams } from '../plugins/gui/scenes/FiatPluginWebView'
import type { FiatPluginSepaTransferParams } from '../plugins/gui/scenes/InfoDisplayScene'
import type { RewardsCardDashboardParams } from '../plugins/gui/scenes/RewardsCardDashboardScene'
import type { RewardsCardWelcomeParams } from '../plugins/gui/scenes/RewardsCardWelcomeScene'
import type { FiatPluginSepaFormParams } from '../plugins/gui/scenes/SepaFormScene'

// -------------------------------------------------------------------------
// Router types
Expand Down
Loading