@akita-protocol/algomd-rn 1.0.0-alpha.12 → 1.0.0-alpha.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akita-protocol/algomd-rn",
3
- "version": "1.0.0-alpha.12",
3
+ "version": "1.0.0-alpha.13",
4
4
  "main": "src/index.ts",
5
5
  "types": "src/index.ts",
6
6
  "react-native": "src/index.ts",
@@ -79,7 +79,7 @@
79
79
  "vite": "^6.4.3"
80
80
  },
81
81
  "dependencies": {
82
- "@akita-protocol/algomd-core": "1.0.0-alpha.12"
82
+ "@akita-protocol/algomd-core": "1.0.0-alpha.13"
83
83
  },
84
84
  "exports": {
85
85
  ".": "./src/index.ts",
@@ -96,7 +96,7 @@ export function priceChange(points: readonly AssetPricePoint[]) {
96
96
  export interface ASADisplayProps {
97
97
  data: ASAType;
98
98
  compact?: boolean;
99
- /** Small and medium cards put a token's price and sparkline on one row with its name. */
99
+ /** Small and medium cards are one row: icon, name, and the price trend or one key fact. */
100
100
  dense?: boolean;
101
101
  showDetails?: boolean;
102
102
  imageUrl?: string;
@@ -298,15 +298,50 @@ export function ASADisplay({
298
298
  </LinearGradient>
299
299
  );
300
300
 
301
- // On a small card a token reads as one line: icon, name, trend and price.
302
- if (dense && change) {
301
+ // A small card reads as one line: icon, name, then the trend and price, or for an asset
302
+ // without a price history, its supply (a token), its ALGO price (a collectible) or nothing.
303
+ if (dense) {
304
+ const art = (isCollectible || isEdition) && imageUrl;
305
+ const icon = art ? (
306
+ <Image
307
+ source={{ uri: imageUrl }}
308
+ style={{ width: 40, height: 40, borderRadius: 8, backgroundColor: theme.colors.background }}
309
+ />
310
+ ) : (
311
+ tokenIcon(40)
312
+ );
313
+ const detail = change ? (
314
+ <>
315
+ <Text size="xs" weight="semiBold" numberOfLines={1} style={{ flexShrink: 0 }}>
316
+ {formatUsdPrice(change.latest)}
317
+ </Text>
318
+ <Text size="xs" weight="medium" numberOfLines={1} style={{ color: changeColor, flexShrink: 0 }}>
319
+ {change.label.split(" · ")[0]}
320
+ </Text>
321
+ </>
322
+ ) : null;
323
+ const label = (isCollectible || isEdition) && data.collection
324
+ ? data.collection.name
325
+ : data.unitName || `#${data.id}`;
326
+ // Without a trend the right of the row holds one fact.
327
+ const fact = change
328
+ ? null
329
+ : data.price != null
330
+ ? { value: `${formatPrice(data.price)} ALGO`, label: "Price" }
331
+ : isCollectible
332
+ ? null
333
+ : { value: supply, label: isEdition ? "Editions" : "Supply" };
303
334
  return (
304
335
  <OnChainActionCard
305
- accessibilityLabel={`${data.name}, ${formatUsdPrice(change.latest)}, ${change.label.replace("·", "over")}`}
336
+ accessibilityLabel={
337
+ change
338
+ ? `${data.name}, ${formatUsdPrice(change.latest)}, ${change.label.replace("·", "over")}`
339
+ : `${data.name}, ${kind.toLowerCase()}${fact ? `, ${fact.label.toLowerCase()} ${fact.value}` : ""}`
340
+ }
306
341
  >
307
342
  <View style={{ flexDirection: "row", alignItems: "center", gap: 10 }}>
308
- {tokenIcon(40)}
309
- <View style={{ flexShrink: 1, minWidth: 0, gap: 1 }}>
343
+ {icon}
344
+ <View style={{ flexShrink: 1, flexGrow: change ? 0 : 1, minWidth: 0, gap: 1 }}>
310
345
  <View style={{ flexDirection: "row", alignItems: "center", gap: 4 }}>
311
346
  <Text size="sm" weight="semiBold" numberOfLines={1} style={{ flexShrink: 1 }}>
312
347
  {data.name}
@@ -318,25 +353,31 @@ export function ASADisplay({
318
353
  ) : null}
319
354
  </View>
320
355
  <View style={{ flexDirection: "row", alignItems: "center", gap: 5 }}>
321
- <Text size="xs" numberOfLines={1} style={{ color: theme.colors.textDim, flexShrink: 0 }}>
322
- {data.unitName || `#${data.id}`}
356
+ <Text size="xs" numberOfLines={1} style={{ color: theme.colors.textDim, flexShrink: change ? 0 : 1 }}>
357
+ {label}
323
358
  </Text>
324
- <Text size="xs" weight="semiBold" numberOfLines={1} style={{ flexShrink: 0 }}>
325
- {formatUsdPrice(change.latest)}
359
+ {detail}
360
+ </View>
361
+ </View>
362
+ {change ? (
363
+ <View style={{ flexGrow: 1, flexShrink: 1, flexBasis: 48, minWidth: 48, maxWidth: 120 + CARD_PADDING, marginRight: -CARD_PADDING }}>
364
+ <Sparkline
365
+ id={`${data.id}-dense`}
366
+ values={history.map((point) => point.price)}
367
+ color={changeColor}
368
+ height={32}
369
+ />
370
+ </View>
371
+ ) : fact ? (
372
+ <View style={{ flexShrink: 0, alignItems: "flex-end", gap: 1 }}>
373
+ <Text size="sm" weight="semiBold" numberOfLines={1}>
374
+ {fact.value}
326
375
  </Text>
327
- <Text size="xs" weight="medium" numberOfLines={1} style={{ color: changeColor, flexShrink: 0 }}>
328
- {change.label.split(" · ")[0]}
376
+ <Text size="xxs" weight="medium" numberOfLines={1} style={{ color: theme.colors.textDim }}>
377
+ {fact.label}
329
378
  </Text>
330
379
  </View>
331
- </View>
332
- <View style={{ flexGrow: 1, flexShrink: 1, flexBasis: 48, minWidth: 48, maxWidth: 120 + CARD_PADDING, marginRight: -CARD_PADDING }}>
333
- <Sparkline
334
- id={`${data.id}-dense`}
335
- values={history.map((point) => point.price)}
336
- color={changeColor}
337
- height={32}
338
- />
339
- </View>
380
+ ) : null}
340
381
  </View>
341
382
  </OnChainActionCard>
342
383
  );