Skip to content

Commit

Permalink
Add dev menu
Browse files Browse the repository at this point in the history
  • Loading branch information
wyne committed Apr 30, 2024
1 parent 8a02e13 commit d581757
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 13 deletions.
5 changes: 5 additions & 0 deletions redux/SettingsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface SettingsState {
showColorPalettes?: boolean;
interactionType: InteractionType;
lastStoreReviewPrompt: number;
devMenuEnabled?: boolean;
};

const initialState: SettingsState = {
Expand Down Expand Up @@ -72,6 +73,9 @@ const settingsSlice = createSlice({
setLastStoreReviewPrompt(state, action: PayloadAction<number>) {
state.lastStoreReviewPrompt = action.payload;
},
toggleDevMenuEnabled(state) {
state.devMenuEnabled = !state.devMenuEnabled;
}
}
});

Expand All @@ -87,6 +91,7 @@ export const {
toggleShowColorPalettes,
setInteractionType,
setLastStoreReviewPrompt,
toggleDevMenuEnabled,
} = settingsSlice.actions;

export default settingsSlice.reducer;
31 changes: 26 additions & 5 deletions src/components/AppInfo/RotatingIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ import Animated, {
withTiming
} from 'react-native-reanimated';

import { useAppDispatch } from '../../../redux/hooks';
import { toggleDevMenuEnabled } from '../../../redux/SettingsSlice';

const RotatingIcon: React.FunctionComponent = ({ }) => {
const dispatch = useAppDispatch();

const rotation = useSharedValue(0);
const rotationCount = useSharedValue(1);
const animatedStyles = useAnimatedStyle(() => {
Expand All @@ -21,12 +26,28 @@ const RotatingIcon: React.FunctionComponent = ({ }) => {
};
});

return <TouchableWithoutFeedback onPress={async () => {
rotationCount.value = rotationCount.value + 1;
rotation.value = withTiming((rotationCount.value * 90), { duration: 1000, easing: Easing.elastic(1) });
let holdCallback: NodeJS.Timeout;
const onPressIn = () => {
holdCallback = setTimeout(() => {
dispatch(toggleDevMenuEnabled());
// spring expand animate the Animated.View
}, 5000);
};

const onPressOut = () => {
if (holdCallback == null) return;
clearTimeout(holdCallback);
};

return <TouchableWithoutFeedback
onPressIn={onPressIn}
onPressOut={onPressOut}
onPress={async () => {
rotationCount.value = rotationCount.value + 1;
rotation.value = withTiming((rotationCount.value * 90), { duration: 1000, easing: Easing.elastic(1) });

await analytics().logEvent('app_icon');
}}>
await analytics().logEvent('app_icon');
}}>
<Animated.View style={[animatedStyles]}>
<Image source={require('../../../assets/icon.png')}
contentFit='contain'
Expand Down
21 changes: 13 additions & 8 deletions src/screens/AppInfoScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const AppInfoScreen: React.FunctionComponent<Props> = ({ navigation }) => {
const showPointParticles = useAppSelector(state => state.settings.showPointParticles);
const showPlayerIndex = useAppSelector(state => state.settings.showPlayerIndex);
const showColorPalettes = useAppSelector(state => state.settings.showColorPalettes);
const devMenuEnabled = useAppSelector(state => state.settings.devMenuEnabled);

const dispatch = useAppDispatch();
const toggleParticleSwitch = () => { dispatch(toggleShowPointParticles()); };
Expand Down Expand Up @@ -74,14 +75,18 @@ const AppInfoScreen: React.FunctionComponent<Props> = ({ navigation }) => {
<SectionItemText text="Point Particle Effect" />
<Switch onValueChange={toggleParticleSwitch} value={showPointParticles} />
</SectionItem>
<SectionItem>
<SectionItemText text="Player Numbers" />
<Switch onValueChange={togglePlayerIndexSwitch} value={showPlayerIndex} />
</SectionItem>
<SectionItem>
<SectionItemText text="Color Palettes" />
<Switch onValueChange={toggleColorPalettesSwitch} value={showColorPalettes} />
</SectionItem>
{devMenuEnabled && (
<>
<SectionItem>
<SectionItemText text="Player Numbers" />
<Switch onValueChange={togglePlayerIndexSwitch} value={showPlayerIndex} />
</SectionItem>
<SectionItem>
<SectionItemText text="Change Colors (Beta)" />
<Switch onValueChange={toggleColorPalettesSwitch} value={showColorPalettes} />
</SectionItem>
</>
)}
</Section>

<Section title="Help">
Expand Down

0 comments on commit d581757

Please sign in to comment.