diff --git a/native/types/themes.js b/lib/types/theme-types.js copy from native/types/themes.js copy to lib/types/theme-types.js --- a/native/types/themes.js +++ b/lib/types/theme-types.js @@ -1,7 +1,5 @@ // @flow -import { Platform } from 'react-native'; - export type GlobalTheme = 'light' | 'dark'; export type GlobalThemePreference = GlobalTheme | 'system'; @@ -11,10 +9,6 @@ +preference: GlobalThemePreference, }; -export const osCanTheme: boolean = - (Platform.OS === 'ios' && parseInt(Platform.Version, 10) >= 13) || - (Platform.OS === 'android' && Platform.Version >= 29); - export const defaultGlobalThemeInfo = { // revert to `activeTheme: osCanTheme ? null : 'light'` to re-enable theming activeTheme: 'dark', diff --git a/native/chat/settings/delete-thread.react.js b/native/chat/settings/delete-thread.react.js --- a/native/chat/settings/delete-thread.react.js +++ b/native/chat/settings/delete-thread.react.js @@ -45,7 +45,6 @@ import type { NavigationRoute } from '../../navigation/route-names.js'; import { useSelector } from '../../redux/redux-utils.js'; import { type Colors, useColors, useStyles } from '../../themes/colors.js'; -import type { GlobalTheme } from '../../types/themes.js'; import Alert from '../../utils/alert.js'; import type { ChatNavigationProp } from '../chat.react.js'; @@ -63,7 +62,6 @@ +threadInfo: ResolvedThreadInfo, +shouldUseDeleteConfirmationAlert: boolean, +loadingStatus: LoadingStatus, - +activeTheme: ?GlobalTheme, +colors: Colors, +styles: typeof unboundStyles, // Redux dispatch functions @@ -269,7 +267,6 @@ const resolvedThreadInfo = useResolvedThreadInfo(threadInfo); const loadingStatus = useSelector(loadingStatusSelector); - const activeTheme = useSelector(state => state.globalThemeInfo.activeTheme); const colors = useColors(); const styles = useStyles(unboundStyles); @@ -290,7 +287,6 @@ threadInfo={resolvedThreadInfo} shouldUseDeleteConfirmationAlert={shouldUseDeleteConfirmationAlert} loadingStatus={loadingStatus} - activeTheme={activeTheme} colors={colors} styles={styles} dispatchActionPromise={dispatchActionPromise} diff --git a/native/markdown/styles.js b/native/markdown/styles.js --- a/native/markdown/styles.js +++ b/native/markdown/styles.js @@ -3,8 +3,9 @@ import _memoize from 'lodash/memoize.js'; import { Platform } from 'react-native'; +import { type GlobalTheme } from 'lib/types/theme-types.js'; + import { getStylesForTheme } from '../themes/colors.js'; -import type { GlobalTheme } from '../types/themes.js'; const unboundStyles = { link: { diff --git a/native/navigation/nav-selectors.js b/native/navigation/nav-selectors.js --- a/native/navigation/nav-selectors.js +++ b/native/navigation/nav-selectors.js @@ -15,6 +15,7 @@ ComposableMessageInfo, RobotextMessageInfo, } from 'lib/types/message-types.js'; +import type { GlobalTheme } from 'lib/types/theme-types.js'; import type { ThreadInfo } from 'lib/types/thread-types.js'; import type { NavContextType } from './navigation-context.js'; @@ -43,7 +44,6 @@ import type { RemoveEditMode } from '../chat/message-list-types'; import { useSelector } from '../redux/redux-utils.js'; import type { NavPlusRedux } from '../types/selector-types.js'; -import type { GlobalTheme } from '../types/themes.js'; const baseCreateIsForegroundSelector = (routeName: string) => createSelector( diff --git a/native/profile/appearance-preferences.react.js b/native/profile/appearance-preferences.react.js --- a/native/profile/appearance-preferences.react.js +++ b/native/profile/appearance-preferences.react.js @@ -6,17 +6,17 @@ import { useDispatch } from 'react-redux'; import type { Dispatch } from 'lib/types/redux-types.js'; +import type { + GlobalThemeInfo, + GlobalThemePreference, +} from 'lib/types/theme-types.js'; import Button from '../components/button.react.js'; import SWMansionIcon from '../components/swmansion-icon.react.js'; import { updateThemeInfoActionType } from '../redux/action-types.js'; import { useSelector } from '../redux/redux-utils.js'; import { type Colors, useColors, useStyles } from '../themes/colors.js'; -import { - type GlobalThemePreference, - type GlobalThemeInfo, - osCanTheme, -} from '../types/themes.js'; +import { osCanTheme } from '../types/themes.js'; const CheckIcon = () => ( state.globalThemeInfo.activeTheme); const colors = useColors(); const styles = useStyles(unboundStyles); @@ -363,7 +360,6 @@ {...props} loadingStatus={loadingStatus} username={username} - activeTheme={activeTheme} colors={colors} styles={styles} dispatchActionPromise={dispatchActionPromise} diff --git a/native/push/in-app-notif.react.js b/native/push/in-app-notif.react.js --- a/native/push/in-app-notif.react.js +++ b/native/push/in-app-notif.react.js @@ -4,8 +4,9 @@ import { View, StyleSheet, Platform } from 'react-native'; import { SafeAreaView } from 'react-native-safe-area-context'; +import type { GlobalTheme } from 'lib/types/theme-types.js'; + import SingleLine from '../components/single-line.react.js'; -import type { GlobalTheme } from '../types/themes.js'; const edges = ['top']; diff --git a/native/push/push-handler.react.js b/native/push/push-handler.react.js --- a/native/push/push-handler.react.js +++ b/native/push/push-handler.react.js @@ -25,6 +25,7 @@ import type { RawMessageInfo } from 'lib/types/message-types.js'; import type { Dispatch } from 'lib/types/redux-types.js'; import { type ConnectionInfo } from 'lib/types/socket-types.js'; +import type { GlobalTheme } from 'lib/types/theme-types.js'; import { type ThreadInfo } from 'lib/types/thread-types.js'; import { useServerCall, @@ -78,7 +79,6 @@ import { useSelector } from '../redux/redux-utils.js'; import { RootContext, type RootContextType } from '../root-context.js'; import type { EventSubscription } from '../types/react-native.js'; -import { type GlobalTheme } from '../types/themes.js'; import Alert from '../utils/alert.js'; LogBox.ignoreLogs([ diff --git a/native/redux/action-types.js b/native/redux/action-types.js --- a/native/redux/action-types.js +++ b/native/redux/action-types.js @@ -5,13 +5,13 @@ import { saveMessagesActionType } from 'lib/actions/message-actions.js'; import type { Shape } from 'lib/types/core.js'; import type { BaseAction } from 'lib/types/redux-types.js'; +import type { GlobalThemeInfo } from 'lib/types/theme-types.js'; import type { DimensionsInfo } from './dimensions-updater.react.js'; import type { AppState } from './state-types.js'; import type { DeviceCameraInfo } from '../types/camera.js'; import type { ConnectivityInfo } from '../types/connectivity.js'; import type { LocalSettings } from '../types/local-settings-types.js'; -import type { GlobalThemeInfo } from '../types/themes.js'; export const updateDimensionsActiveType = 'UPDATE_DIMENSIONS'; export const updateConnectivityActiveType = 'UPDATE_CONNECTIVITY'; diff --git a/native/redux/default-state.js b/native/redux/default-state.js --- a/native/redux/default-state.js +++ b/native/redux/default-state.js @@ -7,6 +7,7 @@ import { defaultCalendarQuery } from 'lib/types/entry-types.js'; import { defaultCalendarFilters } from 'lib/types/filter-types.js'; import { defaultConnectionInfo } from 'lib/types/socket-types.js'; +import { defaultGlobalThemeInfo } from 'lib/types/theme-types.js'; import { defaultNotifPermissionAlertInfo } from 'lib/utils/push-alerts.js'; import { ashoatKeyserverID } from 'lib/utils/validation-utils.js'; @@ -15,7 +16,6 @@ import { defaultNavInfo } from '../navigation/default-state.js'; import { defaultDeviceCameraInfo } from '../types/camera.js'; import { defaultConnectivityInfo } from '../types/connectivity.js'; -import { defaultGlobalThemeInfo } from '../types/themes.js'; import { defaultURLPrefix, natNodeServer } from '../utils/url-utils.js'; const defaultState = ({ diff --git a/native/redux/persist.js b/native/redux/persist.js --- a/native/redux/persist.js +++ b/native/redux/persist.js @@ -58,6 +58,7 @@ defaultConnectionInfo, type ConnectionInfo, } from 'lib/types/socket-types.js'; +import { defaultGlobalThemeInfo } from 'lib/types/theme-types.js'; import type { ClientDBThreadInfo } from 'lib/types/thread-types.js'; import { translateClientDBMessageInfoToRawMessageInfo, @@ -90,7 +91,6 @@ import { updateRolesAndPermissions } from './update-roles-and-permissions.js'; import { commCoreModule } from '../native-modules.js'; import { defaultDeviceCameraInfo } from '../types/camera.js'; -import { defaultGlobalThemeInfo } from '../types/themes.js'; import { isTaskCancelledError } from '../utils/error-handling.js'; const migrations = { diff --git a/native/redux/state-types.js b/native/redux/state-types.js --- a/native/redux/state-types.js +++ b/native/redux/state-types.js @@ -15,6 +15,7 @@ import type { MessageStore } from 'lib/types/message-types.js'; import type { UserPolicies } from 'lib/types/policy-types.js'; import type { ReportStore } from 'lib/types/report-types.js'; +import type { GlobalThemeInfo } from 'lib/types/theme-types.js'; import type { ThreadActivityStore } from 'lib/types/thread-activity-types'; import type { ThreadStore } from 'lib/types/thread-types.js'; import type { CurrentUserInfo, UserStore } from 'lib/types/user-types.js'; @@ -25,7 +26,6 @@ import type { DeviceCameraInfo } from '../types/camera.js'; import type { ConnectivityInfo } from '../types/connectivity.js'; import type { LocalSettings } from '../types/local-settings-types.js'; -import type { GlobalThemeInfo } from '../types/themes.js'; export type AppState = { +navInfo: NavInfo, diff --git a/native/redux/theme-reducer.js b/native/redux/theme-reducer.js --- a/native/redux/theme-reducer.js +++ b/native/redux/theme-reducer.js @@ -7,13 +7,13 @@ logInActionTypes, registerActionTypes, } from 'lib/actions/user-actions.js'; +import { + defaultGlobalThemeInfo, + type GlobalThemeInfo, +} from 'lib/types/theme-types.js'; import { setNewSessionActionType } from 'lib/utils/action-utils.js'; import { updateThemeInfoActionType, type Action } from './action-types.js'; -import { - type GlobalThemeInfo, - defaultGlobalThemeInfo, -} from '../types/themes.js'; export default function reduceGlobalThemeInfo( state: GlobalThemeInfo, diff --git a/native/themes/colors.js b/native/themes/colors.js --- a/native/themes/colors.js +++ b/native/themes/colors.js @@ -4,11 +4,12 @@ import { StyleSheet } from 'react-native'; import { createSelector } from 'reselect'; +import type { GlobalTheme } from 'lib/types/theme-types.js'; + import { selectBackgroundIsDark } from '../navigation/nav-selectors.js'; import { NavContext } from '../navigation/navigation-context.js'; import { useSelector } from '../redux/redux-utils.js'; import type { AppState } from '../redux/state-types.js'; -import type { GlobalTheme } from '../types/themes.js'; const designSystemColors = Object.freeze({ shadesWhite100: '#ffffff', diff --git a/native/themes/theme-handler.react.js b/native/themes/theme-handler.react.js --- a/native/themes/theme-handler.react.js +++ b/native/themes/theme-handler.react.js @@ -6,14 +6,11 @@ import { useDispatch } from 'react-redux'; import type { Shape } from 'lib/types/core.js'; +import type { GlobalTheme, GlobalThemeInfo } from 'lib/types/theme-types.js'; import { updateThemeInfoActionType } from '../redux/action-types.js'; import { useSelector } from '../redux/redux-utils.js'; -import { - type GlobalTheme, - type GlobalThemeInfo, - osCanTheme, -} from '../types/themes.js'; +import { osCanTheme } from '../types/themes.js'; function ThemeHandler(): null { const globalThemeInfo = useSelector(state => state.globalThemeInfo); diff --git a/native/types/themes.js b/native/types/themes.js --- a/native/types/themes.js +++ b/native/types/themes.js @@ -2,24 +2,6 @@ import { Platform } from 'react-native'; -export type GlobalTheme = 'light' | 'dark'; -export type GlobalThemePreference = GlobalTheme | 'system'; - -export type GlobalThemeInfo = { - +activeTheme: ?GlobalTheme, - +systemTheme: ?GlobalTheme, - +preference: GlobalThemePreference, -}; - export const osCanTheme: boolean = (Platform.OS === 'ios' && parseInt(Platform.Version, 10) >= 13) || (Platform.OS === 'android' && Platform.Version >= 29); - -export const defaultGlobalThemeInfo = { - // revert to `activeTheme: osCanTheme ? null : 'light'` to re-enable theming - activeTheme: 'dark', - systemTheme: null, - // revert to `preference: osCanTheme ? 'system' : 'light'` - // to re-enable theming - preference: 'dark', -}; diff --git a/native/utils/alert.js b/native/utils/alert.js --- a/native/utils/alert.js +++ b/native/utils/alert.js @@ -2,8 +2,12 @@ import { Alert } from 'react-native'; +import { + defaultGlobalThemeInfo, + type GlobalTheme, +} from 'lib/types/theme-types.js'; + import { store } from '../redux/redux-setup.js'; -import { type GlobalTheme, defaultGlobalThemeInfo } from '../types/themes.js'; type AlertWrapper = { +alert: typeof Alert.alert,