Skip to content

Commit f4d0fc4

Browse files
committed
Merge branch 'main' into android-back-button
# Conflicts: # screens/MainScreen.tsx
2 parents 86eb196 + 93a7dc1 commit f4d0fc4

5 files changed

Lines changed: 79 additions & 37 deletions

File tree

App.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ function SwitchServerStack() {
7676
}
7777

7878
function AppNavigator() {
79-
const { activeServer, isLoading, servers } = useAppContext();
79+
const { isLoading, servers } = useAppContext();
8080

8181
// Show splash/loading while determining initial route
8282
if (isLoading) {
@@ -88,9 +88,6 @@ function AppNavigator() {
8888
presentation: "modal" as const,
8989
};
9090

91-
console.log("activeServer", activeServer);
92-
console.log("servers", servers);
93-
9491
const linking: LinkingOptions<RootStackParamList> = {
9592
prefixes: [SCHEME + "://"],
9693
config: {

components/Spinner.tsx

Lines changed: 71 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,86 @@
1-
import { Platform, View } from "react-native";
2-
import { size } from "@expo/ui/jetpack-compose/modifiers";
1+
import { useEffect } from "react";
2+
import Svg, { Circle } from "react-native-svg";
3+
import Animated, {
4+
Easing,
5+
useAnimatedProps,
6+
useSharedValue,
7+
withDelay,
8+
withRepeat,
9+
withTiming,
10+
} from "react-native-reanimated";
311
import { useThemeColors } from "utils/theme";
412
import { testingEnvironment } from "helper/launchArguments";
513

6-
// OS-native indeterminate spinner: Material 3 LoadingIndicator on Android,
7-
// SwiftUI ProgressView on iOS. Static under Detox so the idle-sync doesn't hang.
14+
const AnimatedCircle = Animated.createAnimatedComponent(Circle);
15+
16+
const SIZE = 64;
17+
const DURATION = 1800;
18+
const RADIUS_EASING = Easing.bezier(0.165, 0.84, 0.44, 1);
19+
const OPACITY_EASING = Easing.bezier(0.3, 0.61, 0.355, 1);
20+
21+
function PuffCircle({ delay, color }: { delay: number; color: string }) {
22+
const radius = useSharedValue(1);
23+
const opacity = useSharedValue(1);
24+
25+
useEffect(() => {
26+
radius.value = withDelay(
27+
delay,
28+
withRepeat(
29+
withTiming(20, { duration: DURATION, easing: RADIUS_EASING }),
30+
-1,
31+
),
32+
);
33+
opacity.value = withDelay(
34+
delay,
35+
withRepeat(
36+
withTiming(0, { duration: DURATION, easing: OPACITY_EASING }),
37+
-1,
38+
),
39+
);
40+
}, [radius, opacity, delay]);
41+
42+
const animatedProps = useAnimatedProps(() => ({
43+
r: radius.value,
44+
strokeOpacity: opacity.value,
45+
}));
46+
47+
return (
48+
<AnimatedCircle
49+
cx={22}
50+
cy={22}
51+
fill="none"
52+
stroke={color}
53+
strokeWidth={2}
54+
animatedProps={animatedProps}
55+
/>
56+
);
57+
}
58+
59+
// "puff" loader by Sam Herbert (SVG-Loaders, MIT): two expanding, fading
60+
// rings. Static under Detox so the idle-sync doesn't hang.
861
export default function Spinner() {
962
const colors = useThemeColors();
1063

1164
if (testingEnvironment()) {
12-
return <View style={{ width: 48, height: 48 }} />;
13-
}
14-
15-
if (Platform.OS === "android") {
16-
const { Host, LoadingIndicator } =
17-
require("@expo/ui/jetpack-compose") as typeof import("@expo/ui/jetpack-compose");
1865
return (
19-
<Host matchContents>
20-
<LoadingIndicator
21-
color={colors.primary}
22-
modifiers={[size(48, 48)]}
66+
<Svg width={SIZE} height={SIZE} viewBox="0 0 44 44">
67+
<Circle
68+
cx={22}
69+
cy={22}
70+
r={10}
71+
fill="none"
72+
stroke={colors.primary}
73+
strokeWidth={2}
74+
strokeOpacity={0.5}
2375
/>
24-
</Host>
76+
</Svg>
2577
);
2678
}
2779

28-
const { Host, ProgressView } =
29-
require("@expo/ui/swift-ui") as typeof import("@expo/ui/swift-ui");
3080
return (
31-
<Host matchContents>
32-
<ProgressView />
33-
</Host>
81+
<Svg width={SIZE} height={SIZE} viewBox="0 0 44 44">
82+
<PuffCircle delay={0} color={colors.primary} />
83+
<PuffCircle delay={DURATION / 2} color={colors.primary} />
84+
</Svg>
3485
);
3586
}

screens/AddServerScreen.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ function AddServerScreen({
5050

5151
const serverSelected = useCallback(
5252
async (server: Server) => {
53-
console.log("serverSelected");
5453
setInternalServer(server);
5554

5655
// a freshly added server becomes the active one

screens/MainScreen.tsx

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import {
2020
ShouldStartLoadRequest,
2121
WebViewErrorEvent,
2222
WebViewHttpErrorEvent,
23-
WebViewTerminatedEvent,
2423
WebViewNavigation,
2524
} from "react-native-webview/lib/WebViewTypes";
2625
import { NativeStackScreenProps } from "@react-navigation/native-stack";
@@ -93,7 +92,6 @@ export default function MainScreen({
9392

9493
if (!isConnected) {
9594
intervalId = setInterval(() => {
96-
console.log("Attempting to reconnect...");
9795
setWebViewKey((prevKey) => prevKey + 1);
9896
}, 5000);
9997
}
@@ -213,17 +211,17 @@ export default function MainScreen({
213211
);
214212

215213
const onError = useCallback((event: WebViewErrorEvent) => {
216-
console.log("onError", event);
214+
console.log("onError", event.nativeEvent.description);
217215
setIsConnected(false);
218216
}, []);
219217

220218
const onHttpError = useCallback((event: WebViewHttpErrorEvent) => {
221-
console.log("onHttpError", event);
219+
console.log("onHttpError", event.nativeEvent.statusCode);
222220
setIsConnected(false);
223221
}, []);
224222

225-
const onTerminate = useCallback((event: WebViewTerminatedEvent) => {
226-
console.log("onTerminate", event);
223+
const onTerminate = useCallback(() => {
224+
console.log("onTerminate");
227225
setIsConnected(false);
228226
}, []);
229227

@@ -287,13 +285,12 @@ export default function MainScreen({
287285
flex: 1,
288286
justifyContent: "center",
289287
alignItems: "center",
288+
gap: 24,
290289
backgroundColor: colors.background,
291290
}}
292291
>
292+
<AppText color="hint">{t("servers.search.searching")}</AppText>
293293
<Spinner />
294-
<AppText color="hint" style={{ marginTop: 24 }}>
295-
{t("servers.search.searching")}
296-
</AppText>
297294
</View>
298295
<View
299296
style={{
@@ -332,8 +329,6 @@ export default function MainScreen({
332329
return <View style={{ flex: 1, backgroundColor: colors.background }} />;
333330
}
334331

335-
console.log("serverUrl", activeServer.url, isConnected);
336-
337332
return (
338333
<>
339334
{LayoutMemoized}

utils/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export async function verifyEvccServer(server: Server) {
3232
try {
3333
response = await axios.get(server.url, options);
3434
} catch (error) {
35-
console.log(error);
35+
console.log(String(error));
3636
if (axios.isAxiosError(error) && error.response?.status === 401) {
3737
throw new Error(t("servers.manually.missingOrWrongAuthentication"));
3838
}

0 commit comments

Comments
 (0)