@dubsdotapp/expo 0.5.11 → 0.5.12
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 +24 -1
- package/dist/index.d.ts +24 -1
- package/dist/index.js +249 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +259 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +2 -1
- package/src/ui/game/CreateGameSheet.tsx +366 -0
- package/src/ui/game/index.ts +2 -0
- package/src/ui/index.ts +2 -1
package/dist/index.mjs
CHANGED
|
@@ -6905,6 +6905,264 @@ var styles18 = StyleSheet19.create({
|
|
|
6905
6905
|
emptyState: { paddingVertical: 40, alignItems: "center" },
|
|
6906
6906
|
emptyText: { fontSize: 14, fontWeight: "600" }
|
|
6907
6907
|
});
|
|
6908
|
+
|
|
6909
|
+
// src/ui/game/CreateGameSheet.tsx
|
|
6910
|
+
import { useState as useState32, useEffect as useEffect21, useRef as useRef14, useCallback as useCallback28 } from "react";
|
|
6911
|
+
import {
|
|
6912
|
+
View as View19,
|
|
6913
|
+
Text as Text20,
|
|
6914
|
+
Image as Image8,
|
|
6915
|
+
TouchableOpacity as TouchableOpacity15,
|
|
6916
|
+
ActivityIndicator as ActivityIndicator11,
|
|
6917
|
+
Modal as Modal7,
|
|
6918
|
+
Animated as Animated8,
|
|
6919
|
+
StyleSheet as StyleSheet20,
|
|
6920
|
+
KeyboardAvoidingView as KeyboardAvoidingView8,
|
|
6921
|
+
Platform as Platform12
|
|
6922
|
+
} from "react-native";
|
|
6923
|
+
import { jsx as jsx22, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
6924
|
+
var STATUS_LABELS6 = {
|
|
6925
|
+
building: "Building transaction...",
|
|
6926
|
+
signing: "Approve in wallet...",
|
|
6927
|
+
confirming: "Confirming...",
|
|
6928
|
+
success: "Game Created!"
|
|
6929
|
+
};
|
|
6930
|
+
function formatSol2(n) {
|
|
6931
|
+
return parseFloat(n.toFixed(9)).toString();
|
|
6932
|
+
}
|
|
6933
|
+
function CreateGameSheet({
|
|
6934
|
+
visible,
|
|
6935
|
+
onDismiss,
|
|
6936
|
+
event,
|
|
6937
|
+
homeColor = "#3B82F6",
|
|
6938
|
+
awayColor = "#EF4444",
|
|
6939
|
+
onSuccess,
|
|
6940
|
+
onError,
|
|
6941
|
+
onTeamSelect,
|
|
6942
|
+
onCreateSuccess,
|
|
6943
|
+
onSliderTick,
|
|
6944
|
+
maxWager = 1,
|
|
6945
|
+
shortName
|
|
6946
|
+
}) {
|
|
6947
|
+
const t = useDubsTheme();
|
|
6948
|
+
const { wallet } = useDubs();
|
|
6949
|
+
const mutation = useCreateGame();
|
|
6950
|
+
const [selectedTeam, setSelectedTeam] = useState32(null);
|
|
6951
|
+
const [wager, setWager] = useState32(0.01);
|
|
6952
|
+
const [showSuccess, setShowSuccess] = useState32(false);
|
|
6953
|
+
const overlayOpacity = useRef14(new Animated8.Value(0)).current;
|
|
6954
|
+
const successScale = useRef14(new Animated8.Value(0)).current;
|
|
6955
|
+
const successOpacity = useRef14(new Animated8.Value(0)).current;
|
|
6956
|
+
useEffect21(() => {
|
|
6957
|
+
Animated8.timing(overlayOpacity, {
|
|
6958
|
+
toValue: visible ? 1 : 0,
|
|
6959
|
+
duration: 250,
|
|
6960
|
+
useNativeDriver: true
|
|
6961
|
+
}).start();
|
|
6962
|
+
}, [visible]);
|
|
6963
|
+
useEffect21(() => {
|
|
6964
|
+
if (visible) {
|
|
6965
|
+
setSelectedTeam(null);
|
|
6966
|
+
setWager(0.01);
|
|
6967
|
+
setShowSuccess(false);
|
|
6968
|
+
successScale.setValue(0);
|
|
6969
|
+
successOpacity.setValue(0);
|
|
6970
|
+
mutation.reset();
|
|
6971
|
+
}
|
|
6972
|
+
}, [visible]);
|
|
6973
|
+
useEffect21(() => {
|
|
6974
|
+
if (mutation.status === "success" && mutation.data) {
|
|
6975
|
+
setShowSuccess(true);
|
|
6976
|
+
onSuccess?.(mutation.data);
|
|
6977
|
+
onCreateSuccess?.(mutation.data);
|
|
6978
|
+
Animated8.parallel([
|
|
6979
|
+
Animated8.spring(successScale, { toValue: 1, friction: 4, tension: 80, useNativeDriver: true }),
|
|
6980
|
+
Animated8.timing(successOpacity, { toValue: 1, duration: 300, useNativeDriver: true })
|
|
6981
|
+
]).start();
|
|
6982
|
+
const timer = setTimeout(() => {
|
|
6983
|
+
Animated8.timing(successOpacity, { toValue: 0, duration: 300, useNativeDriver: true }).start(() => {
|
|
6984
|
+
onDismiss();
|
|
6985
|
+
});
|
|
6986
|
+
}, 2500);
|
|
6987
|
+
return () => clearTimeout(timer);
|
|
6988
|
+
}
|
|
6989
|
+
}, [mutation.status, mutation.data]);
|
|
6990
|
+
useEffect21(() => {
|
|
6991
|
+
if (mutation.status === "error" && mutation.error) {
|
|
6992
|
+
onError?.(mutation.error);
|
|
6993
|
+
}
|
|
6994
|
+
}, [mutation.status, mutation.error]);
|
|
6995
|
+
const opponents = event.opponents || [];
|
|
6996
|
+
const homeName = shortName ? shortName(opponents[0]?.name) : opponents[0]?.name || "Home";
|
|
6997
|
+
const awayName = shortName ? shortName(opponents[1]?.name) : opponents[1]?.name || "Away";
|
|
6998
|
+
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
6999
|
+
const canCreate = selectedTeam !== null && !isMutating && mutation.status !== "success";
|
|
7000
|
+
const handleCreate = useCallback28(async () => {
|
|
7001
|
+
if (!selectedTeam || !wallet.publicKey) return;
|
|
7002
|
+
try {
|
|
7003
|
+
await mutation.execute({
|
|
7004
|
+
id: event.id,
|
|
7005
|
+
playerWallet: wallet.publicKey.toBase58(),
|
|
7006
|
+
teamChoice: selectedTeam,
|
|
7007
|
+
wagerAmount: wager
|
|
7008
|
+
});
|
|
7009
|
+
} catch {
|
|
7010
|
+
}
|
|
7011
|
+
}, [selectedTeam, wallet.publicKey, mutation.execute, event.id, wager]);
|
|
7012
|
+
const statusLabel = STATUS_LABELS6[mutation.status] || "";
|
|
7013
|
+
const startTime = event.startTime ? new Date(event.startTime) : null;
|
|
7014
|
+
const timeLabel = startTime ? startTime.toLocaleDateString("en-US", { weekday: "short", month: "short", day: "numeric" }) + " at " + startTime.toLocaleTimeString("en-US", { hour: "numeric", minute: "2-digit" }) : "TBD";
|
|
7015
|
+
return /* @__PURE__ */ jsxs19(Modal7, { visible, animationType: "slide", transparent: true, onRequestClose: onDismiss, children: [
|
|
7016
|
+
/* @__PURE__ */ jsx22(Animated8.View, { style: [styles19.overlay, { opacity: overlayOpacity }], children: /* @__PURE__ */ jsx22(TouchableOpacity15, { style: styles19.overlayTap, activeOpacity: 1, onPress: onDismiss }) }),
|
|
7017
|
+
showSuccess && /* @__PURE__ */ jsx22(View19, { style: styles19.successOverlay, children: /* @__PURE__ */ jsxs19(Animated8.View, { style: [styles19.successContent, { opacity: successOpacity, transform: [{ scale: successScale }] }], children: [
|
|
7018
|
+
/* @__PURE__ */ jsx22(Text20, { style: styles19.successEmoji, children: "\u{1F3AF}" }),
|
|
7019
|
+
/* @__PURE__ */ jsx22(Text20, { style: styles19.successTitle, children: "Game Created!" }),
|
|
7020
|
+
/* @__PURE__ */ jsxs19(Text20, { style: styles19.successSub, children: [
|
|
7021
|
+
formatSol2(wager),
|
|
7022
|
+
" SOL on ",
|
|
7023
|
+
selectedTeam === "home" ? homeName : awayName
|
|
7024
|
+
] })
|
|
7025
|
+
] }) }),
|
|
7026
|
+
/* @__PURE__ */ jsx22(KeyboardAvoidingView8, { style: styles19.keyboardView, behavior: Platform12.OS === "ios" ? "padding" : void 0, children: /* @__PURE__ */ jsx22(View19, { style: styles19.sheetPositioner, children: /* @__PURE__ */ jsxs19(View19, { style: [styles19.sheet, { backgroundColor: t.background }], children: [
|
|
7027
|
+
/* @__PURE__ */ jsx22(View19, { style: styles19.handleRow, children: /* @__PURE__ */ jsx22(View19, { style: [styles19.handle, { backgroundColor: t.textMuted }] }) }),
|
|
7028
|
+
/* @__PURE__ */ jsxs19(View19, { style: styles19.header, children: [
|
|
7029
|
+
/* @__PURE__ */ jsxs19(View19, { children: [
|
|
7030
|
+
/* @__PURE__ */ jsx22(Text20, { style: [styles19.headerTitle, { color: t.text }], children: "Create Game" }),
|
|
7031
|
+
/* @__PURE__ */ jsx22(Text20, { style: [styles19.headerSub, { color: t.textMuted }], children: timeLabel })
|
|
7032
|
+
] }),
|
|
7033
|
+
/* @__PURE__ */ jsx22(TouchableOpacity15, { onPress: onDismiss, activeOpacity: 0.8, children: /* @__PURE__ */ jsx22(Text20, { style: [styles19.closeButton, { color: t.textMuted }], children: "\u2715" }) })
|
|
7034
|
+
] }),
|
|
7035
|
+
/* @__PURE__ */ jsxs19(View19, { style: [styles19.matchupBanner, { borderColor: t.border }], children: [
|
|
7036
|
+
/* @__PURE__ */ jsxs19(View19, { style: styles19.matchupTeam, children: [
|
|
7037
|
+
opponents[0]?.imageUrl ? /* @__PURE__ */ jsx22(Image8, { source: { uri: opponents[0].imageUrl }, style: styles19.matchupLogo, resizeMode: "contain" }) : /* @__PURE__ */ jsx22(View19, { style: [styles19.matchupPlaceholder, { backgroundColor: homeColor + "20" }], children: /* @__PURE__ */ jsx22(Text20, { style: [styles19.matchupInitial, { color: homeColor }], children: homeName.charAt(0) }) }),
|
|
7038
|
+
/* @__PURE__ */ jsx22(Text20, { style: [styles19.matchupName, { color: t.text }], numberOfLines: 1, children: homeName })
|
|
7039
|
+
] }),
|
|
7040
|
+
/* @__PURE__ */ jsx22(Text20, { style: [styles19.matchupVs, { color: t.textMuted }], children: "vs" }),
|
|
7041
|
+
/* @__PURE__ */ jsxs19(View19, { style: styles19.matchupTeam, children: [
|
|
7042
|
+
opponents[1]?.imageUrl ? /* @__PURE__ */ jsx22(Image8, { source: { uri: opponents[1].imageUrl }, style: styles19.matchupLogo, resizeMode: "contain" }) : /* @__PURE__ */ jsx22(View19, { style: [styles19.matchupPlaceholder, { backgroundColor: awayColor + "20" }], children: /* @__PURE__ */ jsx22(Text20, { style: [styles19.matchupInitial, { color: awayColor }], children: awayName.charAt(0) }) }),
|
|
7043
|
+
/* @__PURE__ */ jsx22(Text20, { style: [styles19.matchupName, { color: t.text }], numberOfLines: 1, children: awayName })
|
|
7044
|
+
] })
|
|
7045
|
+
] }),
|
|
7046
|
+
/* @__PURE__ */ jsxs19(View19, { style: styles19.section, children: [
|
|
7047
|
+
/* @__PURE__ */ jsx22(Text20, { style: [styles19.sectionLabel, { color: t.textSecondary }], children: "Pick Your Side" }),
|
|
7048
|
+
/* @__PURE__ */ jsxs19(View19, { style: styles19.teamsRow, children: [
|
|
7049
|
+
/* @__PURE__ */ jsxs19(
|
|
7050
|
+
TouchableOpacity15,
|
|
7051
|
+
{
|
|
7052
|
+
style: [styles19.teamOption, { borderColor: selectedTeam === "home" ? homeColor : t.border, backgroundColor: selectedTeam === "home" ? homeColor + "15" : t.background }],
|
|
7053
|
+
onPress: () => {
|
|
7054
|
+
setSelectedTeam("home");
|
|
7055
|
+
onTeamSelect?.("home");
|
|
7056
|
+
},
|
|
7057
|
+
activeOpacity: 0.7,
|
|
7058
|
+
children: [
|
|
7059
|
+
/* @__PURE__ */ jsx22(Text20, { style: [styles19.teamLabel, { color: t.text }], children: homeName }),
|
|
7060
|
+
selectedTeam === "home" && /* @__PURE__ */ jsx22(View19, { style: [styles19.teamBadge, { backgroundColor: homeColor }], children: /* @__PURE__ */ jsx22(Text20, { style: styles19.teamBadgeText, children: "Selected" }) })
|
|
7061
|
+
]
|
|
7062
|
+
}
|
|
7063
|
+
),
|
|
7064
|
+
/* @__PURE__ */ jsxs19(
|
|
7065
|
+
TouchableOpacity15,
|
|
7066
|
+
{
|
|
7067
|
+
style: [styles19.teamOption, { borderColor: selectedTeam === "away" ? awayColor : t.border, backgroundColor: selectedTeam === "away" ? awayColor + "15" : t.background }],
|
|
7068
|
+
onPress: () => {
|
|
7069
|
+
setSelectedTeam("away");
|
|
7070
|
+
onTeamSelect?.("away");
|
|
7071
|
+
},
|
|
7072
|
+
activeOpacity: 0.7,
|
|
7073
|
+
children: [
|
|
7074
|
+
/* @__PURE__ */ jsx22(Text20, { style: [styles19.teamLabel, { color: t.text }], children: awayName }),
|
|
7075
|
+
selectedTeam === "away" && /* @__PURE__ */ jsx22(View19, { style: [styles19.teamBadge, { backgroundColor: awayColor }], children: /* @__PURE__ */ jsx22(Text20, { style: styles19.teamBadgeText, children: "Selected" }) })
|
|
7076
|
+
]
|
|
7077
|
+
}
|
|
7078
|
+
)
|
|
7079
|
+
] })
|
|
7080
|
+
] }),
|
|
7081
|
+
/* @__PURE__ */ jsxs19(View19, { style: [styles19.summaryCard, { backgroundColor: t.surface, borderColor: t.border }], children: [
|
|
7082
|
+
/* @__PURE__ */ jsxs19(View19, { style: styles19.summaryRow, children: [
|
|
7083
|
+
/* @__PURE__ */ jsx22(Text20, { style: [styles19.summaryLabel, { color: t.textMuted }], children: "Your wager" }),
|
|
7084
|
+
/* @__PURE__ */ jsxs19(Text20, { style: [styles19.summaryValue, { color: t.text }], children: [
|
|
7085
|
+
formatSol2(wager),
|
|
7086
|
+
" SOL"
|
|
7087
|
+
] })
|
|
7088
|
+
] }),
|
|
7089
|
+
/* @__PURE__ */ jsx22(View19, { style: [styles19.summarySep, { backgroundColor: t.border }] }),
|
|
7090
|
+
/* @__PURE__ */ jsxs19(View19, { style: styles19.summaryRow, children: [
|
|
7091
|
+
/* @__PURE__ */ jsx22(Text20, { style: [styles19.summaryLabel, { color: t.textMuted }], children: "You're the first" }),
|
|
7092
|
+
/* @__PURE__ */ jsx22(Text20, { style: [styles19.summaryValue, { color: t.success }], children: "Set the odds" })
|
|
7093
|
+
] })
|
|
7094
|
+
] }),
|
|
7095
|
+
selectedTeam && /* @__PURE__ */ jsx22(
|
|
7096
|
+
SolSlider,
|
|
7097
|
+
{
|
|
7098
|
+
value: wager,
|
|
7099
|
+
min: 0.01,
|
|
7100
|
+
max: maxWager,
|
|
7101
|
+
step: 0.01,
|
|
7102
|
+
accentColor: selectedTeam === "home" ? homeColor : awayColor,
|
|
7103
|
+
onValueChange: setWager,
|
|
7104
|
+
onTick: onSliderTick
|
|
7105
|
+
}
|
|
7106
|
+
),
|
|
7107
|
+
mutation.error && /* @__PURE__ */ jsx22(View19, { style: [styles19.errorBox, { backgroundColor: t.errorBg, borderColor: t.errorBorder }], children: /* @__PURE__ */ jsx22(Text20, { style: [styles19.errorText, { color: t.errorText }], children: mutation.error.message }) }),
|
|
7108
|
+
/* @__PURE__ */ jsx22(
|
|
7109
|
+
TouchableOpacity15,
|
|
7110
|
+
{
|
|
7111
|
+
style: [styles19.ctaButton, { backgroundColor: canCreate ? t.accent : t.border }],
|
|
7112
|
+
disabled: !canCreate,
|
|
7113
|
+
onPress: handleCreate,
|
|
7114
|
+
activeOpacity: 0.8,
|
|
7115
|
+
children: isMutating ? /* @__PURE__ */ jsxs19(View19, { style: styles19.ctaLoading, children: [
|
|
7116
|
+
/* @__PURE__ */ jsx22(ActivityIndicator11, { size: "small", color: "#FFFFFF" }),
|
|
7117
|
+
/* @__PURE__ */ jsx22(Text20, { style: styles19.ctaText, children: statusLabel })
|
|
7118
|
+
] }) : mutation.status === "success" ? /* @__PURE__ */ jsx22(Text20, { style: styles19.ctaText, children: "Game Created!" }) : /* @__PURE__ */ jsx22(Text20, { style: [styles19.ctaText, !canCreate && { opacity: 0.5 }], children: selectedTeam ? `Create Game \u2014 ${formatSol2(wager)} SOL` : "Pick a side to start" })
|
|
7119
|
+
}
|
|
7120
|
+
)
|
|
7121
|
+
] }) }) })
|
|
7122
|
+
] });
|
|
7123
|
+
}
|
|
7124
|
+
var styles19 = StyleSheet20.create({
|
|
7125
|
+
overlay: { ...StyleSheet20.absoluteFillObject, backgroundColor: "rgba(0,0,0,0.5)" },
|
|
7126
|
+
overlayTap: { flex: 1 },
|
|
7127
|
+
keyboardView: { flex: 1, justifyContent: "flex-end" },
|
|
7128
|
+
sheetPositioner: { justifyContent: "flex-end" },
|
|
7129
|
+
sheet: { borderTopLeftRadius: 24, borderTopRightRadius: 24, paddingHorizontal: 20, paddingBottom: 40 },
|
|
7130
|
+
handleRow: { alignItems: "center", paddingTop: 10, paddingBottom: 8 },
|
|
7131
|
+
handle: { width: 36, height: 4, borderRadius: 2, opacity: 0.4 },
|
|
7132
|
+
header: { flexDirection: "row", alignItems: "flex-start", justifyContent: "space-between", paddingVertical: 8 },
|
|
7133
|
+
headerTitle: { fontSize: 20, fontWeight: "700" },
|
|
7134
|
+
headerSub: { fontSize: 13, marginTop: 2 },
|
|
7135
|
+
closeButton: { fontSize: 20, padding: 4 },
|
|
7136
|
+
matchupBanner: { flexDirection: "row", alignItems: "center", justifyContent: "center", paddingVertical: 16, borderBottomWidth: 1, gap: 16 },
|
|
7137
|
+
matchupTeam: { flex: 1, alignItems: "center", gap: 6 },
|
|
7138
|
+
matchupLogo: { width: 40, height: 40 },
|
|
7139
|
+
matchupPlaceholder: { width: 40, height: 40, borderRadius: 20, alignItems: "center", justifyContent: "center" },
|
|
7140
|
+
matchupInitial: { fontSize: 18, fontWeight: "800" },
|
|
7141
|
+
matchupName: { fontSize: 13, fontWeight: "600", textAlign: "center" },
|
|
7142
|
+
matchupVs: { fontSize: 13, fontWeight: "600" },
|
|
7143
|
+
section: { gap: 10, paddingTop: 12 },
|
|
7144
|
+
sectionLabel: { fontSize: 14, fontWeight: "600" },
|
|
7145
|
+
teamsRow: { flexDirection: "row", gap: 10 },
|
|
7146
|
+
teamOption: { flex: 1, borderWidth: 2, borderRadius: 14, paddingVertical: 14, alignItems: "center", gap: 6 },
|
|
7147
|
+
teamLabel: { fontSize: 15, fontWeight: "700" },
|
|
7148
|
+
teamBadge: { borderRadius: 8, paddingHorizontal: 10, paddingVertical: 3 },
|
|
7149
|
+
teamBadgeText: { color: "#FFF", fontSize: 11, fontWeight: "700" },
|
|
7150
|
+
summaryCard: { marginTop: 12, borderRadius: 14, borderWidth: 1, overflow: "hidden" },
|
|
7151
|
+
summaryRow: { flexDirection: "row", alignItems: "center", justifyContent: "space-between", paddingHorizontal: 16, paddingVertical: 12 },
|
|
7152
|
+
summaryLabel: { fontSize: 14 },
|
|
7153
|
+
summaryValue: { fontSize: 15, fontWeight: "700" },
|
|
7154
|
+
summarySep: { height: 1, marginHorizontal: 16 },
|
|
7155
|
+
errorBox: { marginTop: 12, borderRadius: 12, borderWidth: 1, padding: 12 },
|
|
7156
|
+
errorText: { fontSize: 13, fontWeight: "500" },
|
|
7157
|
+
ctaButton: { marginTop: 16, height: 54, borderRadius: 14, justifyContent: "center", alignItems: "center" },
|
|
7158
|
+
ctaText: { color: "#FFFFFF", fontSize: 16, fontWeight: "700" },
|
|
7159
|
+
ctaLoading: { flexDirection: "row", alignItems: "center", gap: 10 },
|
|
7160
|
+
successOverlay: { ...StyleSheet20.absoluteFillObject, zIndex: 100, alignItems: "center", justifyContent: "center", backgroundColor: "rgba(0,0,0,0.85)" },
|
|
7161
|
+
successContent: { alignItems: "center", gap: 12 },
|
|
7162
|
+
successEmoji: { fontSize: 64 },
|
|
7163
|
+
successTitle: { color: "#FFFFFF", fontSize: 28, fontWeight: "900" },
|
|
7164
|
+
successSub: { color: "#8E8E93", fontSize: 16 }
|
|
7165
|
+
});
|
|
6908
7166
|
export {
|
|
6909
7167
|
ArcadeLeaderboardSheet,
|
|
6910
7168
|
AuthGate,
|
|
@@ -6913,6 +7171,7 @@ export {
|
|
|
6913
7171
|
ConnectWalletButton,
|
|
6914
7172
|
ConnectWalletScreen,
|
|
6915
7173
|
CreateCustomGameSheet,
|
|
7174
|
+
CreateGameSheet,
|
|
6916
7175
|
DEFAULT_BASE_URL,
|
|
6917
7176
|
DEFAULT_RPC_URL,
|
|
6918
7177
|
DubsApiError,
|