@akita-protocol/algomd-rn 0.0.0-stage → 1.0.0-alpha.0
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 +268 -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/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 +137 -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,334 @@
|
|
|
1
|
+
// Shared AlgoMD presentation. Edit this library source.
|
|
2
|
+
import React, { useCallback, useEffect, useRef } from "react";
|
|
3
|
+
import { Image, Pressable, View } from "react-native";
|
|
4
|
+
import * as Haptics from "expo-haptics";
|
|
5
|
+
import {
|
|
6
|
+
BottomSheetModal,
|
|
7
|
+
BottomSheetBackdrop,
|
|
8
|
+
BottomSheetScrollView,
|
|
9
|
+
} from "./sheets";
|
|
10
|
+
import {
|
|
11
|
+
AtSymbolIcon,
|
|
12
|
+
ChartBarIcon,
|
|
13
|
+
CircleStackIcon,
|
|
14
|
+
CheckIcon,
|
|
15
|
+
XMarkIcon,
|
|
16
|
+
KeyIcon,
|
|
17
|
+
LockClosedIcon,
|
|
18
|
+
ShieldCheckIcon,
|
|
19
|
+
PhotoIcon,
|
|
20
|
+
Squares2X2Icon,
|
|
21
|
+
UserGroupIcon,
|
|
22
|
+
UserIcon,
|
|
23
|
+
} from "./icons";
|
|
24
|
+
import {
|
|
25
|
+
AppPresentationProvider,
|
|
26
|
+
Text,
|
|
27
|
+
useAppTheme,
|
|
28
|
+
usePresentation,
|
|
29
|
+
} from "./runtime";
|
|
30
|
+
import { getAssetIconSource } from "./assetHelpers";
|
|
31
|
+
import {
|
|
32
|
+
describeGate,
|
|
33
|
+
describeGateRule,
|
|
34
|
+
gateRuleAsset,
|
|
35
|
+
isCollectibleAsset,
|
|
36
|
+
} from "./gates";
|
|
37
|
+
import type { GateRule, GatingInfo } from "../types/algorand";
|
|
38
|
+
|
|
39
|
+
const SHEET_SPRING = {
|
|
40
|
+
damping: 70,
|
|
41
|
+
stiffness: 900,
|
|
42
|
+
mass: 2,
|
|
43
|
+
overshootClamping: false,
|
|
44
|
+
};
|
|
45
|
+
const ICON = 40;
|
|
46
|
+
|
|
47
|
+
type Theme = ReturnType<typeof useAppTheme>["theme"];
|
|
48
|
+
|
|
49
|
+
export interface GateRequirementsProps {
|
|
50
|
+
gating: GatingInfo;
|
|
51
|
+
/** What the gate unlocks, e.g. "buy", "enter", "bid". */
|
|
52
|
+
action: string;
|
|
53
|
+
/** Whether the viewer passes the gate; undefined when it hasn't been checked. */
|
|
54
|
+
eligible?: boolean;
|
|
55
|
+
/** Pass (true) or fail (false) for each rule, in rule order; omit when unchecked. */
|
|
56
|
+
results?: boolean[];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** The art, token icon or kind icon that leads a requirement row. */
|
|
60
|
+
function RuleIcon({ rule, theme }: { rule?: GateRule; theme: Theme }) {
|
|
61
|
+
const asset = rule ? gateRuleAsset(rule) : undefined;
|
|
62
|
+
const source = asset ? getAssetIconSource(asset) : undefined;
|
|
63
|
+
if (asset && source) {
|
|
64
|
+
// Collectibles keep their art in a rounded square; tokens get a round icon.
|
|
65
|
+
return (
|
|
66
|
+
<Image
|
|
67
|
+
source={source}
|
|
68
|
+
accessibilityLabel={asset.name}
|
|
69
|
+
style={{
|
|
70
|
+
width: ICON,
|
|
71
|
+
height: ICON,
|
|
72
|
+
borderRadius: isCollectibleAsset(asset) ? 10 : ICON / 2,
|
|
73
|
+
}}
|
|
74
|
+
/>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
const color = theme.colors.primary;
|
|
78
|
+
const glyph = (() => {
|
|
79
|
+
switch (rule?.type) {
|
|
80
|
+
case "asset":
|
|
81
|
+
return <PhotoIcon size={18} color={color} />;
|
|
82
|
+
case "staking_amount":
|
|
83
|
+
case "staking_power":
|
|
84
|
+
return <CircleStackIcon size={18} color={color} />;
|
|
85
|
+
case "nfd":
|
|
86
|
+
case "nfd_root":
|
|
87
|
+
return <AtSymbolIcon size={18} color={color} />;
|
|
88
|
+
case "akita_referrer":
|
|
89
|
+
case "social_follower_index":
|
|
90
|
+
return <UserIcon size={18} color={color} />;
|
|
91
|
+
case "merkle_address":
|
|
92
|
+
case "merkle_asset":
|
|
93
|
+
return <Squares2X2Icon size={18} color={color} />;
|
|
94
|
+
case "poll":
|
|
95
|
+
return <ChartBarIcon size={18} color={color} />;
|
|
96
|
+
case "subscription":
|
|
97
|
+
case "subscription_streak":
|
|
98
|
+
return <KeyIcon size={18} color={color} />;
|
|
99
|
+
case undefined:
|
|
100
|
+
return <LockClosedIcon size={18} color={color} />;
|
|
101
|
+
default:
|
|
102
|
+
return <UserGroupIcon size={18} color={color} />;
|
|
103
|
+
}
|
|
104
|
+
})();
|
|
105
|
+
return (
|
|
106
|
+
<View
|
|
107
|
+
style={{
|
|
108
|
+
width: ICON,
|
|
109
|
+
height: ICON,
|
|
110
|
+
borderRadius: ICON / 2,
|
|
111
|
+
alignItems: "center",
|
|
112
|
+
justifyContent: "center",
|
|
113
|
+
backgroundColor: `${color}1F`,
|
|
114
|
+
}}
|
|
115
|
+
>
|
|
116
|
+
{glyph}
|
|
117
|
+
</View>
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Who may act on a gated contract: one row per rule with the token's icon or the
|
|
123
|
+
* collectible's art. When the rules can't be read, it says the check happens on signing.
|
|
124
|
+
*/
|
|
125
|
+
export function GateRequirements({
|
|
126
|
+
gating,
|
|
127
|
+
action,
|
|
128
|
+
eligible,
|
|
129
|
+
results,
|
|
130
|
+
}: GateRequirementsProps) {
|
|
131
|
+
const { theme } = useAppTheme();
|
|
132
|
+
const rules = gating.rules ?? [];
|
|
133
|
+
// Legacy gates carry no typed rules; fall back to their plain lines.
|
|
134
|
+
const lines = rules.length
|
|
135
|
+
? rules.map(describeGateRule)
|
|
136
|
+
: describeGate(gating);
|
|
137
|
+
const headline =
|
|
138
|
+
eligible === false
|
|
139
|
+
? "Requirements not met"
|
|
140
|
+
: eligible
|
|
141
|
+
? "Requirements met"
|
|
142
|
+
: `Requirements to ${action}`;
|
|
143
|
+
const headColor =
|
|
144
|
+
eligible === false
|
|
145
|
+
? theme.colors.warningText
|
|
146
|
+
: eligible
|
|
147
|
+
? theme.colors.success
|
|
148
|
+
: theme.colors.text;
|
|
149
|
+
return (
|
|
150
|
+
<View
|
|
151
|
+
accessibilityLabel={
|
|
152
|
+
lines.length
|
|
153
|
+
? `To ${action}: ${lines.join("; ")}`
|
|
154
|
+
: `Gated. Requirements are checked when you ${action}.`
|
|
155
|
+
}
|
|
156
|
+
style={{ gap: 6 }}
|
|
157
|
+
>
|
|
158
|
+
<View style={{ gap: 4 }}>
|
|
159
|
+
<View style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
|
|
160
|
+
<ShieldCheckIcon
|
|
161
|
+
size={18}
|
|
162
|
+
color={eligible === undefined ? theme.colors.primary : headColor}
|
|
163
|
+
/>
|
|
164
|
+
<Text size="md" weight="bold" style={{ color: headColor }}>
|
|
165
|
+
{headline}
|
|
166
|
+
</Text>
|
|
167
|
+
</View>
|
|
168
|
+
<Text size="xs" style={{ color: theme.colors.textDim }}>
|
|
169
|
+
{lines.length
|
|
170
|
+
? lines.length > 1
|
|
171
|
+
? `You need all of these. They're checked when you ${action}.`
|
|
172
|
+
: `They're checked when you ${action}.`
|
|
173
|
+
: `The requirements couldn't be read here. They're checked when you ${action}.`}
|
|
174
|
+
</Text>
|
|
175
|
+
</View>
|
|
176
|
+
{lines.map((line, index) => {
|
|
177
|
+
const rule = rules[index];
|
|
178
|
+
const asset = rule ? gateRuleAsset(rule) : undefined;
|
|
179
|
+
const passed = rule ? results?.[index] : undefined;
|
|
180
|
+
return (
|
|
181
|
+
<View
|
|
182
|
+
key={`${line}-${index}`}
|
|
183
|
+
accessibilityLabel={
|
|
184
|
+
passed === undefined
|
|
185
|
+
? line
|
|
186
|
+
: `${line}: ${passed ? "you pass" : "you don't pass"}`
|
|
187
|
+
}
|
|
188
|
+
style={{
|
|
189
|
+
flexDirection: "row",
|
|
190
|
+
alignItems: "center",
|
|
191
|
+
gap: 12,
|
|
192
|
+
// Rows get a little inset so a passed rule's tint has room;
|
|
193
|
+
// the negative margin keeps icons in line with the heading.
|
|
194
|
+
padding: 8,
|
|
195
|
+
marginHorizontal: -8,
|
|
196
|
+
borderRadius: 14,
|
|
197
|
+
backgroundColor: passed
|
|
198
|
+
? `${theme.colors.success}1A`
|
|
199
|
+
: "transparent",
|
|
200
|
+
}}
|
|
201
|
+
>
|
|
202
|
+
<RuleIcon rule={rule} theme={theme} />
|
|
203
|
+
<View style={{ flex: 1, gap: 2 }}>
|
|
204
|
+
<Text size="sm" weight="semiBold">
|
|
205
|
+
{line}
|
|
206
|
+
</Text>
|
|
207
|
+
{asset ? (
|
|
208
|
+
<Text
|
|
209
|
+
size="xxs"
|
|
210
|
+
numberOfLines={1}
|
|
211
|
+
style={{ color: theme.colors.textDim }}
|
|
212
|
+
>
|
|
213
|
+
{isCollectibleAsset(asset)
|
|
214
|
+
? `Collectible · #${asset.id}`
|
|
215
|
+
: [asset.name, `#${asset.id}`].filter(Boolean).join(" · ")}
|
|
216
|
+
</Text>
|
|
217
|
+
) : null}
|
|
218
|
+
</View>
|
|
219
|
+
{passed === undefined ? null : passed ? (
|
|
220
|
+
<CheckIcon size={20} color={theme.colors.success} />
|
|
221
|
+
) : (
|
|
222
|
+
<XMarkIcon size={20} color={theme.colors.error} />
|
|
223
|
+
)}
|
|
224
|
+
</View>
|
|
225
|
+
);
|
|
226
|
+
})}
|
|
227
|
+
</View>
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* The gate, sized to sit with the action. A viewer who fails it gets a warning box
|
|
233
|
+
* in place of the action; otherwise a quiet line. Either opens the requirements in
|
|
234
|
+
* a bottom sheet.
|
|
235
|
+
*/
|
|
236
|
+
export function GateNotice({
|
|
237
|
+
gating,
|
|
238
|
+
action,
|
|
239
|
+
eligible,
|
|
240
|
+
results,
|
|
241
|
+
}: GateRequirementsProps) {
|
|
242
|
+
const { theme } = useAppTheme();
|
|
243
|
+
const presentation = usePresentation();
|
|
244
|
+
const PortalProvider =
|
|
245
|
+
presentation.components?.PortalProvider ?? React.Fragment;
|
|
246
|
+
const sheetRef = useRef<BottomSheetModal>(null);
|
|
247
|
+
useEffect(() => {
|
|
248
|
+
const sheet = sheetRef.current;
|
|
249
|
+
return () => sheet?.dismiss();
|
|
250
|
+
}, []);
|
|
251
|
+
const open = useCallback(() => {
|
|
252
|
+
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
|
|
253
|
+
sheetRef.current?.present();
|
|
254
|
+
}, []);
|
|
255
|
+
const color =
|
|
256
|
+
eligible === false
|
|
257
|
+
? theme.colors.warningText
|
|
258
|
+
: eligible
|
|
259
|
+
? theme.colors.success
|
|
260
|
+
: theme.colors.primary;
|
|
261
|
+
const label =
|
|
262
|
+
eligible === false
|
|
263
|
+
? "Requirements not met"
|
|
264
|
+
: eligible
|
|
265
|
+
? "Requirements met"
|
|
266
|
+
: `Requirements to ${action}`;
|
|
267
|
+
|
|
268
|
+
return (
|
|
269
|
+
<>
|
|
270
|
+
<Pressable
|
|
271
|
+
accessibilityRole="button"
|
|
272
|
+
accessibilityLabel={label}
|
|
273
|
+
accessibilityHint="Shows the requirements"
|
|
274
|
+
onPress={open}
|
|
275
|
+
// A text button: the line itself opens the requirements.
|
|
276
|
+
style={({ pressed }) => [
|
|
277
|
+
{
|
|
278
|
+
flexDirection: "row",
|
|
279
|
+
alignItems: "center",
|
|
280
|
+
alignSelf: "flex-start",
|
|
281
|
+
gap: 6,
|
|
282
|
+
},
|
|
283
|
+
pressed && { opacity: 0.7 },
|
|
284
|
+
]}
|
|
285
|
+
>
|
|
286
|
+
<ShieldCheckIcon size={14} color={color} />
|
|
287
|
+
<Text
|
|
288
|
+
size="xs"
|
|
289
|
+
weight="semiBold"
|
|
290
|
+
numberOfLines={1}
|
|
291
|
+
style={{ color, flexShrink: 1 }}
|
|
292
|
+
>
|
|
293
|
+
{label}
|
|
294
|
+
</Text>
|
|
295
|
+
</Pressable>
|
|
296
|
+
<BottomSheetModal
|
|
297
|
+
ref={sheetRef}
|
|
298
|
+
enableDynamicSizing
|
|
299
|
+
backgroundStyle={{ backgroundColor: theme.colors.background }}
|
|
300
|
+
handleIndicatorStyle={{ backgroundColor: theme.colors.border }}
|
|
301
|
+
animationConfigs={SHEET_SPRING}
|
|
302
|
+
backdropComponent={(
|
|
303
|
+
props: React.ComponentProps<typeof BottomSheetBackdrop>,
|
|
304
|
+
) => (
|
|
305
|
+
<BottomSheetBackdrop
|
|
306
|
+
{...props}
|
|
307
|
+
appearsOnIndex={0}
|
|
308
|
+
disappearsOnIndex={-1}
|
|
309
|
+
pressBehavior="close"
|
|
310
|
+
/>
|
|
311
|
+
)}
|
|
312
|
+
>
|
|
313
|
+
<PortalProvider>
|
|
314
|
+
<AppPresentationProvider {...presentation}>
|
|
315
|
+
<BottomSheetScrollView
|
|
316
|
+
contentContainerStyle={{
|
|
317
|
+
paddingHorizontal: 20,
|
|
318
|
+
paddingTop: 4,
|
|
319
|
+
paddingBottom: 40,
|
|
320
|
+
}}
|
|
321
|
+
>
|
|
322
|
+
<GateRequirements
|
|
323
|
+
gating={gating}
|
|
324
|
+
action={action}
|
|
325
|
+
eligible={eligible}
|
|
326
|
+
results={results}
|
|
327
|
+
/>
|
|
328
|
+
</BottomSheetScrollView>
|
|
329
|
+
</AppPresentationProvider>
|
|
330
|
+
</PortalProvider>
|
|
331
|
+
</BottomSheetModal>
|
|
332
|
+
</>
|
|
333
|
+
);
|
|
334
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 impulse
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
// Shared AlgoMD presentation, migrated from akita-rn. Edit this library source.
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Image, View } from "react-native";
|
|
4
|
+
import { CheckBadgeIcon } from "./icons";
|
|
5
|
+
|
|
6
|
+
import type { NFDProfile as NFDProfileType } from "../types/algorand";
|
|
7
|
+
import { Text } from "./runtime";
|
|
8
|
+
import { useProfileDisplayPreferences } from "./runtime";
|
|
9
|
+
import { LinearGradient } from "./runtime";
|
|
10
|
+
import { useAppTheme } from "./runtime";
|
|
11
|
+
import { formatNfdName } from "./runtime";
|
|
12
|
+
import { AddressIdentityInline, avatarRadius, verifiedBadgeColor } from "./identity";
|
|
13
|
+
import { CardContainer } from "./CardContainer";
|
|
14
|
+
import { ContractMenu } from "./ContractMenu";
|
|
15
|
+
import {
|
|
16
|
+
OnChainActionButton,
|
|
17
|
+
OnChainActionCard,
|
|
18
|
+
OnChainActionHeader,
|
|
19
|
+
} from "./OnChainActionCard";
|
|
20
|
+
|
|
21
|
+
import { fallbackAvatar as FALLBACK_AVATAR } from "./assets";
|
|
22
|
+
const SOCIAL_FIELDS = [
|
|
23
|
+
{ key: "twitter", label: "Twitter" },
|
|
24
|
+
{ key: "discord", label: "Discord" },
|
|
25
|
+
{ key: "github", label: "GitHub" },
|
|
26
|
+
{ key: "website", label: "Website" },
|
|
27
|
+
{ key: "domain", label: "Website" },
|
|
28
|
+
{ key: "telegram", label: "Telegram" },
|
|
29
|
+
] as const;
|
|
30
|
+
|
|
31
|
+
export interface NFDProfileDisplayProps {
|
|
32
|
+
data: NFDProfileType;
|
|
33
|
+
compact?: boolean;
|
|
34
|
+
onOpenProfile?: () => void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function NFDProfileDisplay({
|
|
38
|
+
data,
|
|
39
|
+
compact,
|
|
40
|
+
onOpenProfile,
|
|
41
|
+
}: NFDProfileDisplayProps) {
|
|
42
|
+
const { theme } = useAppTheme();
|
|
43
|
+
const { showNfdSuffix } = useProfileDisplayPreferences();
|
|
44
|
+
const displayName = formatNfdName(data.name, { showNfdSuffix });
|
|
45
|
+
|
|
46
|
+
if (compact) {
|
|
47
|
+
return (
|
|
48
|
+
<CardContainer compact>
|
|
49
|
+
<View style={{ flexDirection: "row", alignItems: "center", gap: 3 }}>
|
|
50
|
+
<Image
|
|
51
|
+
source={data.avatar ? { uri: data.avatar } : FALLBACK_AVATAR}
|
|
52
|
+
style={{
|
|
53
|
+
width: 14,
|
|
54
|
+
height: 14,
|
|
55
|
+
borderRadius: avatarRadius(14, data.isCommunity),
|
|
56
|
+
}}
|
|
57
|
+
/>
|
|
58
|
+
<Text size="xxs" weight="semiBold" numberOfLines={1}>
|
|
59
|
+
{displayName}
|
|
60
|
+
</Text>
|
|
61
|
+
</View>
|
|
62
|
+
</CardContainer>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const socialLinks = SOCIAL_FIELDS.filter(
|
|
67
|
+
({ key }) =>
|
|
68
|
+
data.properties?.[key] && (key !== "domain" || !data.properties?.website),
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const banner = data.properties?.banner;
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<OnChainActionCard
|
|
75
|
+
accessibilityLabel={`${displayName} NFD profile`}
|
|
76
|
+
testID={`nfd-card-${data.id}`}
|
|
77
|
+
media={
|
|
78
|
+
banner ? (
|
|
79
|
+
<Image
|
|
80
|
+
source={{ uri: banner }}
|
|
81
|
+
style={{
|
|
82
|
+
width: "100%",
|
|
83
|
+
aspectRatio: 3,
|
|
84
|
+
backgroundColor: theme.colors.background,
|
|
85
|
+
}}
|
|
86
|
+
resizeMode="cover"
|
|
87
|
+
/>
|
|
88
|
+
) : (
|
|
89
|
+
<LinearGradient
|
|
90
|
+
colors={theme.gradients.interactive}
|
|
91
|
+
locations={theme.gradients.interactiveLocations}
|
|
92
|
+
start={{ x: 0, y: 0 }}
|
|
93
|
+
end={{ x: 1, y: 1 }}
|
|
94
|
+
style={{ width: "100%", height: 56, opacity: 0.85 }}
|
|
95
|
+
/>
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
>
|
|
99
|
+
<View style={{ gap: 10, marginTop: -48 }}>
|
|
100
|
+
<Image
|
|
101
|
+
source={data.avatar ? { uri: data.avatar } : FALLBACK_AVATAR}
|
|
102
|
+
style={{
|
|
103
|
+
width: 64,
|
|
104
|
+
height: 64,
|
|
105
|
+
borderRadius: avatarRadius(64, data.isCommunity),
|
|
106
|
+
borderWidth: 3,
|
|
107
|
+
borderColor: theme.colors.accentBackground,
|
|
108
|
+
backgroundColor: theme.colors.background,
|
|
109
|
+
}}
|
|
110
|
+
/>
|
|
111
|
+
<View style={{ flex: 1 }}>
|
|
112
|
+
<OnChainActionHeader
|
|
113
|
+
eyebrow="NFD"
|
|
114
|
+
title={displayName}
|
|
115
|
+
titleAccessory={
|
|
116
|
+
data.verified ? (
|
|
117
|
+
<CheckBadgeIcon
|
|
118
|
+
size={17}
|
|
119
|
+
color={verifiedBadgeColor(data.isCommunity)}
|
|
120
|
+
/>
|
|
121
|
+
) : undefined
|
|
122
|
+
}
|
|
123
|
+
menu={
|
|
124
|
+
/^\d+$/.test(data.id) ? (
|
|
125
|
+
<ContractMenu
|
|
126
|
+
appId={data.id}
|
|
127
|
+
embedType="NFDProfile"
|
|
128
|
+
embedValue={data.name}
|
|
129
|
+
/>
|
|
130
|
+
) : undefined
|
|
131
|
+
}
|
|
132
|
+
/>
|
|
133
|
+
</View>
|
|
134
|
+
</View>
|
|
135
|
+
|
|
136
|
+
<View style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
|
|
137
|
+
<Text
|
|
138
|
+
size="xxs"
|
|
139
|
+
weight="medium"
|
|
140
|
+
style={{ color: theme.colors.textDim }}
|
|
141
|
+
>
|
|
142
|
+
Resolves to
|
|
143
|
+
</Text>
|
|
144
|
+
<AddressIdentityInline address={data.address} />
|
|
145
|
+
</View>
|
|
146
|
+
|
|
147
|
+
{data.bio ? (
|
|
148
|
+
<Text
|
|
149
|
+
size="xs"
|
|
150
|
+
style={{ color: theme.colors.textDim }}
|
|
151
|
+
numberOfLines={4}
|
|
152
|
+
>
|
|
153
|
+
{data.bio}
|
|
154
|
+
</Text>
|
|
155
|
+
) : null}
|
|
156
|
+
|
|
157
|
+
{socialLinks.length > 0 ? (
|
|
158
|
+
<View style={{ flexDirection: "row", flexWrap: "wrap", gap: 6 }}>
|
|
159
|
+
{socialLinks.map(({ key, label }) => (
|
|
160
|
+
<View
|
|
161
|
+
key={key}
|
|
162
|
+
style={{
|
|
163
|
+
backgroundColor: `${theme.colors.primary}12`,
|
|
164
|
+
borderCurve: "continuous",
|
|
165
|
+
borderRadius: 8,
|
|
166
|
+
paddingHorizontal: 9,
|
|
167
|
+
paddingVertical: 5,
|
|
168
|
+
}}
|
|
169
|
+
>
|
|
170
|
+
<Text
|
|
171
|
+
size="xxs"
|
|
172
|
+
weight="medium"
|
|
173
|
+
style={{ color: theme.colors.primary }}
|
|
174
|
+
>
|
|
175
|
+
{label}
|
|
176
|
+
</Text>
|
|
177
|
+
</View>
|
|
178
|
+
))}
|
|
179
|
+
</View>
|
|
180
|
+
) : null}
|
|
181
|
+
|
|
182
|
+
{onOpenProfile ? (
|
|
183
|
+
<View style={{ flexDirection: "row" }}>
|
|
184
|
+
<OnChainActionButton
|
|
185
|
+
accessibilityLabel={`Open ${displayName} profile`}
|
|
186
|
+
label="View profile"
|
|
187
|
+
onPress={onOpenProfile}
|
|
188
|
+
variant="secondary"
|
|
189
|
+
/>
|
|
190
|
+
</View>
|
|
191
|
+
) : null}
|
|
192
|
+
</OnChainActionCard>
|
|
193
|
+
);
|
|
194
|
+
}
|