Skip to content

Commit 2d54aa0

Browse files
committed
Add ability to applyLiquidGlass and update navigationBarStyle
1 parent c02ca25 commit 2d54aa0

File tree

6 files changed

+212
-68
lines changed

6 files changed

+212
-68
lines changed

example/ios/Podfile.lock

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,13 +1685,13 @@ PODS:
16851685
- ReactCommon/turbomodule/core
16861686
- Yoga
16871687
- SocketRocket (0.7.1)
1688-
- Stripe (24.23.0):
1689-
- StripeApplePay (= 24.23.0)
1690-
- StripeCore (= 24.23.0)
1691-
- StripePayments (= 24.23.0)
1692-
- StripePaymentsUI (= 24.23.0)
1693-
- StripeUICore (= 24.23.0)
1694-
- stripe-react-native (0.53.0):
1688+
- Stripe (24.24.0):
1689+
- StripeApplePay (= 24.24.0)
1690+
- StripeCore (= 24.24.0)
1691+
- StripePayments (= 24.24.0)
1692+
- StripePaymentsUI (= 24.24.0)
1693+
- StripeUICore (= 24.24.0)
1694+
- stripe-react-native (0.53.1):
16951695
- DoubleConversion
16961696
- glog
16971697
- hermes-engine
@@ -1711,15 +1711,15 @@ PODS:
17111711
- ReactCodegen
17121712
- ReactCommon/turbomodule/bridging
17131713
- ReactCommon/turbomodule/core
1714-
- Stripe (~> 24.23.0)
1715-
- stripe-react-native/NewArch (= 0.53.0)
1716-
- StripeApplePay (~> 24.23.0)
1717-
- StripeFinancialConnections (~> 24.23.0)
1718-
- StripePayments (~> 24.23.0)
1719-
- StripePaymentSheet (~> 24.23.0)
1720-
- StripePaymentsUI (~> 24.23.0)
1714+
- Stripe (~> 24.24.0)
1715+
- stripe-react-native/NewArch (= 0.53.1)
1716+
- StripeApplePay (~> 24.24.0)
1717+
- StripeFinancialConnections (~> 24.24.0)
1718+
- StripePayments (~> 24.24.0)
1719+
- StripePaymentSheet (~> 24.24.0)
1720+
- StripePaymentsUI (~> 24.24.0)
17211721
- Yoga
1722-
- stripe-react-native/NewArch (0.53.0):
1722+
- stripe-react-native/NewArch (0.53.1):
17231723
- DoubleConversion
17241724
- glog
17251725
- hermes-engine
@@ -1739,14 +1739,14 @@ PODS:
17391739
- ReactCodegen
17401740
- ReactCommon/turbomodule/bridging
17411741
- ReactCommon/turbomodule/core
1742-
- Stripe (~> 24.23.0)
1743-
- StripeApplePay (~> 24.23.0)
1744-
- StripeFinancialConnections (~> 24.23.0)
1745-
- StripePayments (~> 24.23.0)
1746-
- StripePaymentSheet (~> 24.23.0)
1747-
- StripePaymentsUI (~> 24.23.0)
1742+
- Stripe (~> 24.24.0)
1743+
- StripeApplePay (~> 24.24.0)
1744+
- StripeFinancialConnections (~> 24.24.0)
1745+
- StripePayments (~> 24.24.0)
1746+
- StripePaymentSheet (~> 24.24.0)
1747+
- StripePaymentsUI (~> 24.24.0)
17481748
- Yoga
1749-
- stripe-react-native/Tests (0.53.0):
1749+
- stripe-react-native/Tests (0.53.1):
17501750
- DoubleConversion
17511751
- glog
17521752
- hermes-engine
@@ -1766,35 +1766,35 @@ PODS:
17661766
- ReactCodegen
17671767
- ReactCommon/turbomodule/bridging
17681768
- ReactCommon/turbomodule/core
1769-
- Stripe (~> 24.23.0)
1770-
- StripeApplePay (~> 24.23.0)
1771-
- StripeFinancialConnections (~> 24.23.0)
1772-
- StripePayments (~> 24.23.0)
1773-
- StripePaymentSheet (~> 24.23.0)
1774-
- StripePaymentsUI (~> 24.23.0)
1769+
- Stripe (~> 24.24.0)
1770+
- StripeApplePay (~> 24.24.0)
1771+
- StripeFinancialConnections (~> 24.24.0)
1772+
- StripePayments (~> 24.24.0)
1773+
- StripePaymentSheet (~> 24.24.0)
1774+
- StripePaymentsUI (~> 24.24.0)
17751775
- Yoga
1776-
- StripeApplePay (24.23.0):
1777-
- StripeCore (= 24.23.0)
1778-
- StripeCore (24.23.0)
1779-
- StripeFinancialConnections (24.23.0):
1780-
- StripeCore (= 24.23.0)
1781-
- StripeUICore (= 24.23.0)
1782-
- StripePayments (24.23.0):
1783-
- StripeCore (= 24.23.0)
1784-
- StripePayments/Stripe3DS2 (= 24.23.0)
1785-
- StripePayments/Stripe3DS2 (24.23.0):
1786-
- StripeCore (= 24.23.0)
1787-
- StripePaymentSheet (24.23.0):
1788-
- StripeApplePay (= 24.23.0)
1789-
- StripeCore (= 24.23.0)
1790-
- StripePayments (= 24.23.0)
1791-
- StripePaymentsUI (= 24.23.0)
1792-
- StripePaymentsUI (24.23.0):
1793-
- StripeCore (= 24.23.0)
1794-
- StripePayments (= 24.23.0)
1795-
- StripeUICore (= 24.23.0)
1796-
- StripeUICore (24.23.0):
1797-
- StripeCore (= 24.23.0)
1776+
- StripeApplePay (24.24.0):
1777+
- StripeCore (= 24.24.0)
1778+
- StripeCore (24.24.0)
1779+
- StripeFinancialConnections (24.24.0):
1780+
- StripeCore (= 24.24.0)
1781+
- StripeUICore (= 24.24.0)
1782+
- StripePayments (24.24.0):
1783+
- StripeCore (= 24.24.0)
1784+
- StripePayments/Stripe3DS2 (= 24.24.0)
1785+
- StripePayments/Stripe3DS2 (24.24.0):
1786+
- StripeCore (= 24.24.0)
1787+
- StripePaymentSheet (24.24.0):
1788+
- StripeApplePay (= 24.24.0)
1789+
- StripeCore (= 24.24.0)
1790+
- StripePayments (= 24.24.0)
1791+
- StripePaymentsUI (= 24.24.0)
1792+
- StripePaymentsUI (24.24.0):
1793+
- StripeCore (= 24.24.0)
1794+
- StripePayments (= 24.24.0)
1795+
- StripeUICore (= 24.24.0)
1796+
- StripeUICore (24.24.0):
1797+
- StripeCore (= 24.24.0)
17981798
- Yoga (0.0.0)
17991799

