@dubsdotapp/expo 0.2.55 → 0.2.56
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/dist/index.d.mts +18 -1
- package/dist/index.d.ts +18 -1
- package/dist/index.js +722 -302
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +758 -327
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +11 -0
- package/src/index.ts +2 -2
- package/src/ui/UserProfileSheet.tsx +478 -0
- package/src/ui/index.ts +2 -0
package/dist/index.mjs
CHANGED
|
@@ -474,6 +474,15 @@ var DubsClient = class {
|
|
|
474
474
|
{ token }
|
|
475
475
|
);
|
|
476
476
|
}
|
|
477
|
+
// ── Profile ──
|
|
478
|
+
async updateProfile(params) {
|
|
479
|
+
const res = await this.request(
|
|
480
|
+
"PATCH",
|
|
481
|
+
"/auth/profile",
|
|
482
|
+
params
|
|
483
|
+
);
|
|
484
|
+
return res.data.user;
|
|
485
|
+
}
|
|
477
486
|
// ── Error Utilities ──
|
|
478
487
|
async parseError(error) {
|
|
479
488
|
const res = await this.request(
|
|
@@ -3437,10 +3446,431 @@ var styles3 = StyleSheet4.create({
|
|
|
3437
3446
|
}
|
|
3438
3447
|
});
|
|
3439
3448
|
|
|
3440
|
-
// src/ui/
|
|
3441
|
-
import { useState as useState17 } from "react";
|
|
3442
|
-
import {
|
|
3449
|
+
// src/ui/UserProfileSheet.tsx
|
|
3450
|
+
import { useState as useState17, useEffect as useEffect11, useRef as useRef5, useCallback as useCallback16, useMemo as useMemo4 } from "react";
|
|
3451
|
+
import {
|
|
3452
|
+
View as View5,
|
|
3453
|
+
Text as Text5,
|
|
3454
|
+
TouchableOpacity as TouchableOpacity4,
|
|
3455
|
+
ActivityIndicator as ActivityIndicator4,
|
|
3456
|
+
Modal,
|
|
3457
|
+
Animated as Animated2,
|
|
3458
|
+
StyleSheet as StyleSheet5,
|
|
3459
|
+
KeyboardAvoidingView as KeyboardAvoidingView2,
|
|
3460
|
+
Platform as Platform5,
|
|
3461
|
+
Image as Image4,
|
|
3462
|
+
ScrollView as ScrollView3
|
|
3463
|
+
} from "react-native";
|
|
3443
3464
|
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
3465
|
+
var DICEBEAR_STYLES2 = [
|
|
3466
|
+
"adventurer",
|
|
3467
|
+
"avataaars",
|
|
3468
|
+
"fun-emoji",
|
|
3469
|
+
"bottts",
|
|
3470
|
+
"big-smile",
|
|
3471
|
+
"thumbs"
|
|
3472
|
+
];
|
|
3473
|
+
function generateSeed2() {
|
|
3474
|
+
return Math.random().toString(36).slice(2, 10);
|
|
3475
|
+
}
|
|
3476
|
+
function getAvatarUrl2(style, seed, size = 256) {
|
|
3477
|
+
return `https://api.dicebear.com/9.x/${style}/png?seed=${seed}&size=${size}`;
|
|
3478
|
+
}
|
|
3479
|
+
function parseAvatarUrl(url) {
|
|
3480
|
+
if (!url) return { style: "adventurer", seed: generateSeed2() };
|
|
3481
|
+
try {
|
|
3482
|
+
const match = url.match(/\/9\.x\/([^/]+)\/png\?seed=([^&]+)/);
|
|
3483
|
+
if (match) return { style: match[1], seed: match[2] };
|
|
3484
|
+
} catch {
|
|
3485
|
+
}
|
|
3486
|
+
return { style: "adventurer", seed: generateSeed2() };
|
|
3487
|
+
}
|
|
3488
|
+
function truncateAddress3(address, chars = 4) {
|
|
3489
|
+
if (address.length <= chars * 2 + 3) return address;
|
|
3490
|
+
return `${address.slice(0, chars)}...${address.slice(-chars)}`;
|
|
3491
|
+
}
|
|
3492
|
+
function UserProfileSheet({
|
|
3493
|
+
visible,
|
|
3494
|
+
onDismiss,
|
|
3495
|
+
user,
|
|
3496
|
+
onAvatarUpdated,
|
|
3497
|
+
onDisconnect
|
|
3498
|
+
}) {
|
|
3499
|
+
const t = useDubsTheme();
|
|
3500
|
+
const { client } = useDubs();
|
|
3501
|
+
const push = usePushNotifications();
|
|
3502
|
+
const overlayOpacity = useRef5(new Animated2.Value(0)).current;
|
|
3503
|
+
const parsed = useMemo4(() => parseAvatarUrl(user.avatar), [user.avatar]);
|
|
3504
|
+
const [avatarStyle, setAvatarStyle] = useState17(parsed.style);
|
|
3505
|
+
const [avatarSeed, setAvatarSeed] = useState17(parsed.seed);
|
|
3506
|
+
const [saving, setSaving] = useState17(false);
|
|
3507
|
+
const [error, setError] = useState17(null);
|
|
3508
|
+
useEffect11(() => {
|
|
3509
|
+
const p = parseAvatarUrl(user.avatar);
|
|
3510
|
+
setAvatarStyle(p.style);
|
|
3511
|
+
setAvatarSeed(p.seed);
|
|
3512
|
+
}, [user.avatar]);
|
|
3513
|
+
useEffect11(() => {
|
|
3514
|
+
Animated2.timing(overlayOpacity, {
|
|
3515
|
+
toValue: visible ? 1 : 0,
|
|
3516
|
+
duration: 250,
|
|
3517
|
+
useNativeDriver: true
|
|
3518
|
+
}).start();
|
|
3519
|
+
}, [visible, overlayOpacity]);
|
|
3520
|
+
useEffect11(() => {
|
|
3521
|
+
if (visible) setError(null);
|
|
3522
|
+
}, [visible]);
|
|
3523
|
+
const currentAvatarUrl = getAvatarUrl2(avatarStyle, avatarSeed);
|
|
3524
|
+
const handleSelectStyle = useCallback16(
|
|
3525
|
+
async (style) => {
|
|
3526
|
+
const newUrl = getAvatarUrl2(style, avatarSeed);
|
|
3527
|
+
setAvatarStyle(style);
|
|
3528
|
+
setSaving(true);
|
|
3529
|
+
setError(null);
|
|
3530
|
+
try {
|
|
3531
|
+
await client.updateProfile({ avatar: newUrl });
|
|
3532
|
+
onAvatarUpdated?.(newUrl);
|
|
3533
|
+
} catch (err) {
|
|
3534
|
+
setError(err instanceof Error ? err.message : "Failed to update avatar");
|
|
3535
|
+
} finally {
|
|
3536
|
+
setSaving(false);
|
|
3537
|
+
}
|
|
3538
|
+
},
|
|
3539
|
+
[avatarSeed, client, onAvatarUpdated]
|
|
3540
|
+
);
|
|
3541
|
+
const handleShuffle = useCallback16(async () => {
|
|
3542
|
+
const newSeed = generateSeed2();
|
|
3543
|
+
const newUrl = getAvatarUrl2(avatarStyle, newSeed);
|
|
3544
|
+
setAvatarSeed(newSeed);
|
|
3545
|
+
setSaving(true);
|
|
3546
|
+
setError(null);
|
|
3547
|
+
try {
|
|
3548
|
+
await client.updateProfile({ avatar: newUrl });
|
|
3549
|
+
onAvatarUpdated?.(newUrl);
|
|
3550
|
+
} catch (err) {
|
|
3551
|
+
setError(err instanceof Error ? err.message : "Failed to update avatar");
|
|
3552
|
+
} finally {
|
|
3553
|
+
setSaving(false);
|
|
3554
|
+
}
|
|
3555
|
+
}, [avatarStyle, client, onAvatarUpdated]);
|
|
3556
|
+
return /* @__PURE__ */ jsxs5(
|
|
3557
|
+
Modal,
|
|
3558
|
+
{
|
|
3559
|
+
visible,
|
|
3560
|
+
animationType: "slide",
|
|
3561
|
+
transparent: true,
|
|
3562
|
+
onRequestClose: onDismiss,
|
|
3563
|
+
children: [
|
|
3564
|
+
/* @__PURE__ */ jsx7(Animated2.View, { style: [styles4.overlay, { opacity: overlayOpacity }], children: /* @__PURE__ */ jsx7(TouchableOpacity4, { style: styles4.overlayTap, activeOpacity: 1, onPress: onDismiss }) }),
|
|
3565
|
+
/* @__PURE__ */ jsx7(
|
|
3566
|
+
KeyboardAvoidingView2,
|
|
3567
|
+
{
|
|
3568
|
+
style: styles4.keyboardView,
|
|
3569
|
+
behavior: Platform5.OS === "ios" ? "padding" : void 0,
|
|
3570
|
+
children: /* @__PURE__ */ jsx7(View5, { style: styles4.sheetPositioner, children: /* @__PURE__ */ jsxs5(View5, { style: [styles4.sheet, { backgroundColor: t.background }], children: [
|
|
3571
|
+
/* @__PURE__ */ jsx7(View5, { style: styles4.handleRow, children: /* @__PURE__ */ jsx7(View5, { style: [styles4.handle, { backgroundColor: t.textMuted }] }) }),
|
|
3572
|
+
/* @__PURE__ */ jsxs5(View5, { style: styles4.header, children: [
|
|
3573
|
+
/* @__PURE__ */ jsx7(Text5, { style: [styles4.headerTitle, { color: t.text }], children: "Profile" }),
|
|
3574
|
+
/* @__PURE__ */ jsx7(TouchableOpacity4, { onPress: onDismiss, activeOpacity: 0.8, children: /* @__PURE__ */ jsx7(Text5, { style: [styles4.closeButton, { color: t.textMuted }], children: "\u2715" }) })
|
|
3575
|
+
] }),
|
|
3576
|
+
/* @__PURE__ */ jsxs5(
|
|
3577
|
+
ScrollView3,
|
|
3578
|
+
{
|
|
3579
|
+
style: styles4.scrollContent,
|
|
3580
|
+
contentContainerStyle: styles4.scrollContentInner,
|
|
3581
|
+
showsVerticalScrollIndicator: false,
|
|
3582
|
+
bounces: false,
|
|
3583
|
+
children: [
|
|
3584
|
+
/* @__PURE__ */ jsxs5(View5, { style: styles4.avatarSection, children: [
|
|
3585
|
+
/* @__PURE__ */ jsxs5(View5, { style: [styles4.avatarContainer, { borderColor: t.border }], children: [
|
|
3586
|
+
/* @__PURE__ */ jsx7(
|
|
3587
|
+
Image4,
|
|
3588
|
+
{
|
|
3589
|
+
source: { uri: currentAvatarUrl },
|
|
3590
|
+
style: styles4.avatar
|
|
3591
|
+
}
|
|
3592
|
+
),
|
|
3593
|
+
saving && /* @__PURE__ */ jsx7(View5, { style: styles4.avatarLoading, children: /* @__PURE__ */ jsx7(ActivityIndicator4, { size: "small", color: "#FFFFFF" }) })
|
|
3594
|
+
] }),
|
|
3595
|
+
user.username ? /* @__PURE__ */ jsx7(Text5, { style: [styles4.username, { color: t.text }], children: user.username }) : null,
|
|
3596
|
+
/* @__PURE__ */ jsx7(Text5, { style: [styles4.walletAddress, { color: t.textMuted }], children: truncateAddress3(user.walletAddress, 6) })
|
|
3597
|
+
] }),
|
|
3598
|
+
/* @__PURE__ */ jsxs5(View5, { style: styles4.section, children: [
|
|
3599
|
+
/* @__PURE__ */ jsxs5(View5, { style: styles4.sectionHeaderRow, children: [
|
|
3600
|
+
/* @__PURE__ */ jsx7(Text5, { style: [styles4.sectionLabel, { color: t.textSecondary }], children: "Change Avatar" }),
|
|
3601
|
+
/* @__PURE__ */ jsx7(
|
|
3602
|
+
TouchableOpacity4,
|
|
3603
|
+
{
|
|
3604
|
+
style: [styles4.shuffleButton, { borderColor: t.border }],
|
|
3605
|
+
onPress: handleShuffle,
|
|
3606
|
+
activeOpacity: 0.7,
|
|
3607
|
+
disabled: saving,
|
|
3608
|
+
children: /* @__PURE__ */ jsx7(Text5, { style: [styles4.shuffleText, { color: t.accent }], children: "Shuffle" })
|
|
3609
|
+
}
|
|
3610
|
+
)
|
|
3611
|
+
] }),
|
|
3612
|
+
/* @__PURE__ */ jsx7(
|
|
3613
|
+
ScrollView3,
|
|
3614
|
+
{
|
|
3615
|
+
horizontal: true,
|
|
3616
|
+
showsHorizontalScrollIndicator: false,
|
|
3617
|
+
contentContainerStyle: styles4.stylePickerContent,
|
|
3618
|
+
children: DICEBEAR_STYLES2.map((style) => {
|
|
3619
|
+
const isSelected = style === avatarStyle;
|
|
3620
|
+
return /* @__PURE__ */ jsx7(
|
|
3621
|
+
TouchableOpacity4,
|
|
3622
|
+
{
|
|
3623
|
+
onPress: () => handleSelectStyle(style),
|
|
3624
|
+
activeOpacity: 0.7,
|
|
3625
|
+
disabled: saving,
|
|
3626
|
+
style: [
|
|
3627
|
+
styles4.styleTile,
|
|
3628
|
+
{
|
|
3629
|
+
borderColor: isSelected ? t.accent : t.border,
|
|
3630
|
+
borderWidth: isSelected ? 2 : 1
|
|
3631
|
+
}
|
|
3632
|
+
],
|
|
3633
|
+
children: /* @__PURE__ */ jsx7(
|
|
3634
|
+
Image4,
|
|
3635
|
+
{
|
|
3636
|
+
source: { uri: getAvatarUrl2(style, avatarSeed, 80) },
|
|
3637
|
+
style: styles4.styleTileImage
|
|
3638
|
+
}
|
|
3639
|
+
)
|
|
3640
|
+
},
|
|
3641
|
+
style
|
|
3642
|
+
);
|
|
3643
|
+
})
|
|
3644
|
+
}
|
|
3645
|
+
)
|
|
3646
|
+
] }),
|
|
3647
|
+
error ? /* @__PURE__ */ jsx7(View5, { style: [styles4.errorBox, { backgroundColor: t.errorBg, borderColor: t.errorBorder }], children: /* @__PURE__ */ jsx7(Text5, { style: [styles4.errorText, { color: t.errorText }], children: error }) }) : null,
|
|
3648
|
+
/* @__PURE__ */ jsxs5(View5, { style: [styles4.notifRow, { backgroundColor: t.surface, borderColor: t.border }], children: [
|
|
3649
|
+
/* @__PURE__ */ jsxs5(View5, { style: styles4.notifLeft, children: [
|
|
3650
|
+
/* @__PURE__ */ jsx7(Text5, { style: [styles4.notifLabel, { color: t.text }], children: "Push Notifications" }),
|
|
3651
|
+
/* @__PURE__ */ jsx7(
|
|
3652
|
+
Text5,
|
|
3653
|
+
{
|
|
3654
|
+
style: [
|
|
3655
|
+
styles4.notifStatus,
|
|
3656
|
+
{ color: push.hasPermission ? t.success : t.textMuted }
|
|
3657
|
+
],
|
|
3658
|
+
children: push.hasPermission ? "Enabled" : "Disabled"
|
|
3659
|
+
}
|
|
3660
|
+
)
|
|
3661
|
+
] }),
|
|
3662
|
+
!push.hasPermission && /* @__PURE__ */ jsx7(
|
|
3663
|
+
TouchableOpacity4,
|
|
3664
|
+
{
|
|
3665
|
+
style: [styles4.enableButton, { backgroundColor: t.accent }],
|
|
3666
|
+
onPress: push.register,
|
|
3667
|
+
disabled: push.loading,
|
|
3668
|
+
activeOpacity: 0.8,
|
|
3669
|
+
children: push.loading ? /* @__PURE__ */ jsx7(ActivityIndicator4, { size: "small", color: "#FFFFFF" }) : /* @__PURE__ */ jsx7(Text5, { style: styles4.enableText, children: "Enable" })
|
|
3670
|
+
}
|
|
3671
|
+
)
|
|
3672
|
+
] }),
|
|
3673
|
+
onDisconnect ? /* @__PURE__ */ jsx7(
|
|
3674
|
+
TouchableOpacity4,
|
|
3675
|
+
{
|
|
3676
|
+
style: [styles4.disconnectButton, { borderColor: t.live }],
|
|
3677
|
+
onPress: onDisconnect,
|
|
3678
|
+
activeOpacity: 0.7,
|
|
3679
|
+
children: /* @__PURE__ */ jsx7(Text5, { style: [styles4.disconnectText, { color: t.live }], children: "Disconnect Wallet" })
|
|
3680
|
+
}
|
|
3681
|
+
) : null
|
|
3682
|
+
]
|
|
3683
|
+
}
|
|
3684
|
+
)
|
|
3685
|
+
] }) })
|
|
3686
|
+
}
|
|
3687
|
+
)
|
|
3688
|
+
]
|
|
3689
|
+
}
|
|
3690
|
+
);
|
|
3691
|
+
}
|
|
3692
|
+
var styles4 = StyleSheet5.create({
|
|
3693
|
+
overlay: {
|
|
3694
|
+
...StyleSheet5.absoluteFillObject,
|
|
3695
|
+
backgroundColor: "rgba(0,0,0,0.5)"
|
|
3696
|
+
},
|
|
3697
|
+
overlayTap: {
|
|
3698
|
+
flex: 1
|
|
3699
|
+
},
|
|
3700
|
+
keyboardView: {
|
|
3701
|
+
flex: 1,
|
|
3702
|
+
justifyContent: "flex-end"
|
|
3703
|
+
},
|
|
3704
|
+
sheetPositioner: {
|
|
3705
|
+
justifyContent: "flex-end"
|
|
3706
|
+
},
|
|
3707
|
+
sheet: {
|
|
3708
|
+
borderTopLeftRadius: 24,
|
|
3709
|
+
borderTopRightRadius: 24,
|
|
3710
|
+
paddingHorizontal: 20,
|
|
3711
|
+
paddingBottom: 40,
|
|
3712
|
+
maxHeight: "85%"
|
|
3713
|
+
},
|
|
3714
|
+
handleRow: {
|
|
3715
|
+
alignItems: "center",
|
|
3716
|
+
paddingTop: 10,
|
|
3717
|
+
paddingBottom: 8
|
|
3718
|
+
},
|
|
3719
|
+
handle: {
|
|
3720
|
+
width: 36,
|
|
3721
|
+
height: 4,
|
|
3722
|
+
borderRadius: 2,
|
|
3723
|
+
opacity: 0.4
|
|
3724
|
+
},
|
|
3725
|
+
header: {
|
|
3726
|
+
flexDirection: "row",
|
|
3727
|
+
alignItems: "center",
|
|
3728
|
+
justifyContent: "space-between",
|
|
3729
|
+
paddingVertical: 12
|
|
3730
|
+
},
|
|
3731
|
+
headerTitle: {
|
|
3732
|
+
fontSize: 20,
|
|
3733
|
+
fontWeight: "700"
|
|
3734
|
+
},
|
|
3735
|
+
closeButton: {
|
|
3736
|
+
fontSize: 20,
|
|
3737
|
+
padding: 4
|
|
3738
|
+
},
|
|
3739
|
+
scrollContent: {
|
|
3740
|
+
flexGrow: 0
|
|
3741
|
+
},
|
|
3742
|
+
scrollContentInner: {
|
|
3743
|
+
paddingBottom: 8
|
|
3744
|
+
},
|
|
3745
|
+
// Avatar
|
|
3746
|
+
avatarSection: {
|
|
3747
|
+
alignItems: "center",
|
|
3748
|
+
paddingTop: 8,
|
|
3749
|
+
paddingBottom: 20,
|
|
3750
|
+
gap: 8
|
|
3751
|
+
},
|
|
3752
|
+
avatarContainer: {
|
|
3753
|
+
width: 120,
|
|
3754
|
+
height: 120,
|
|
3755
|
+
borderRadius: 60,
|
|
3756
|
+
borderWidth: 2,
|
|
3757
|
+
overflow: "hidden"
|
|
3758
|
+
},
|
|
3759
|
+
avatar: {
|
|
3760
|
+
width: "100%",
|
|
3761
|
+
height: "100%"
|
|
3762
|
+
},
|
|
3763
|
+
avatarLoading: {
|
|
3764
|
+
...StyleSheet5.absoluteFillObject,
|
|
3765
|
+
backgroundColor: "rgba(0,0,0,0.35)",
|
|
3766
|
+
justifyContent: "center",
|
|
3767
|
+
alignItems: "center"
|
|
3768
|
+
},
|
|
3769
|
+
username: {
|
|
3770
|
+
fontSize: 18,
|
|
3771
|
+
fontWeight: "700"
|
|
3772
|
+
},
|
|
3773
|
+
walletAddress: {
|
|
3774
|
+
fontSize: 13,
|
|
3775
|
+
fontFamily: "monospace"
|
|
3776
|
+
},
|
|
3777
|
+
// Change Avatar
|
|
3778
|
+
section: {
|
|
3779
|
+
marginBottom: 20,
|
|
3780
|
+
gap: 12
|
|
3781
|
+
},
|
|
3782
|
+
sectionHeaderRow: {
|
|
3783
|
+
flexDirection: "row",
|
|
3784
|
+
alignItems: "center",
|
|
3785
|
+
justifyContent: "space-between"
|
|
3786
|
+
},
|
|
3787
|
+
sectionLabel: {
|
|
3788
|
+
fontSize: 14,
|
|
3789
|
+
fontWeight: "600"
|
|
3790
|
+
},
|
|
3791
|
+
shuffleButton: {
|
|
3792
|
+
paddingHorizontal: 14,
|
|
3793
|
+
paddingVertical: 6,
|
|
3794
|
+
borderRadius: 12,
|
|
3795
|
+
borderWidth: 1
|
|
3796
|
+
},
|
|
3797
|
+
shuffleText: {
|
|
3798
|
+
fontSize: 13,
|
|
3799
|
+
fontWeight: "600"
|
|
3800
|
+
},
|
|
3801
|
+
stylePickerContent: {
|
|
3802
|
+
gap: 10
|
|
3803
|
+
},
|
|
3804
|
+
styleTile: {
|
|
3805
|
+
width: 72,
|
|
3806
|
+
height: 72,
|
|
3807
|
+
borderRadius: 16,
|
|
3808
|
+
overflow: "hidden"
|
|
3809
|
+
},
|
|
3810
|
+
styleTileImage: {
|
|
3811
|
+
width: "100%",
|
|
3812
|
+
height: "100%"
|
|
3813
|
+
},
|
|
3814
|
+
// Error
|
|
3815
|
+
errorBox: {
|
|
3816
|
+
marginBottom: 16,
|
|
3817
|
+
borderRadius: 12,
|
|
3818
|
+
borderWidth: 1,
|
|
3819
|
+
padding: 12
|
|
3820
|
+
},
|
|
3821
|
+
errorText: {
|
|
3822
|
+
fontSize: 13,
|
|
3823
|
+
fontWeight: "500"
|
|
3824
|
+
},
|
|
3825
|
+
// Push Notifications
|
|
3826
|
+
notifRow: {
|
|
3827
|
+
flexDirection: "row",
|
|
3828
|
+
alignItems: "center",
|
|
3829
|
+
justifyContent: "space-between",
|
|
3830
|
+
borderRadius: 16,
|
|
3831
|
+
borderWidth: 1,
|
|
3832
|
+
paddingHorizontal: 16,
|
|
3833
|
+
paddingVertical: 14,
|
|
3834
|
+
marginBottom: 16
|
|
3835
|
+
},
|
|
3836
|
+
notifLeft: {
|
|
3837
|
+
gap: 2
|
|
3838
|
+
},
|
|
3839
|
+
notifLabel: {
|
|
3840
|
+
fontSize: 15,
|
|
3841
|
+
fontWeight: "600"
|
|
3842
|
+
},
|
|
3843
|
+
notifStatus: {
|
|
3844
|
+
fontSize: 13
|
|
3845
|
+
},
|
|
3846
|
+
enableButton: {
|
|
3847
|
+
paddingHorizontal: 18,
|
|
3848
|
+
paddingVertical: 10,
|
|
3849
|
+
borderRadius: 12
|
|
3850
|
+
},
|
|
3851
|
+
enableText: {
|
|
3852
|
+
color: "#FFFFFF",
|
|
3853
|
+
fontSize: 14,
|
|
3854
|
+
fontWeight: "700"
|
|
3855
|
+
},
|
|
3856
|
+
// Disconnect
|
|
3857
|
+
disconnectButton: {
|
|
3858
|
+
height: 52,
|
|
3859
|
+
borderRadius: 16,
|
|
3860
|
+
borderWidth: 1.5,
|
|
3861
|
+
justifyContent: "center",
|
|
3862
|
+
alignItems: "center"
|
|
3863
|
+
},
|
|
3864
|
+
disconnectText: {
|
|
3865
|
+
fontSize: 16,
|
|
3866
|
+
fontWeight: "700"
|
|
3867
|
+
}
|
|
3868
|
+
});
|
|
3869
|
+
|
|
3870
|
+
// src/ui/game/GamePoster.tsx
|
|
3871
|
+
import { useState as useState18 } from "react";
|
|
3872
|
+
import { StyleSheet as StyleSheet6, View as View6, Text as Text6 } from "react-native";
|
|
3873
|
+
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
3444
3874
|
function computeCountdown(lockTimestamp) {
|
|
3445
3875
|
if (!lockTimestamp) return "";
|
|
3446
3876
|
const ts = typeof lockTimestamp === "string" ? parseInt(lockTimestamp) : lockTimestamp;
|
|
@@ -3461,38 +3891,38 @@ function GamePoster({ game, ImageComponent }) {
|
|
|
3461
3891
|
const away = opponents[1];
|
|
3462
3892
|
const countdown = computeCountdown(game.lockTimestamp);
|
|
3463
3893
|
const isLive = countdown === "LIVE";
|
|
3464
|
-
return /* @__PURE__ */
|
|
3465
|
-
game.media?.poster ? /* @__PURE__ */
|
|
3894
|
+
return /* @__PURE__ */ jsxs6(View6, { style: styles5.container, children: [
|
|
3895
|
+
game.media?.poster ? /* @__PURE__ */ jsx8(
|
|
3466
3896
|
Img,
|
|
3467
3897
|
{
|
|
3468
3898
|
source: { uri: game.media.poster },
|
|
3469
|
-
style:
|
|
3899
|
+
style: styles5.image,
|
|
3470
3900
|
resizeMode: "cover"
|
|
3471
3901
|
}
|
|
3472
|
-
) : /* @__PURE__ */
|
|
3473
|
-
/* @__PURE__ */
|
|
3474
|
-
/* @__PURE__ */
|
|
3475
|
-
/* @__PURE__ */
|
|
3902
|
+
) : /* @__PURE__ */ jsx8(View6, { style: [styles5.image, { backgroundColor: t.surface }], children: /* @__PURE__ */ jsxs6(View6, { style: styles5.fallback, children: [
|
|
3903
|
+
/* @__PURE__ */ jsx8(TeamLogoInternal, { url: home?.imageUrl, size: 56, Img }),
|
|
3904
|
+
/* @__PURE__ */ jsx8(Text6, { style: styles5.vs, children: "VS" }),
|
|
3905
|
+
/* @__PURE__ */ jsx8(TeamLogoInternal, { url: away?.imageUrl, size: 56, Img })
|
|
3476
3906
|
] }) }),
|
|
3477
|
-
/* @__PURE__ */
|
|
3478
|
-
/* @__PURE__ */
|
|
3479
|
-
/* @__PURE__ */
|
|
3480
|
-
/* @__PURE__ */
|
|
3481
|
-
/* @__PURE__ */
|
|
3907
|
+
/* @__PURE__ */ jsx8(View6, { style: styles5.overlay }),
|
|
3908
|
+
/* @__PURE__ */ jsxs6(View6, { style: styles5.teamNames, children: [
|
|
3909
|
+
/* @__PURE__ */ jsx8(Text6, { style: styles5.teamNameText, numberOfLines: 1, children: home?.name || "Home" }),
|
|
3910
|
+
/* @__PURE__ */ jsx8(Text6, { style: styles5.teamNameVs, children: "vs" }),
|
|
3911
|
+
/* @__PURE__ */ jsx8(Text6, { style: styles5.teamNameText, numberOfLines: 1, children: away?.name || "Away" })
|
|
3482
3912
|
] }),
|
|
3483
|
-
countdown ? /* @__PURE__ */
|
|
3484
|
-
/* @__PURE__ */
|
|
3913
|
+
countdown ? /* @__PURE__ */ jsx8(View6, { style: styles5.countdownPill, children: /* @__PURE__ */ jsx8(Text6, { style: [styles5.countdownText, isLive && styles5.countdownLive], children: countdown }) }) : null,
|
|
3914
|
+
/* @__PURE__ */ jsx8(View6, { style: styles5.poolPill, children: /* @__PURE__ */ jsxs6(Text6, { style: styles5.poolText, children: [
|
|
3485
3915
|
game.totalPool || 0,
|
|
3486
3916
|
" SOL"
|
|
3487
3917
|
] }) })
|
|
3488
3918
|
] });
|
|
3489
3919
|
}
|
|
3490
3920
|
function TeamLogoInternal({ url, size, Img }) {
|
|
3491
|
-
const [failed, setFailed] =
|
|
3921
|
+
const [failed, setFailed] = useState18(false);
|
|
3492
3922
|
if (!url || failed) {
|
|
3493
|
-
return /* @__PURE__ */
|
|
3923
|
+
return /* @__PURE__ */ jsx8(View6, { style: [styles5.logoPlaceholder, { width: size, height: size, borderRadius: size / 2 }] });
|
|
3494
3924
|
}
|
|
3495
|
-
return /* @__PURE__ */
|
|
3925
|
+
return /* @__PURE__ */ jsx8(
|
|
3496
3926
|
Img,
|
|
3497
3927
|
{
|
|
3498
3928
|
source: { uri: url },
|
|
@@ -3502,7 +3932,7 @@ function TeamLogoInternal({ url, size, Img }) {
|
|
|
3502
3932
|
}
|
|
3503
3933
|
);
|
|
3504
3934
|
}
|
|
3505
|
-
var
|
|
3935
|
+
var styles5 = StyleSheet6.create({
|
|
3506
3936
|
container: {
|
|
3507
3937
|
height: 200,
|
|
3508
3938
|
borderRadius: 16,
|
|
@@ -3510,12 +3940,12 @@ var styles4 = StyleSheet5.create({
|
|
|
3510
3940
|
position: "relative"
|
|
3511
3941
|
},
|
|
3512
3942
|
image: {
|
|
3513
|
-
...
|
|
3943
|
+
...StyleSheet6.absoluteFillObject,
|
|
3514
3944
|
justifyContent: "center",
|
|
3515
3945
|
alignItems: "center"
|
|
3516
3946
|
},
|
|
3517
3947
|
overlay: {
|
|
3518
|
-
...
|
|
3948
|
+
...StyleSheet6.absoluteFillObject,
|
|
3519
3949
|
backgroundColor: "rgba(0,0,0,0.35)"
|
|
3520
3950
|
},
|
|
3521
3951
|
fallback: {
|
|
@@ -3589,9 +4019,9 @@ var styles4 = StyleSheet5.create({
|
|
|
3589
4019
|
});
|
|
3590
4020
|
|
|
3591
4021
|
// src/ui/game/LivePoolsCard.tsx
|
|
3592
|
-
import { useMemo as
|
|
3593
|
-
import { StyleSheet as
|
|
3594
|
-
import { jsx as
|
|
4022
|
+
import { useMemo as useMemo5 } from "react";
|
|
4023
|
+
import { StyleSheet as StyleSheet7, View as View7, Text as Text7 } from "react-native";
|
|
4024
|
+
import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
3595
4025
|
function LivePoolsCard({
|
|
3596
4026
|
game,
|
|
3597
4027
|
shortName,
|
|
@@ -3605,7 +4035,7 @@ function LivePoolsCard({
|
|
|
3605
4035
|
const homePool = game.homePool || 0;
|
|
3606
4036
|
const awayPool = game.awayPool || 0;
|
|
3607
4037
|
const totalPool = game.totalPool || 0;
|
|
3608
|
-
const { homePercent, awayPercent, homeOdds, awayOdds } =
|
|
4038
|
+
const { homePercent, awayPercent, homeOdds, awayOdds } = useMemo5(() => {
|
|
3609
4039
|
return {
|
|
3610
4040
|
homePercent: totalPool > 0 ? homePool / totalPool * 100 : 50,
|
|
3611
4041
|
awayPercent: totalPool > 0 ? awayPool / totalPool * 100 : 50,
|
|
@@ -3613,29 +4043,29 @@ function LivePoolsCard({
|
|
|
3613
4043
|
awayOdds: awayPool > 0 ? (totalPool / awayPool).toFixed(2) : "\u2014"
|
|
3614
4044
|
};
|
|
3615
4045
|
}, [homePool, awayPool, totalPool]);
|
|
3616
|
-
return /* @__PURE__ */
|
|
3617
|
-
/* @__PURE__ */
|
|
3618
|
-
/* @__PURE__ */
|
|
4046
|
+
return /* @__PURE__ */ jsxs7(View7, { style: [styles6.card, { backgroundColor: t.surface, borderColor: t.border }], children: [
|
|
4047
|
+
/* @__PURE__ */ jsx9(Text7, { style: [styles6.title, { color: t.text }], children: "Live Pools" }),
|
|
4048
|
+
/* @__PURE__ */ jsxs7(Text7, { style: [styles6.total, { color: t.accent }], children: [
|
|
3619
4049
|
totalPool,
|
|
3620
4050
|
" SOL total"
|
|
3621
4051
|
] }),
|
|
3622
|
-
/* @__PURE__ */
|
|
3623
|
-
/* @__PURE__ */
|
|
3624
|
-
/* @__PURE__ */
|
|
4052
|
+
/* @__PURE__ */ jsxs7(View7, { style: styles6.bars, children: [
|
|
4053
|
+
/* @__PURE__ */ jsx9(PoolBar, { name: homeName, amount: homePool, percent: homePercent, color: homeColor, t }),
|
|
4054
|
+
/* @__PURE__ */ jsx9(PoolBar, { name: awayName, amount: awayPool, percent: awayPercent, color: awayColor, t })
|
|
3625
4055
|
] }),
|
|
3626
|
-
/* @__PURE__ */
|
|
3627
|
-
/* @__PURE__ */
|
|
4056
|
+
/* @__PURE__ */ jsxs7(View7, { style: styles6.oddsRow, children: [
|
|
4057
|
+
/* @__PURE__ */ jsxs7(Text7, { style: [styles6.oddsText, { color: t.textMuted }], children: [
|
|
3628
4058
|
homeName,
|
|
3629
4059
|
": ",
|
|
3630
|
-
/* @__PURE__ */
|
|
4060
|
+
/* @__PURE__ */ jsxs7(Text7, { style: { color: t.text, fontWeight: "700" }, children: [
|
|
3631
4061
|
homeOdds,
|
|
3632
4062
|
"x"
|
|
3633
4063
|
] })
|
|
3634
4064
|
] }),
|
|
3635
|
-
/* @__PURE__ */
|
|
4065
|
+
/* @__PURE__ */ jsxs7(Text7, { style: [styles6.oddsText, { color: t.textMuted }], children: [
|
|
3636
4066
|
awayName,
|
|
3637
4067
|
": ",
|
|
3638
|
-
/* @__PURE__ */
|
|
4068
|
+
/* @__PURE__ */ jsxs7(Text7, { style: { color: t.text, fontWeight: "700" }, children: [
|
|
3639
4069
|
awayOdds,
|
|
3640
4070
|
"x"
|
|
3641
4071
|
] })
|
|
@@ -3644,16 +4074,16 @@ function LivePoolsCard({
|
|
|
3644
4074
|
] });
|
|
3645
4075
|
}
|
|
3646
4076
|
function PoolBar({ name, amount, percent, color, t }) {
|
|
3647
|
-
return /* @__PURE__ */
|
|
3648
|
-
/* @__PURE__ */
|
|
3649
|
-
/* @__PURE__ */
|
|
3650
|
-
/* @__PURE__ */
|
|
4077
|
+
return /* @__PURE__ */ jsxs7(View7, { style: styles6.barRow, children: [
|
|
4078
|
+
/* @__PURE__ */ jsx9(Text7, { style: [styles6.barLabel, { color: t.textSecondary }], numberOfLines: 1, children: name }),
|
|
4079
|
+
/* @__PURE__ */ jsx9(View7, { style: [styles6.barTrack, { backgroundColor: t.border }], children: /* @__PURE__ */ jsx9(View7, { style: [styles6.barFill, { width: `${Math.max(percent, 2)}%`, backgroundColor: color }] }) }),
|
|
4080
|
+
/* @__PURE__ */ jsxs7(Text7, { style: [styles6.barAmount, { color: t.text }], children: [
|
|
3651
4081
|
amount,
|
|
3652
4082
|
" SOL"
|
|
3653
4083
|
] })
|
|
3654
4084
|
] });
|
|
3655
4085
|
}
|
|
3656
|
-
var
|
|
4086
|
+
var styles6 = StyleSheet7.create({
|
|
3657
4087
|
card: { borderRadius: 16, borderWidth: 1, padding: 16 },
|
|
3658
4088
|
title: { fontSize: 17, fontWeight: "700", marginBottom: 4 },
|
|
3659
4089
|
total: { fontSize: 14, fontWeight: "600", marginBottom: 14 },
|
|
@@ -3668,9 +4098,9 @@ var styles5 = StyleSheet6.create({
|
|
|
3668
4098
|
});
|
|
3669
4099
|
|
|
3670
4100
|
// src/ui/game/PickWinnerCard.tsx
|
|
3671
|
-
import { useState as
|
|
3672
|
-
import { StyleSheet as
|
|
3673
|
-
import { jsx as
|
|
4101
|
+
import { useState as useState19, useMemo as useMemo6 } from "react";
|
|
4102
|
+
import { StyleSheet as StyleSheet8, View as View8, Text as Text8, TouchableOpacity as TouchableOpacity5 } from "react-native";
|
|
4103
|
+
import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
3674
4104
|
function PickWinnerCard({
|
|
3675
4105
|
game,
|
|
3676
4106
|
selectedTeam,
|
|
@@ -3686,7 +4116,7 @@ function PickWinnerCard({
|
|
|
3686
4116
|
const totalPool = game.totalPool || 0;
|
|
3687
4117
|
const homePool = game.homePool || 0;
|
|
3688
4118
|
const awayPool = game.awayPool || 0;
|
|
3689
|
-
const { homeOdds, awayOdds, homeBets, awayBets } =
|
|
4119
|
+
const { homeOdds, awayOdds, homeBets, awayBets } = useMemo6(() => ({
|
|
3690
4120
|
homeOdds: homePool > 0 ? (totalPool / homePool).toFixed(2) : "\u2014",
|
|
3691
4121
|
awayOdds: awayPool > 0 ? (totalPool / awayPool).toFixed(2) : "\u2014",
|
|
3692
4122
|
homeBets: bettors.filter((b) => b.team === "home").length,
|
|
@@ -3694,10 +4124,10 @@ function PickWinnerCard({
|
|
|
3694
4124
|
}), [totalPool, homePool, awayPool, bettors]);
|
|
3695
4125
|
const homeName = shortName ? shortName(opponents[0]?.name) : opponents[0]?.name || "Home";
|
|
3696
4126
|
const awayName = shortName ? shortName(opponents[1]?.name) : opponents[1]?.name || "Away";
|
|
3697
|
-
return /* @__PURE__ */
|
|
3698
|
-
/* @__PURE__ */
|
|
3699
|
-
/* @__PURE__ */
|
|
3700
|
-
/* @__PURE__ */
|
|
4127
|
+
return /* @__PURE__ */ jsxs8(View8, { style: [styles7.card, { backgroundColor: t.surface, borderColor: t.border }], children: [
|
|
4128
|
+
/* @__PURE__ */ jsx10(Text8, { style: [styles7.title, { color: t.text }], children: "Pick Your Winner" }),
|
|
4129
|
+
/* @__PURE__ */ jsxs8(View8, { style: styles7.row, children: [
|
|
4130
|
+
/* @__PURE__ */ jsx10(
|
|
3701
4131
|
TeamOption,
|
|
3702
4132
|
{
|
|
3703
4133
|
name: homeName,
|
|
@@ -3711,7 +4141,7 @@ function PickWinnerCard({
|
|
|
3711
4141
|
t
|
|
3712
4142
|
}
|
|
3713
4143
|
),
|
|
3714
|
-
/* @__PURE__ */
|
|
4144
|
+
/* @__PURE__ */ jsx10(
|
|
3715
4145
|
TeamOption,
|
|
3716
4146
|
{
|
|
3717
4147
|
name: awayName,
|
|
@@ -3739,33 +4169,33 @@ function TeamOption({
|
|
|
3739
4169
|
ImageComponent,
|
|
3740
4170
|
t
|
|
3741
4171
|
}) {
|
|
3742
|
-
const [imgFailed, setImgFailed] =
|
|
4172
|
+
const [imgFailed, setImgFailed] = useState19(false);
|
|
3743
4173
|
const Img = ImageComponent || __require("react-native").Image;
|
|
3744
4174
|
const showImage = imageUrl && !imgFailed;
|
|
3745
|
-
return /* @__PURE__ */
|
|
3746
|
-
|
|
4175
|
+
return /* @__PURE__ */ jsxs8(
|
|
4176
|
+
TouchableOpacity5,
|
|
3747
4177
|
{
|
|
3748
|
-
style: [
|
|
4178
|
+
style: [styles7.option, { borderColor: selected ? color : t.border, backgroundColor: selected ? color + "15" : t.background }],
|
|
3749
4179
|
onPress,
|
|
3750
4180
|
activeOpacity: 0.7,
|
|
3751
4181
|
children: [
|
|
3752
|
-
showImage ? /* @__PURE__ */
|
|
3753
|
-
/* @__PURE__ */
|
|
3754
|
-
/* @__PURE__ */
|
|
4182
|
+
showImage ? /* @__PURE__ */ jsx10(Img, { source: { uri: imageUrl }, style: styles7.logo, resizeMode: "contain", onError: () => setImgFailed(true) }) : /* @__PURE__ */ jsx10(View8, { style: [styles7.logo, styles7.logoPlaceholder] }),
|
|
4183
|
+
/* @__PURE__ */ jsx10(Text8, { style: [styles7.name, { color: t.text }], numberOfLines: 1, children: name }),
|
|
4184
|
+
/* @__PURE__ */ jsxs8(Text8, { style: [styles7.odds, { color }], children: [
|
|
3755
4185
|
odds,
|
|
3756
4186
|
"x"
|
|
3757
4187
|
] }),
|
|
3758
|
-
/* @__PURE__ */
|
|
4188
|
+
/* @__PURE__ */ jsxs8(Text8, { style: [styles7.bets, { color: t.textMuted }], children: [
|
|
3759
4189
|
bets,
|
|
3760
4190
|
" ",
|
|
3761
4191
|
bets === 1 ? "bet" : "bets"
|
|
3762
4192
|
] }),
|
|
3763
|
-
selected && /* @__PURE__ */
|
|
4193
|
+
selected && /* @__PURE__ */ jsx10(View8, { style: [styles7.badge, { backgroundColor: color }], children: /* @__PURE__ */ jsx10(Text8, { style: styles7.badgeText, children: "Selected" }) })
|
|
3764
4194
|
]
|
|
3765
4195
|
}
|
|
3766
4196
|
);
|
|
3767
4197
|
}
|
|
3768
|
-
var
|
|
4198
|
+
var styles7 = StyleSheet8.create({
|
|
3769
4199
|
card: { borderRadius: 16, borderWidth: 1, padding: 16 },
|
|
3770
4200
|
title: { fontSize: 17, fontWeight: "700", marginBottom: 12 },
|
|
3771
4201
|
row: { flexDirection: "row", gap: 12 },
|
|
@@ -3780,9 +4210,9 @@ var styles6 = StyleSheet7.create({
|
|
|
3780
4210
|
});
|
|
3781
4211
|
|
|
3782
4212
|
// src/ui/game/PlayersCard.tsx
|
|
3783
|
-
import { useState as
|
|
3784
|
-
import { StyleSheet as
|
|
3785
|
-
import { jsx as
|
|
4213
|
+
import { useState as useState20 } from "react";
|
|
4214
|
+
import { StyleSheet as StyleSheet9, View as View9, Text as Text9 } from "react-native";
|
|
4215
|
+
import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
3786
4216
|
function truncateWallet(addr, chars) {
|
|
3787
4217
|
if (addr.length <= chars * 2 + 3) return addr;
|
|
3788
4218
|
return `${addr.slice(0, chars)}...${addr.slice(-chars)}`;
|
|
@@ -3802,12 +4232,12 @@ function PlayersCard({
|
|
|
3802
4232
|
if (team === "away") return awayColor;
|
|
3803
4233
|
return drawColor;
|
|
3804
4234
|
};
|
|
3805
|
-
return /* @__PURE__ */
|
|
3806
|
-
/* @__PURE__ */
|
|
4235
|
+
return /* @__PURE__ */ jsxs9(View9, { style: [styles8.card, { backgroundColor: t.surface, borderColor: t.border }], children: [
|
|
4236
|
+
/* @__PURE__ */ jsxs9(Text9, { style: [styles8.title, { color: t.text }], children: [
|
|
3807
4237
|
"Players",
|
|
3808
4238
|
bettors.length > 0 ? ` (${bettors.length})` : ""
|
|
3809
4239
|
] }),
|
|
3810
|
-
bettors.length === 0 ? /* @__PURE__ */
|
|
4240
|
+
bettors.length === 0 ? /* @__PURE__ */ jsx11(Text9, { style: [styles8.empty, { color: t.textMuted }], children: "No players yet \u2014 be the first!" }) : bettors.map((b, i) => /* @__PURE__ */ jsx11(
|
|
3811
4241
|
BettorRow,
|
|
3812
4242
|
{
|
|
3813
4243
|
bettor: b,
|
|
@@ -3829,20 +4259,20 @@ function BettorRow({
|
|
|
3829
4259
|
ImageComponent,
|
|
3830
4260
|
t
|
|
3831
4261
|
}) {
|
|
3832
|
-
const [imgFailed, setImgFailed] =
|
|
4262
|
+
const [imgFailed, setImgFailed] = useState20(false);
|
|
3833
4263
|
const Img = ImageComponent || __require("react-native").Image;
|
|
3834
4264
|
const showAvatar = bettor.avatar && !imgFailed;
|
|
3835
|
-
return /* @__PURE__ */
|
|
3836
|
-
/* @__PURE__ */
|
|
3837
|
-
showAvatar ? /* @__PURE__ */
|
|
3838
|
-
/* @__PURE__ */
|
|
3839
|
-
/* @__PURE__ */
|
|
4265
|
+
return /* @__PURE__ */ jsxs9(View9, { style: [styles8.row, !isFirst && { borderTopColor: t.border, borderTopWidth: 1 }], children: [
|
|
4266
|
+
/* @__PURE__ */ jsx11(View9, { style: [styles8.dot, { backgroundColor: dotColor }] }),
|
|
4267
|
+
showAvatar ? /* @__PURE__ */ jsx11(Img, { source: { uri: bettor.avatar }, style: styles8.avatar, resizeMode: "cover", onError: () => setImgFailed(true) }) : /* @__PURE__ */ jsx11(View9, { style: [styles8.avatar, styles8.avatarPlaceholder] }),
|
|
4268
|
+
/* @__PURE__ */ jsx11(View9, { style: styles8.nameCol, children: /* @__PURE__ */ jsx11(Text9, { style: [styles8.username, { color: t.text }], numberOfLines: 1, children: bettor.username || truncateWallet(bettor.wallet, truncateChars) }) }),
|
|
4269
|
+
/* @__PURE__ */ jsxs9(Text9, { style: [styles8.amount, { color: t.textSecondary }], children: [
|
|
3840
4270
|
bettor.amount,
|
|
3841
4271
|
" SOL"
|
|
3842
4272
|
] })
|
|
3843
4273
|
] });
|
|
3844
4274
|
}
|
|
3845
|
-
var
|
|
4275
|
+
var styles8 = StyleSheet9.create({
|
|
3846
4276
|
card: { borderRadius: 16, borderWidth: 1, padding: 16 },
|
|
3847
4277
|
title: { fontSize: 17, fontWeight: "700", marginBottom: 12 },
|
|
3848
4278
|
empty: { fontSize: 14, textAlign: "center", paddingVertical: 16 },
|
|
@@ -3856,9 +4286,9 @@ var styles7 = StyleSheet8.create({
|
|
|
3856
4286
|
});
|
|
3857
4287
|
|
|
3858
4288
|
// src/ui/game/JoinGameButton.tsx
|
|
3859
|
-
import { useMemo as
|
|
3860
|
-
import { StyleSheet as
|
|
3861
|
-
import { jsx as
|
|
4289
|
+
import { useMemo as useMemo7 } from "react";
|
|
4290
|
+
import { StyleSheet as StyleSheet10, View as View10, Text as Text10, TouchableOpacity as TouchableOpacity6, ActivityIndicator as ActivityIndicator5 } from "react-native";
|
|
4291
|
+
import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
3862
4292
|
var STATUS_LABELS = {
|
|
3863
4293
|
building: "Building transaction...",
|
|
3864
4294
|
signing: "Approve in wallet...",
|
|
@@ -3867,37 +4297,37 @@ var STATUS_LABELS = {
|
|
|
3867
4297
|
};
|
|
3868
4298
|
function JoinGameButton({ game, walletAddress, selectedTeam, status, onJoin }) {
|
|
3869
4299
|
const t = useDubsTheme();
|
|
3870
|
-
const alreadyJoined =
|
|
4300
|
+
const alreadyJoined = useMemo7(() => {
|
|
3871
4301
|
if (!walletAddress) return false;
|
|
3872
4302
|
return (game.bettors || []).some((b) => b.wallet === walletAddress);
|
|
3873
4303
|
}, [game.bettors, walletAddress]);
|
|
3874
4304
|
if (alreadyJoined || game.isLocked || game.isResolved) return null;
|
|
3875
4305
|
const isJoining = status !== "idle" && status !== "success" && status !== "error";
|
|
3876
4306
|
const statusLabel = STATUS_LABELS[status] || "";
|
|
3877
|
-
return /* @__PURE__ */
|
|
3878
|
-
/* @__PURE__ */
|
|
3879
|
-
/* @__PURE__ */
|
|
3880
|
-
/* @__PURE__ */
|
|
4307
|
+
return /* @__PURE__ */ jsxs10(View10, { style: [styles9.bar, { backgroundColor: t.background, borderTopColor: t.border }], children: [
|
|
4308
|
+
/* @__PURE__ */ jsxs10(View10, { style: styles9.buyInRow, children: [
|
|
4309
|
+
/* @__PURE__ */ jsx12(Text10, { style: [styles9.buyInLabel, { color: t.textMuted }], children: "Buy-in" }),
|
|
4310
|
+
/* @__PURE__ */ jsxs10(Text10, { style: [styles9.buyInValue, { color: t.text }], children: [
|
|
3881
4311
|
game.buyIn,
|
|
3882
4312
|
" SOL"
|
|
3883
4313
|
] })
|
|
3884
4314
|
] }),
|
|
3885
|
-
/* @__PURE__ */
|
|
3886
|
-
|
|
4315
|
+
/* @__PURE__ */ jsx12(
|
|
4316
|
+
TouchableOpacity6,
|
|
3887
4317
|
{
|
|
3888
|
-
style: [
|
|
4318
|
+
style: [styles9.button, { backgroundColor: selectedTeam ? t.accent : t.border }],
|
|
3889
4319
|
disabled: !selectedTeam || isJoining,
|
|
3890
4320
|
onPress: onJoin,
|
|
3891
4321
|
activeOpacity: 0.8,
|
|
3892
|
-
children: isJoining ? /* @__PURE__ */
|
|
3893
|
-
/* @__PURE__ */
|
|
3894
|
-
/* @__PURE__ */
|
|
3895
|
-
] }) : /* @__PURE__ */
|
|
4322
|
+
children: isJoining ? /* @__PURE__ */ jsxs10(View10, { style: styles9.joiningRow, children: [
|
|
4323
|
+
/* @__PURE__ */ jsx12(ActivityIndicator5, { size: "small", color: "#000" }),
|
|
4324
|
+
/* @__PURE__ */ jsx12(Text10, { style: styles9.buttonText, children: statusLabel })
|
|
4325
|
+
] }) : /* @__PURE__ */ jsx12(Text10, { style: [styles9.buttonText, !selectedTeam && { color: t.textMuted }], children: selectedTeam ? `Join Bet \u2014 ${game.buyIn} SOL` : "Pick a team to bet" })
|
|
3896
4326
|
}
|
|
3897
4327
|
)
|
|
3898
4328
|
] });
|
|
3899
4329
|
}
|
|
3900
|
-
var
|
|
4330
|
+
var styles9 = StyleSheet10.create({
|
|
3901
4331
|
bar: { position: "absolute", bottom: 0, left: 0, right: 0, paddingHorizontal: 16, paddingTop: 12, paddingBottom: 36, borderTopWidth: 1 },
|
|
3902
4332
|
buyInRow: { flexDirection: "row", alignItems: "center", justifyContent: "space-between", marginBottom: 10 },
|
|
3903
4333
|
buyInLabel: { fontSize: 13 },
|
|
@@ -3908,20 +4338,20 @@ var styles8 = StyleSheet9.create({
|
|
|
3908
4338
|
});
|
|
3909
4339
|
|
|
3910
4340
|
// src/ui/game/CreateCustomGameSheet.tsx
|
|
3911
|
-
import { useState as
|
|
4341
|
+
import { useState as useState21, useEffect as useEffect12, useRef as useRef6, useCallback as useCallback17 } from "react";
|
|
3912
4342
|
import {
|
|
3913
|
-
View as
|
|
3914
|
-
Text as
|
|
4343
|
+
View as View11,
|
|
4344
|
+
Text as Text11,
|
|
3915
4345
|
TextInput as TextInput2,
|
|
3916
|
-
TouchableOpacity as
|
|
3917
|
-
ActivityIndicator as
|
|
3918
|
-
Modal,
|
|
3919
|
-
Animated as
|
|
3920
|
-
StyleSheet as
|
|
3921
|
-
KeyboardAvoidingView as
|
|
3922
|
-
Platform as
|
|
4346
|
+
TouchableOpacity as TouchableOpacity7,
|
|
4347
|
+
ActivityIndicator as ActivityIndicator6,
|
|
4348
|
+
Modal as Modal2,
|
|
4349
|
+
Animated as Animated3,
|
|
4350
|
+
StyleSheet as StyleSheet11,
|
|
4351
|
+
KeyboardAvoidingView as KeyboardAvoidingView3,
|
|
4352
|
+
Platform as Platform6
|
|
3923
4353
|
} from "react-native";
|
|
3924
|
-
import { jsx as
|
|
4354
|
+
import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
3925
4355
|
var STATUS_LABELS2 = {
|
|
3926
4356
|
building: "Building transaction...",
|
|
3927
4357
|
signing: "Approve in wallet...",
|
|
@@ -3945,18 +4375,18 @@ function CreateCustomGameSheet({
|
|
|
3945
4375
|
const t = useDubsTheme();
|
|
3946
4376
|
const { wallet } = useDubs();
|
|
3947
4377
|
const mutation = useCreateCustomGame();
|
|
3948
|
-
const [selectedAmount, setSelectedAmount] =
|
|
3949
|
-
const [customAmount, setCustomAmount] =
|
|
3950
|
-
const [isCustom, setIsCustom] =
|
|
3951
|
-
const overlayOpacity =
|
|
3952
|
-
|
|
3953
|
-
|
|
4378
|
+
const [selectedAmount, setSelectedAmount] = useState21(null);
|
|
4379
|
+
const [customAmount, setCustomAmount] = useState21("");
|
|
4380
|
+
const [isCustom, setIsCustom] = useState21(false);
|
|
4381
|
+
const overlayOpacity = useRef6(new Animated3.Value(0)).current;
|
|
4382
|
+
useEffect12(() => {
|
|
4383
|
+
Animated3.timing(overlayOpacity, {
|
|
3954
4384
|
toValue: visible ? 1 : 0,
|
|
3955
4385
|
duration: 250,
|
|
3956
4386
|
useNativeDriver: true
|
|
3957
4387
|
}).start();
|
|
3958
4388
|
}, [visible, overlayOpacity]);
|
|
3959
|
-
|
|
4389
|
+
useEffect12(() => {
|
|
3960
4390
|
if (visible) {
|
|
3961
4391
|
setSelectedAmount(defaultAmount ?? null);
|
|
3962
4392
|
setCustomAmount("");
|
|
@@ -3964,7 +4394,7 @@ function CreateCustomGameSheet({
|
|
|
3964
4394
|
mutation.reset();
|
|
3965
4395
|
}
|
|
3966
4396
|
}, [visible]);
|
|
3967
|
-
|
|
4397
|
+
useEffect12(() => {
|
|
3968
4398
|
if (mutation.status === "success" && mutation.data) {
|
|
3969
4399
|
onSuccess?.(mutation.data);
|
|
3970
4400
|
const timer = setTimeout(() => {
|
|
@@ -3973,23 +4403,23 @@ function CreateCustomGameSheet({
|
|
|
3973
4403
|
return () => clearTimeout(timer);
|
|
3974
4404
|
}
|
|
3975
4405
|
}, [mutation.status, mutation.data]);
|
|
3976
|
-
|
|
4406
|
+
useEffect12(() => {
|
|
3977
4407
|
if (mutation.status === "error" && mutation.error) {
|
|
3978
4408
|
onError?.(mutation.error);
|
|
3979
4409
|
}
|
|
3980
4410
|
}, [mutation.status, mutation.error]);
|
|
3981
|
-
const handlePresetSelect =
|
|
4411
|
+
const handlePresetSelect = useCallback17((amount) => {
|
|
3982
4412
|
setSelectedAmount(amount);
|
|
3983
4413
|
setIsCustom(false);
|
|
3984
4414
|
setCustomAmount("");
|
|
3985
4415
|
onAmountChange?.(amount);
|
|
3986
4416
|
}, [onAmountChange]);
|
|
3987
|
-
const handleCustomSelect =
|
|
4417
|
+
const handleCustomSelect = useCallback17(() => {
|
|
3988
4418
|
setIsCustom(true);
|
|
3989
4419
|
setSelectedAmount(null);
|
|
3990
4420
|
onAmountChange?.(null);
|
|
3991
4421
|
}, [onAmountChange]);
|
|
3992
|
-
const handleCustomAmountChange =
|
|
4422
|
+
const handleCustomAmountChange = useCallback17((text) => {
|
|
3993
4423
|
const cleaned = text.replace(/[^0-9.]/g, "").replace(/(\..*?)\..*/g, "$1");
|
|
3994
4424
|
setCustomAmount(cleaned);
|
|
3995
4425
|
const parsed = parseFloat(cleaned);
|
|
@@ -4004,7 +4434,7 @@ function CreateCustomGameSheet({
|
|
|
4004
4434
|
const winnerTakes = pot * (1 - fee / 100);
|
|
4005
4435
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
4006
4436
|
const canCreate = finalAmount !== null && finalAmount > 0 && !isMutating && mutation.status !== "success";
|
|
4007
|
-
const handleCreate =
|
|
4437
|
+
const handleCreate = useCallback17(async () => {
|
|
4008
4438
|
if (!finalAmount || !wallet.publicKey) return;
|
|
4009
4439
|
try {
|
|
4010
4440
|
await mutation.execute({
|
|
@@ -4020,42 +4450,42 @@ function CreateCustomGameSheet({
|
|
|
4020
4450
|
}, [finalAmount, wallet.publicKey, mutation.execute, title, maxPlayers, metadata]);
|
|
4021
4451
|
const statusLabel = STATUS_LABELS2[mutation.status] || "";
|
|
4022
4452
|
const playersLabel = playerCount === 2 ? "2 (1v1)" : `${playerCount} players`;
|
|
4023
|
-
return /* @__PURE__ */
|
|
4024
|
-
|
|
4453
|
+
return /* @__PURE__ */ jsxs11(
|
|
4454
|
+
Modal2,
|
|
4025
4455
|
{
|
|
4026
4456
|
visible,
|
|
4027
4457
|
animationType: "slide",
|
|
4028
4458
|
transparent: true,
|
|
4029
4459
|
onRequestClose: onDismiss,
|
|
4030
4460
|
children: [
|
|
4031
|
-
/* @__PURE__ */
|
|
4032
|
-
/* @__PURE__ */
|
|
4033
|
-
|
|
4461
|
+
/* @__PURE__ */ jsx13(Animated3.View, { style: [styles10.overlay, { opacity: overlayOpacity }], children: /* @__PURE__ */ jsx13(TouchableOpacity7, { style: styles10.overlayTap, activeOpacity: 1, onPress: onDismiss }) }),
|
|
4462
|
+
/* @__PURE__ */ jsx13(
|
|
4463
|
+
KeyboardAvoidingView3,
|
|
4034
4464
|
{
|
|
4035
|
-
style:
|
|
4036
|
-
behavior:
|
|
4037
|
-
children: /* @__PURE__ */
|
|
4038
|
-
/* @__PURE__ */
|
|
4039
|
-
/* @__PURE__ */
|
|
4040
|
-
/* @__PURE__ */
|
|
4041
|
-
/* @__PURE__ */
|
|
4465
|
+
style: styles10.keyboardView,
|
|
4466
|
+
behavior: Platform6.OS === "ios" ? "padding" : void 0,
|
|
4467
|
+
children: /* @__PURE__ */ jsx13(View11, { style: styles10.sheetPositioner, children: /* @__PURE__ */ jsxs11(View11, { style: [styles10.sheet, { backgroundColor: t.background }], children: [
|
|
4468
|
+
/* @__PURE__ */ jsx13(View11, { style: styles10.handleRow, children: /* @__PURE__ */ jsx13(View11, { style: [styles10.handle, { backgroundColor: t.textMuted }] }) }),
|
|
4469
|
+
/* @__PURE__ */ jsxs11(View11, { style: styles10.header, children: [
|
|
4470
|
+
/* @__PURE__ */ jsx13(Text11, { style: [styles10.headerTitle, { color: t.text }], children: isPoolModeEnabled ? "Create Pool" : "New Game" }),
|
|
4471
|
+
/* @__PURE__ */ jsx13(TouchableOpacity7, { onPress: onDismiss, activeOpacity: 0.8, children: /* @__PURE__ */ jsx13(Text11, { style: [styles10.closeButton, { color: t.textMuted }], children: "\u2715" }) })
|
|
4042
4472
|
] }),
|
|
4043
|
-
!isPoolModeEnabled && /* @__PURE__ */
|
|
4044
|
-
/* @__PURE__ */
|
|
4045
|
-
/* @__PURE__ */
|
|
4473
|
+
!isPoolModeEnabled && /* @__PURE__ */ jsxs11(View11, { style: styles10.section, children: [
|
|
4474
|
+
/* @__PURE__ */ jsx13(Text11, { style: [styles10.sectionLabel, { color: t.textSecondary }], children: "Buy-In Amount" }),
|
|
4475
|
+
/* @__PURE__ */ jsxs11(View11, { style: styles10.chipsRow, children: [
|
|
4046
4476
|
presetAmounts.map((amount) => {
|
|
4047
4477
|
const active = !isCustom && selectedAmount === amount;
|
|
4048
|
-
return /* @__PURE__ */
|
|
4049
|
-
|
|
4478
|
+
return /* @__PURE__ */ jsx13(
|
|
4479
|
+
TouchableOpacity7,
|
|
4050
4480
|
{
|
|
4051
4481
|
style: [
|
|
4052
|
-
|
|
4482
|
+
styles10.chip,
|
|
4053
4483
|
{ borderColor: active ? t.accent : t.border },
|
|
4054
4484
|
active && { backgroundColor: t.accent }
|
|
4055
4485
|
],
|
|
4056
4486
|
onPress: () => handlePresetSelect(amount),
|
|
4057
4487
|
activeOpacity: 0.8,
|
|
4058
|
-
children: /* @__PURE__ */
|
|
4488
|
+
children: /* @__PURE__ */ jsxs11(Text11, { style: [styles10.chipText, { color: active ? "#FFFFFF" : t.text }], children: [
|
|
4059
4489
|
amount,
|
|
4060
4490
|
" SOL"
|
|
4061
4491
|
] })
|
|
@@ -4063,24 +4493,24 @@ function CreateCustomGameSheet({
|
|
|
4063
4493
|
amount
|
|
4064
4494
|
);
|
|
4065
4495
|
}),
|
|
4066
|
-
/* @__PURE__ */
|
|
4067
|
-
|
|
4496
|
+
/* @__PURE__ */ jsx13(
|
|
4497
|
+
TouchableOpacity7,
|
|
4068
4498
|
{
|
|
4069
4499
|
style: [
|
|
4070
|
-
|
|
4500
|
+
styles10.chip,
|
|
4071
4501
|
{ borderColor: isCustom ? t.accent : t.border },
|
|
4072
4502
|
isCustom && { backgroundColor: t.accent }
|
|
4073
4503
|
],
|
|
4074
4504
|
onPress: handleCustomSelect,
|
|
4075
4505
|
activeOpacity: 0.8,
|
|
4076
|
-
children: /* @__PURE__ */
|
|
4506
|
+
children: /* @__PURE__ */ jsx13(Text11, { style: [styles10.chipText, { color: isCustom ? "#FFFFFF" : t.text }], children: "Custom" })
|
|
4077
4507
|
}
|
|
4078
4508
|
)
|
|
4079
4509
|
] }),
|
|
4080
|
-
isCustom && /* @__PURE__ */
|
|
4510
|
+
isCustom && /* @__PURE__ */ jsx13(
|
|
4081
4511
|
TextInput2,
|
|
4082
4512
|
{
|
|
4083
|
-
style: [
|
|
4513
|
+
style: [styles10.input, { backgroundColor: t.surface, color: t.text, borderColor: t.accent }],
|
|
4084
4514
|
placeholder: "Enter amount in SOL",
|
|
4085
4515
|
placeholderTextColor: t.textDim,
|
|
4086
4516
|
keyboardType: "decimal-pad",
|
|
@@ -4090,43 +4520,43 @@ function CreateCustomGameSheet({
|
|
|
4090
4520
|
}
|
|
4091
4521
|
)
|
|
4092
4522
|
] }),
|
|
4093
|
-
/* @__PURE__ */
|
|
4094
|
-
/* @__PURE__ */
|
|
4095
|
-
/* @__PURE__ */
|
|
4096
|
-
/* @__PURE__ */
|
|
4523
|
+
/* @__PURE__ */ jsxs11(View11, { style: [styles10.summaryCard, { backgroundColor: t.surface, borderColor: t.border }], children: [
|
|
4524
|
+
/* @__PURE__ */ jsxs11(View11, { style: styles10.summaryRow, children: [
|
|
4525
|
+
/* @__PURE__ */ jsx13(Text11, { style: [styles10.summaryLabel, { color: t.textMuted }], children: "Buy-in" }),
|
|
4526
|
+
/* @__PURE__ */ jsx13(Text11, { style: [styles10.summaryValue, { color: t.text }], children: finalAmount ? `${finalAmount} SOL` : "\u2014" })
|
|
4097
4527
|
] }),
|
|
4098
|
-
/* @__PURE__ */
|
|
4099
|
-
/* @__PURE__ */
|
|
4100
|
-
/* @__PURE__ */
|
|
4101
|
-
/* @__PURE__ */
|
|
4528
|
+
/* @__PURE__ */ jsx13(View11, { style: [styles10.summarySep, { backgroundColor: t.border }] }),
|
|
4529
|
+
/* @__PURE__ */ jsxs11(View11, { style: styles10.summaryRow, children: [
|
|
4530
|
+
/* @__PURE__ */ jsx13(Text11, { style: [styles10.summaryLabel, { color: t.textMuted }], children: isPoolModeEnabled ? "Max players" : "Players" }),
|
|
4531
|
+
/* @__PURE__ */ jsx13(Text11, { style: [styles10.summaryValue, { color: t.text }], children: isPoolModeEnabled ? playerCount : playersLabel })
|
|
4102
4532
|
] }),
|
|
4103
|
-
/* @__PURE__ */
|
|
4104
|
-
/* @__PURE__ */
|
|
4105
|
-
/* @__PURE__ */
|
|
4106
|
-
/* @__PURE__ */
|
|
4107
|
-
/* @__PURE__ */
|
|
4108
|
-
finalAmount ? /* @__PURE__ */
|
|
4533
|
+
/* @__PURE__ */ jsx13(View11, { style: [styles10.summarySep, { backgroundColor: t.border }] }),
|
|
4534
|
+
/* @__PURE__ */ jsxs11(View11, { style: styles10.summaryRow, children: [
|
|
4535
|
+
/* @__PURE__ */ jsx13(Text11, { style: [styles10.summaryLabel, { color: t.textMuted }], children: isPoolModeEnabled ? "Max pot" : "Winner Takes" }),
|
|
4536
|
+
/* @__PURE__ */ jsxs11(View11, { style: styles10.winnerCol, children: [
|
|
4537
|
+
/* @__PURE__ */ jsx13(Text11, { style: [styles10.summaryValue, { color: t.success }], children: finalAmount ? `${(finalAmount * playerCount * (1 - fee / 100)).toFixed(4)} SOL` : "\u2014" }),
|
|
4538
|
+
finalAmount ? /* @__PURE__ */ jsxs11(Text11, { style: [styles10.feeNote, { color: t.textDim }], children: [
|
|
4109
4539
|
fee,
|
|
4110
4540
|
"% platform fee"
|
|
4111
4541
|
] }) : null
|
|
4112
4542
|
] })
|
|
4113
4543
|
] })
|
|
4114
4544
|
] }),
|
|
4115
|
-
mutation.error && /* @__PURE__ */
|
|
4116
|
-
/* @__PURE__ */
|
|
4117
|
-
|
|
4545
|
+
mutation.error && /* @__PURE__ */ jsx13(View11, { style: [styles10.errorBox, { backgroundColor: t.errorBg, borderColor: t.errorBorder }], children: /* @__PURE__ */ jsx13(Text11, { style: [styles10.errorText, { color: t.errorText }], children: mutation.error.message }) }),
|
|
4546
|
+
/* @__PURE__ */ jsx13(
|
|
4547
|
+
TouchableOpacity7,
|
|
4118
4548
|
{
|
|
4119
4549
|
style: [
|
|
4120
|
-
|
|
4550
|
+
styles10.ctaButton,
|
|
4121
4551
|
{ backgroundColor: canCreate ? t.accent : t.border }
|
|
4122
4552
|
],
|
|
4123
4553
|
disabled: !canCreate,
|
|
4124
4554
|
onPress: handleCreate,
|
|
4125
4555
|
activeOpacity: 0.8,
|
|
4126
|
-
children: isMutating ? /* @__PURE__ */
|
|
4127
|
-
/* @__PURE__ */
|
|
4128
|
-
/* @__PURE__ */
|
|
4129
|
-
] }) : mutation.status === "success" ? /* @__PURE__ */
|
|
4556
|
+
children: isMutating ? /* @__PURE__ */ jsxs11(View11, { style: styles10.ctaLoading, children: [
|
|
4557
|
+
/* @__PURE__ */ jsx13(ActivityIndicator6, { size: "small", color: "#FFFFFF" }),
|
|
4558
|
+
/* @__PURE__ */ jsx13(Text11, { style: styles10.ctaText, children: statusLabel })
|
|
4559
|
+
] }) : mutation.status === "success" ? /* @__PURE__ */ jsx13(Text11, { style: styles10.ctaText, children: isPoolModeEnabled ? "Pool Created!" : STATUS_LABELS2.success }) : /* @__PURE__ */ jsx13(Text11, { style: [styles10.ctaText, !canCreate && { opacity: 0.5 }], children: isPoolModeEnabled ? `Create Pool \u2014 ${finalAmount} SOL` : effectiveAmount ? `Create Game \u2014 ${effectiveAmount} SOL` : "Select buy-in amount" })
|
|
4130
4560
|
}
|
|
4131
4561
|
)
|
|
4132
4562
|
] }) })
|
|
@@ -4136,9 +4566,9 @@ function CreateCustomGameSheet({
|
|
|
4136
4566
|
}
|
|
4137
4567
|
);
|
|
4138
4568
|
}
|
|
4139
|
-
var
|
|
4569
|
+
var styles10 = StyleSheet11.create({
|
|
4140
4570
|
overlay: {
|
|
4141
|
-
...
|
|
4571
|
+
...StyleSheet11.absoluteFillObject,
|
|
4142
4572
|
backgroundColor: "rgba(0,0,0,0.5)"
|
|
4143
4573
|
},
|
|
4144
4574
|
overlayTap: {
|
|
@@ -4273,19 +4703,19 @@ var styles9 = StyleSheet10.create({
|
|
|
4273
4703
|
});
|
|
4274
4704
|
|
|
4275
4705
|
// src/ui/game/JoinGameSheet.tsx
|
|
4276
|
-
import { useState as
|
|
4706
|
+
import { useState as useState22, useEffect as useEffect13, useRef as useRef7, useCallback as useCallback18, useMemo as useMemo8 } from "react";
|
|
4277
4707
|
import {
|
|
4278
|
-
View as
|
|
4279
|
-
Text as
|
|
4280
|
-
TouchableOpacity as
|
|
4281
|
-
ActivityIndicator as
|
|
4282
|
-
Modal as
|
|
4283
|
-
Animated as
|
|
4284
|
-
StyleSheet as
|
|
4285
|
-
KeyboardAvoidingView as
|
|
4286
|
-
Platform as
|
|
4708
|
+
View as View12,
|
|
4709
|
+
Text as Text12,
|
|
4710
|
+
TouchableOpacity as TouchableOpacity8,
|
|
4711
|
+
ActivityIndicator as ActivityIndicator7,
|
|
4712
|
+
Modal as Modal3,
|
|
4713
|
+
Animated as Animated4,
|
|
4714
|
+
StyleSheet as StyleSheet12,
|
|
4715
|
+
KeyboardAvoidingView as KeyboardAvoidingView4,
|
|
4716
|
+
Platform as Platform7
|
|
4287
4717
|
} from "react-native";
|
|
4288
|
-
import { Fragment as Fragment4, jsx as
|
|
4718
|
+
import { Fragment as Fragment4, jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
4289
4719
|
var STATUS_LABELS3 = {
|
|
4290
4720
|
building: "Building transaction...",
|
|
4291
4721
|
signing: "Approve in wallet...",
|
|
@@ -4309,22 +4739,22 @@ function JoinGameSheet({
|
|
|
4309
4739
|
const { wallet } = useDubs();
|
|
4310
4740
|
const mutation = useJoinGame();
|
|
4311
4741
|
const isCustomGame = game.gameMode === CUSTOM_GAME_MODE;
|
|
4312
|
-
const [selectedTeam, setSelectedTeam] =
|
|
4313
|
-
const overlayOpacity =
|
|
4314
|
-
|
|
4315
|
-
|
|
4742
|
+
const [selectedTeam, setSelectedTeam] = useState22(null);
|
|
4743
|
+
const overlayOpacity = useRef7(new Animated4.Value(0)).current;
|
|
4744
|
+
useEffect13(() => {
|
|
4745
|
+
Animated4.timing(overlayOpacity, {
|
|
4316
4746
|
toValue: visible ? 1 : 0,
|
|
4317
4747
|
duration: 250,
|
|
4318
4748
|
useNativeDriver: true
|
|
4319
4749
|
}).start();
|
|
4320
4750
|
}, [visible, overlayOpacity]);
|
|
4321
|
-
|
|
4751
|
+
useEffect13(() => {
|
|
4322
4752
|
if (visible) {
|
|
4323
4753
|
setSelectedTeam(isPoolModeEnabled ? "home" : isCustomGame ? "away" : null);
|
|
4324
4754
|
mutation.reset();
|
|
4325
4755
|
}
|
|
4326
4756
|
}, [visible]);
|
|
4327
|
-
|
|
4757
|
+
useEffect13(() => {
|
|
4328
4758
|
if (mutation.status === "success" && mutation.data) {
|
|
4329
4759
|
onSuccess?.(mutation.data);
|
|
4330
4760
|
const timer = setTimeout(() => {
|
|
@@ -4333,7 +4763,7 @@ function JoinGameSheet({
|
|
|
4333
4763
|
return () => clearTimeout(timer);
|
|
4334
4764
|
}
|
|
4335
4765
|
}, [mutation.status, mutation.data]);
|
|
4336
|
-
|
|
4766
|
+
useEffect13(() => {
|
|
4337
4767
|
if (mutation.status === "error" && mutation.error) {
|
|
4338
4768
|
onError?.(mutation.error);
|
|
4339
4769
|
}
|
|
@@ -4344,7 +4774,7 @@ function JoinGameSheet({
|
|
|
4344
4774
|
const homePool = game.homePool || 0;
|
|
4345
4775
|
const awayPool = game.awayPool || 0;
|
|
4346
4776
|
const buyIn = game.buyIn;
|
|
4347
|
-
const { homeOdds, awayOdds, homeBets, awayBets } =
|
|
4777
|
+
const { homeOdds, awayOdds, homeBets, awayBets } = useMemo8(() => ({
|
|
4348
4778
|
homeOdds: homePool > 0 ? (totalPool / homePool).toFixed(2) : "\u2014",
|
|
4349
4779
|
awayOdds: awayPool > 0 ? (totalPool / awayPool).toFixed(2) : "\u2014",
|
|
4350
4780
|
homeBets: bettors.filter((b) => b.team === "home").length,
|
|
@@ -4356,14 +4786,14 @@ function JoinGameSheet({
|
|
|
4356
4786
|
const homeName = shortName ? shortName(opponents[0]?.name) : opponents[0]?.name || "Home";
|
|
4357
4787
|
const awayName = shortName ? shortName(opponents[1]?.name) : opponents[1]?.name || "Away";
|
|
4358
4788
|
const selectedName = selectedTeam === "home" ? homeName : selectedTeam === "away" ? awayName : "\u2014";
|
|
4359
|
-
const alreadyJoined =
|
|
4789
|
+
const alreadyJoined = useMemo8(() => {
|
|
4360
4790
|
if (!wallet.publicKey) return false;
|
|
4361
4791
|
const addr = wallet.publicKey.toBase58();
|
|
4362
4792
|
return bettors.some((b) => b.wallet === addr);
|
|
4363
4793
|
}, [bettors, wallet.publicKey]);
|
|
4364
4794
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
4365
4795
|
const canJoin = selectedTeam !== null && !isMutating && mutation.status !== "success" && !alreadyJoined;
|
|
4366
|
-
const handleJoin =
|
|
4796
|
+
const handleJoin = useCallback18(async () => {
|
|
4367
4797
|
if (!selectedTeam || !wallet.publicKey) return;
|
|
4368
4798
|
try {
|
|
4369
4799
|
await mutation.execute({
|
|
@@ -4376,30 +4806,30 @@ function JoinGameSheet({
|
|
|
4376
4806
|
}
|
|
4377
4807
|
}, [selectedTeam, wallet.publicKey, mutation.execute, game.gameId, buyIn]);
|
|
4378
4808
|
const statusLabel = STATUS_LABELS3[mutation.status] || "";
|
|
4379
|
-
return /* @__PURE__ */
|
|
4380
|
-
|
|
4809
|
+
return /* @__PURE__ */ jsxs12(
|
|
4810
|
+
Modal3,
|
|
4381
4811
|
{
|
|
4382
4812
|
visible,
|
|
4383
4813
|
animationType: "slide",
|
|
4384
4814
|
transparent: true,
|
|
4385
4815
|
onRequestClose: onDismiss,
|
|
4386
4816
|
children: [
|
|
4387
|
-
/* @__PURE__ */
|
|
4388
|
-
/* @__PURE__ */
|
|
4389
|
-
|
|
4817
|
+
/* @__PURE__ */ jsx14(Animated4.View, { style: [styles11.overlay, { opacity: overlayOpacity }], children: /* @__PURE__ */ jsx14(TouchableOpacity8, { style: styles11.overlayTap, activeOpacity: 1, onPress: onDismiss }) }),
|
|
4818
|
+
/* @__PURE__ */ jsx14(
|
|
4819
|
+
KeyboardAvoidingView4,
|
|
4390
4820
|
{
|
|
4391
|
-
style:
|
|
4392
|
-
behavior:
|
|
4393
|
-
children: /* @__PURE__ */
|
|
4394
|
-
/* @__PURE__ */
|
|
4395
|
-
/* @__PURE__ */
|
|
4396
|
-
/* @__PURE__ */
|
|
4397
|
-
/* @__PURE__ */
|
|
4821
|
+
style: styles11.keyboardView,
|
|
4822
|
+
behavior: Platform7.OS === "ios" ? "padding" : void 0,
|
|
4823
|
+
children: /* @__PURE__ */ jsx14(View12, { style: styles11.sheetPositioner, children: /* @__PURE__ */ jsxs12(View12, { style: [styles11.sheet, { backgroundColor: t.background }], children: [
|
|
4824
|
+
/* @__PURE__ */ jsx14(View12, { style: styles11.handleRow, children: /* @__PURE__ */ jsx14(View12, { style: [styles11.handle, { backgroundColor: t.textMuted }] }) }),
|
|
4825
|
+
/* @__PURE__ */ jsxs12(View12, { style: styles11.header, children: [
|
|
4826
|
+
/* @__PURE__ */ jsx14(Text12, { style: [styles11.headerTitle, { color: t.text }], children: isPoolModeEnabled ? "Join Pool" : "Join Game" }),
|
|
4827
|
+
/* @__PURE__ */ jsx14(TouchableOpacity8, { onPress: onDismiss, activeOpacity: 0.8, children: /* @__PURE__ */ jsx14(Text12, { style: [styles11.closeButton, { color: t.textMuted }], children: "\u2715" }) })
|
|
4398
4828
|
] }),
|
|
4399
|
-
!isCustomGame && !isPoolModeEnabled && /* @__PURE__ */
|
|
4400
|
-
/* @__PURE__ */
|
|
4401
|
-
/* @__PURE__ */
|
|
4402
|
-
/* @__PURE__ */
|
|
4829
|
+
!isCustomGame && !isPoolModeEnabled && /* @__PURE__ */ jsxs12(View12, { style: styles11.section, children: [
|
|
4830
|
+
/* @__PURE__ */ jsx14(Text12, { style: [styles11.sectionLabel, { color: t.textSecondary }], children: "Pick Your Side" }),
|
|
4831
|
+
/* @__PURE__ */ jsxs12(View12, { style: styles11.teamsRow, children: [
|
|
4832
|
+
/* @__PURE__ */ jsx14(
|
|
4403
4833
|
TeamButton,
|
|
4404
4834
|
{
|
|
4405
4835
|
name: homeName,
|
|
@@ -4413,7 +4843,7 @@ function JoinGameSheet({
|
|
|
4413
4843
|
t
|
|
4414
4844
|
}
|
|
4415
4845
|
),
|
|
4416
|
-
/* @__PURE__ */
|
|
4846
|
+
/* @__PURE__ */ jsx14(
|
|
4417
4847
|
TeamButton,
|
|
4418
4848
|
{
|
|
4419
4849
|
name: awayName,
|
|
@@ -4429,64 +4859,64 @@ function JoinGameSheet({
|
|
|
4429
4859
|
)
|
|
4430
4860
|
] })
|
|
4431
4861
|
] }),
|
|
4432
|
-
/* @__PURE__ */
|
|
4433
|
-
/* @__PURE__ */
|
|
4434
|
-
/* @__PURE__ */
|
|
4435
|
-
/* @__PURE__ */
|
|
4862
|
+
/* @__PURE__ */ jsxs12(View12, { style: [styles11.summaryCard, { backgroundColor: t.surface, borderColor: t.border }], children: [
|
|
4863
|
+
/* @__PURE__ */ jsxs12(View12, { style: styles11.summaryRow, children: [
|
|
4864
|
+
/* @__PURE__ */ jsx14(Text12, { style: [styles11.summaryLabel, { color: t.textMuted }], children: "Buy-in" }),
|
|
4865
|
+
/* @__PURE__ */ jsxs12(Text12, { style: [styles11.summaryValue, { color: t.text }], children: [
|
|
4436
4866
|
buyIn,
|
|
4437
4867
|
" SOL"
|
|
4438
4868
|
] })
|
|
4439
4869
|
] }),
|
|
4440
|
-
/* @__PURE__ */
|
|
4441
|
-
isPoolModeEnabled ? /* @__PURE__ */
|
|
4442
|
-
/* @__PURE__ */
|
|
4443
|
-
/* @__PURE__ */
|
|
4444
|
-
/* @__PURE__ */
|
|
4870
|
+
/* @__PURE__ */ jsx14(View12, { style: [styles11.summarySep, { backgroundColor: t.border }] }),
|
|
4871
|
+
isPoolModeEnabled ? /* @__PURE__ */ jsxs12(Fragment4, { children: [
|
|
4872
|
+
/* @__PURE__ */ jsxs12(View12, { style: styles11.summaryRow, children: [
|
|
4873
|
+
/* @__PURE__ */ jsx14(Text12, { style: [styles11.summaryLabel, { color: t.textMuted }], children: "Players in" }),
|
|
4874
|
+
/* @__PURE__ */ jsx14(Text12, { style: [styles11.summaryValue, { color: t.text }], children: bettors.length })
|
|
4445
4875
|
] }),
|
|
4446
|
-
/* @__PURE__ */
|
|
4447
|
-
/* @__PURE__ */
|
|
4448
|
-
/* @__PURE__ */
|
|
4449
|
-
/* @__PURE__ */
|
|
4876
|
+
/* @__PURE__ */ jsx14(View12, { style: [styles11.summarySep, { backgroundColor: t.border }] }),
|
|
4877
|
+
/* @__PURE__ */ jsxs12(View12, { style: styles11.summaryRow, children: [
|
|
4878
|
+
/* @__PURE__ */ jsx14(Text12, { style: [styles11.summaryLabel, { color: t.textMuted }], children: "Current pot" }),
|
|
4879
|
+
/* @__PURE__ */ jsxs12(Text12, { style: [styles11.summaryValue, { color: t.success }], children: [
|
|
4450
4880
|
totalPool,
|
|
4451
4881
|
" SOL"
|
|
4452
4882
|
] })
|
|
4453
4883
|
] })
|
|
4454
|
-
] }) : /* @__PURE__ */
|
|
4455
|
-
/* @__PURE__ */
|
|
4456
|
-
/* @__PURE__ */
|
|
4457
|
-
/* @__PURE__ */
|
|
4884
|
+
] }) : /* @__PURE__ */ jsxs12(Fragment4, { children: [
|
|
4885
|
+
/* @__PURE__ */ jsxs12(View12, { style: styles11.summaryRow, children: [
|
|
4886
|
+
/* @__PURE__ */ jsx14(Text12, { style: [styles11.summaryLabel, { color: t.textMuted }], children: "Your side" }),
|
|
4887
|
+
/* @__PURE__ */ jsx14(Text12, { style: [styles11.summaryValue, { color: t.text }], children: selectedName })
|
|
4458
4888
|
] }),
|
|
4459
|
-
/* @__PURE__ */
|
|
4460
|
-
/* @__PURE__ */
|
|
4461
|
-
/* @__PURE__ */
|
|
4462
|
-
/* @__PURE__ */
|
|
4889
|
+
/* @__PURE__ */ jsx14(View12, { style: [styles11.summarySep, { backgroundColor: t.border }] }),
|
|
4890
|
+
/* @__PURE__ */ jsxs12(View12, { style: styles11.summaryRow, children: [
|
|
4891
|
+
/* @__PURE__ */ jsx14(Text12, { style: [styles11.summaryLabel, { color: t.textMuted }], children: "Total pool" }),
|
|
4892
|
+
/* @__PURE__ */ jsxs12(Text12, { style: [styles11.summaryValue, { color: t.text }], children: [
|
|
4463
4893
|
poolAfterJoin,
|
|
4464
4894
|
" SOL"
|
|
4465
4895
|
] })
|
|
4466
4896
|
] }),
|
|
4467
|
-
/* @__PURE__ */
|
|
4468
|
-
/* @__PURE__ */
|
|
4469
|
-
/* @__PURE__ */
|
|
4470
|
-
/* @__PURE__ */
|
|
4897
|
+
/* @__PURE__ */ jsx14(View12, { style: [styles11.summarySep, { backgroundColor: t.border }] }),
|
|
4898
|
+
/* @__PURE__ */ jsxs12(View12, { style: styles11.summaryRow, children: [
|
|
4899
|
+
/* @__PURE__ */ jsx14(Text12, { style: [styles11.summaryLabel, { color: t.textMuted }], children: "Potential winnings" }),
|
|
4900
|
+
/* @__PURE__ */ jsx14(Text12, { style: [styles11.summaryValue, { color: t.success }], children: potentialWinnings !== "\u2014" ? `${potentialWinnings} SOL` : "\u2014" })
|
|
4471
4901
|
] })
|
|
4472
4902
|
] })
|
|
4473
4903
|
] }),
|
|
4474
|
-
alreadyJoined && /* @__PURE__ */
|
|
4475
|
-
mutation.error && /* @__PURE__ */
|
|
4476
|
-
/* @__PURE__ */
|
|
4477
|
-
|
|
4904
|
+
alreadyJoined && /* @__PURE__ */ jsx14(View12, { style: [styles11.errorBox, { backgroundColor: t.surface, borderColor: t.border }], children: /* @__PURE__ */ jsx14(Text12, { style: [styles11.errorText, { color: t.textMuted }], children: isPoolModeEnabled ? "You've already joined this pool." : "You've already joined this game." }) }),
|
|
4905
|
+
mutation.error && /* @__PURE__ */ jsx14(View12, { style: [styles11.errorBox, { backgroundColor: t.errorBg, borderColor: t.errorBorder }], children: /* @__PURE__ */ jsx14(Text12, { style: [styles11.errorText, { color: t.errorText }], children: mutation.error.message }) }),
|
|
4906
|
+
/* @__PURE__ */ jsx14(
|
|
4907
|
+
TouchableOpacity8,
|
|
4478
4908
|
{
|
|
4479
4909
|
style: [
|
|
4480
|
-
|
|
4910
|
+
styles11.ctaButton,
|
|
4481
4911
|
{ backgroundColor: canJoin ? t.accent : t.border }
|
|
4482
4912
|
],
|
|
4483
4913
|
disabled: !canJoin,
|
|
4484
4914
|
onPress: handleJoin,
|
|
4485
4915
|
activeOpacity: 0.8,
|
|
4486
|
-
children: isMutating ? /* @__PURE__ */
|
|
4487
|
-
/* @__PURE__ */
|
|
4488
|
-
/* @__PURE__ */
|
|
4489
|
-
] }) : mutation.status === "success" ? /* @__PURE__ */
|
|
4916
|
+
children: isMutating ? /* @__PURE__ */ jsxs12(View12, { style: styles11.ctaLoading, children: [
|
|
4917
|
+
/* @__PURE__ */ jsx14(ActivityIndicator7, { size: "small", color: "#FFFFFF" }),
|
|
4918
|
+
/* @__PURE__ */ jsx14(Text12, { style: styles11.ctaText, children: statusLabel })
|
|
4919
|
+
] }) : mutation.status === "success" ? /* @__PURE__ */ jsx14(Text12, { style: styles11.ctaText, children: isPoolModeEnabled ? "Joined!" : STATUS_LABELS3.success }) : /* @__PURE__ */ jsx14(Text12, { style: [styles11.ctaText, !canJoin && { opacity: 0.5 }], children: alreadyJoined ? "Already Joined" : isPoolModeEnabled ? `Join Pool \u2014 ${buyIn} SOL` : selectedTeam ? `Join Game \u2014 ${buyIn} SOL` : "Pick a side to join" })
|
|
4490
4920
|
}
|
|
4491
4921
|
)
|
|
4492
4922
|
] }) })
|
|
@@ -4507,35 +4937,35 @@ function TeamButton({
|
|
|
4507
4937
|
ImageComponent,
|
|
4508
4938
|
t
|
|
4509
4939
|
}) {
|
|
4510
|
-
const [imgFailed, setImgFailed] =
|
|
4940
|
+
const [imgFailed, setImgFailed] = useState22(false);
|
|
4511
4941
|
const Img = ImageComponent || __require("react-native").Image;
|
|
4512
4942
|
const showImage = imageUrl && !imgFailed;
|
|
4513
|
-
return /* @__PURE__ */
|
|
4514
|
-
|
|
4943
|
+
return /* @__PURE__ */ jsxs12(
|
|
4944
|
+
TouchableOpacity8,
|
|
4515
4945
|
{
|
|
4516
|
-
style: [
|
|
4946
|
+
style: [styles11.teamOption, { borderColor: selected ? color : t.border, backgroundColor: selected ? color + "15" : t.background }],
|
|
4517
4947
|
onPress,
|
|
4518
4948
|
activeOpacity: 0.7,
|
|
4519
4949
|
children: [
|
|
4520
|
-
showImage ? /* @__PURE__ */
|
|
4521
|
-
/* @__PURE__ */
|
|
4522
|
-
/* @__PURE__ */
|
|
4950
|
+
showImage ? /* @__PURE__ */ jsx14(Img, { source: { uri: imageUrl }, style: styles11.teamLogo, resizeMode: "contain", onError: () => setImgFailed(true) }) : /* @__PURE__ */ jsx14(View12, { style: [styles11.teamLogo, styles11.teamLogoPlaceholder] }),
|
|
4951
|
+
/* @__PURE__ */ jsx14(Text12, { style: [styles11.teamName, { color: t.text }], numberOfLines: 1, children: name }),
|
|
4952
|
+
/* @__PURE__ */ jsxs12(Text12, { style: [styles11.teamOdds, { color }], children: [
|
|
4523
4953
|
odds,
|
|
4524
4954
|
"x"
|
|
4525
4955
|
] }),
|
|
4526
|
-
/* @__PURE__ */
|
|
4956
|
+
/* @__PURE__ */ jsxs12(Text12, { style: [styles11.teamBets, { color: t.textMuted }], children: [
|
|
4527
4957
|
bets,
|
|
4528
4958
|
" ",
|
|
4529
4959
|
bets === 1 ? "bet" : "bets"
|
|
4530
4960
|
] }),
|
|
4531
|
-
selected && /* @__PURE__ */
|
|
4961
|
+
selected && /* @__PURE__ */ jsx14(View12, { style: [styles11.teamBadge, { backgroundColor: color }], children: /* @__PURE__ */ jsx14(Text12, { style: styles11.teamBadgeText, children: "Selected" }) })
|
|
4532
4962
|
]
|
|
4533
4963
|
}
|
|
4534
4964
|
);
|
|
4535
4965
|
}
|
|
4536
|
-
var
|
|
4966
|
+
var styles11 = StyleSheet12.create({
|
|
4537
4967
|
overlay: {
|
|
4538
|
-
...
|
|
4968
|
+
...StyleSheet12.absoluteFillObject,
|
|
4539
4969
|
backgroundColor: "rgba(0,0,0,0.5)"
|
|
4540
4970
|
},
|
|
4541
4971
|
overlayTap: {
|
|
@@ -4684,19 +5114,19 @@ var styles10 = StyleSheet11.create({
|
|
|
4684
5114
|
});
|
|
4685
5115
|
|
|
4686
5116
|
// src/ui/game/ClaimPrizeSheet.tsx
|
|
4687
|
-
import { useState as
|
|
5117
|
+
import { useState as useState23, useEffect as useEffect14, useRef as useRef8, useCallback as useCallback19 } from "react";
|
|
4688
5118
|
import {
|
|
4689
|
-
View as
|
|
4690
|
-
Text as
|
|
4691
|
-
TouchableOpacity as
|
|
4692
|
-
ActivityIndicator as
|
|
4693
|
-
Modal as
|
|
4694
|
-
Animated as
|
|
4695
|
-
StyleSheet as
|
|
4696
|
-
KeyboardAvoidingView as
|
|
4697
|
-
Platform as
|
|
5119
|
+
View as View13,
|
|
5120
|
+
Text as Text13,
|
|
5121
|
+
TouchableOpacity as TouchableOpacity9,
|
|
5122
|
+
ActivityIndicator as ActivityIndicator8,
|
|
5123
|
+
Modal as Modal4,
|
|
5124
|
+
Animated as Animated5,
|
|
5125
|
+
StyleSheet as StyleSheet13,
|
|
5126
|
+
KeyboardAvoidingView as KeyboardAvoidingView5,
|
|
5127
|
+
Platform as Platform8
|
|
4698
5128
|
} from "react-native";
|
|
4699
|
-
import { jsx as
|
|
5129
|
+
import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
4700
5130
|
var STATUS_LABELS4 = {
|
|
4701
5131
|
building: "Building transaction...",
|
|
4702
5132
|
signing: "Approve in wallet...",
|
|
@@ -4715,18 +5145,18 @@ function ClaimPrizeSheet({
|
|
|
4715
5145
|
const t = useDubsTheme();
|
|
4716
5146
|
const { wallet } = useDubs();
|
|
4717
5147
|
const mutation = useClaim();
|
|
4718
|
-
const overlayOpacity =
|
|
4719
|
-
const celebrationScale =
|
|
4720
|
-
const celebrationOpacity =
|
|
4721
|
-
const [showCelebration, setShowCelebration] =
|
|
4722
|
-
|
|
4723
|
-
|
|
5148
|
+
const overlayOpacity = useRef8(new Animated5.Value(0)).current;
|
|
5149
|
+
const celebrationScale = useRef8(new Animated5.Value(0)).current;
|
|
5150
|
+
const celebrationOpacity = useRef8(new Animated5.Value(0)).current;
|
|
5151
|
+
const [showCelebration, setShowCelebration] = useState23(false);
|
|
5152
|
+
useEffect14(() => {
|
|
5153
|
+
Animated5.timing(overlayOpacity, {
|
|
4724
5154
|
toValue: visible ? 1 : 0,
|
|
4725
5155
|
duration: 250,
|
|
4726
5156
|
useNativeDriver: true
|
|
4727
5157
|
}).start();
|
|
4728
5158
|
}, [visible, overlayOpacity]);
|
|
4729
|
-
|
|
5159
|
+
useEffect14(() => {
|
|
4730
5160
|
if (visible) {
|
|
4731
5161
|
mutation.reset();
|
|
4732
5162
|
setShowCelebration(false);
|
|
@@ -4734,17 +5164,17 @@ function ClaimPrizeSheet({
|
|
|
4734
5164
|
celebrationOpacity.setValue(0);
|
|
4735
5165
|
}
|
|
4736
5166
|
}, [visible]);
|
|
4737
|
-
|
|
5167
|
+
useEffect14(() => {
|
|
4738
5168
|
if (mutation.status === "success" && mutation.data) {
|
|
4739
5169
|
setShowCelebration(true);
|
|
4740
|
-
|
|
4741
|
-
|
|
5170
|
+
Animated5.parallel([
|
|
5171
|
+
Animated5.spring(celebrationScale, {
|
|
4742
5172
|
toValue: 1,
|
|
4743
5173
|
tension: 50,
|
|
4744
5174
|
friction: 6,
|
|
4745
5175
|
useNativeDriver: true
|
|
4746
5176
|
}),
|
|
4747
|
-
|
|
5177
|
+
Animated5.timing(celebrationOpacity, {
|
|
4748
5178
|
toValue: 1,
|
|
4749
5179
|
duration: 300,
|
|
4750
5180
|
useNativeDriver: true
|
|
@@ -4757,14 +5187,14 @@ function ClaimPrizeSheet({
|
|
|
4757
5187
|
return () => clearTimeout(timer);
|
|
4758
5188
|
}
|
|
4759
5189
|
}, [mutation.status, mutation.data]);
|
|
4760
|
-
|
|
5190
|
+
useEffect14(() => {
|
|
4761
5191
|
if (mutation.status === "error" && mutation.error) {
|
|
4762
5192
|
onError?.(mutation.error);
|
|
4763
5193
|
}
|
|
4764
5194
|
}, [mutation.status, mutation.error]);
|
|
4765
5195
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
4766
5196
|
const canClaim = !isMutating && mutation.status !== "success" && !!wallet.publicKey;
|
|
4767
|
-
const handleClaim =
|
|
5197
|
+
const handleClaim = useCallback19(async () => {
|
|
4768
5198
|
if (!wallet.publicKey) return;
|
|
4769
5199
|
try {
|
|
4770
5200
|
await mutation.execute({
|
|
@@ -4776,62 +5206,62 @@ function ClaimPrizeSheet({
|
|
|
4776
5206
|
}
|
|
4777
5207
|
}, [wallet.publicKey, mutation.execute, gameId, prizeAmount]);
|
|
4778
5208
|
const statusLabel = STATUS_LABELS4[mutation.status] || "";
|
|
4779
|
-
return /* @__PURE__ */
|
|
4780
|
-
|
|
5209
|
+
return /* @__PURE__ */ jsxs13(
|
|
5210
|
+
Modal4,
|
|
4781
5211
|
{
|
|
4782
5212
|
visible,
|
|
4783
5213
|
animationType: "slide",
|
|
4784
5214
|
transparent: true,
|
|
4785
5215
|
onRequestClose: onDismiss,
|
|
4786
5216
|
children: [
|
|
4787
|
-
/* @__PURE__ */
|
|
4788
|
-
/* @__PURE__ */
|
|
4789
|
-
|
|
5217
|
+
/* @__PURE__ */ jsx15(Animated5.View, { style: [styles12.overlay, { opacity: overlayOpacity }], children: /* @__PURE__ */ jsx15(TouchableOpacity9, { style: styles12.overlayTap, activeOpacity: 1, onPress: onDismiss }) }),
|
|
5218
|
+
/* @__PURE__ */ jsx15(
|
|
5219
|
+
KeyboardAvoidingView5,
|
|
4790
5220
|
{
|
|
4791
|
-
style:
|
|
4792
|
-
behavior:
|
|
4793
|
-
children: /* @__PURE__ */
|
|
4794
|
-
/* @__PURE__ */
|
|
4795
|
-
/* @__PURE__ */
|
|
4796
|
-
/* @__PURE__ */
|
|
4797
|
-
/* @__PURE__ */
|
|
5221
|
+
style: styles12.keyboardView,
|
|
5222
|
+
behavior: Platform8.OS === "ios" ? "padding" : void 0,
|
|
5223
|
+
children: /* @__PURE__ */ jsx15(View13, { style: styles12.sheetPositioner, children: /* @__PURE__ */ jsxs13(View13, { style: [styles12.sheet, { backgroundColor: t.background }], children: [
|
|
5224
|
+
/* @__PURE__ */ jsx15(View13, { style: styles12.handleRow, children: /* @__PURE__ */ jsx15(View13, { style: [styles12.handle, { backgroundColor: t.textMuted }] }) }),
|
|
5225
|
+
/* @__PURE__ */ jsxs13(View13, { style: styles12.header, children: [
|
|
5226
|
+
/* @__PURE__ */ jsx15(Text13, { style: [styles12.headerTitle, { color: t.text }], children: showCelebration ? isRefund ? "Refund Claimed!" : "Prize Claimed!" : isRefund ? "Claim Refund" : "Claim Prize" }),
|
|
5227
|
+
/* @__PURE__ */ jsx15(TouchableOpacity9, { onPress: onDismiss, activeOpacity: 0.8, children: /* @__PURE__ */ jsx15(Text13, { style: [styles12.closeButton, { color: t.textMuted }], children: "\u2715" }) })
|
|
4798
5228
|
] }),
|
|
4799
|
-
showCelebration && /* @__PURE__ */
|
|
4800
|
-
|
|
5229
|
+
showCelebration && /* @__PURE__ */ jsxs13(
|
|
5230
|
+
Animated5.View,
|
|
4801
5231
|
{
|
|
4802
5232
|
style: [
|
|
4803
|
-
|
|
5233
|
+
styles12.celebrationContainer,
|
|
4804
5234
|
{
|
|
4805
5235
|
opacity: celebrationOpacity,
|
|
4806
5236
|
transform: [{ scale: celebrationScale }]
|
|
4807
5237
|
}
|
|
4808
5238
|
],
|
|
4809
5239
|
children: [
|
|
4810
|
-
/* @__PURE__ */
|
|
4811
|
-
/* @__PURE__ */
|
|
5240
|
+
/* @__PURE__ */ jsx15(Text13, { style: styles12.celebrationEmoji, children: "\u{1F3C6}" }),
|
|
5241
|
+
/* @__PURE__ */ jsxs13(Text13, { style: [styles12.celebrationText, { color: t.success }], children: [
|
|
4812
5242
|
"+",
|
|
4813
5243
|
prizeAmount,
|
|
4814
5244
|
" SOL"
|
|
4815
5245
|
] }),
|
|
4816
|
-
/* @__PURE__ */
|
|
5246
|
+
/* @__PURE__ */ jsx15(Text13, { style: [styles12.celebrationSubtext, { color: t.textMuted }], children: isRefund ? "Refund sent to your wallet" : "Winnings sent to your wallet" })
|
|
4817
5247
|
]
|
|
4818
5248
|
}
|
|
4819
5249
|
),
|
|
4820
|
-
!showCelebration && /* @__PURE__ */
|
|
4821
|
-
/* @__PURE__ */
|
|
4822
|
-
/* @__PURE__ */
|
|
4823
|
-
/* @__PURE__ */
|
|
5250
|
+
!showCelebration && /* @__PURE__ */ jsxs13(View13, { style: [styles12.summaryCard, { backgroundColor: t.surface, borderColor: t.border }], children: [
|
|
5251
|
+
/* @__PURE__ */ jsxs13(View13, { style: styles12.summaryRow, children: [
|
|
5252
|
+
/* @__PURE__ */ jsx15(Text13, { style: [styles12.summaryLabel, { color: t.textMuted }], children: isRefund ? "Refund" : "Prize" }),
|
|
5253
|
+
/* @__PURE__ */ jsxs13(Text13, { style: [styles12.summaryValue, { color: t.success }], children: [
|
|
4824
5254
|
prizeAmount,
|
|
4825
5255
|
" SOL"
|
|
4826
5256
|
] })
|
|
4827
5257
|
] }),
|
|
4828
|
-
/* @__PURE__ */
|
|
4829
|
-
/* @__PURE__ */
|
|
4830
|
-
/* @__PURE__ */
|
|
4831
|
-
/* @__PURE__ */
|
|
4832
|
-
|
|
5258
|
+
/* @__PURE__ */ jsx15(View13, { style: [styles12.summarySep, { backgroundColor: t.border }] }),
|
|
5259
|
+
/* @__PURE__ */ jsxs13(View13, { style: styles12.summaryRow, children: [
|
|
5260
|
+
/* @__PURE__ */ jsx15(Text13, { style: [styles12.summaryLabel, { color: t.textMuted }], children: "Game" }),
|
|
5261
|
+
/* @__PURE__ */ jsxs13(
|
|
5262
|
+
Text13,
|
|
4833
5263
|
{
|
|
4834
|
-
style: [
|
|
5264
|
+
style: [styles12.summaryValue, { color: t.text }],
|
|
4835
5265
|
numberOfLines: 1,
|
|
4836
5266
|
children: [
|
|
4837
5267
|
gameId.slice(0, 8),
|
|
@@ -4842,21 +5272,21 @@ function ClaimPrizeSheet({
|
|
|
4842
5272
|
)
|
|
4843
5273
|
] })
|
|
4844
5274
|
] }),
|
|
4845
|
-
mutation.error && /* @__PURE__ */
|
|
4846
|
-
!showCelebration && /* @__PURE__ */
|
|
4847
|
-
|
|
5275
|
+
mutation.error && /* @__PURE__ */ jsx15(View13, { style: [styles12.errorBox, { backgroundColor: t.errorBg, borderColor: t.errorBorder }], children: /* @__PURE__ */ jsx15(Text13, { style: [styles12.errorText, { color: t.errorText }], children: mutation.error.message }) }),
|
|
5276
|
+
!showCelebration && /* @__PURE__ */ jsx15(
|
|
5277
|
+
TouchableOpacity9,
|
|
4848
5278
|
{
|
|
4849
5279
|
style: [
|
|
4850
|
-
|
|
5280
|
+
styles12.ctaButton,
|
|
4851
5281
|
{ backgroundColor: canClaim ? t.accent : t.border }
|
|
4852
5282
|
],
|
|
4853
5283
|
disabled: !canClaim,
|
|
4854
5284
|
onPress: handleClaim,
|
|
4855
5285
|
activeOpacity: 0.8,
|
|
4856
|
-
children: isMutating ? /* @__PURE__ */
|
|
4857
|
-
/* @__PURE__ */
|
|
4858
|
-
/* @__PURE__ */
|
|
4859
|
-
] }) : /* @__PURE__ */
|
|
5286
|
+
children: isMutating ? /* @__PURE__ */ jsxs13(View13, { style: styles12.ctaLoading, children: [
|
|
5287
|
+
/* @__PURE__ */ jsx15(ActivityIndicator8, { size: "small", color: "#FFFFFF" }),
|
|
5288
|
+
/* @__PURE__ */ jsx15(Text13, { style: styles12.ctaText, children: statusLabel })
|
|
5289
|
+
] }) : /* @__PURE__ */ jsxs13(Text13, { style: [styles12.ctaText, !canClaim && { opacity: 0.5 }], children: [
|
|
4860
5290
|
isRefund ? "Claim Refund" : "Claim Prize",
|
|
4861
5291
|
" \u2014 ",
|
|
4862
5292
|
prizeAmount,
|
|
@@ -4864,7 +5294,7 @@ function ClaimPrizeSheet({
|
|
|
4864
5294
|
] })
|
|
4865
5295
|
}
|
|
4866
5296
|
),
|
|
4867
|
-
mutation.data?.explorerUrl && /* @__PURE__ */
|
|
5297
|
+
mutation.data?.explorerUrl && /* @__PURE__ */ jsx15(Text13, { style: [styles12.explorerHint, { color: t.textMuted }], children: "View on Solscan" })
|
|
4868
5298
|
] }) })
|
|
4869
5299
|
}
|
|
4870
5300
|
)
|
|
@@ -4872,9 +5302,9 @@ function ClaimPrizeSheet({
|
|
|
4872
5302
|
}
|
|
4873
5303
|
);
|
|
4874
5304
|
}
|
|
4875
|
-
var
|
|
5305
|
+
var styles12 = StyleSheet13.create({
|
|
4876
5306
|
overlay: {
|
|
4877
|
-
...
|
|
5307
|
+
...StyleSheet13.absoluteFillObject,
|
|
4878
5308
|
backgroundColor: "rgba(0,0,0,0.5)"
|
|
4879
5309
|
},
|
|
4880
5310
|
overlayTap: {
|
|
@@ -4997,17 +5427,17 @@ var styles11 = StyleSheet12.create({
|
|
|
4997
5427
|
});
|
|
4998
5428
|
|
|
4999
5429
|
// src/ui/game/ClaimButton.tsx
|
|
5000
|
-
import { useState as
|
|
5001
|
-
import { StyleSheet as
|
|
5002
|
-
import { Fragment as Fragment5, jsx as
|
|
5430
|
+
import { useState as useState24, useMemo as useMemo9, useCallback as useCallback20 } from "react";
|
|
5431
|
+
import { StyleSheet as StyleSheet14, Text as Text14, TouchableOpacity as TouchableOpacity10 } from "react-native";
|
|
5432
|
+
import { Fragment as Fragment5, jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
5003
5433
|
function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
5004
5434
|
const t = useDubsTheme();
|
|
5005
5435
|
const { wallet } = useDubs();
|
|
5006
5436
|
const game = useGame(gameId);
|
|
5007
5437
|
const claimStatus = useHasClaimed(gameId);
|
|
5008
|
-
const [sheetVisible, setSheetVisible] =
|
|
5438
|
+
const [sheetVisible, setSheetVisible] = useState24(false);
|
|
5009
5439
|
const walletAddress = wallet.publicKey?.toBase58() ?? null;
|
|
5010
|
-
const myBet =
|
|
5440
|
+
const myBet = useMemo9(() => {
|
|
5011
5441
|
if (!walletAddress || !game.data?.bettors) return null;
|
|
5012
5442
|
return game.data.bettors.find((b) => b.wallet === walletAddress) ?? null;
|
|
5013
5443
|
}, [walletAddress, game.data?.bettors]);
|
|
@@ -5016,7 +5446,7 @@ function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
|
5016
5446
|
const isWinner = isResolved && myBet != null && myBet.team === game.data?.winnerSide;
|
|
5017
5447
|
const isEligible = myBet != null && isResolved && (isWinner || isRefund);
|
|
5018
5448
|
const prizeAmount = isRefund ? myBet?.amount ?? 0 : game.data?.totalPool ?? 0;
|
|
5019
|
-
const handleSuccess =
|
|
5449
|
+
const handleSuccess = useCallback20(
|
|
5020
5450
|
(result) => {
|
|
5021
5451
|
claimStatus.refetch();
|
|
5022
5452
|
onSuccess?.(result);
|
|
@@ -5029,13 +5459,13 @@ function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
|
5029
5459
|
}
|
|
5030
5460
|
const label = isRefund ? "Refund" : "Prize";
|
|
5031
5461
|
if (claimStatus.hasClaimed) {
|
|
5032
|
-
return /* @__PURE__ */
|
|
5033
|
-
|
|
5462
|
+
return /* @__PURE__ */ jsx16(
|
|
5463
|
+
TouchableOpacity10,
|
|
5034
5464
|
{
|
|
5035
|
-
style: [
|
|
5465
|
+
style: [styles13.badge, { borderColor: t.accent }, style],
|
|
5036
5466
|
activeOpacity: 1,
|
|
5037
5467
|
disabled: true,
|
|
5038
|
-
children: /* @__PURE__ */
|
|
5468
|
+
children: /* @__PURE__ */ jsxs14(Text14, { style: [styles13.badgeText, { color: t.accent }], children: [
|
|
5039
5469
|
label,
|
|
5040
5470
|
" Claimed!"
|
|
5041
5471
|
] })
|
|
@@ -5045,14 +5475,14 @@ function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
|
5045
5475
|
if (!isEligible) {
|
|
5046
5476
|
return null;
|
|
5047
5477
|
}
|
|
5048
|
-
return /* @__PURE__ */
|
|
5049
|
-
/* @__PURE__ */
|
|
5050
|
-
|
|
5478
|
+
return /* @__PURE__ */ jsxs14(Fragment5, { children: [
|
|
5479
|
+
/* @__PURE__ */ jsx16(
|
|
5480
|
+
TouchableOpacity10,
|
|
5051
5481
|
{
|
|
5052
|
-
style: [
|
|
5482
|
+
style: [styles13.button, { backgroundColor: t.accent }, style],
|
|
5053
5483
|
activeOpacity: 0.8,
|
|
5054
5484
|
onPress: () => setSheetVisible(true),
|
|
5055
|
-
children: /* @__PURE__ */
|
|
5485
|
+
children: /* @__PURE__ */ jsxs14(Text14, { style: styles13.buttonText, children: [
|
|
5056
5486
|
"Claim ",
|
|
5057
5487
|
label,
|
|
5058
5488
|
" \u2014 ",
|
|
@@ -5061,7 +5491,7 @@ function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
|
5061
5491
|
] })
|
|
5062
5492
|
}
|
|
5063
5493
|
),
|
|
5064
|
-
/* @__PURE__ */
|
|
5494
|
+
/* @__PURE__ */ jsx16(
|
|
5065
5495
|
ClaimPrizeSheet,
|
|
5066
5496
|
{
|
|
5067
5497
|
visible: sheetVisible,
|
|
@@ -5075,7 +5505,7 @@ function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
|
5075
5505
|
)
|
|
5076
5506
|
] });
|
|
5077
5507
|
}
|
|
5078
|
-
var
|
|
5508
|
+
var styles13 = StyleSheet14.create({
|
|
5079
5509
|
button: {
|
|
5080
5510
|
height: 52,
|
|
5081
5511
|
borderRadius: 14,
|
|
@@ -5125,6 +5555,7 @@ export {
|
|
|
5125
5555
|
STORAGE_KEYS,
|
|
5126
5556
|
SettingsSheet,
|
|
5127
5557
|
UserProfileCard,
|
|
5558
|
+
UserProfileSheet,
|
|
5128
5559
|
createSecureStoreStorage,
|
|
5129
5560
|
getDeviceInfo,
|
|
5130
5561
|
isSolanaSeeker,
|