@dubsdotapp/expo 0.5.7 → 0.5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dubsdotapp/expo",
3
- "version": "0.5.7",
3
+ "version": "0.5.8",
4
4
  "description": "React Native SDK for the Dubs betting platform",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
package/src/index.ts CHANGED
@@ -134,7 +134,8 @@ export { AuthGate, ConnectWalletScreen, ConnectWalletButton, UserProfileCard, Se
134
134
  export type { AuthGateProps, RegistrationScreenProps, ConnectWalletScreenProps, ConnectWalletButtonProps, AuthGateConnectWalletProps, UserProfileCardProps, SettingsSheetProps, UserProfileSheetProps, DubsTheme } from './ui';
135
135
 
136
136
  // Game widgets
137
- export { GamePoster, LivePoolsCard, PickWinnerCard, PlayersCard, JoinGameButton, CreateCustomGameSheet, JoinGameSheet, ClaimPrizeSheet, ClaimButton, EnterArcadePoolSheet, ArcadeLeaderboardSheet } from './ui';
137
+ export { GamePoster, LivePoolsCard, PickWinnerCard, PlayersCard, JoinGameButton, CreateCustomGameSheet, JoinGameSheet, ClaimPrizeSheet, ClaimButton, EnterArcadePoolSheet, ArcadeLeaderboardSheet, SolSlider } from './ui';
138
+ export type { SolSliderProps } from './ui';
138
139
  export type {
139
140
  GamePosterProps,
140
141
  LivePoolsCardProps,
@@ -16,6 +16,7 @@ import { useDubs } from '../../provider';
16
16
  import { useJoinGame } from '../../hooks/useJoinGame';
17
17
  import type { JoinGameMutationResult } from '../../hooks/useJoinGame';
18
18
  import type { GameDetail } from '../../types';
19
+ import { SolSlider } from './SolSlider';
19
20
 
20
21
  export interface JoinGameSheetProps {
21
22
  visible: boolean;
@@ -35,6 +36,10 @@ export interface JoinGameSheetProps {
35
36
  onTeamSelect?: (team: 'home' | 'away') => void;
36
37
  /** Called when the join succeeds (useful for success sound/animation) */
37
38
  onJoinSuccess?: (result: JoinGameMutationResult) => void;
39
+ /** Called on each slider tick (useful for haptics/sound) */
40
+ onSliderTick?: (value: number) => void;
41
+ /** Max wager in SOL (default 5) */
42
+ maxWager?: number;
38
43
  /** Pool mode: hides team selection, auto-assigns team, shows "Join Pool" labels */
39
44
  isPoolModeEnabled?: boolean;
40
45
  }
@@ -70,6 +75,8 @@ export function JoinGameSheet({
70
75
  onError,
71
76
  onTeamSelect,
72
77
  onJoinSuccess,
78
+ onSliderTick,
79
+ maxWager = 5,
73
80
  isPoolModeEnabled = false,
74
81
  }: JoinGameSheetProps) {
75
82
  const t = useDubsTheme();
@@ -79,6 +86,7 @@ export function JoinGameSheet({
79
86
  const isCustomGame = game.gameMode === CUSTOM_GAME_MODE;
80
87
 
81
88
  const [selectedTeam, setSelectedTeam] = useState<'home' | 'away' | null>(null);
89
+ const [wager, setWager] = useState(game.buyIn);
82
90
  const [showSuccess, setShowSuccess] = useState(false);
83
91
 
84
92
  const overlayOpacity = useRef(new Animated.Value(0)).current;
@@ -98,6 +106,7 @@ export function JoinGameSheet({
98
106
  useEffect(() => {
99
107
  if (visible) {
100
108
  setSelectedTeam(isPoolModeEnabled ? 'home' : isCustomGame ? 'away' : null);
109
+ setWager(game.buyIn);
101
110
  setShowSuccess(false);
102
111
  successScale.setValue(0);
103
112
  successOpacity.setValue(0);
@@ -143,16 +152,20 @@ export function JoinGameSheet({
143
152
  const awayPool = game.awayPool || 0;
144
153
  const buyIn = game.buyIn;
145
154
 
146
- const { homeOdds, awayOdds, homeBets, awayBets } = useMemo(() => ({
147
- homeOdds: homePool > 0 ? (totalPool / homePool).toFixed(2) : '—',
148
- awayOdds: awayPool > 0 ? (totalPool / awayPool).toFixed(2) : '—',
149
- homeBets: bettors.filter(b => b.team === 'home').length,
150
- awayBets: bettors.filter(b => b.team === 'away').length,
151
- }), [totalPool, homePool, awayPool, bettors]);
155
+ const poolAfterJoin = totalPool + wager;
156
+
157
+ const { homeOdds, awayOdds, homeBets, awayBets } = useMemo(() => {
158
+ const newPool = totalPool + wager;
159
+ return {
160
+ homeOdds: homePool > 0 ? (newPool / (homePool + (selectedTeam === 'home' ? wager : 0))).toFixed(2) : '—',
161
+ awayOdds: awayPool > 0 ? (newPool / (awayPool + (selectedTeam === 'away' ? wager : 0))).toFixed(2) : '—',
162
+ homeBets: bettors.filter(b => b.team === 'home').length,
163
+ awayBets: bettors.filter(b => b.team === 'away').length,
164
+ };
165
+ }, [totalPool, homePool, awayPool, bettors, wager, selectedTeam]);
152
166
 
153
- const poolAfterJoin = totalPool + buyIn;
154
167
  const selectedOdds = selectedTeam === 'home' ? homeOdds : selectedTeam === 'away' ? awayOdds : '—';
155
- const potentialWinnings = selectedOdds !== '—' ? formatSol(parseFloat(selectedOdds) * buyIn) : '—';
168
+ const potentialWinnings = selectedOdds !== '—' ? formatSol(parseFloat(selectedOdds) * wager) : '—';
156
169
 
157
170
  const homeName = shortName ? shortName(opponents[0]?.name) : (opponents[0]?.name || 'Home');
158
171
  const awayName = shortName ? shortName(opponents[1]?.name) : (opponents[1]?.name || 'Away');
@@ -175,12 +188,12 @@ export function JoinGameSheet({
175
188
  playerWallet: wallet.publicKey.toBase58(),
176
189
  gameId: game.gameId,
177
190
  teamChoice: selectedTeam,
178
- amount: buyIn,
191
+ amount: wager,
179
192
  });
180
193
  } catch {
181
194
  // Error is already captured in mutation state
182
195
  }
183
- }, [selectedTeam, wallet.publicKey, mutation.execute, game.gameId, buyIn]); // eslint-disable-line react-hooks/exhaustive-deps
196
+ }, [selectedTeam, wallet.publicKey, mutation.execute, game.gameId, wager]); // eslint-disable-line react-hooks/exhaustive-deps
184
197
 
185
198
  const statusLabel = STATUS_LABELS[mutation.status] || '';
186
199
 
@@ -286,11 +299,26 @@ export function JoinGameSheet({
286
299
  </View>
287
300
  )}
288
301
 
302
+ {/* SOL Slider */}
303
+ {selectedTeam && !isPoolModeEnabled && (
304
+ <View style={styles.sliderSection}>
305
+ <SolSlider
306
+ value={wager}
307
+ min={game.buyIn}
308
+ max={maxWager}
309
+ step={0.01}
310
+ accentColor={selectedTeam === 'home' ? homeColor : awayColor}
311
+ onValueChange={setWager}
312
+ onTick={onSliderTick}
313
+ />
314
+ </View>
315
+ )}
316
+
289
317
  {/* Summary Card */}
290
318
  <View style={[styles.summaryCard, { backgroundColor: t.surface, borderColor: t.border }]}>
291
319
  <View style={styles.summaryRow}>
292
- <Text style={[styles.summaryLabel, { color: t.textMuted }]}>Buy-in</Text>
293
- <Text style={[styles.summaryValue, { color: t.text }]}>{formatSol(buyIn)} SOL</Text>
320
+ <Text style={[styles.summaryLabel, { color: t.textMuted }]}>Your wager</Text>
321
+ <Text style={[styles.summaryValue, { color: t.text }]}>{formatSol(wager)} SOL</Text>
294
322
  </View>
295
323
  <View style={[styles.summarySep, { backgroundColor: t.border }]} />
296
324
  {isPoolModeEnabled ? (
@@ -363,9 +391,9 @@ export function JoinGameSheet({
363
391
  {alreadyJoined
364
392
  ? 'Already Joined'
365
393
  : isPoolModeEnabled
366
- ? `Join Pool \u2014 ${formatSol(buyIn)} SOL`
394
+ ? `Join Pool \u2014 ${formatSol(wager)} SOL`
367
395
  : selectedTeam
368
- ? `Join Game \u2014 ${formatSol(buyIn)} SOL`
396
+ ? `Join Game \u2014 ${formatSol(wager)} SOL`
369
397
  : 'Pick a side to join'}
370
398
  </Text>
371
399
  )}
@@ -535,8 +563,11 @@ const styles = StyleSheet.create({
535
563
  flexDirection: 'row',
536
564
  gap: 12,
537
565
  },
566
+ sliderSection: {
567
+ marginTop: 16,
568
+ },
538
569
  summaryCard: {
539
- marginTop: 20,
570
+ marginTop: 12,
540
571
  borderRadius: 16,
541
572
  borderWidth: 1,
542
573
  overflow: 'hidden',
@@ -0,0 +1,259 @@
1
+ import React, { useRef, useCallback } from 'react';
2
+ import {
3
+ View,
4
+ Text,
5
+ StyleSheet,
6
+ PanResponder,
7
+ Dimensions,
8
+ Platform,
9
+ } from 'react-native';
10
+ import { useDubsTheme } from '../theme';
11
+
12
+ const THUMB_SIZE = 32;
13
+ const TRACK_HEIGHT = 6;
14
+ const TICK_INTERVAL = 0.01; // haptic every 0.01 SOL
15
+
16
+ export interface SolSliderProps {
17
+ /** Current value in SOL */
18
+ value: number;
19
+ /** Min SOL (default 0.01) */
20
+ min?: number;
21
+ /** Max SOL (default 5) */
22
+ max?: number;
23
+ /** Step size in SOL (default 0.01) */
24
+ step?: number;
25
+ /** Accent color for filled track + thumb glow */
26
+ accentColor?: string;
27
+ /** Called on every drag frame */
28
+ onValueChange: (value: number) => void;
29
+ /** Called when user lifts finger */
30
+ onSlidingComplete?: (value: number) => void;
31
+ /** Called on each tick for haptics/sound */
32
+ onTick?: (value: number) => void;
33
+ /** Disabled state */
34
+ disabled?: boolean;
35
+ }
36
+
37
+ export function SolSlider({
38
+ value,
39
+ min = 0.01,
40
+ max = 5,
41
+ step = 0.01,
42
+ accentColor,
43
+ onValueChange,
44
+ onSlidingComplete,
45
+ onTick,
46
+ disabled = false,
47
+ }: SolSliderProps) {
48
+ const t = useDubsTheme();
49
+ const accent = accentColor || t.accent;
50
+ const trackRef = useRef<View>(null);
51
+ const trackWidth = useRef(0);
52
+ const lastTickValue = useRef(value);
53
+
54
+ const clamp = (v: number) => {
55
+ const stepped = Math.round(v / step) * step;
56
+ return Math.max(min, Math.min(max, parseFloat(stepped.toFixed(4))));
57
+ };
58
+
59
+ const valueToPosition = (v: number) => {
60
+ const ratio = (v - min) / (max - min);
61
+ return ratio * trackWidth.current;
62
+ };
63
+
64
+ const positionToValue = (x: number) => {
65
+ const ratio = Math.max(0, Math.min(1, x / trackWidth.current));
66
+ return clamp(min + ratio * (max - min));
67
+ };
68
+
69
+ const panResponder = useRef(
70
+ PanResponder.create({
71
+ onStartShouldSetPanResponder: () => !disabled,
72
+ onMoveShouldSetPanResponder: () => !disabled,
73
+ onPanResponderGrant: (_, gestureState) => {
74
+ lastTickValue.current = value;
75
+ },
76
+ onPanResponderMove: (evt, gestureState) => {
77
+ // Calculate position relative to track
78
+ const touchX = gestureState.moveX;
79
+ trackRef.current?.measureInWindow((trackX) => {
80
+ const relX = touchX - trackX;
81
+ const newVal = positionToValue(relX);
82
+
83
+ // Fire tick if we crossed a tick boundary
84
+ const tickDelta = Math.abs(newVal - lastTickValue.current);
85
+ if (tickDelta >= TICK_INTERVAL) {
86
+ lastTickValue.current = newVal;
87
+ onTick?.(newVal);
88
+ }
89
+
90
+ onValueChange(newVal);
91
+ });
92
+ },
93
+ onPanResponderRelease: () => {
94
+ onSlidingComplete?.(value);
95
+ },
96
+ })
97
+ ).current;
98
+
99
+ const ratio = (value - min) / (max - min);
100
+ const filledWidth = `${ratio * 100}%`;
101
+
102
+ // Snap points for visual markers
103
+ const markers = [min, max * 0.25, max * 0.5, max * 0.75, max];
104
+
105
+ return (
106
+ <View style={styles.container}>
107
+ {/* Value display */}
108
+ <View style={styles.valueRow}>
109
+ <Text style={[styles.valueText, { color: accent }]}>
110
+ {parseFloat(value.toFixed(4))}
111
+ </Text>
112
+ <Text style={[styles.solLabel, { color: accent }]}>SOL</Text>
113
+ </View>
114
+
115
+ {/* Track */}
116
+ <View
117
+ ref={trackRef}
118
+ style={styles.trackContainer}
119
+ onLayout={(e) => { trackWidth.current = e.nativeEvent.layout.width; }}
120
+ {...panResponder.panHandlers}
121
+ >
122
+ {/* Background track */}
123
+ <View style={[styles.track, { backgroundColor: '#2C2C2E' }]}>
124
+ {/* Filled track */}
125
+ <View style={[styles.trackFilled, { width: filledWidth as any, backgroundColor: accent }]} />
126
+ </View>
127
+
128
+ {/* Tick markers */}
129
+ <View style={styles.markerRow}>
130
+ {markers.map((m, i) => {
131
+ const mRatio = (m - min) / (max - min);
132
+ return (
133
+ <View
134
+ key={i}
135
+ style={[
136
+ styles.marker,
137
+ {
138
+ left: `${mRatio * 100}%`,
139
+ backgroundColor: value >= m ? accent : '#3A3A3C',
140
+ },
141
+ ]}
142
+ />
143
+ );
144
+ })}
145
+ </View>
146
+
147
+ {/* Thumb */}
148
+ <View
149
+ style={[
150
+ styles.thumb,
151
+ {
152
+ left: filledWidth as any,
153
+ backgroundColor: accent,
154
+ shadowColor: accent,
155
+ },
156
+ ]}
157
+ >
158
+ <View style={styles.thumbInner} />
159
+ </View>
160
+ </View>
161
+
162
+ {/* Min/Max labels */}
163
+ <View style={styles.rangeRow}>
164
+ <Text style={styles.rangeText}>{min}</Text>
165
+ <Text style={styles.rangeText}>{max} SOL</Text>
166
+ </View>
167
+ </View>
168
+ );
169
+ }
170
+
171
+ const styles = StyleSheet.create({
172
+ container: {
173
+ paddingVertical: 8,
174
+ },
175
+ valueRow: {
176
+ flexDirection: 'row',
177
+ alignItems: 'baseline',
178
+ justifyContent: 'center',
179
+ marginBottom: 16,
180
+ gap: 4,
181
+ },
182
+ valueText: {
183
+ fontSize: 36,
184
+ fontWeight: '900',
185
+ letterSpacing: -1,
186
+ fontVariant: ['tabular-nums'],
187
+ },
188
+ solLabel: {
189
+ fontSize: 16,
190
+ fontWeight: '700',
191
+ opacity: 0.6,
192
+ },
193
+ trackContainer: {
194
+ height: THUMB_SIZE + 16,
195
+ justifyContent: 'center',
196
+ paddingHorizontal: THUMB_SIZE / 2,
197
+ },
198
+ track: {
199
+ height: TRACK_HEIGHT,
200
+ borderRadius: TRACK_HEIGHT / 2,
201
+ overflow: 'hidden',
202
+ },
203
+ trackFilled: {
204
+ height: '100%',
205
+ borderRadius: TRACK_HEIGHT / 2,
206
+ },
207
+ markerRow: {
208
+ position: 'absolute',
209
+ left: THUMB_SIZE / 2,
210
+ right: THUMB_SIZE / 2,
211
+ height: TRACK_HEIGHT,
212
+ top: (THUMB_SIZE + 16 - TRACK_HEIGHT) / 2,
213
+ },
214
+ marker: {
215
+ position: 'absolute',
216
+ width: 3,
217
+ height: 12,
218
+ borderRadius: 1.5,
219
+ top: -3,
220
+ marginLeft: -1.5,
221
+ },
222
+ thumb: {
223
+ position: 'absolute',
224
+ width: THUMB_SIZE,
225
+ height: THUMB_SIZE,
226
+ borderRadius: THUMB_SIZE / 2,
227
+ top: 8,
228
+ marginLeft: 0,
229
+ alignItems: 'center',
230
+ justifyContent: 'center',
231
+ ...Platform.select({
232
+ ios: {
233
+ shadowOffset: { width: 0, height: 0 },
234
+ shadowOpacity: 0.6,
235
+ shadowRadius: 10,
236
+ },
237
+ android: {
238
+ elevation: 8,
239
+ },
240
+ }),
241
+ },
242
+ thumbInner: {
243
+ width: 12,
244
+ height: 12,
245
+ borderRadius: 6,
246
+ backgroundColor: '#FFFFFF',
247
+ },
248
+ rangeRow: {
249
+ flexDirection: 'row',
250
+ justifyContent: 'space-between',
251
+ paddingHorizontal: THUMB_SIZE / 2,
252
+ marginTop: 4,
253
+ },
254
+ rangeText: {
255
+ color: '#5A5A5E',
256
+ fontSize: 11,
257
+ fontWeight: '600',
258
+ },
259
+ });
@@ -20,3 +20,5 @@ export { EnterArcadePoolSheet } from './EnterArcadePoolSheet';
20
20
  export type { EnterArcadePoolSheetProps } from './EnterArcadePoolSheet';
21
21
  export { ArcadeLeaderboardSheet } from './ArcadeLeaderboardSheet';
22
22
  export type { ArcadeLeaderboardSheetProps } from './ArcadeLeaderboardSheet';
23
+ export { SolSlider } from './SolSlider';
24
+ export type { SolSliderProps } from './SolSlider';
package/src/ui/index.ts CHANGED
@@ -14,7 +14,7 @@ export { useDubsTheme, mergeTheme } from './theme';
14
14
  export type { DubsTheme } from './theme';
15
15
 
16
16
  // Game widgets
17
- export { GamePoster, LivePoolsCard, PickWinnerCard, PlayersCard, JoinGameButton, CreateCustomGameSheet, JoinGameSheet, ClaimPrizeSheet, ClaimButton, EnterArcadePoolSheet, ArcadeLeaderboardSheet } from './game';
17
+ export { GamePoster, LivePoolsCard, PickWinnerCard, PlayersCard, JoinGameButton, CreateCustomGameSheet, JoinGameSheet, ClaimPrizeSheet, ClaimButton, EnterArcadePoolSheet, ArcadeLeaderboardSheet, SolSlider } from './game';
18
18
  export type {
19
19
  GamePosterProps,
20
20
  LivePoolsCardProps,
@@ -27,4 +27,5 @@ export type {
27
27
  ClaimButtonProps,
28
28
  EnterArcadePoolSheetProps,
29
29
  ArcadeLeaderboardSheetProps,
30
+ SolSliderProps,
30
31
  } from './game';