18001800
DEPENDENCIES:
@@ -2109,15 +2109,15 @@ SPEC CHECKSUMS:
21092109
RNCPicker: cfb51a08c6e10357d9a65832e791825b0747b483
21102110
RNScreens: 0d4cb9afe052607ad0aa71f645a88bb7c7f2e64c
21112111
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
2112-
Stripe: 2306d32be47f9632942f3385e9c2bad31d6ddcab
2113-
stripe-react-native: 5250f17648f652dd5c570e76bd8b7bca579a238d
2114-
StripeApplePay: edf515972406df57bd860d5f00416a552be6a450
2115-
StripeCore: ff6173a175acc7c4c25acc7cfabbade717dbc4de
2116-
StripeFinancialConnections: 34a90401657135130fe5bfd93db5ac27c001ec65
2117-
StripePayments: 9efe7bd14cae1821dba13997e12e070dfb38610b
2118-
StripePaymentSheet: 1c04531a7eff2c721736fc7d433ee342a59fae0e
2119-
StripePaymentsUI: 1cd35149b88de69c3364b4d1d4bb28c653c7d626
2120-
StripeUICore: 539e667170d9c5c86c02a9c63f320d132c7c1b73
2112+
Stripe: 64849211528185870444d8ca696eeab40bdcacce
2113+
stripe-react-native: bc53c1a2eaf455bd9065b4dbe64c5a6707a4b2a9
2114+
StripeApplePay: 1e65bbf41e4844a02b0dff60cb56c8d37261e53d
2115+
StripeCore: 63f2337bceb55db0095c5e29a61cfad33a61963c
2116+
StripeFinancialConnections: 2b2b2c9c0ed71ad22a038b3a4caf73ca5128dae2
2117+
StripePayments: 7a994f28bedd16bc0e4eb9091d2811425adaa6af
2118+
StripePaymentSheet: 82477c8b000ba6446d2294106e3f4f96fc043ea8
2119+
StripePaymentsUI: 8302dfe8094abb32cd2e0998a5b601164216d9db
2120+
StripeUICore: defd03b91fd5fb2838c59284e697b8da9cef0db0
21212121
Yoga: afd04ff05ebe0121a00c468a8a3c8080221cb14c
21222122

