-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE: new version of VKUI
- Обновлен VKUI до последней версии, что привело к изменениям в структуре приложения и отказу от некоторых хуков. - Обновлен шаблон-пример с точки зрения модальных окон. Также добавлена новая страница для навигации.
- Loading branch information
1 parent
8e2a5db
commit 13f8920
Showing
16 changed files
with
249 additions
and
200 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
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,67 +1,58 @@ | ||
import { useEffect, useState } from "react"; | ||
import { useRecoilState } from "recoil"; | ||
import { | ||
AppearanceProvider, | ||
AppRoot, | ||
ConfigProvider, | ||
usePlatform, | ||
withAdaptivity, | ||
useAdaptivityWithJSMediaQueries, | ||
usePlatform | ||
} from "@vkontakte/vkui"; | ||
|
||
import Navigation from "/src/Navigation"; | ||
import bridge from "@vkontakte/vk-bridge"; | ||
import main from "/src/storage/atoms/main"; | ||
import SnackbarProvider from "./components/__global/SnackbarProvider"; | ||
|
||
const App = withAdaptivity( | ||
({ viewWidth }) => { | ||
const [theme, setTheme] = useState("light"); | ||
const [mainCoil, updateMainCoil] = useRecoilState(main); | ||
|
||
const platform = usePlatform(); | ||
|
||
const isDesktop = | ||
viewWidth > 3 || | ||
new URLSearchParams(window.location.search).get("vk_platform") === | ||
"desktop_web"; | ||
|
||
useEffect(() => { | ||
bridge.subscribe(({ detail: { type, data } }) => { | ||
if (type === "VKWebAppUpdateConfig") | ||
setTheme(data?.scheme.includes("light") ? "light" : "dark"); | ||
}); | ||
}, []); | ||
|
||
useEffect(() => { | ||
bridge.send("VKWebAppInit").then(() => console.log("VKWebAppInit")); | ||
|
||
updateMainCoil({ | ||
...mainCoil, | ||
isDesktop, | ||
platform, | ||
}); | ||
}, []); | ||
|
||
return ( | ||
<ConfigProvider | ||
locale={"ru"} | ||
isWebView={false} | ||
appearance={theme} | ||
platform={isDesktop ? "android" : platform} | ||
> | ||
<AppearanceProvider appearance={theme}> | ||
<AppRoot mode="full" className={isDesktop ? "desktop" : "mobile"}> | ||
<SnackbarProvider> | ||
<Navigation isDesktop={isDesktop} /> | ||
</SnackbarProvider> | ||
</AppRoot> | ||
</AppearanceProvider> | ||
</ConfigProvider> | ||
); | ||
}, | ||
{ | ||
viewWidth: true, | ||
}, | ||
); | ||
bridge.send("VKWebAppInit").then(() => console.log("VKWebAppInit")); | ||
|
||
const App = () => { | ||
const [theme, setTheme] = useState("light"); | ||
const [mainCoil, updateMainCoil] = useRecoilState(main); | ||
|
||
const platform = usePlatform(); | ||
const { viewWidth } = useAdaptivityWithJSMediaQueries(); | ||
|
||
const isDesktop = viewWidth >= 3 || platform === "vkcom"; | ||
|
||
useEffect(() => { | ||
bridge.subscribe(({ detail: { type, data } }) => { | ||
if (type === "VKWebAppUpdateConfig" && data?.appearance) | ||
setTheme(data.appearance); | ||
}); | ||
}, []); | ||
|
||
useEffect(() => { | ||
updateMainCoil({ | ||
...mainCoil, | ||
isDesktop, | ||
platform | ||
}); | ||
}, [isDesktop, platform]); | ||
|
||
return ( | ||
<ConfigProvider | ||
locale={"ru"} | ||
isWebView={true} | ||
appearance={theme} | ||
platform={isDesktop ? "android" : platform} | ||
hasCustomPanelHeaderAfter | ||
> | ||
<AppRoot mode="full" userSelectMode={"disabled"}> | ||
<SnackbarProvider> | ||
<Navigation isDesktop={isDesktop} /> | ||
</SnackbarProvider> | ||
</AppRoot> | ||
</ConfigProvider> | ||
); | ||
}; | ||
|
||
export default App; |
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
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
Oops, something went wrong.