@dubsdotapp/expo 0.2.73 → 0.2.75
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 +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +18 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/ui/UserProfileCard.tsx +2 -1
- package/src/ui/UserProfileSheet.tsx +5 -2
- package/src/ui/game/PlayersCard.tsx +2 -1
- package/src/utils/avatarUrl.ts +9 -0
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
2
|
import { View, Text, Image, StyleSheet } from 'react-native';
|
|
3
3
|
import { useDubsTheme } from './theme';
|
|
4
|
+
import { ensurePngAvatar } from '../utils/avatarUrl';
|
|
4
5
|
|
|
5
6
|
export interface UserProfileCardProps {
|
|
6
7
|
walletAddress: string;
|
|
@@ -31,7 +32,7 @@ export function UserProfileCard({
|
|
|
31
32
|
|
|
32
33
|
const imageUri = useMemo(
|
|
33
34
|
() =>
|
|
34
|
-
avatarUrl ||
|
|
35
|
+
ensurePngAvatar(avatarUrl) ||
|
|
35
36
|
`https://api.dicebear.com/9.x/avataaars/png?seed=${walletAddress}&size=128`,
|
|
36
37
|
[avatarUrl, walletAddress],
|
|
37
38
|
);
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
import { useDubsTheme } from './theme';
|
|
17
17
|
import { useDubs } from '../provider';
|
|
18
18
|
import { usePushNotifications } from '../hooks/usePushNotifications';
|
|
19
|
+
import { ensurePngAvatar } from '../utils/avatarUrl';
|
|
19
20
|
|
|
20
21
|
// ── Avatar Helpers ──
|
|
21
22
|
|
|
@@ -40,8 +41,8 @@ function getAvatarUrl(style: string, seed: string, size = 256): string {
|
|
|
40
41
|
function parseAvatarUrl(url?: string | null): { style: string; seed: string } {
|
|
41
42
|
if (!url) return { style: 'adventurer', seed: generateSeed() };
|
|
42
43
|
try {
|
|
43
|
-
//
|
|
44
|
-
const match = url.match(
|
|
44
|
+
// Match both png and svg formats, any API version (7.x, 9.x, etc.)
|
|
45
|
+
const match = url.match(/\/\d+\.x\/([^/]+)\/(?:png|svg)\?seed=([^&]+)/);
|
|
45
46
|
if (match) return { style: match[1], seed: match[2] };
|
|
46
47
|
} catch {}
|
|
47
48
|
return { style: 'adventurer', seed: generateSeed() };
|
|
@@ -379,6 +380,7 @@ const styles = StyleSheet.create({
|
|
|
379
380
|
avatar: {
|
|
380
381
|
width: '100%',
|
|
381
382
|
height: '100%',
|
|
383
|
+
backgroundColor: '#1a1a2e',
|
|
382
384
|
},
|
|
383
385
|
avatarLoading: {
|
|
384
386
|
...StyleSheet.absoluteFillObject,
|
|
@@ -430,6 +432,7 @@ const styles = StyleSheet.create({
|
|
|
430
432
|
styleTileImage: {
|
|
431
433
|
width: '100%',
|
|
432
434
|
height: '100%',
|
|
435
|
+
backgroundColor: '#1a1a2e',
|
|
433
436
|
},
|
|
434
437
|
// Error
|
|
435
438
|
errorBox: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
2
|
import { StyleSheet, View, Text } from 'react-native';
|
|
3
3
|
import { useDubsTheme } from '../theme';
|
|
4
|
+
import { ensurePngAvatar } from '../../utils/avatarUrl';
|
|
4
5
|
import type { GameDetail } from '../../types';
|
|
5
6
|
|
|
6
7
|
export interface PlayersCardProps {
|
|
@@ -80,7 +81,7 @@ function BettorRow({
|
|
|
80
81
|
<View style={[styles.row, !isFirst && { borderTopColor: t.border, borderTopWidth: 1 }]}>
|
|
81
82
|
<View style={[styles.dot, { backgroundColor: dotColor }]} />
|
|
82
83
|
{showAvatar ? (
|
|
83
|
-
<Img source={{ uri: bettor.avatar }} style={styles.avatar} resizeMode="cover" onError={() => setImgFailed(true)} />
|
|
84
|
+
<Img source={{ uri: ensurePngAvatar(bettor.avatar) }} style={styles.avatar} resizeMode="cover" onError={() => setImgFailed(true)} />
|
|
84
85
|
) : (
|
|
85
86
|
<View style={[styles.avatar, styles.avatarPlaceholder]} />
|
|
86
87
|
)}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ensure a DiceBear avatar URL uses PNG format for React Native compatibility.
|
|
3
|
+
* React Native's Image component cannot render SVGs.
|
|
4
|
+
* This converts at render time only — the stored URL in the DB is never modified.
|
|
5
|
+
*/
|
|
6
|
+
export function ensurePngAvatar(url: string | null | undefined): string | undefined {
|
|
7
|
+
if (!url) return undefined;
|
|
8
|
+
return url.replace('/svg?', '/png?');
|
|
9
|
+
}
|