21232123
PODFILE CHECKSUM: a2ed964678852d4cc306ff4add3e4fa90be77ea6

example/src/screens/PaymentSheetAppearance.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
import { Platform } from 'react-native';
2-
import type { PaymentSheet } from '@stripe/stripe-react-native';
2+
import {
3+
NavigationBarStyle,
4+
type PaymentSheet,
5+
} from '@stripe/stripe-react-native';
36

4-
const appearance: PaymentSheet.AppearanceParams = {
7+
const appearance: PaymentSheet.AppearanceParams = {};
8+
9+
const liquidGlassAppearance: PaymentSheet.AppearanceParams = {
10+
applyLiquidGlass: true,
11+
};
12+
13+
const liquidGlassNavigationOnlyAppearance: PaymentSheet.AppearanceParams = {
14+
navigationBarStyle: NavigationBarStyle.Glass,
15+
};
16+
17+
const customAppearance: PaymentSheet.AppearanceParams = {
518
font: {
619
scale: 1.1,
720
family: Platform.OS === 'android' ? 'macondoregular' : 'Macondo-Regular',
@@ -64,3 +77,9 @@ const appearance: PaymentSheet.AppearanceParams = {
6477
};
6578

6679
export default appearance;
80+
export {
81+
appearance,
82+
liquidGlassAppearance,
83+
liquidGlassNavigationOnlyAppearance,
84+
customAppearance,
85+
};

example/src/screens/PaymentsUICompleteScreen.tsx

Lines changed: 92 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,29 @@ import CustomerSessionSwitch from '../components/CustomerSessionSwitch';
1919
import PaymentScreen from '../components/PaymentScreen';
2020
import { API_URL } from '../Config';
2121
import { getClientSecretParams } from '../helpers';
22-
import appearance from './PaymentSheetAppearance';
22+
import {
23+
appearance,
24+
liquidGlassAppearance,
25+
liquidGlassNavigationOnlyAppearance,
26+
customAppearance,
27+
} from './PaymentSheetAppearance';
28+
import { Platform, View, Text, TouchableOpacity } from 'react-native';
29+
30+
enum AppearanceSettings {
31+
default = `default`,
32+
glass = 'glass',
33+
glassNavigation = 'glassNavigation',
34+
custom = 'custom',
35+
}
2336

2437
export default function PaymentsUICompleteScreen() {
2538
const { initPaymentSheet, presentPaymentSheet, resetPaymentSheetCustomer } =
2639
useStripe();
2740
const [paymentSheetEnabled, setPaymentSheetEnabled] = useState(false);
2841
const [loading, setLoading] = useState(false);
2942
const [addressSheetVisible, setAddressSheetVisible] = useState(false);
43+
const [appearanceSettings, setAppearanceSettings] =
44+
useState<AppearanceSettings>(AppearanceSettings.default);
3045
const [clientSecret, setClientSecret] = useState<string>();
3146

3247
const [customerKeyType, setCustomerKeyType] = useState<string>(
@@ -63,7 +78,6 @@ export default function PaymentsUICompleteScreen() {
6378
};
6479
}
6580
};
66-
6781
const openPaymentSheet = async () => {
6882
if (!clientSecret) {
6983
return;
@@ -99,6 +113,19 @@ export default function PaymentsUICompleteScreen() {
99113
setLoading(false);
100114
};
101115

116+
const getAppearanceForSetting = (setting: AppearanceSettings) => {
117+
switch (setting) {
118+
case AppearanceSettings.default:
119+
return appearance;
120+
case AppearanceSettings.glass:
121+
return liquidGlassAppearance;
122+
case AppearanceSettings.glassNavigation:
123+
return liquidGlassNavigationOnlyAppearance;
124+
case AppearanceSettings.custom:
125+
return customAppearance;
126+
}
127+
};
128+
102129
const initialisePaymentSheet = useCallback(
103130
async (shippingDetails?: AddressDetails) => {
104131
const { paymentIntent, customer, ...remainingParams } =
@@ -139,7 +166,7 @@ export default function PaymentsUICompleteScreen() {
139166
defaultBillingDetails: billingDetails,
140167
defaultShippingDetails: shippingDetails,
141168
allowsDelayedPaymentMethods: true,
142-
appearance,
169+
appearance: getAppearanceForSetting(appearanceSettings),
143170
primaryButtonLabel: 'purchase!',
144171
paymentMethodLayout: PaymentMethodLayout.Automatic,
145172
removeSavedPaymentMethodMessage: 'remove this payment method?',
@@ -206,7 +233,7 @@ export default function PaymentsUICompleteScreen() {
206233
);
207234
}
208235
},
209-
[customerKeyType, initPaymentSheet]
236+
[customerKeyType, appearanceSettings, initPaymentSheet]
210237
);
211238

212239
const toggleCustomerKeyType = (value: boolean) => {
@@ -242,6 +269,67 @@ export default function PaymentsUICompleteScreen() {
242269
onValueChange={toggleCustomerKeyType}
243270
value={customerKeyType === 'customer_session'}
244271
/>
272+
{Platform.OS === 'ios' && (
273+
<View style={{ marginVertical: 10 }}>
274+
<Text style={{ marginBottom: 8, fontWeight: '500', marginLeft: 10 }}>
275+
Appearance Style
276+
</Text>
277+
<View
278+
style={{
279+
flexDirection: 'row',
280+
borderRadius: 8,
281+
borderWidth: 1,
282+
borderColor: '#ccc',
283+
overflow: 'hidden',
284+
}}
285+
>
286+
{[
287+
{ title: 'Default', value: AppearanceSettings.default },
288+
{ title: 'Glass', value: AppearanceSettings.glass },
289+
{ title: 'Glass Nav', value: AppearanceSettings.glassNavigation },
290+
{ title: 'Custom', value: AppearanceSettings.custom },
291+
].map((option) => (
292+
<TouchableOpacity
293+
key={option.title}
294+
style={{
295+
flex: 1,
296+
padding: 10,
297+
backgroundColor:
298+
appearanceSettings === option.value
299+
? '#007AFF'
300+
: 'transparent',
301+
alignItems: 'center',
302+
}}
303+
onPress={() => {
304+
setAppearanceSettings(option.value);
305+
(async () => {
306+
setLoading(true);
307+
try {
308+
await initialisePaymentSheet();
309+
} catch (error) {
310+
console.error('Error initializing payment sheet:', error);
311+
} finally {
312+
setLoading(false);
313+
}
314+
})();
315+
}}
316+
>
317+
<Text
318+
style={{
319+
fontSize: 13,
320+
color:
321+
appearanceSettings === option.value ? 'white' : '#333',
322+
fontWeight:
323+
appearanceSettings === option.value ? '600' : 'normal',
324+
}}
325+
>
326+
{option.title}
327+
</Text>
328+
</TouchableOpacity>
329+
))}
330+
</View>
331+
</View>
332+
)}
245333
<Button
246334
variant="primary"
247335
loading={loading}

ios/PaymentSheetAppearance.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@ internal class PaymentSheetAppearance {
1111
var appearance = PaymentSheet.Appearance()
1212
guard let userParams = userParams else { return appearance }
1313

14+
if #available(iOS 26.0, *), let applyLiquidGlass = userParams[PaymentSheetAppearanceKeys.APPLY_LIQUID_GLASS] as? Bool,
15+
applyLiquidGlass {
16+
appearance.applyLiquidGlass()
17+
}
18+
19+
if #available(iOS 26.0, *), let navigationBarStyle = userParams[PaymentSheetAppearanceKeys.NAVIGATION_BAR_STYLE] as? String {
20+
if navigationBarStyle == "plain" {
21+
appearance.navigationBarStyle = .plain
22+
} else if navigationBarStyle == "glass" {
23+
appearance.navigationBarStyle = .glass
24+
}
25+
}
26+
1427
if let fontParams = userParams[PaymentSheetAppearanceKeys.FONT] as? NSDictionary {
1528
appearance.font = try buildFont(params: fontParams)
1629
}
@@ -426,6 +439,8 @@ private struct PaymentSheetAppearanceKeys {
426439
static let BLUR_RADIUS = "blurRadius"
427440
static let X = "x"
428441
static let Y = "y"
442+
static let APPLY_LIQUID_GLASS = "applyLiquidGlass"
443+
static let NAVIGATION_BAR_STYLE = "navigationBarStyle"
429444

430445
static let PRIMARY_BUTTON = "primaryButton"
431446
static let TEXT = "text"

0 commit comments

Comments
 (0)