-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f2a6d57
commit c1a1298
Showing
25 changed files
with
606 additions
and
170 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,29 @@ | ||
import { LazyLoadPage } from '@onekeyhq/kit/src/components/LazyLoadPage'; | ||
import { ConfigProvider } from '@onekeyhq/components'; | ||
import React from 'react'; | ||
import '@onekeyhq/shared/src/polyfills'; | ||
import React, { lazy, Suspense } from 'react'; | ||
import { createRoot } from 'react-dom/client'; | ||
import { HashRouter, Route, Routes } from 'react-router-dom'; | ||
|
||
const PageWebEmbedApi = LazyLoadPage(() => import('./pages/PageWebEmbedApi')); | ||
const PagePrivyLogin = LazyLoadPage(() => import('./pages/PagePrivyLogin')); | ||
import AppProvider from './pages/AppProvider'; | ||
|
||
const PageIndex = lazy(() => import('./pages/PageIndex')); | ||
const PageWebEmbedApi = lazy(() => import('./pages/PageWebEmbedApi')); | ||
const PagePrivyLogin = lazy(() => import('./pages/PagePrivyLogin')); | ||
|
||
const container = document.getElementById('root'); | ||
const root = createRoot(container); | ||
|
||
root.render( | ||
<React.StrictMode> | ||
<ConfigProvider theme="light" locale="en-us" onLocaleChange={() => {}}> | ||
<HashRouter> | ||
<Routes> | ||
<Route path="/" element={<PageWebEmbedApi />} /> | ||
<Route path="/prime/login" element={<PagePrivyLogin />} /> | ||
</Routes> | ||
</HashRouter> | ||
</ConfigProvider> | ||
<AppProvider> | ||
<Suspense fallback={<div />}> | ||
<HashRouter> | ||
<Routes> | ||
<Route path="/" element={<PageIndex />} /> | ||
<Route path="/webembed-api" element={<PageWebEmbedApi />} /> | ||
<Route path="/prime/login" element={<PagePrivyLogin />} /> | ||
</Routes> | ||
</HashRouter> | ||
</Suspense> | ||
</AppProvider> | ||
</React.StrictMode>, | ||
); |
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,14 @@ | ||
import { ConfigProvider } from '@onekeyhq/components'; | ||
|
||
export default function AppProvider({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) { | ||
// TODO Toast support | ||
return ( | ||
<ConfigProvider theme="light" locale="en-US"> | ||
{children} | ||
</ConfigProvider> | ||
); | ||
} |
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,3 @@ | ||
export default function PageIndex() { | ||
return <div>PageIndex</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,5 +1,68 @@ | ||
import { Button } from '@onekeyhq/components'; | ||
/* eslint-disable unicorn/prefer-global-this */ | ||
import { useState } from 'react'; | ||
|
||
import { Button, SizableText, Stack, Toast } from '@onekeyhq/components'; | ||
import { PrimeSubscriptionPlans } from '@onekeyhq/kit/src/views/Prime/pages/PrimeDashboard/PrimeSubscriptionPlans'; | ||
import purchasesSdk from '@onekeyhq/kit/src/views/Prime/purchasesSdk/purchasesSdk'; | ||
import errorToastUtils from '@onekeyhq/shared/src/errors/utils/errorToastUtils'; | ||
|
||
import type { Package } from '@revenuecat/purchases-js'; | ||
|
||
export default function PagePrivyLogin() { | ||
return <Button>PagePrivyLogin</Button>; | ||
const [packages, setPackages] = useState<Package[]>([]); | ||
const [selectedPackageId, setSelectedPackageId] = useState<string | null>( | ||
null, | ||
); | ||
// @ts-ignore | ||
const settings = window.WEB_EMBED_ONEKEY_APP_SETTINGS as { | ||
themeVariant: string; | ||
localeVariant: string; | ||
primeUserId: string; | ||
primeUserEmail: string; | ||
}; | ||
return ( | ||
<Stack p="$4"> | ||
<PrimeSubscriptionPlans | ||
packages={packages} | ||
onPackageSelected={setSelectedPackageId} | ||
/> | ||
<Button | ||
onPress={async () => { | ||
await purchasesSdk.login({ userId: settings.primeUserId }); | ||
const packages0 = await purchasesSdk.getPaywallPackages(); | ||
setPackages(packages0); | ||
}} | ||
> | ||
ShowPackages | ||
</Button> | ||
<Button | ||
onPress={async () => { | ||
await errorToastUtils.withErrorAutoToast(async () => { | ||
if (!selectedPackageId) { | ||
throw new Error('No package selected'); | ||
} | ||
await purchasesSdk.purchasePackage({ | ||
userId: settings.primeUserId, | ||
email: settings.primeUserEmail, | ||
packageId: selectedPackageId, | ||
}); | ||
}); | ||
}} | ||
> | ||
PurchasePackage | ||
</Button> | ||
<Button | ||
onPress={async () => { | ||
// TODO call app Toast by $onekey.$private | ||
Toast.success({ | ||
title: 'success', | ||
message: 'success', | ||
}); | ||
}} | ||
> | ||
ShowToast | ||
</Button> | ||
<SizableText>{JSON.stringify(settings)}</SizableText> | ||
</Stack> | ||
); | ||
} |
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
17 changes: 15 additions & 2 deletions
17
packages/kit/src/views/Developer/pages/Gallery/Components/stories/WebView.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
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.