@akita-protocol/algomd-rn 0.0.0-stage → 1.0.0-alpha.1
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/README.md +137 -2
- package/package.json +118 -3
- package/src/adapters/index.ts +4 -0
- package/src/adapters/txn-graph.ts +138 -0
- package/src/components/ASA.tsx +38 -0
- package/src/components/ASASearch.tsx +79 -0
- package/src/components/Account.tsx +42 -0
- package/src/components/AccountSearch.tsx +75 -0
- package/src/components/AuctionListing.tsx +40 -0
- package/src/components/Collection.tsx +42 -0
- package/src/components/DualStakePool.tsx +244 -0
- package/src/components/NFDProfile.tsx +45 -0
- package/src/components/NFDSearch.tsx +81 -0
- package/src/components/NFTListing.tsx +73 -0
- package/src/components/NFTSearch.tsx +68 -0
- package/src/components/Poll.tsx +39 -0
- package/src/components/PollSearch.tsx +79 -0
- package/src/components/PrizeBoxBundle.tsx +1 -0
- package/src/components/RaffleListing.tsx +40 -0
- package/src/components/SelfFetching.tsx +1048 -0
- package/src/components/StakingPool.tsx +134 -0
- package/src/components/TradeOffer.tsx +47 -0
- package/src/components/TradeSearch.tsx +103 -0
- package/src/components/TransactionDetails.tsx +37 -0
- package/src/components/TransactionSearch.tsx +102 -0
- package/src/components/TransactionsGraph.tsx +60 -0
- package/src/components/index.ts +41 -0
- package/src/fonts/OFL.txt +93 -0
- package/src/fonts/SpaceGrotesk_300Light.ttf +0 -0
- package/src/fonts/SpaceGrotesk_400Regular.ttf +0 -0
- package/src/fonts/SpaceGrotesk_500Medium.ttf +0 -0
- package/src/fonts/SpaceGrotesk_600SemiBold.ttf +0 -0
- package/src/fonts/SpaceGrotesk_700Bold.ttf +0 -0
- package/src/fonts/app.css +5 -0
- package/src/graph.ts +3 -0
- package/src/hooks/index.ts +17 -0
- package/src/hooks/useAlgomdData.ts +1539 -0
- package/src/hooks/useAlgorandClient.ts +54 -0
- package/src/index.ts +147 -0
- package/src/presentation/ASADisplay.tsx +380 -0
- package/src/presentation/AccountDisplay.tsx +132 -0
- package/src/presentation/AccountMentionInline.tsx +38 -0
- package/src/presentation/AccountMentionText.tsx +80 -0
- package/src/presentation/AdaptiveImage.tsx +314 -0
- package/src/presentation/AssetMention.tsx +87 -0
- package/src/presentation/AuctionListingDisplay.tsx +428 -0
- package/src/presentation/BundleContents.tsx +228 -0
- package/src/presentation/CardContainer.tsx +61 -0
- package/src/presentation/CardEntrance.tsx +21 -0
- package/src/presentation/CollectionDisplay.tsx +168 -0
- package/src/presentation/ContractMenu.tsx +243 -0
- package/src/presentation/DualStakePoolDisplay.tsx +335 -0
- package/src/presentation/Embeds.tsx +300 -0
- package/src/presentation/GateRequirements.tsx +334 -0
- package/src/presentation/HEROICONS-LICENSE.txt +21 -0
- package/src/presentation/NFDProfileDisplay.tsx +194 -0
- package/src/presentation/NFTListingDisplay.tsx +284 -0
- package/src/presentation/OnChainActionCard.tsx +557 -0
- package/src/presentation/PollDisplay.tsx +222 -0
- package/src/presentation/PrizeBoxBundleDisplay.tsx +103 -0
- package/src/presentation/PrizeBoxMedia.tsx +46 -0
- package/src/presentation/PrizePreview.tsx +296 -0
- package/src/presentation/ProgressBar.tsx +50 -0
- package/src/presentation/RaffleListingDisplay.tsx +399 -0
- package/src/presentation/References.tsx +310 -0
- package/src/presentation/ReservedNotice.tsx +73 -0
- package/src/presentation/ResultsPanel.tsx +241 -0
- package/src/presentation/Sparkline.tsx +70 -0
- package/src/presentation/SquishyPressable.tsx +145 -0
- package/src/presentation/StakingPoolDisplay.tsx +419 -0
- package/src/presentation/StatusBadge.tsx +56 -0
- package/src/presentation/TradeOfferDisplay.tsx +275 -0
- package/src/presentation/TransactionDisplay.tsx +262 -0
- package/src/presentation/WinnerBadge.tsx +58 -0
- package/src/presentation/assetHelpers.ts +36 -0
- package/src/presentation/assets.ts +7 -0
- package/src/presentation/explorer.ts +95 -0
- package/src/presentation/format.ts +90 -0
- package/src/presentation/gates.ts +100 -0
- package/src/presentation/icons.tsx +1178 -0
- package/src/presentation/identity.tsx +175 -0
- package/src/presentation/index.ts +88 -0
- package/src/presentation/media.ts +70 -0
- package/src/presentation/pluginColors.ts +8 -0
- package/src/presentation/runtime.tsx +280 -0
- package/src/presentation/sheets.tsx +7 -0
- package/src/presentation/subject.tsx +31 -0
- package/src/presentation/textTheme.ts +17 -0
- package/src/presentation/themes.json +158 -0
- package/src/presentation/variants.ts +14 -0
- package/src/provider/AlgomdProvider.tsx +45 -0
- package/src/provider/context.ts +18 -0
- package/src/provider/imageResolver.ts +12 -0
- package/src/provider/index.ts +5 -0
- package/src/provider/networks.ts +23 -0
- package/src/provider/types.ts +29 -0
- package/src/refs/AccountRef.tsx +226 -0
- package/src/refs/ApplicationRef.tsx +72 -0
- package/src/refs/AssetRef.tsx +142 -0
- package/src/refs/AuctionRef.tsx +108 -0
- package/src/refs/CollectionRef.tsx +70 -0
- package/src/refs/DualStakeRef.tsx +88 -0
- package/src/refs/GuildProposalRef.tsx +285 -0
- package/src/refs/HostRefs.tsx +82 -0
- package/src/refs/ListingRef.tsx +90 -0
- package/src/refs/NfdRef.tsx +96 -0
- package/src/refs/PollRef.tsx +120 -0
- package/src/refs/RaffleRef.tsx +101 -0
- package/src/refs/RewardRef.tsx +78 -0
- package/src/refs/StakingPoolRef.tsx +136 -0
- package/src/refs/SubscriptionRef.tsx +200 -0
- package/src/refs/TradeRef.tsx +100 -0
- package/src/refs/TransactionRef.tsx +156 -0
- package/src/refs/assetInfo.ts +49 -0
- package/src/refs/contractParts.tsx +159 -0
- package/src/refs/index.tsx +140 -0
- package/src/refs/primitives.tsx +588 -0
- package/src/refs/types.ts +13 -0
- package/src/types/algorand.ts +496 -0
- package/src/types/index.ts +1 -0
- package/src/ui/CopyButton.tsx +44 -0
- package/src/ui/DataStates.tsx +45 -0
- package/src/ui/ProgressBar.tsx +64 -0
- package/src/ui/SearchSheet.tsx +141 -0
- package/src/ui/SizeContainer.tsx +25 -0
- package/src/ui/StatusBadge.tsx +51 -0
- package/src/ui/index.ts +6 -0
- package/src/utils/algomdImageUrl.ts +20 -0
- package/src/utils/arc19.ts +120 -0
- package/src/utils/arc62.ts +246 -0
- package/src/utils/capacity.ts +26 -0
- package/src/utils/format.ts +181 -0
- package/src/utils/ids.ts +31 -0
- package/src/utils/index.ts +6 -0
- package/src/utils/nfdDisplay.ts +45 -0
- package/src/utils/search.ts +87 -0
- package/src/utils/stakingPool.ts +174 -0
- package/src/utils/stakingSnapshot.ts +132 -0
|
@@ -0,0 +1,557 @@
|
|
|
1
|
+
// Shared AlgoMD presentation, migrated from akita-rn. Edit this library source.
|
|
2
|
+
import React, { type ReactNode } from "react";
|
|
3
|
+
import {
|
|
4
|
+
ActivityIndicator,
|
|
5
|
+
Pressable,
|
|
6
|
+
type StyleProp,
|
|
7
|
+
View,
|
|
8
|
+
type ViewStyle,
|
|
9
|
+
} from "react-native";
|
|
10
|
+
import {
|
|
11
|
+
OutlineArrowPathIcon as ArrowPathIcon,
|
|
12
|
+
OutlineExclamationTriangleIcon as ExclamationTriangleIcon,
|
|
13
|
+
} from "./icons";
|
|
14
|
+
|
|
15
|
+
import { LinearGradient, Text } from "./runtime";
|
|
16
|
+
import { useAppTheme } from "./runtime";
|
|
17
|
+
import { CardEntrance } from "./CardEntrance";
|
|
18
|
+
import { SquishyPressable } from "./SquishyPressable";
|
|
19
|
+
import { StatusBadge } from "./StatusBadge";
|
|
20
|
+
|
|
21
|
+
export type OnChainStatusTone =
|
|
22
|
+
| "success"
|
|
23
|
+
| "error"
|
|
24
|
+
| "warning"
|
|
25
|
+
| "info"
|
|
26
|
+
| "neutral";
|
|
27
|
+
|
|
28
|
+
export interface OnChainActionCardProps {
|
|
29
|
+
accessibilityLabel: string;
|
|
30
|
+
children: ReactNode;
|
|
31
|
+
media?: ReactNode;
|
|
32
|
+
/** Kind label and status pinned over the media, so the art carries the card. */
|
|
33
|
+
mediaOverlay?: {
|
|
34
|
+
eyebrow?: string;
|
|
35
|
+
status?: { label: string; tone?: OnChainStatusTone };
|
|
36
|
+
};
|
|
37
|
+
style?: StyleProp<ViewStyle>;
|
|
38
|
+
testID?: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function OnChainActionCard({
|
|
42
|
+
accessibilityLabel,
|
|
43
|
+
children,
|
|
44
|
+
media,
|
|
45
|
+
mediaOverlay,
|
|
46
|
+
style,
|
|
47
|
+
testID,
|
|
48
|
+
}: OnChainActionCardProps) {
|
|
49
|
+
const { theme } = useAppTheme();
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<CardEntrance>
|
|
53
|
+
<View
|
|
54
|
+
accessibilityLabel={accessibilityLabel}
|
|
55
|
+
accessible={false}
|
|
56
|
+
testID={testID}
|
|
57
|
+
style={[
|
|
58
|
+
{
|
|
59
|
+
alignSelf: "stretch",
|
|
60
|
+
backgroundColor: theme.colors.accentBackground,
|
|
61
|
+
borderCurve: "continuous",
|
|
62
|
+
borderRadius: 20,
|
|
63
|
+
overflow: "hidden",
|
|
64
|
+
width: "100%",
|
|
65
|
+
},
|
|
66
|
+
style,
|
|
67
|
+
]}
|
|
68
|
+
>
|
|
69
|
+
{media ? (
|
|
70
|
+
<View style={{ position: "relative" }}>
|
|
71
|
+
{media}
|
|
72
|
+
{mediaOverlay ? <MediaOverlay {...mediaOverlay} /> : null}
|
|
73
|
+
</View>
|
|
74
|
+
) : null}
|
|
75
|
+
<View style={{ gap: 14, padding: 16 }}>{children}</View>
|
|
76
|
+
</View>
|
|
77
|
+
</CardEntrance>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function MediaOverlay({
|
|
82
|
+
eyebrow,
|
|
83
|
+
status,
|
|
84
|
+
}: NonNullable<OnChainActionCardProps["mediaOverlay"]>) {
|
|
85
|
+
return (
|
|
86
|
+
<View
|
|
87
|
+
pointerEvents="none"
|
|
88
|
+
style={{
|
|
89
|
+
position: "absolute",
|
|
90
|
+
left: 12,
|
|
91
|
+
right: 12,
|
|
92
|
+
top: 12,
|
|
93
|
+
flexDirection: "row",
|
|
94
|
+
alignItems: "center",
|
|
95
|
+
justifyContent: "space-between",
|
|
96
|
+
gap: 8,
|
|
97
|
+
}}
|
|
98
|
+
>
|
|
99
|
+
{eyebrow ? (
|
|
100
|
+
<View
|
|
101
|
+
style={{
|
|
102
|
+
backgroundColor: "rgba(9, 9, 11, 0.72)",
|
|
103
|
+
borderRadius: 999,
|
|
104
|
+
paddingHorizontal: 10,
|
|
105
|
+
paddingVertical: 4,
|
|
106
|
+
}}
|
|
107
|
+
>
|
|
108
|
+
<Text
|
|
109
|
+
size="xxs"
|
|
110
|
+
weight="semiBold"
|
|
111
|
+
style={{
|
|
112
|
+
color: "#f4f4f5",
|
|
113
|
+
letterSpacing: 0.6,
|
|
114
|
+
textTransform: "uppercase",
|
|
115
|
+
}}
|
|
116
|
+
>
|
|
117
|
+
{eyebrow}
|
|
118
|
+
</Text>
|
|
119
|
+
</View>
|
|
120
|
+
) : (
|
|
121
|
+
<View />
|
|
122
|
+
)}
|
|
123
|
+
{status ? (
|
|
124
|
+
<StatusBadge label={status.label} variant={status.tone} solid />
|
|
125
|
+
) : null}
|
|
126
|
+
</View>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface OnChainActionHeaderProps {
|
|
131
|
+
description?: string | null;
|
|
132
|
+
/** Omit when the media overlay already shows the kind. */
|
|
133
|
+
eyebrow?: string;
|
|
134
|
+
/** Colours the eyebrow, e.g. in the kind's plugin colour. Defaults to the accent. */
|
|
135
|
+
eyebrowColor?: string;
|
|
136
|
+
/** An icon before the eyebrow, e.g. the kind's plugin icon. */
|
|
137
|
+
eyebrowIcon?: ReactNode;
|
|
138
|
+
menu?: ReactNode;
|
|
139
|
+
/** Creator, collection or other context under the title. */
|
|
140
|
+
subtitle?: ReactNode;
|
|
141
|
+
status?: { label: string; tone?: OnChainStatusTone };
|
|
142
|
+
title: string;
|
|
143
|
+
titleAccessory?: ReactNode;
|
|
144
|
+
/** An icon before the title. */
|
|
145
|
+
titleIcon?: ReactNode;
|
|
146
|
+
/** Colours the title, e.g. to label the block by its kind. */
|
|
147
|
+
titleColor?: string;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export function OnChainActionHeader({
|
|
151
|
+
description,
|
|
152
|
+
eyebrow,
|
|
153
|
+
eyebrowColor,
|
|
154
|
+
eyebrowIcon,
|
|
155
|
+
menu,
|
|
156
|
+
status,
|
|
157
|
+
subtitle,
|
|
158
|
+
title,
|
|
159
|
+
titleAccessory,
|
|
160
|
+
titleIcon,
|
|
161
|
+
titleColor,
|
|
162
|
+
}: OnChainActionHeaderProps) {
|
|
163
|
+
const { theme } = useAppTheme();
|
|
164
|
+
|
|
165
|
+
return (
|
|
166
|
+
<View style={{ gap: 6 }}>
|
|
167
|
+
<View style={{ flexDirection: "row", alignItems: "flex-start", gap: 10 }}>
|
|
168
|
+
<View style={{ flex: 1, minWidth: 0, gap: 2 }}>
|
|
169
|
+
{eyebrow ? (
|
|
170
|
+
<View
|
|
171
|
+
style={{ flexDirection: "row", alignItems: "center", gap: 4 }}
|
|
172
|
+
>
|
|
173
|
+
{eyebrowIcon}
|
|
174
|
+
<Text
|
|
175
|
+
size="xxs"
|
|
176
|
+
weight="semiBold"
|
|
177
|
+
style={{
|
|
178
|
+
color: eyebrowColor ?? theme.colors.primary,
|
|
179
|
+
letterSpacing: 0.6,
|
|
180
|
+
textTransform: "uppercase",
|
|
181
|
+
}}
|
|
182
|
+
>
|
|
183
|
+
{eyebrow}
|
|
184
|
+
</Text>
|
|
185
|
+
</View>
|
|
186
|
+
) : null}
|
|
187
|
+
<View style={{ flexDirection: "row", alignItems: "center", gap: 6 }}>
|
|
188
|
+
{titleIcon}
|
|
189
|
+
<Text
|
|
190
|
+
accessibilityRole="header"
|
|
191
|
+
size="md"
|
|
192
|
+
weight="semiBold"
|
|
193
|
+
numberOfLines={2}
|
|
194
|
+
style={{
|
|
195
|
+
flexShrink: 1,
|
|
196
|
+
...(titleColor ? { color: titleColor } : {}),
|
|
197
|
+
}}
|
|
198
|
+
>
|
|
199
|
+
{title}
|
|
200
|
+
</Text>
|
|
201
|
+
{/* Keep the badge whole when a long title wraps. */}
|
|
202
|
+
{titleAccessory ? (
|
|
203
|
+
<View style={{ flexShrink: 0 }}>{titleAccessory}</View>
|
|
204
|
+
) : null}
|
|
205
|
+
</View>
|
|
206
|
+
{subtitle ? (
|
|
207
|
+
typeof subtitle === "string" ? (
|
|
208
|
+
<Text
|
|
209
|
+
size="xs"
|
|
210
|
+
numberOfLines={1}
|
|
211
|
+
style={{ color: theme.colors.textDim }}
|
|
212
|
+
>
|
|
213
|
+
{subtitle}
|
|
214
|
+
</Text>
|
|
215
|
+
) : (
|
|
216
|
+
subtitle
|
|
217
|
+
)
|
|
218
|
+
) : null}
|
|
219
|
+
</View>
|
|
220
|
+
{status ? (
|
|
221
|
+
<StatusBadge label={status.label} variant={status.tone} />
|
|
222
|
+
) : null}
|
|
223
|
+
{menu}
|
|
224
|
+
</View>
|
|
225
|
+
{description ? (
|
|
226
|
+
<Text
|
|
227
|
+
size="xs"
|
|
228
|
+
numberOfLines={2}
|
|
229
|
+
style={{ color: theme.colors.textDim }}
|
|
230
|
+
>
|
|
231
|
+
{description}
|
|
232
|
+
</Text>
|
|
233
|
+
) : null}
|
|
234
|
+
</View>
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/** Facts laid out in two columns straight on the card surface: no fill, no dividers. */
|
|
239
|
+
export function OnChainMetricGrid({ children }: { children: ReactNode }) {
|
|
240
|
+
return (
|
|
241
|
+
<View
|
|
242
|
+
style={{
|
|
243
|
+
flexDirection: "row",
|
|
244
|
+
flexWrap: "wrap",
|
|
245
|
+
columnGap: 16,
|
|
246
|
+
rowGap: 12,
|
|
247
|
+
}}
|
|
248
|
+
>
|
|
249
|
+
{children}
|
|
250
|
+
</View>
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export interface OnChainMetricProps {
|
|
255
|
+
accessibilityLabel?: string;
|
|
256
|
+
icon?: ReactNode;
|
|
257
|
+
label: string;
|
|
258
|
+
secondary?: string | null;
|
|
259
|
+
/** Colours the value, e.g. sky for a countdown under an hour. */
|
|
260
|
+
tone?: "default" | "accent" | "warning";
|
|
261
|
+
value: string;
|
|
262
|
+
/** Sits inline before the value, e.g. the token an amount is paid in. */
|
|
263
|
+
valueIcon?: ReactNode;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export function OnChainMetric({
|
|
267
|
+
accessibilityLabel,
|
|
268
|
+
icon,
|
|
269
|
+
label,
|
|
270
|
+
secondary,
|
|
271
|
+
tone = "default",
|
|
272
|
+
value,
|
|
273
|
+
valueIcon,
|
|
274
|
+
}: OnChainMetricProps) {
|
|
275
|
+
const { theme } = useAppTheme();
|
|
276
|
+
|
|
277
|
+
return (
|
|
278
|
+
<View
|
|
279
|
+
accessible
|
|
280
|
+
accessibilityLabel={
|
|
281
|
+
accessibilityLabel ??
|
|
282
|
+
`${label}: ${value}${secondary ? `, ${secondary}` : ""}`
|
|
283
|
+
}
|
|
284
|
+
style={{
|
|
285
|
+
flexBasis: "40%",
|
|
286
|
+
flexGrow: 1,
|
|
287
|
+
gap: 2,
|
|
288
|
+
minWidth: 112,
|
|
289
|
+
}}
|
|
290
|
+
>
|
|
291
|
+
<View style={{ flexDirection: "row", alignItems: "center", gap: 4 }}>
|
|
292
|
+
{icon}
|
|
293
|
+
<Text
|
|
294
|
+
size="xxs"
|
|
295
|
+
weight="medium"
|
|
296
|
+
style={{ color: theme.colors.textDim }}
|
|
297
|
+
>
|
|
298
|
+
{label}
|
|
299
|
+
</Text>
|
|
300
|
+
</View>
|
|
301
|
+
<View style={{ flexDirection: "row", alignItems: "center", gap: 5 }}>
|
|
302
|
+
{valueIcon}
|
|
303
|
+
<Text
|
|
304
|
+
size="sm"
|
|
305
|
+
weight="semiBold"
|
|
306
|
+
numberOfLines={2}
|
|
307
|
+
adjustsFontSizeToFit
|
|
308
|
+
minimumFontScale={0.8}
|
|
309
|
+
style={{
|
|
310
|
+
flexShrink: 1,
|
|
311
|
+
...(tone === "accent"
|
|
312
|
+
? { color: theme.colors.secondary ?? theme.colors.primary }
|
|
313
|
+
: tone === "warning"
|
|
314
|
+
? { color: theme.colors.warningText }
|
|
315
|
+
: {}),
|
|
316
|
+
}}
|
|
317
|
+
>
|
|
318
|
+
{value}
|
|
319
|
+
</Text>
|
|
320
|
+
</View>
|
|
321
|
+
{secondary ? (
|
|
322
|
+
<Text
|
|
323
|
+
size="xxs"
|
|
324
|
+
numberOfLines={2}
|
|
325
|
+
style={{ color: theme.colors.textDim }}
|
|
326
|
+
>
|
|
327
|
+
{secondary}
|
|
328
|
+
</Text>
|
|
329
|
+
) : null}
|
|
330
|
+
</View>
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
export interface OnChainActionButtonProps {
|
|
335
|
+
accessibilityLabel?: string;
|
|
336
|
+
disabled?: boolean;
|
|
337
|
+
/** Why the action is unavailable, shown above the button. */
|
|
338
|
+
disabledReason?: string | null;
|
|
339
|
+
label: string;
|
|
340
|
+
onPress: () => void;
|
|
341
|
+
/** primary: gradient, for value moving in (buy, bid, enter, join). secondary: outline. */
|
|
342
|
+
variant?: "primary" | "secondary";
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export function OnChainActionButton({
|
|
346
|
+
accessibilityLabel,
|
|
347
|
+
disabled,
|
|
348
|
+
disabledReason,
|
|
349
|
+
label,
|
|
350
|
+
onPress,
|
|
351
|
+
variant = "primary",
|
|
352
|
+
}: OnChainActionButtonProps) {
|
|
353
|
+
const { theme } = useAppTheme();
|
|
354
|
+
const primary = variant === "primary";
|
|
355
|
+
const inactive = !!disabled;
|
|
356
|
+
const shape = {
|
|
357
|
+
alignItems: "center" as const,
|
|
358
|
+
borderCurve: "continuous" as const,
|
|
359
|
+
borderRadius: 14,
|
|
360
|
+
height: 48,
|
|
361
|
+
justifyContent: "center" as const,
|
|
362
|
+
paddingHorizontal: 16,
|
|
363
|
+
};
|
|
364
|
+
const labelNode = (
|
|
365
|
+
<Text
|
|
366
|
+
size="sm"
|
|
367
|
+
weight="bold"
|
|
368
|
+
style={{
|
|
369
|
+
color: inactive
|
|
370
|
+
? theme.colors.textDim
|
|
371
|
+
: primary
|
|
372
|
+
? theme.gradients.interactiveText
|
|
373
|
+
: theme.colors.primary,
|
|
374
|
+
}}
|
|
375
|
+
>
|
|
376
|
+
{label}
|
|
377
|
+
</Text>
|
|
378
|
+
);
|
|
379
|
+
|
|
380
|
+
return (
|
|
381
|
+
<View style={{ flex: 1, gap: 8 }}>
|
|
382
|
+
{disabledReason ? (
|
|
383
|
+
<Text
|
|
384
|
+
size="xxs"
|
|
385
|
+
style={{ color: theme.colors.textDim, textAlign: "center" }}
|
|
386
|
+
>
|
|
387
|
+
{disabledReason}
|
|
388
|
+
</Text>
|
|
389
|
+
) : null}
|
|
390
|
+
<SquishyPressable
|
|
391
|
+
accessibilityLabel={accessibilityLabel ?? label}
|
|
392
|
+
accessibilityState={{ disabled: inactive }}
|
|
393
|
+
disabled={inactive}
|
|
394
|
+
onPress={onPress}
|
|
395
|
+
pressedScale={0.97}
|
|
396
|
+
animation="timing"
|
|
397
|
+
timingConfig={{ duration: 120 }}
|
|
398
|
+
>
|
|
399
|
+
{inactive ? (
|
|
400
|
+
<View
|
|
401
|
+
style={[shape, { backgroundColor: `${theme.colors.textDim}18` }]}
|
|
402
|
+
>
|
|
403
|
+
{labelNode}
|
|
404
|
+
</View>
|
|
405
|
+
) : primary ? (
|
|
406
|
+
<LinearGradient
|
|
407
|
+
colors={theme.gradients.interactive}
|
|
408
|
+
locations={theme.gradients.interactiveLocations}
|
|
409
|
+
start={{ x: 0, y: 0 }}
|
|
410
|
+
end={{ x: 1, y: 0 }}
|
|
411
|
+
style={shape}
|
|
412
|
+
>
|
|
413
|
+
{labelNode}
|
|
414
|
+
</LinearGradient>
|
|
415
|
+
) : (
|
|
416
|
+
<View
|
|
417
|
+
style={[shape, { backgroundColor: `${theme.colors.primary}1f` }]}
|
|
418
|
+
>
|
|
419
|
+
{labelNode}
|
|
420
|
+
</View>
|
|
421
|
+
)}
|
|
422
|
+
</SquishyPressable>
|
|
423
|
+
</View>
|
|
424
|
+
);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
export function OnChainActionNotice({
|
|
428
|
+
detail,
|
|
429
|
+
onRetry,
|
|
430
|
+
}: {
|
|
431
|
+
detail: string;
|
|
432
|
+
onRetry?: () => void;
|
|
433
|
+
}) {
|
|
434
|
+
const { theme } = useAppTheme();
|
|
435
|
+
|
|
436
|
+
return (
|
|
437
|
+
<View
|
|
438
|
+
style={{
|
|
439
|
+
alignItems: "center",
|
|
440
|
+
backgroundColor: `${theme.colors.warning}12`,
|
|
441
|
+
borderCurve: "continuous",
|
|
442
|
+
borderRadius: 10,
|
|
443
|
+
flexDirection: "row",
|
|
444
|
+
gap: 8,
|
|
445
|
+
padding: 9,
|
|
446
|
+
}}
|
|
447
|
+
>
|
|
448
|
+
<Text size="xxs" style={{ color: theme.colors.warningText, flex: 1 }}>
|
|
449
|
+
{detail}
|
|
450
|
+
</Text>
|
|
451
|
+
{onRetry ? (
|
|
452
|
+
<Pressable
|
|
453
|
+
accessibilityLabel="Refresh on-chain state"
|
|
454
|
+
accessibilityRole="button"
|
|
455
|
+
hitSlop={8}
|
|
456
|
+
onPress={onRetry}
|
|
457
|
+
>
|
|
458
|
+
<ArrowPathIcon size={16} color={theme.colors.warningText} />
|
|
459
|
+
</Pressable>
|
|
460
|
+
) : null}
|
|
461
|
+
</View>
|
|
462
|
+
);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
export interface OnChainStateCardProps {
|
|
466
|
+
appId?: string | number;
|
|
467
|
+
detail?: string | null;
|
|
468
|
+
loading?: boolean;
|
|
469
|
+
menu?: ReactNode;
|
|
470
|
+
onRetry?: () => void;
|
|
471
|
+
stateLabel?: string;
|
|
472
|
+
title: string;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
export function OnChainStateCard({
|
|
476
|
+
appId,
|
|
477
|
+
detail,
|
|
478
|
+
loading,
|
|
479
|
+
menu,
|
|
480
|
+
onRetry,
|
|
481
|
+
stateLabel,
|
|
482
|
+
title,
|
|
483
|
+
}: OnChainStateCardProps) {
|
|
484
|
+
const { theme } = useAppTheme();
|
|
485
|
+
const label = loading
|
|
486
|
+
? `Loading ${title}`
|
|
487
|
+
: (stateLabel ?? `${title} unavailable`);
|
|
488
|
+
|
|
489
|
+
return (
|
|
490
|
+
<OnChainActionCard accessibilityLabel={label}>
|
|
491
|
+
<View style={{ flexDirection: "row", alignItems: "flex-start", gap: 10 }}>
|
|
492
|
+
<View
|
|
493
|
+
style={{
|
|
494
|
+
alignItems: "center",
|
|
495
|
+
backgroundColor: loading
|
|
496
|
+
? `${theme.colors.primary}12`
|
|
497
|
+
: `${theme.colors.warning}16`,
|
|
498
|
+
borderRadius: 12,
|
|
499
|
+
height: 38,
|
|
500
|
+
justifyContent: "center",
|
|
501
|
+
width: 38,
|
|
502
|
+
}}
|
|
503
|
+
>
|
|
504
|
+
{loading ? (
|
|
505
|
+
<ActivityIndicator size="small" color={theme.colors.primary} />
|
|
506
|
+
) : (
|
|
507
|
+
<ExclamationTriangleIcon
|
|
508
|
+
size={20}
|
|
509
|
+
color={theme.colors.warningText}
|
|
510
|
+
/>
|
|
511
|
+
)}
|
|
512
|
+
</View>
|
|
513
|
+
<View style={{ flex: 1, gap: 3 }}>
|
|
514
|
+
<Text accessibilityRole="header" size="sm" weight="semiBold">
|
|
515
|
+
{label}
|
|
516
|
+
</Text>
|
|
517
|
+
<Text size="xxs" style={{ color: theme.colors.textDim }}>
|
|
518
|
+
{detail ??
|
|
519
|
+
(loading
|
|
520
|
+
? "Fetching the latest on-chain state…"
|
|
521
|
+
: "The live state may have been archived, but this reference is still preserved.")}
|
|
522
|
+
</Text>
|
|
523
|
+
{appId ? (
|
|
524
|
+
<Text size="xxs" style={{ color: theme.colors.textDim }}>
|
|
525
|
+
App #{appId}
|
|
526
|
+
</Text>
|
|
527
|
+
) : null}
|
|
528
|
+
</View>
|
|
529
|
+
{menu}
|
|
530
|
+
</View>
|
|
531
|
+
{!loading && onRetry ? (
|
|
532
|
+
<Pressable
|
|
533
|
+
accessibilityLabel={`Retry loading ${title}`}
|
|
534
|
+
accessibilityRole="button"
|
|
535
|
+
onPress={onRetry}
|
|
536
|
+
style={({ pressed }) => ({
|
|
537
|
+
alignItems: "center",
|
|
538
|
+
alignSelf: "flex-start",
|
|
539
|
+
borderColor: theme.colors.border,
|
|
540
|
+
borderRadius: 10,
|
|
541
|
+
borderWidth: 1,
|
|
542
|
+
flexDirection: "row",
|
|
543
|
+
gap: 6,
|
|
544
|
+
opacity: pressed ? 0.7 : 1,
|
|
545
|
+
paddingHorizontal: 10,
|
|
546
|
+
paddingVertical: 7,
|
|
547
|
+
})}
|
|
548
|
+
>
|
|
549
|
+
<ArrowPathIcon size={14} color={theme.colors.text} />
|
|
550
|
+
<Text size="xs" weight="semiBold">
|
|
551
|
+
Try again
|
|
552
|
+
</Text>
|
|
553
|
+
</Pressable>
|
|
554
|
+
) : null}
|
|
555
|
+
</OnChainActionCard>
|
|
556
|
+
);
|
|
557
|
+
}
|