Skip to content

Commit

Permalink
Merge 089ba32 into f8b81a3
Browse files Browse the repository at this point in the history
  • Loading branch information
bruce-glazier committed Apr 17, 2024
2 parents f8b81a3 + 089ba32 commit e768942
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 46 deletions.
2 changes: 2 additions & 0 deletions src/common/LoggedInProviders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { LoginScreen } from '../screens/LoginScreen';
import { ActivityIndicatorView } from '../components/ActivityIndicatorView';
import { InviteProvider } from '../components/Invitations/InviteProvider';
import { t } from 'i18next';
import AppConfigSwitcher from '../components/AppConfigSwitcher';

export type LoggedInProvidersProps = {
children?: React.ReactNode;
Expand Down Expand Up @@ -53,6 +54,7 @@ export const LoggedInProviders = ({ children }: LoggedInProvidersProps) => {
<InviteProvider>
<ActiveProjectContextProvider>
<AppConfigContextProvider>
<AppConfigSwitcher />
<TrackTileProvider>
<WearableLifecycleProvider>
<CircleTileContextProvider>
Expand Down
76 changes: 34 additions & 42 deletions src/components/AppConfigSwitcher.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import * as React from 'react';
import {
Appbar,
Drawer,
IconButton,
Portal,
Provider,
} from 'react-native-paper';
import { Appbar, Drawer, IconButton, Portal } from 'react-native-paper';
import { useAppConfig, useAppConfigList } from '../hooks/useAppConfig';
import { Modal, NativeEventEmitter, View } from 'react-native';
import { createStyles } from './BrandConfigProvider/styles/createStyles';
Expand Down Expand Up @@ -43,41 +37,39 @@ const AppConfigSwitcher = () => {
}, []);

return (
<Provider>
<Portal>
<Modal
visible={visible}
onDismiss={hideModal}
animationType={'slide'}
style={styles.modal}
>
<View style={styles.container}>
<Appbar.Header style={styles.header}>
<IconButton onPress={() => hideModal()} icon={ArrowLeft} />
</Appbar.Header>
<Drawer.Section
title="Adaptive Experiences: Tailored by Cohort"
showDivider={true}
titleMaxFontSizeMultiplier={4}
>
{configs?.map((config) => (
<Drawer.Item
key={config.id}
label={config.name}
active={active === config.id}
style={styles.itemText}
onPress={() => {
setActive(config.id);
setAppConfigId(config.id);
setVisible(false);
}}
/>
))}
</Drawer.Section>
</View>
</Modal>
</Portal>
</Provider>
<Portal>
<Modal
visible={visible}
onDismiss={hideModal}
animationType={'slide'}
style={styles.modal}
>
<View style={styles.container}>
<Appbar.Header style={styles.header}>
<IconButton onPress={() => hideModal()} icon={ArrowLeft} />
</Appbar.Header>
<Drawer.Section
title="Adaptive Experiences: Tailored by Cohort"
showDivider={true}
titleMaxFontSizeMultiplier={4}
>
{configs?.map((config) => (
<Drawer.Item
key={config.id}
label={config.name}
active={active === config.id}
style={styles.itemText}
onPress={() => {
setActive(config.id);
setAppConfigId(config.id);
setVisible(false);
}}
/>
))}
</Drawer.Section>
</View>
</Modal>
</Portal>
);
};

Expand Down
4 changes: 2 additions & 2 deletions src/components/AppConfigSwitcherButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ const AppConfigSwitcherButton = () => {
<IconButton
onPress={emitShowAppConfigSwitcher}
icon={Menu}
style={styles.button}
style={styles.iconButton}
/>
);
};

export default AppConfigSwitcherButton;

const defaultStyles = createStyles('AppConfigSwitcherButton', () => ({
button: {},
iconButton: {},
}));

declare module '@styles' {
Expand Down
2 changes: 0 additions & 2 deletions src/hooks/useAppConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,6 @@ export const AppConfigContextProvider = ({
const configList = useAppConfigList();
const [appConfigId, setAppConfigId] = useState<string | undefined>();

console.log('ConfigList', configList);

useEffect(() => {
if (configList) {
setAppConfigId(configList[0]?.id);
Expand Down

0 comments on commit e768942

Please sign in to comment.