2023-11-01 16:15:37 +01:00
|
|
|
import 'lib/sentry' // must be near top
|
|
|
|
|
2022-06-09 20:03:25 +02:00
|
|
|
import React, {useState, useEffect} from 'react'
|
2023-11-01 16:15:37 +01:00
|
|
|
import {QueryClientProvider} from '@tanstack/react-query'
|
2023-01-26 19:53:46 +01:00
|
|
|
import {SafeAreaProvider} from 'react-native-safe-area-context'
|
2023-03-13 22:01:43 +01:00
|
|
|
import {RootSiblingParent} from 'react-native-root-siblings'
|
2023-11-01 16:15:37 +01:00
|
|
|
|
|
|
|
import 'view/icons'
|
|
|
|
|
2024-01-09 02:43:56 +01:00
|
|
|
import {ThemeProvider as Alf} from '#/alf'
|
New component library based on ALF (#2459)
* Install on native as well
* Add button and link components
* Comments
* Use new prop
* Add some form elements
* Add labels to input
* Fix line height, add suffix
* Date inputs
* Autofill styles
* Clean up InputDate types
* Improve types for InputText, value handling
* Enforce a11y props on buttons
* Add Dialog, Portal
* Dialog contents
* Native dialog
* Clean up
* Fix animations
* Improvements to web modal, exiting still broken
* Clean up dialog types
* Add Prompt, Dialog refinement, mobile refinement
* Integrate new design tokens, reorg storybook
* Button colors
* Dim mode
* Reorg
* Some styles
* Toggles
* Improve a11y
* Autosize dialog, handle max height, Dialog.ScrolLView not working
* Try to use BottomSheet's own APIs
* Scrollable dialogs
* Add web shadow
* Handle overscroll
* Styles
* Dialog text input
* Shadows
* Button focus states
* Button pressed states
* Gradient poc
* Gradient colors and hovers
* Add hrefAttrs to Link
* Some more a11y
* Toggle invalid states
* Update dialog descriptions for demo
* Icons
* WIP Toggle cleanup
* Refactor toggle to not rely on immediate children
* Make Toggle controlled
* Clean up Toggles storybook
* ToggleButton styles
* Improve a11y labels
* ToggleButton hover darkmode
* Some i18n
* Refactor input
* Allow extension of input
* Remove old input
* Improve icons, add CalendarDays
* Refactor DateField, web done
* Add label example
* Clean up old InputDate, DateField android, text area example
* Consistent imports
* Button context, icons
* Add todo
* Add closeAllDialogs control
* Alignment
* Expand color palette
* Hitslops, add shortcut to Storybook in dev
* Fix multiline on ios
* Mark dialog close button as unused
2024-01-19 03:28:04 +01:00
|
|
|
import {useColorModeTheme} from '#/alf/util/useColorModeTheme'
|
2023-11-07 23:06:17 +01:00
|
|
|
import {init as initPersistedState} from '#/state/persisted'
|
2023-11-01 16:15:37 +01:00
|
|
|
import {Shell} from 'view/shell/index'
|
|
|
|
import {ToastContainer} from 'view/com/util/Toast.web'
|
2023-04-13 03:49:40 +02:00
|
|
|
import {ThemeProvider} from 'lib/ThemeContext'
|
2023-09-15 18:32:44 +02:00
|
|
|
import {queryClient} from 'lib/react-query'
|
2023-11-07 20:37:47 +01:00
|
|
|
import {Provider as ShellStateProvider} from 'state/shell'
|
2023-11-08 19:34:10 +01:00
|
|
|
import {Provider as ModalStateProvider} from 'state/modals'
|
New component library based on ALF (#2459)
* Install on native as well
* Add button and link components
* Comments
* Use new prop
* Add some form elements
* Add labels to input
* Fix line height, add suffix
* Date inputs
* Autofill styles
* Clean up InputDate types
* Improve types for InputText, value handling
* Enforce a11y props on buttons
* Add Dialog, Portal
* Dialog contents
* Native dialog
* Clean up
* Fix animations
* Improvements to web modal, exiting still broken
* Clean up dialog types
* Add Prompt, Dialog refinement, mobile refinement
* Integrate new design tokens, reorg storybook
* Button colors
* Dim mode
* Reorg
* Some styles
* Toggles
* Improve a11y
* Autosize dialog, handle max height, Dialog.ScrolLView not working
* Try to use BottomSheet's own APIs
* Scrollable dialogs
* Add web shadow
* Handle overscroll
* Styles
* Dialog text input
* Shadows
* Button focus states
* Button pressed states
* Gradient poc
* Gradient colors and hovers
* Add hrefAttrs to Link
* Some more a11y
* Toggle invalid states
* Update dialog descriptions for demo
* Icons
* WIP Toggle cleanup
* Refactor toggle to not rely on immediate children
* Make Toggle controlled
* Clean up Toggles storybook
* ToggleButton styles
* Improve a11y labels
* ToggleButton hover darkmode
* Some i18n
* Refactor input
* Allow extension of input
* Remove old input
* Improve icons, add CalendarDays
* Refactor DateField, web done
* Add label example
* Clean up old InputDate, DateField android, text area example
* Consistent imports
* Button context, icons
* Add todo
* Add closeAllDialogs control
* Alignment
* Expand color palette
* Hitslops, add shortcut to Storybook in dev
* Fix multiline on ios
* Mark dialog close button as unused
2024-01-19 03:28:04 +01:00
|
|
|
import {Provider as DialogStateProvider} from 'state/dialogs'
|
2023-11-16 03:17:03 +01:00
|
|
|
import {Provider as LightboxStateProvider} from 'state/lightbox'
|
2023-11-08 18:08:42 +01:00
|
|
|
import {Provider as MutedThreadsProvider} from 'state/muted-threads'
|
2023-11-08 18:10:59 +01:00
|
|
|
import {Provider as InvitesStateProvider} from 'state/invites'
|
2023-11-08 18:38:28 +01:00
|
|
|
import {Provider as PrefsStateProvider} from 'state/preferences'
|
2023-11-24 23:31:33 +01:00
|
|
|
import {Provider as LoggedOutViewProvider} from 'state/shell/logged-out'
|
2024-02-08 21:37:08 +01:00
|
|
|
import {Provider as SelectedFeedProvider} from 'state/shell/selected-feed'
|
2023-11-20 22:29:27 +01:00
|
|
|
import I18nProvider from './locale/i18nProvider'
|
2023-11-10 00:14:51 +01:00
|
|
|
import {
|
|
|
|
Provider as SessionProvider,
|
|
|
|
useSession,
|
|
|
|
useSessionApi,
|
|
|
|
} from 'state/session'
|
2023-11-13 03:13:11 +01:00
|
|
|
import {Provider as UnreadNotifsProvider} from 'state/queries/notifications/unread'
|
2023-11-10 00:14:51 +01:00
|
|
|
import * as persisted from '#/state/persisted'
|
New component library based on ALF (#2459)
* Install on native as well
* Add button and link components
* Comments
* Use new prop
* Add some form elements
* Add labels to input
* Fix line height, add suffix
* Date inputs
* Autofill styles
* Clean up InputDate types
* Improve types for InputText, value handling
* Enforce a11y props on buttons
* Add Dialog, Portal
* Dialog contents
* Native dialog
* Clean up
* Fix animations
* Improvements to web modal, exiting still broken
* Clean up dialog types
* Add Prompt, Dialog refinement, mobile refinement
* Integrate new design tokens, reorg storybook
* Button colors
* Dim mode
* Reorg
* Some styles
* Toggles
* Improve a11y
* Autosize dialog, handle max height, Dialog.ScrolLView not working
* Try to use BottomSheet's own APIs
* Scrollable dialogs
* Add web shadow
* Handle overscroll
* Styles
* Dialog text input
* Shadows
* Button focus states
* Button pressed states
* Gradient poc
* Gradient colors and hovers
* Add hrefAttrs to Link
* Some more a11y
* Toggle invalid states
* Update dialog descriptions for demo
* Icons
* WIP Toggle cleanup
* Refactor toggle to not rely on immediate children
* Make Toggle controlled
* Clean up Toggles storybook
* ToggleButton styles
* Improve a11y labels
* ToggleButton hover darkmode
* Some i18n
* Refactor input
* Allow extension of input
* Remove old input
* Improve icons, add CalendarDays
* Refactor DateField, web done
* Add label example
* Clean up old InputDate, DateField android, text area example
* Consistent imports
* Button context, icons
* Add todo
* Add closeAllDialogs control
* Alignment
* Expand color palette
* Hitslops, add shortcut to Storybook in dev
* Fix multiline on ios
* Mark dialog close button as unused
2024-01-19 03:28:04 +01:00
|
|
|
import {Provider as PortalProvider} from '#/components/Portal'
|
2024-02-27 19:35:38 +01:00
|
|
|
import {useIntentHandler} from 'lib/hooks/useIntentHandler'
|
2023-11-17 07:20:08 +01:00
|
|
|
|
2023-11-16 21:53:43 +01:00
|
|
|
function InnerApp() {
|
2023-12-10 00:10:12 +01:00
|
|
|
const {isInitialLoad, currentAccount} = useSession()
|
2023-11-10 00:14:51 +01:00
|
|
|
const {resumeSession} = useSessionApi()
|
2024-02-06 20:43:51 +01:00
|
|
|
const theme = useColorModeTheme()
|
2024-02-27 19:35:38 +01:00
|
|
|
useIntentHandler()
|
2022-06-09 20:03:25 +02:00
|
|
|
|
|
|
|
// init
|
2023-11-10 00:14:51 +01:00
|
|
|
useEffect(() => {
|
|
|
|
const account = persisted.get('session').currentAccount
|
|
|
|
resumeSession(account)
|
|
|
|
}, [resumeSession])
|
2022-06-09 20:03:25 +02:00
|
|
|
|
2023-12-10 00:10:12 +01:00
|
|
|
// wait for session to resume
|
|
|
|
if (isInitialLoad) return null
|
|
|
|
|
2023-11-07 23:06:17 +01:00
|
|
|
return (
|
2024-01-09 02:43:56 +01:00
|
|
|
<Alf theme={theme}>
|
|
|
|
<React.Fragment
|
|
|
|
// Resets the entire tree below when it changes:
|
|
|
|
key={currentAccount?.did}>
|
|
|
|
<LoggedOutViewProvider>
|
2024-02-08 21:37:08 +01:00
|
|
|
<SelectedFeedProvider>
|
|
|
|
<UnreadNotifsProvider>
|
|
|
|
<ThemeProvider theme={theme}>
|
|
|
|
{/* All components should be within this provider */}
|
|
|
|
<RootSiblingParent>
|
|
|
|
<SafeAreaProvider>
|
|
|
|
<Shell />
|
|
|
|
</SafeAreaProvider>
|
|
|
|
</RootSiblingParent>
|
|
|
|
<ToastContainer />
|
|
|
|
</ThemeProvider>
|
|
|
|
</UnreadNotifsProvider>
|
|
|
|
</SelectedFeedProvider>
|
2024-01-09 02:43:56 +01:00
|
|
|
</LoggedOutViewProvider>
|
|
|
|
</React.Fragment>
|
|
|
|
</Alf>
|
2023-11-07 23:06:17 +01:00
|
|
|
)
|
2023-11-16 21:53:43 +01:00
|
|
|
}
|
2023-11-07 23:06:17 +01:00
|
|
|
|
|
|
|
function App() {
|
|
|
|
const [isReady, setReady] = useState(false)
|
|
|
|
|
|
|
|
React.useEffect(() => {
|
|
|
|
initPersistedState().then(() => setReady(true))
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
if (!isReady) {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
2023-11-14 23:54:02 +01:00
|
|
|
/*
|
|
|
|
* NOTE: only nothing here can depend on other data or session state, since
|
|
|
|
* that is set up in the InnerApp component above.
|
|
|
|
*/
|
2022-06-09 20:03:25 +02:00
|
|
|
return (
|
2023-11-13 03:13:11 +01:00
|
|
|
<QueryClientProvider client={queryClient}>
|
|
|
|
<SessionProvider>
|
|
|
|
<ShellStateProvider>
|
|
|
|
<PrefsStateProvider>
|
|
|
|
<MutedThreadsProvider>
|
2023-11-14 23:54:02 +01:00
|
|
|
<InvitesStateProvider>
|
|
|
|
<ModalStateProvider>
|
New component library based on ALF (#2459)
* Install on native as well
* Add button and link components
* Comments
* Use new prop
* Add some form elements
* Add labels to input
* Fix line height, add suffix
* Date inputs
* Autofill styles
* Clean up InputDate types
* Improve types for InputText, value handling
* Enforce a11y props on buttons
* Add Dialog, Portal
* Dialog contents
* Native dialog
* Clean up
* Fix animations
* Improvements to web modal, exiting still broken
* Clean up dialog types
* Add Prompt, Dialog refinement, mobile refinement
* Integrate new design tokens, reorg storybook
* Button colors
* Dim mode
* Reorg
* Some styles
* Toggles
* Improve a11y
* Autosize dialog, handle max height, Dialog.ScrolLView not working
* Try to use BottomSheet's own APIs
* Scrollable dialogs
* Add web shadow
* Handle overscroll
* Styles
* Dialog text input
* Shadows
* Button focus states
* Button pressed states
* Gradient poc
* Gradient colors and hovers
* Add hrefAttrs to Link
* Some more a11y
* Toggle invalid states
* Update dialog descriptions for demo
* Icons
* WIP Toggle cleanup
* Refactor toggle to not rely on immediate children
* Make Toggle controlled
* Clean up Toggles storybook
* ToggleButton styles
* Improve a11y labels
* ToggleButton hover darkmode
* Some i18n
* Refactor input
* Allow extension of input
* Remove old input
* Improve icons, add CalendarDays
* Refactor DateField, web done
* Add label example
* Clean up old InputDate, DateField android, text area example
* Consistent imports
* Button context, icons
* Add todo
* Add closeAllDialogs control
* Alignment
* Expand color palette
* Hitslops, add shortcut to Storybook in dev
* Fix multiline on ios
* Mark dialog close button as unused
2024-01-19 03:28:04 +01:00
|
|
|
<DialogStateProvider>
|
|
|
|
<LightboxStateProvider>
|
|
|
|
<I18nProvider>
|
|
|
|
<PortalProvider>
|
|
|
|
<InnerApp />
|
|
|
|
</PortalProvider>
|
|
|
|
</I18nProvider>
|
|
|
|
</LightboxStateProvider>
|
|
|
|
</DialogStateProvider>
|
2023-11-14 23:54:02 +01:00
|
|
|
</ModalStateProvider>
|
|
|
|
</InvitesStateProvider>
|
2023-11-13 03:13:11 +01:00
|
|
|
</MutedThreadsProvider>
|
|
|
|
</PrefsStateProvider>
|
|
|
|
</ShellStateProvider>
|
|
|
|
</SessionProvider>
|
|
|
|
</QueryClientProvider>
|
2022-06-09 20:03:25 +02:00
|
|
|
)
|
2023-11-07 23:06:17 +01:00
|
|
|
}
|
2022-06-09 20:03:25 +02:00
|
|
|
|
|
|
|
export default App
|