@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,335 @@
|
|
|
1
|
+
// Shared AlgoMD presentation, migrated from akita-rn. Edit this library source.
|
|
2
|
+
import React from "react";
|
|
3
|
+
import {
|
|
4
|
+
ActivityIndicator,
|
|
5
|
+
Image,
|
|
6
|
+
Pressable,
|
|
7
|
+
TextInput,
|
|
8
|
+
View,
|
|
9
|
+
} from "react-native";
|
|
10
|
+
import { OutlineArrowPathIcon as ArrowPathIcon } from "./icons";
|
|
11
|
+
|
|
12
|
+
import { Text } from "./runtime";
|
|
13
|
+
import { useAppTheme } from "./runtime";
|
|
14
|
+
import { ContractMenu } from "./ContractMenu";
|
|
15
|
+
import {
|
|
16
|
+
OnChainActionButton,
|
|
17
|
+
OnChainActionCard,
|
|
18
|
+
OnChainActionHeader,
|
|
19
|
+
OnChainMetric,
|
|
20
|
+
OnChainMetricGrid,
|
|
21
|
+
} from "./OnChainActionCard";
|
|
22
|
+
|
|
23
|
+
export interface AssetSummary {
|
|
24
|
+
imageUrl?: string | null;
|
|
25
|
+
label: string;
|
|
26
|
+
loading?: boolean;
|
|
27
|
+
subtitle: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface DualStakePoolDisplayProps {
|
|
31
|
+
algoBalanceLabel?: string | null;
|
|
32
|
+
appId: string;
|
|
33
|
+
asaBalanceLabel?: string | null;
|
|
34
|
+
asaBalanceUnit?: string;
|
|
35
|
+
canMint: boolean;
|
|
36
|
+
canRedeem: boolean;
|
|
37
|
+
connected: boolean;
|
|
38
|
+
description?: string;
|
|
39
|
+
dualStakeAsset?: AssetSummary;
|
|
40
|
+
metadataState: "loading" | "ready" | "error";
|
|
41
|
+
mintAmount: string;
|
|
42
|
+
onMint: () => void;
|
|
43
|
+
onMintAmountChange: (value: string) => void;
|
|
44
|
+
onRedeem: () => void;
|
|
45
|
+
onRedeemAmountChange: (value: string) => void;
|
|
46
|
+
onRetry?: () => void;
|
|
47
|
+
online?: boolean;
|
|
48
|
+
rewardAsset: AssetSummary;
|
|
49
|
+
redeemAmount: string;
|
|
50
|
+
stakedLabel?: string | null;
|
|
51
|
+
submitting: boolean;
|
|
52
|
+
title: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function DualStakePoolDisplay({
|
|
56
|
+
algoBalanceLabel,
|
|
57
|
+
appId,
|
|
58
|
+
asaBalanceLabel,
|
|
59
|
+
asaBalanceUnit,
|
|
60
|
+
canMint,
|
|
61
|
+
canRedeem,
|
|
62
|
+
connected,
|
|
63
|
+
description,
|
|
64
|
+
dualStakeAsset,
|
|
65
|
+
metadataState,
|
|
66
|
+
mintAmount,
|
|
67
|
+
onMint,
|
|
68
|
+
onMintAmountChange,
|
|
69
|
+
onRedeem,
|
|
70
|
+
onRedeemAmountChange,
|
|
71
|
+
onRetry,
|
|
72
|
+
online,
|
|
73
|
+
rewardAsset,
|
|
74
|
+
redeemAmount,
|
|
75
|
+
stakedLabel,
|
|
76
|
+
submitting,
|
|
77
|
+
title,
|
|
78
|
+
}: DualStakePoolDisplayProps) {
|
|
79
|
+
const { theme } = useAppTheme();
|
|
80
|
+
const status =
|
|
81
|
+
metadataState === "loading"
|
|
82
|
+
? { label: "Syncing", tone: "info" as const }
|
|
83
|
+
: metadataState === "error"
|
|
84
|
+
? { label: "Snapshot", tone: "warning" as const }
|
|
85
|
+
: online === false
|
|
86
|
+
? { label: "Offline", tone: "warning" as const }
|
|
87
|
+
: { label: "Online", tone: "success" as const };
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<OnChainActionCard
|
|
91
|
+
accessibilityLabel={`${title}, ${status.label} dual stake pool`}
|
|
92
|
+
testID={`dual-stake-card-${appId}`}
|
|
93
|
+
>
|
|
94
|
+
<OnChainActionHeader
|
|
95
|
+
eyebrow="Dual stake"
|
|
96
|
+
title={title}
|
|
97
|
+
description={
|
|
98
|
+
description ||
|
|
99
|
+
"Pair ALGO with the reward asset, then mint or redeem dual stake."
|
|
100
|
+
}
|
|
101
|
+
status={status}
|
|
102
|
+
menu={<ContractMenu appId={appId} embedType="DualStakePool" />}
|
|
103
|
+
/>
|
|
104
|
+
|
|
105
|
+
<View style={{ flexDirection: "row", alignItems: "center", gap: 7 }}>
|
|
106
|
+
<AssetPill label="ALGO" subtitle="Algorand" />
|
|
107
|
+
<Text
|
|
108
|
+
size="sm"
|
|
109
|
+
weight="semiBold"
|
|
110
|
+
style={{ color: theme.colors.textDim }}
|
|
111
|
+
>
|
|
112
|
+
+
|
|
113
|
+
</Text>
|
|
114
|
+
<AssetPill {...rewardAsset} />
|
|
115
|
+
{dualStakeAsset ? (
|
|
116
|
+
<>
|
|
117
|
+
<Text
|
|
118
|
+
size="sm"
|
|
119
|
+
weight="semiBold"
|
|
120
|
+
style={{ color: theme.colors.textDim }}
|
|
121
|
+
>
|
|
122
|
+
→
|
|
123
|
+
</Text>
|
|
124
|
+
<AssetPill {...dualStakeAsset} />
|
|
125
|
+
</>
|
|
126
|
+
) : null}
|
|
127
|
+
</View>
|
|
128
|
+
|
|
129
|
+
{stakedLabel || algoBalanceLabel || asaBalanceLabel ? (
|
|
130
|
+
<OnChainMetricGrid>
|
|
131
|
+
{stakedLabel ? (
|
|
132
|
+
<OnChainMetric label="Total staked" value={`${stakedLabel} ALGO`} />
|
|
133
|
+
) : null}
|
|
134
|
+
{algoBalanceLabel ? (
|
|
135
|
+
<OnChainMetric
|
|
136
|
+
label="Pool liquidity"
|
|
137
|
+
value={`${algoBalanceLabel} ALGO`}
|
|
138
|
+
/>
|
|
139
|
+
) : null}
|
|
140
|
+
{asaBalanceLabel ? (
|
|
141
|
+
<OnChainMetric
|
|
142
|
+
label="Reward liquidity"
|
|
143
|
+
value={`${asaBalanceLabel} ${asaBalanceUnit || rewardAsset.label}`}
|
|
144
|
+
/>
|
|
145
|
+
) : null}
|
|
146
|
+
</OnChainMetricGrid>
|
|
147
|
+
) : null}
|
|
148
|
+
|
|
149
|
+
{metadataState === "error" ? (
|
|
150
|
+
<View
|
|
151
|
+
style={{
|
|
152
|
+
alignItems: "center",
|
|
153
|
+
backgroundColor: `${theme.colors.warning}12`,
|
|
154
|
+
borderCurve: "continuous",
|
|
155
|
+
borderRadius: 10,
|
|
156
|
+
flexDirection: "row",
|
|
157
|
+
gap: 8,
|
|
158
|
+
padding: 9,
|
|
159
|
+
}}
|
|
160
|
+
>
|
|
161
|
+
<Text size="xxs" style={{ color: theme.colors.warningText, flex: 1 }}>
|
|
162
|
+
Live pool details are unavailable. Snapshot details and the contract
|
|
163
|
+
reference remain visible.
|
|
164
|
+
</Text>
|
|
165
|
+
{onRetry ? (
|
|
166
|
+
<Pressable
|
|
167
|
+
accessibilityLabel="Retry loading dual stake pool"
|
|
168
|
+
accessibilityRole="button"
|
|
169
|
+
onPress={onRetry}
|
|
170
|
+
hitSlop={8}
|
|
171
|
+
>
|
|
172
|
+
<ArrowPathIcon size={16} color={theme.colors.warningText} />
|
|
173
|
+
</Pressable>
|
|
174
|
+
) : null}
|
|
175
|
+
</View>
|
|
176
|
+
) : null}
|
|
177
|
+
|
|
178
|
+
<View style={{ gap: 10 }}>
|
|
179
|
+
<AmountActionRow
|
|
180
|
+
accessibilityLabel="ALGO amount to mint dual stake"
|
|
181
|
+
amount={mintAmount}
|
|
182
|
+
buttonLabel={submitting ? "Minting…" : "Mint"}
|
|
183
|
+
buttonAccessibilityLabel="Mint dual stake"
|
|
184
|
+
disabled={!canMint}
|
|
185
|
+
inputDisabled={submitting}
|
|
186
|
+
onAmountChange={onMintAmountChange}
|
|
187
|
+
onPress={onMint}
|
|
188
|
+
placeholder="0.00 ALGO"
|
|
189
|
+
/>
|
|
190
|
+
<AmountActionRow
|
|
191
|
+
accessibilityLabel={`${dualStakeAsset?.label || "dual stake"} amount to redeem`}
|
|
192
|
+
amount={redeemAmount}
|
|
193
|
+
buttonLabel={submitting ? "Redeeming…" : "Redeem"}
|
|
194
|
+
disabled={!canRedeem}
|
|
195
|
+
inputDisabled={submitting}
|
|
196
|
+
onAmountChange={onRedeemAmountChange}
|
|
197
|
+
onPress={onRedeem}
|
|
198
|
+
placeholder={`0.00 ${dualStakeAsset?.label || "dual stake"}`}
|
|
199
|
+
variant="secondary"
|
|
200
|
+
/>
|
|
201
|
+
</View>
|
|
202
|
+
|
|
203
|
+
{!connected ? (
|
|
204
|
+
<Text size="xxs" style={{ color: theme.colors.textDim }}>
|
|
205
|
+
Connect a wallet to mint or redeem dual stake.
|
|
206
|
+
</Text>
|
|
207
|
+
) : null}
|
|
208
|
+
</OnChainActionCard>
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function AmountActionRow({
|
|
213
|
+
accessibilityLabel,
|
|
214
|
+
buttonAccessibilityLabel,
|
|
215
|
+
amount,
|
|
216
|
+
buttonLabel,
|
|
217
|
+
disabled,
|
|
218
|
+
inputDisabled,
|
|
219
|
+
onAmountChange,
|
|
220
|
+
onPress,
|
|
221
|
+
placeholder,
|
|
222
|
+
variant = "primary",
|
|
223
|
+
}: {
|
|
224
|
+
accessibilityLabel: string;
|
|
225
|
+
buttonAccessibilityLabel?: string;
|
|
226
|
+
amount: string;
|
|
227
|
+
buttonLabel: string;
|
|
228
|
+
disabled: boolean;
|
|
229
|
+
inputDisabled: boolean;
|
|
230
|
+
onAmountChange: (value: string) => void;
|
|
231
|
+
onPress: () => void;
|
|
232
|
+
placeholder: string;
|
|
233
|
+
variant?: "primary" | "secondary";
|
|
234
|
+
}) {
|
|
235
|
+
const { theme } = useAppTheme();
|
|
236
|
+
|
|
237
|
+
return (
|
|
238
|
+
<View style={{ flexDirection: "row", gap: 8 }}>
|
|
239
|
+
<TextInput
|
|
240
|
+
accessibilityLabel={accessibilityLabel}
|
|
241
|
+
value={amount}
|
|
242
|
+
onChangeText={onAmountChange}
|
|
243
|
+
editable={!inputDisabled}
|
|
244
|
+
keyboardType="decimal-pad"
|
|
245
|
+
placeholder={placeholder}
|
|
246
|
+
placeholderTextColor={theme.colors.textDim}
|
|
247
|
+
style={{
|
|
248
|
+
borderColor: theme.colors.border,
|
|
249
|
+
borderCurve: "continuous",
|
|
250
|
+
borderRadius: 12,
|
|
251
|
+
borderWidth: 1,
|
|
252
|
+
color: theme.colors.text,
|
|
253
|
+
flex: 1,
|
|
254
|
+
minWidth: 0,
|
|
255
|
+
fontFamily: theme.typography.primary.medium,
|
|
256
|
+
fontSize: 15,
|
|
257
|
+
minHeight: 48,
|
|
258
|
+
paddingHorizontal: 12,
|
|
259
|
+
paddingVertical: 10,
|
|
260
|
+
}}
|
|
261
|
+
/>
|
|
262
|
+
<View style={{ flexBasis: 120, flexShrink: 0, flexDirection: "row" }}>
|
|
263
|
+
<OnChainActionButton
|
|
264
|
+
accessibilityLabel={buttonAccessibilityLabel}
|
|
265
|
+
label={buttonLabel}
|
|
266
|
+
disabled={disabled}
|
|
267
|
+
onPress={onPress}
|
|
268
|
+
variant={variant}
|
|
269
|
+
/>
|
|
270
|
+
</View>
|
|
271
|
+
</View>
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function AssetPill({ label, subtitle, imageUrl, loading }: AssetSummary) {
|
|
276
|
+
const { theme } = useAppTheme();
|
|
277
|
+
|
|
278
|
+
return (
|
|
279
|
+
<View
|
|
280
|
+
accessible
|
|
281
|
+
accessibilityLabel={`${label}, ${subtitle}`}
|
|
282
|
+
style={{
|
|
283
|
+
alignItems: "center",
|
|
284
|
+
backgroundColor: `${theme.colors.textDim}10`,
|
|
285
|
+
borderCurve: "continuous",
|
|
286
|
+
borderRadius: 12,
|
|
287
|
+
flex: 1,
|
|
288
|
+
gap: 5,
|
|
289
|
+
minWidth: 0,
|
|
290
|
+
padding: 8,
|
|
291
|
+
}}
|
|
292
|
+
>
|
|
293
|
+
<View
|
|
294
|
+
style={{
|
|
295
|
+
alignItems: "center",
|
|
296
|
+
backgroundColor: `${theme.colors.primary}16`,
|
|
297
|
+
borderCurve: "continuous",
|
|
298
|
+
borderRadius: 9,
|
|
299
|
+
height: 34,
|
|
300
|
+
justifyContent: "center",
|
|
301
|
+
overflow: "hidden",
|
|
302
|
+
width: 34,
|
|
303
|
+
}}
|
|
304
|
+
>
|
|
305
|
+
{loading ? (
|
|
306
|
+
<ActivityIndicator size="small" color={theme.colors.textDim} />
|
|
307
|
+
) : imageUrl ? (
|
|
308
|
+
<Image
|
|
309
|
+
source={{ uri: imageUrl }}
|
|
310
|
+
style={{ height: 34, width: 34 }}
|
|
311
|
+
resizeMode="cover"
|
|
312
|
+
/>
|
|
313
|
+
) : (
|
|
314
|
+
<Text
|
|
315
|
+
size="xxs"
|
|
316
|
+
weight="bold"
|
|
317
|
+
style={{ color: theme.colors.primary }}
|
|
318
|
+
>
|
|
319
|
+
{label.slice(0, 3)}
|
|
320
|
+
</Text>
|
|
321
|
+
)}
|
|
322
|
+
</View>
|
|
323
|
+
<Text size="xxs" weight="semiBold" numberOfLines={1}>
|
|
324
|
+
{label}
|
|
325
|
+
</Text>
|
|
326
|
+
<Text
|
|
327
|
+
size="xxs"
|
|
328
|
+
numberOfLines={1}
|
|
329
|
+
style={{ color: theme.colors.textDim }}
|
|
330
|
+
>
|
|
331
|
+
{subtitle}
|
|
332
|
+
</Text>
|
|
333
|
+
</View>
|
|
334
|
+
);
|
|
335
|
+
}
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
// Shared layouts for MDX page links, private content and unresolved embed types.
|
|
2
|
+
import React, { useMemo } from "react";
|
|
3
|
+
import { View, Pressable, StyleSheet } from "react-native";
|
|
4
|
+
import * as Haptics from "expo-haptics";
|
|
5
|
+
import { Text, useAppTheme, useOpenExplorer } from "./runtime";
|
|
6
|
+
import {
|
|
7
|
+
OutlineDocumentTextIcon as DocumentTextIcon,
|
|
8
|
+
OutlineLockClosedIcon as LockClosedIcon,
|
|
9
|
+
ChevronRightIcon,
|
|
10
|
+
} from "./icons";
|
|
11
|
+
import { CompactPill } from "./References";
|
|
12
|
+
|
|
13
|
+
export function PlaceholderPresentation({
|
|
14
|
+
name,
|
|
15
|
+
appId,
|
|
16
|
+
inline,
|
|
17
|
+
}: {
|
|
18
|
+
name: string;
|
|
19
|
+
appId?: string;
|
|
20
|
+
inline?: boolean;
|
|
21
|
+
}) {
|
|
22
|
+
const { theme } = useAppTheme();
|
|
23
|
+
const openExplorer = useOpenExplorer();
|
|
24
|
+
|
|
25
|
+
if (inline) {
|
|
26
|
+
return <CompactPill label={`${name} #${appId || "?"}`} inline />;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<View
|
|
31
|
+
style={{
|
|
32
|
+
backgroundColor: theme.colors.accentBackground,
|
|
33
|
+
borderRadius: 16,
|
|
34
|
+
padding: 16,
|
|
35
|
+
minHeight: 60,
|
|
36
|
+
}}
|
|
37
|
+
>
|
|
38
|
+
<Text size="sm" weight="semiBold" style={{ color: theme.colors.text }}>
|
|
39
|
+
{name}
|
|
40
|
+
</Text>
|
|
41
|
+
{appId && (
|
|
42
|
+
<Pressable onPress={() => openExplorer(`application/${appId}`)}>
|
|
43
|
+
<Text size="xs" style={{ color: theme.colors.primary, marginTop: 4 }}>
|
|
44
|
+
App ID: {appId} — View on Explorer
|
|
45
|
+
</Text>
|
|
46
|
+
</Pressable>
|
|
47
|
+
)}
|
|
48
|
+
</View>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface PageCardPresentationProps {
|
|
53
|
+
pagePath?: string;
|
|
54
|
+
title?: string;
|
|
55
|
+
preview?: string;
|
|
56
|
+
inline?: boolean;
|
|
57
|
+
onOpen?: (path: string) => void;
|
|
58
|
+
}
|
|
59
|
+
export function PageCardPresentation({
|
|
60
|
+
pagePath,
|
|
61
|
+
title = "Linked page",
|
|
62
|
+
preview = "Open page",
|
|
63
|
+
inline,
|
|
64
|
+
onOpen,
|
|
65
|
+
}: PageCardPresentationProps) {
|
|
66
|
+
const { theme } = useAppTheme();
|
|
67
|
+
const styles = useMemo(
|
|
68
|
+
() =>
|
|
69
|
+
StyleSheet.create({
|
|
70
|
+
card: {
|
|
71
|
+
alignItems: "center",
|
|
72
|
+
alignSelf: "stretch",
|
|
73
|
+
backgroundColor: theme.colors.accentBackground,
|
|
74
|
+
borderColor: theme.colors.border,
|
|
75
|
+
borderRadius: 12,
|
|
76
|
+
borderWidth: 1,
|
|
77
|
+
flexDirection: "row",
|
|
78
|
+
gap: 10,
|
|
79
|
+
minWidth: 0,
|
|
80
|
+
paddingHorizontal: 12,
|
|
81
|
+
paddingVertical: 11,
|
|
82
|
+
width: "100%",
|
|
83
|
+
},
|
|
84
|
+
cardPressed: {
|
|
85
|
+
opacity: 0.82,
|
|
86
|
+
},
|
|
87
|
+
icon: {
|
|
88
|
+
alignItems: "center",
|
|
89
|
+
backgroundColor: `${theme.colors.primary}22`,
|
|
90
|
+
borderRadius: 9,
|
|
91
|
+
height: 38,
|
|
92
|
+
justifyContent: "center",
|
|
93
|
+
width: 38,
|
|
94
|
+
},
|
|
95
|
+
previewText: {
|
|
96
|
+
color: theme.colors.textDim,
|
|
97
|
+
marginTop: 2,
|
|
98
|
+
},
|
|
99
|
+
textColumn: {
|
|
100
|
+
flex: 1,
|
|
101
|
+
minWidth: 0,
|
|
102
|
+
},
|
|
103
|
+
titleText: {
|
|
104
|
+
color: theme.colors.text,
|
|
105
|
+
},
|
|
106
|
+
}),
|
|
107
|
+
[
|
|
108
|
+
theme.colors.accentBackground,
|
|
109
|
+
theme.colors.border,
|
|
110
|
+
theme.colors.primary,
|
|
111
|
+
theme.colors.text,
|
|
112
|
+
theme.colors.textDim,
|
|
113
|
+
],
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
if (inline) {
|
|
117
|
+
return <CompactPill label={title} inline />;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<Pressable
|
|
122
|
+
accessibilityRole="link"
|
|
123
|
+
accessibilityLabel={`Open ${title}`}
|
|
124
|
+
disabled={!pagePath}
|
|
125
|
+
onPress={() => {
|
|
126
|
+
if (!pagePath) return;
|
|
127
|
+
Haptics.selectionAsync();
|
|
128
|
+
onOpen?.(pagePath);
|
|
129
|
+
}}
|
|
130
|
+
style={({ pressed }) => [styles.card, pressed && styles.cardPressed]}
|
|
131
|
+
>
|
|
132
|
+
<View style={styles.icon}>
|
|
133
|
+
<DocumentTextIcon size={19} color={theme.colors.primary} />
|
|
134
|
+
</View>
|
|
135
|
+
<View style={styles.textColumn}>
|
|
136
|
+
<Text
|
|
137
|
+
size="sm"
|
|
138
|
+
weight="semiBold"
|
|
139
|
+
numberOfLines={1}
|
|
140
|
+
style={styles.titleText}
|
|
141
|
+
>
|
|
142
|
+
{title}
|
|
143
|
+
</Text>
|
|
144
|
+
<Text size="xs" numberOfLines={2} style={styles.previewText}>
|
|
145
|
+
{preview}
|
|
146
|
+
</Text>
|
|
147
|
+
</View>
|
|
148
|
+
<ChevronRightIcon size={17} color={theme.colors.textDim} />
|
|
149
|
+
</Pressable>
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface PrivateContentPresentationProps {
|
|
154
|
+
contentId?: string;
|
|
155
|
+
title?: string;
|
|
156
|
+
inline?: boolean;
|
|
157
|
+
isLoading?: boolean;
|
|
158
|
+
isError?: boolean;
|
|
159
|
+
isUnlocked?: boolean;
|
|
160
|
+
onUnlock?: () => Promise<void> | void;
|
|
161
|
+
children?: React.ReactNode;
|
|
162
|
+
}
|
|
163
|
+
export function PrivateContentPresentation({
|
|
164
|
+
contentId,
|
|
165
|
+
title = "Private content",
|
|
166
|
+
inline,
|
|
167
|
+
isLoading,
|
|
168
|
+
isError,
|
|
169
|
+
isUnlocked,
|
|
170
|
+
onUnlock,
|
|
171
|
+
children,
|
|
172
|
+
}: PrivateContentPresentationProps) {
|
|
173
|
+
const { theme } = useAppTheme();
|
|
174
|
+
const styles = useMemo(
|
|
175
|
+
() =>
|
|
176
|
+
StyleSheet.create({
|
|
177
|
+
body: {
|
|
178
|
+
marginTop: 12,
|
|
179
|
+
},
|
|
180
|
+
button: {
|
|
181
|
+
backgroundColor: theme.colors.primary,
|
|
182
|
+
borderRadius: 9,
|
|
183
|
+
paddingHorizontal: 12,
|
|
184
|
+
paddingVertical: 8,
|
|
185
|
+
},
|
|
186
|
+
buttonText: {
|
|
187
|
+
color: theme.colors.primaryText,
|
|
188
|
+
},
|
|
189
|
+
card: {
|
|
190
|
+
backgroundColor: theme.colors.accentBackground,
|
|
191
|
+
borderColor: theme.colors.border,
|
|
192
|
+
borderRadius: 12,
|
|
193
|
+
borderWidth: 1,
|
|
194
|
+
paddingHorizontal: 14,
|
|
195
|
+
paddingVertical: 13,
|
|
196
|
+
},
|
|
197
|
+
header: {
|
|
198
|
+
alignItems: "center",
|
|
199
|
+
flexDirection: "row",
|
|
200
|
+
gap: 10,
|
|
201
|
+
},
|
|
202
|
+
icon: {
|
|
203
|
+
alignItems: "center",
|
|
204
|
+
backgroundColor: `${theme.colors.primary}22`,
|
|
205
|
+
borderRadius: 9,
|
|
206
|
+
height: 36,
|
|
207
|
+
justifyContent: "center",
|
|
208
|
+
width: 36,
|
|
209
|
+
},
|
|
210
|
+
subtitle: {
|
|
211
|
+
color: theme.colors.textDim,
|
|
212
|
+
marginTop: 2,
|
|
213
|
+
},
|
|
214
|
+
textColumn: {
|
|
215
|
+
flex: 1,
|
|
216
|
+
minWidth: 0,
|
|
217
|
+
},
|
|
218
|
+
title: {
|
|
219
|
+
color: theme.colors.text,
|
|
220
|
+
},
|
|
221
|
+
}),
|
|
222
|
+
[
|
|
223
|
+
theme.colors.accentBackground,
|
|
224
|
+
theme.colors.border,
|
|
225
|
+
theme.colors.primary,
|
|
226
|
+
theme.colors.primaryText,
|
|
227
|
+
theme.colors.text,
|
|
228
|
+
theme.colors.textDim,
|
|
229
|
+
],
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
if (inline) {
|
|
233
|
+
return <CompactPill label={title} inline />;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (children) {
|
|
237
|
+
return (
|
|
238
|
+
<View style={styles.card}>
|
|
239
|
+
<View style={styles.header}>
|
|
240
|
+
<View style={styles.icon}>
|
|
241
|
+
<LockClosedIcon size={18} color={theme.colors.primary} />
|
|
242
|
+
</View>
|
|
243
|
+
<View style={styles.textColumn}>
|
|
244
|
+
<Text size="sm" weight="semiBold" style={styles.title}>
|
|
245
|
+
{title}
|
|
246
|
+
</Text>
|
|
247
|
+
<Text size="xs" style={styles.subtitle}>
|
|
248
|
+
Unlocked
|
|
249
|
+
</Text>
|
|
250
|
+
</View>
|
|
251
|
+
</View>
|
|
252
|
+
<View style={styles.body}>{children}</View>
|
|
253
|
+
</View>
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
return (
|
|
258
|
+
<View style={styles.card}>
|
|
259
|
+
<View style={styles.header}>
|
|
260
|
+
<View style={styles.icon}>
|
|
261
|
+
<LockClosedIcon size={18} color={theme.colors.primary} />
|
|
262
|
+
</View>
|
|
263
|
+
<View style={styles.textColumn}>
|
|
264
|
+
<Text
|
|
265
|
+
size="sm"
|
|
266
|
+
weight="semiBold"
|
|
267
|
+
style={styles.title}
|
|
268
|
+
numberOfLines={1}
|
|
269
|
+
>
|
|
270
|
+
{title}
|
|
271
|
+
</Text>
|
|
272
|
+
<Text size="xs" style={styles.subtitle} numberOfLines={1}>
|
|
273
|
+
{isError
|
|
274
|
+
? "Unavailable"
|
|
275
|
+
: isLoading
|
|
276
|
+
? "Loading"
|
|
277
|
+
: isUnlocked
|
|
278
|
+
? "No grant"
|
|
279
|
+
: "Locked"}
|
|
280
|
+
</Text>
|
|
281
|
+
</View>
|
|
282
|
+
<Pressable
|
|
283
|
+
accessibilityRole="button"
|
|
284
|
+
disabled={!contentId || isLoading}
|
|
285
|
+
onPress={() => {
|
|
286
|
+
Haptics.selectionAsync();
|
|
287
|
+
Promise.resolve(onUnlock?.()).catch((error) => {
|
|
288
|
+
console.warn("[PrivateContent] Failed to unlock content:", error);
|
|
289
|
+
});
|
|
290
|
+
}}
|
|
291
|
+
style={({ pressed }) => [styles.button, pressed && { opacity: 0.82 }]}
|
|
292
|
+
>
|
|
293
|
+
<Text size="xs" weight="semiBold" style={styles.buttonText}>
|
|
294
|
+
Unlock
|
|
295
|
+
</Text>
|
|
296
|
+
</Pressable>
|
|
297
|
+
</View>
|
|
298
|
+
</View>
|
|
299
|
+
);
|
|
300
|
+
}
|