Skip to content

Commit dbef2b8

Browse files
committed
(fix): image viewer #89
Changelog: fix
1 parent eb075d1 commit dbef2b8

12 files changed

Lines changed: 601 additions & 298 deletions

File tree

apps/polycentric/app.config.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default ({ config }: ConfigContext): ExpoConfig => ({
1010
name: NAME,
1111
slug: 'polycentric',
1212
version: process.env.APP_VERSION ?? '0.0.1',
13-
orientation: 'portrait',
13+
orientation: 'default',
1414
icon: './src/common/assets/images/app-icons/android-icon-foreground.png',
1515
scheme: 'polycentric',
1616
web: {
@@ -23,6 +23,7 @@ export default ({ config }: ConfigContext): ExpoConfig => ({
2323
light: './src/common/assets/images/app-icons/ios-icon-default.png',
2424
tinted: './src/common/assets/images/app-icons/ios-icon-monochrome.png',
2525
},
26+
requireFullScreen: true,
2627
supportsTablet: true,
2728
bundleIdentifier: ID,
2829
infoPlist: {
@@ -81,6 +82,12 @@ export default ({ config }: ConfigContext): ExpoConfig => ({
8182
],
8283
'expo-image',
8384
'expo-notifications',
85+
[
86+
'expo-screen-orientation',
87+
{
88+
initialOrientation: 'DEFAULT',
89+
},
90+
],
8491
],
8592
experiments: {
8693
typedRoutes: true,

apps/polycentric/app/_layout.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ function RootStack() {
3333
headerShown: false,
3434
fullScreenGestureEnabled: !isWeb,
3535
contentStyle: [theme.atoms.bg, Atoms.flex_1, Atoms.overflow_auto],
36-
...(isWeb ? { animation: 'none' as const } : {}),
36+
...(isWeb
37+
? { animation: 'none' as const }
38+
: { orientation: 'portrait_up' }),
3739
}}
3840
>
3941
<Stack.Screen name="(tabs)" />
@@ -55,6 +57,17 @@ function RootStack() {
5557
contentStyle: { backgroundColor: 'transparent' },
5658
}}
5759
/>
60+
<Stack.Screen
61+
name="image-viewer"
62+
options={{
63+
presentation: 'transparentModal',
64+
animation: 'fade',
65+
contentStyle: { backgroundColor: 'transparent' },
66+
// Let just this screen rotate to landscape; the rest of the
67+
// app stays portrait.
68+
...(isWeb ? {} : { orientation: 'all' as const }),
69+
}}
70+
/>
5871
</Stack>
5972
</>
6073
);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from '@/src/features/post/ImageViewer/ImageViewerScreen';

apps/polycentric/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"expo-linking": "~55.0.7",
5353
"expo-notifications": "~55.0.0",
5454
"expo-router": "~55.0.3",
55+
"expo-screen-orientation": "~55.0.16",
5556
"expo-server": "~55.0.8",
5657
"expo-splash-screen": "~55.0.10",
5758
"expo-sqlite": "~55.0.15",
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import * as ScreenOrientation from 'expo-screen-orientation';
2+
import { useEffect, useState } from 'react';
3+
import { Platform } from 'react-native';
4+
5+
/**
6+
* Tracks the device's current screen orientation
7+
*/
8+
export function useOrientation(): ScreenOrientation.Orientation {
9+
const [orientation, setOrientation] = useState<ScreenOrientation.Orientation>(
10+
ScreenOrientation.Orientation.PORTRAIT_UP,
11+
);
12+
13+
useEffect(() => {
14+
if (Platform.OS === 'web') return;
15+
16+
let active = true;
17+
void ScreenOrientation.getOrientationAsync().then((current) => {
18+
if (active) setOrientation(current);
19+
});
20+
21+
const subscription = ScreenOrientation.addOrientationChangeListener(
22+
(event) => {
23+
console.log(event);
24+
setOrientation(event.orientationInfo.orientation);
25+
},
26+
);
27+
28+
return () => {
29+
active = false;
30+
ScreenOrientation.removeOrientationChangeListener(subscription);
31+
};
32+
}, []);
33+
34+
return orientation;
35+
}

apps/polycentric/src/features/post/ImageViewer.tsx

Lines changed: 0 additions & 210 deletions
This file was deleted.

0 commit comments

Comments
 (0)