Skip to content

Commit

Permalink
merge onboarding wizard w/ widget editing
Browse files Browse the repository at this point in the history
  • Loading branch information
kibagateaux committed Jan 30, 2024
1 parent 5183a1e commit 2c9cd16
Show file tree
Hide file tree
Showing 29 changed files with 1,336 additions and 234 deletions.
9 changes: 6 additions & 3 deletions eas.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"distribution": "internal",
"env": {
"APP_VARIANT": "development",
"EXPO_PUBLIC_API_URL": "apprentice-scryer.jinni.health"
"EXPO_PUBLIC_API_URL": "apprentice-scryer.jinni.health",
"EXPO_PUBLIC_REDIRECT_URL": "apprentice-scryer.jinni.health"
},
"android": {
"buildType": "apk",
Expand All @@ -19,7 +20,8 @@
"env": {
"NODE_ENV": "production",
"APP_VARIANT": "staging",
"EXPO_PUBLIC_API_URL": "apprentice-scryer.jinni.health"
"EXPO_PUBLIC_API_URL": "apprentice-scryer.jinni.health",
"EXPO_PUBLIC_REDIRECT_URL": "apprentice-scryer.jinni.health"
},
"android": {
"buildType": "apk",
Expand All @@ -29,7 +31,8 @@
"production": {
"env": {
"APP_VARIANT": "production",
"EXPO_PUBLIC_API_URL": "apprentice-scryer.jinni.health"
"EXPO_PUBLIC_API_URL": "scryer.jinni.health",
"EXPO_PUBLIC_REDIRECT_URL": "scryer.jinni.health"
},
"android": {
"buildType": "app-bundle",
Expand Down
145 changes: 138 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
"@arx-research/libhalo": "^1.2.17",
"@react-native-async-storage/async-storage": "1.18.2",
"@react-native-community/masked-view": "^0.1.11",
"@rneui/base": "^4.0.0-rc.7",
"@rneui/themed": "^4.0.0-rc.8",
"@segment/analytics-react-native": "^2.16.1",
"@segment/sovran-react-native": "^1.0.4",
"@semaphore-protocol/group": "^3.11.1",
Expand Down
1 change: 0 additions & 1 deletion sample.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
EXPO_PUBLIC_API_URL="{someapi.domain.com}"
EXPO_PUBLIC_API_KEY="!believeme!"
EXPO_ETH_RPC_PROVIDER="{alchemy/infura/etc}"

EXPO_PUBLIC_SEGMENT_API_KEY="{some_key}"
Expand Down
78 changes: 66 additions & 12 deletions src/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,47 @@ import Animated, { useAnimatedStyle, useSharedValue, withSpring } from 'react-na
import { isEmpty } from 'lodash/fp';

import { useHomeConfig } from 'hooks';
import { useTheme, useAuth } from 'contexts';
import { WidgetConfig } from 'types/UserConfig';
import { WidgetConfig, obj } from 'types/UserConfig';
import { getIconForWidget } from 'utils/rendering';
import { saveHomeConfig } from 'utils/config';
import { saveHomeConfig } from 'utils/api';
import { getActivityData } from 'inventory/android-health-connect';

import { AvatarViewer, WidgetIcon } from 'components/index';
import DefaultAvatar from 'assets/avatars/red-yellow-egg';
import WidgetContainer from 'components/home/WidgetContainer';
import OnboardingWizard from 'components/wizards/OnboardingWizard';
import {
STAGE_AVATAR_CONFIG,
TRACK_ONBOARDING_STAGE,
filterOutDefaultWidgets,
getStorage,
saveStorage,
} from 'utils/config';
import { debug } from 'utils/logging';

const HomeScreen = () => {
const { player } = useAuth();
const homeConfig = useHomeConfig();
const eggRollAngle = useSharedValue(30);
const eggAnimatedStyles = useAnimatedStyle(() => ({
transform: [{ rotate: `${eggRollAngle.value}deg` }],
}));
const [widgetConfig, setWidgetConfig] = useState<WidgetConfig[]>([]);
const [onboardingStage, setOnboardingStage] = useState<string>();

useMemo(() => {
if (isEmpty(widgetConfig) && homeConfig?.widgets) {
setWidgetConfig(homeConfig.widgets);
}
}, [homeConfig, widgetConfig]);

useMemo(async () => {
const currentStage = await getStorage<obj>(TRACK_ONBOARDING_STAGE);
console.log('onboarding stage', onboardingStage, currentStage);
if (!onboardingStage && !currentStage?.[STAGE_AVATAR_CONFIG]) {
setOnboardingStage(STAGE_AVATAR_CONFIG);
}
}, [onboardingStage]);

useEffect(() => {
const intervalId = setInterval(() => {
const otherSide = eggRollAngle.value < 0 ? 30 : -30;
Expand All @@ -53,12 +69,23 @@ const HomeScreen = () => {
[setWidgetConfig],
);

const finalizeRenovation = () =>
saveHomeConfig({
username: player?.name || 'sampleusername',
widgets: widgetConfig,
proof: '!believeme!',
});
const finalizeRenovation = useCallback(
(widgets?: WidgetConfig[]) =>
// TODO widgetConfig is not updated when adding/removing widgets
saveHomeConfig({
widgets: widgets ?? widgetConfig,
}),
[widgetConfig],
);

const completeWizardStage = useCallback(
(stage: string) => {
saveStorage(TRACK_ONBOARDING_STAGE, { [stage]: String(true) }, true, {}).then(() =>
setOnboardingStage(undefined),
);
},
[setOnboardingStage],
);

const HomeWidget = ({ id, title, path }: WidgetConfig) => {
return (
Expand All @@ -84,8 +111,35 @@ const HomeScreen = () => {

console.log('eggroll ', eggRollAngle.value);

if (onboardingStage === STAGE_AVATAR_CONFIG)
return (
<OnboardingWizard
startIndex={0}
onComplete={async (config) => {
try {
await finalizeRenovation([
...widgetConfig,
{
id: 'maliksmajik-avatar-viewer',
provider: 'MaliksMajik',
routeName: 'index', // home page
title: 'Avatar Viewer',
path: '/',
config,
// They can't have registered yet so no jinni id to specify for config
// eventually need to link with jiini. Could do in activate_jinni but :Widget wont be there if they start from desktop flow (github/facrcaster)
// target_uuid: await getStorage(ID_JINNI_SLOT)
},
]);
completeWizardStage(STAGE_AVATAR_CONFIG);
} catch (e) {
debug(e, { extra: { onboardingStage } });
}
}}
/>
);
return (
<View style={{ flex: 1, ...useTheme() }}>
<View style={{ flex: 1 }}>
<View style={styles.container}>
<View style={styles.avatarContainer}>
<Animated.View style={[styles.avatar, eggAnimatedStyles]}>
Expand All @@ -94,7 +148,7 @@ const HomeScreen = () => {
<Button color="purple" title="Speak Intention" onPress={onIntentionPress} />
</View>
<WidgetContainer
widgets={widgetConfig}
widgets={filterOutDefaultWidgets(widgetConfig) as WidgetConfig[]}
WidgetRenderer={HomeWidget}
saveWidgets={saveWidgets}
finalizeRenovation={finalizeRenovation}
Expand Down
7 changes: 6 additions & 1 deletion src/app/inventory/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ export default function Layout() {
title: 'Inventory',
}}
/>
<Stack.Screen name="[item]" />
<Stack.Screen
name="[item]"
options={{
headerBackButtonMenuEnabled: true,
}}
/>
</Stack>
);
}
Loading

0 comments on commit 2c9cd16

Please sign in to comment.