Skip to content

Commit cb8041b

Browse files
Fix iOS git action toast glass rendering
- Use Liquid Glass for the git action progress overlay - Avoid forwarding refs through GlassSurface on unsupported glass APIs
1 parent faf65cb commit cb8041b

2 files changed

Lines changed: 43 additions & 20 deletions

File tree

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

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

20-
export const GlassSurface = forwardRef<View, GlassSurfaceProps>(function GlassSurface(
21-
{ children, glassEffectStyle = "regular", chrome = "default", tintColor, style, ...props },
22-
ref,
23-
) {
20+
export function GlassSurface({
21+
children,
22+
glassEffectStyle = "regular",
23+
chrome = "default",
24+
tintColor,
25+
style,
26+
...props
27+
}: GlassSurfaceProps) {
2428
const isDarkMode = useColorScheme() === "dark";
2529
const borderColor = useThemeColor("--color-border");
2630
const glassSurface = useThemeColor("--color-glass-surface");
@@ -52,7 +56,6 @@ export const GlassSurface = forwardRef<View, GlassSurfaceProps>(function GlassSu
5256
return (
5357
<GlassView
5458
{...props}
55-
ref={ref}
5659
glassEffectStyle={glassEffectStyle}
5760
tintColor={String(tintColor ?? glassTint)}
5861
colorScheme={isDarkMode ? "dark" : "light"}
@@ -64,8 +67,8 @@ export const GlassSurface = forwardRef<View, GlassSurfaceProps>(function GlassSu
6467
}
6568

6669
return (
67-
<View {...props} ref={ref} style={[surfaceStyle, style]}>
70+
<View {...props} style={[surfaceStyle, style]}>
6871
{children}
6972
</View>
7073
);
71-
});
74+
}

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

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
import * as Haptics from "expo-haptics";
2+
import { isLiquidGlassSupported, LiquidGlassView } from "@callstack/liquid-glass";
23
import { SymbolView } from "../../components/AppSymbol";
34
import { useCallback, useEffect, useRef } from "react";
4-
import { ActivityIndicator, Platform, Pressable, View } from "react-native";
5+
import { ActivityIndicator, Pressable, StyleSheet, useColorScheme, View } from "react-native";
56
import Animated, { FadeIn, FadeOut, LinearTransition } from "react-native-reanimated";
67
import { useSafeAreaInsets } from "react-native-safe-area-context";
7-
import { isGlassEffectAPIAvailable } from "expo-glass-effect";
88

99
import { AppText as Text } from "../../components/AppText";
10-
import { GlassSurface } from "../../components/GlassSurface";
1110
import { tryOpenExternalUrl } from "../../lib/openExternalUrl";
1211
import { useThemeColor } from "../../lib/useThemeColor";
1312
import type { GitActionProgress } from "../../state/use-vcs-action-state";
1413

1514
const OVERLAY_LAYOUT_TRANSITION = LinearTransition.duration(220);
16-
const AnimatedGlassSurface = Animated.createAnimatedComponent(GlassSurface);
15+
const AnimatedLiquidGlassView = Animated.createAnimatedComponent(LiquidGlassView);
1716

1817
export function GitActionProgressOverlay(props: {
1918
readonly progress: GitActionProgress;
@@ -50,7 +49,7 @@ export function GitActionProgressOverlay(props: {
5049

5150
return (
5251
<Animated.View
53-
entering={FadeIn.duration(200)}
52+
entering={isLiquidGlassSupported ? undefined : FadeIn.duration(200)}
5453
exiting={FadeOut.duration(150)}
5554
className="absolute inset-x-3 z-[100]"
5655
style={{ top: insets.top + 48 }}
@@ -66,7 +65,9 @@ export function GitActionProgressOverlay(props: {
6665
function OverlayContent(props: { readonly progress: GitActionProgress }) {
6766
const { progress } = props;
6867
const iconColor = useThemeColor("--color-icon");
69-
const supportsGlass = Platform.OS === "ios" && isGlassEffectAPIAvailable();
68+
const glassBorder = useThemeColor("--color-header-border");
69+
const glassTint = useThemeColor("--color-glass-tint");
70+
const isDarkMode = useColorScheme() === "dark";
7071
const content = (
7172
<>
7273
<OverlayIcon phase={progress.phase} iconColor={iconColor} />
@@ -90,19 +91,38 @@ function OverlayContent(props: { readonly progress: GitActionProgress }) {
9091
</>
9192
);
9293

93-
if (supportsGlass) {
94+
if (isLiquidGlassSupported) {
9495
return (
95-
<AnimatedGlassSurface
96-
chrome="none"
97-
glassEffectStyle="regular"
96+
<Animated.View
9897
layout={OVERLAY_LAYOUT_TRANSITION}
9998
style={{
99+
backgroundColor: glassTint,
100+
borderColor: glassBorder,
100101
borderCurve: "continuous",
101102
borderRadius: 26,
103+
borderWidth: StyleSheet.hairlineWidth,
104+
overflow: "hidden",
102105
}}
103106
>
104-
<View className="flex-row items-center gap-2.5 px-3.5 py-3">{content}</View>
105-
</AnimatedGlassSurface>
107+
<AnimatedLiquidGlassView
108+
colorScheme={isDarkMode ? "dark" : "light"}
109+
effect="regular"
110+
interactive
111+
layout={OVERLAY_LAYOUT_TRANSITION}
112+
style={{
113+
borderCurve: "continuous",
114+
borderRadius: 26,
115+
overflow: "hidden",
116+
}}
117+
>
118+
<Animated.View
119+
entering={FadeIn.delay(60).duration(140)}
120+
className="flex-row items-center gap-2.5 px-3.5 py-3"
121+
>
122+
{content}
123+
</Animated.View>
124+
</AnimatedLiquidGlassView>
125+
</Animated.View>
106126
);
107127
}
108128

0 commit comments

Comments
 (0)