Skip to content

Commit faf65cb

Browse files
Polish iOS git progress overlay with glass effects
- Forward refs through GlassSurface for animated glass overlays - Add iOS glass styling with an animated fallback for unsupported platforms
1 parent 9798548 commit faf65cb

2 files changed

Lines changed: 49 additions & 24 deletions

File tree

‎apps/mobile/src/components/GlassSurface.tsx‎

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { GlassView, isGlassEffectAPIAvailable } from "expo-glass-effect";
2-
import type { ReactNode } from "react";
2+
import { forwardRef, type ReactNode } from "react";
33
import {
44
Platform,
55
useColorScheme,
@@ -17,14 +17,10 @@ export interface GlassSurfaceProps extends Omit<ViewProps, "className"> {
1717
readonly chrome?: "default" | "none";
1818
}
1919

20-
export function GlassSurface({
21-
children,
22-
glassEffectStyle = "regular",
23-
chrome = "default",
24-
tintColor,
25-
style,
26-
...props
27-
}: GlassSurfaceProps) {
20+
export const GlassSurface = forwardRef<View, GlassSurfaceProps>(function GlassSurface(
21+
{ children, glassEffectStyle = "regular", chrome = "default", tintColor, style, ...props },
22+
ref,
23+
) {
2824
const isDarkMode = useColorScheme() === "dark";
2925
const borderColor = useThemeColor("--color-border");
3026
const glassSurface = useThemeColor("--color-glass-surface");
@@ -56,6 +52,7 @@ export function GlassSurface({
5652
return (
5753
<GlassView
5854
{...props}
55+
ref={ref}
5956
glassEffectStyle={glassEffectStyle}
6057
tintColor={String(tintColor ?? glassTint)}
6158
colorScheme={isDarkMode ? "dark" : "light"}
@@ -67,8 +64,8 @@ export function GlassSurface({
6764
}
6865

6966
return (
70-
<View {...props} style={[surfaceStyle, style]}>
67+
<View {...props} ref={ref} style={[surfaceStyle, style]}>
7168
{children}
7269
</View>
7370
);
74-
}
71+
});

‎apps/mobile/src/features/threads/GitActionProgressOverlay.tsx‎

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
import * as Haptics from "expo-haptics";
22
import { SymbolView } from "../../components/AppSymbol";
33
import { useCallback, useEffect, useRef } from "react";
4-
import { ActivityIndicator, Pressable, View } from "react-native";
5-
import Animated, { FadeIn, FadeOut } from "react-native-reanimated";
4+
import { ActivityIndicator, Platform, Pressable, View } from "react-native";
5+
import Animated, { FadeIn, FadeOut, LinearTransition } from "react-native-reanimated";
66
import { useSafeAreaInsets } from "react-native-safe-area-context";
7+
import { isGlassEffectAPIAvailable } from "expo-glass-effect";
78

89
import { AppText as Text } from "../../components/AppText";
10+
import { GlassSurface } from "../../components/GlassSurface";
911
import { tryOpenExternalUrl } from "../../lib/openExternalUrl";
1012
import { useThemeColor } from "../../lib/useThemeColor";
1113
import type { GitActionProgress } from "../../state/use-vcs-action-state";
1214

15+
const OVERLAY_LAYOUT_TRANSITION = LinearTransition.duration(220);
16+
const AnimatedGlassSurface = Animated.createAnimatedComponent(GlassSurface);
17+
1318
export function GitActionProgressOverlay(props: {
1419
readonly progress: GitActionProgress;
1520
readonly onDismiss: () => void;
@@ -61,16 +66,9 @@ export function GitActionProgressOverlay(props: {
6166
function OverlayContent(props: { readonly progress: GitActionProgress }) {
6267
const { progress } = props;
6368
const iconColor = useThemeColor("--color-icon");
64-
65-
const bgClass =
66-
progress.phase === "error"
67-
? "bg-red-50 dark:bg-red-950/80 border-red-200 dark:border-red-800"
68-
: "bg-card border-border";
69-
70-
return (
71-
<View
72-
className={`flex-row items-center gap-2.5 rounded-2xl border px-3.5 py-3 shadow-lg shadow-black/10 ${bgClass}`}
73-
>
69+
const supportsGlass = Platform.OS === "ios" && isGlassEffectAPIAvailable();
70+
const content = (
71+
<>
7472
<OverlayIcon phase={progress.phase} iconColor={iconColor} />
7573

7674
<View className="flex-1 gap-0.5">
@@ -89,7 +87,37 @@ function OverlayContent(props: { readonly progress: GitActionProgress }) {
8987
{progress.prUrl ? (
9088
<SymbolView name="arrow.up.right" size={13} tintColor={iconColor} type="monochrome" />
9189
) : null}
92-
</View>
90+
</>
91+
);
92+
93+
if (supportsGlass) {
94+
return (
95+
<AnimatedGlassSurface
96+
chrome="none"
97+
glassEffectStyle="regular"
98+
layout={OVERLAY_LAYOUT_TRANSITION}
99+
style={{
100+
borderCurve: "continuous",
101+
borderRadius: 26,
102+
}}
103+
>
104+
<View className="flex-row items-center gap-2.5 px-3.5 py-3">{content}</View>
105+
</AnimatedGlassSurface>
106+
);
107+
}
108+
109+
const bgClass =
110+
progress.phase === "error"
111+
? "bg-red-50 dark:bg-red-950/80 border-red-200 dark:border-red-800"
112+
: "bg-card border-border";
113+
114+
return (
115+
<Animated.View
116+
layout={OVERLAY_LAYOUT_TRANSITION}
117+
className={`flex-row items-center gap-2.5 rounded-[26px] border border-continuous px-3.5 py-3 shadow-lg shadow-black/10 ${bgClass}`}
118+
>
119+
{content}
120+
</Animated.View>
93121
);
94122
}
95123

0 commit comments

Comments
 (0)