@akita-protocol/algomd-rn 1.0.0-alpha.1 → 1.0.0-alpha.3
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 +2 -2
- package/src/index.ts +1 -1
- package/src/presentation/icons.tsx +108 -1
- package/src/presentation/pluginColors.ts +1 -0
- package/src/presentation/runtime.tsx +26 -0
- package/src/refs/AccountRef.tsx +24 -10
- package/src/refs/GuildActions.tsx +925 -0
- package/src/refs/GuildProposalRef.tsx +86 -59
- package/src/refs/index.tsx +1 -0
- package/src/refs/primitives.tsx +51 -19
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akita-protocol/algomd-rn",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.3",
|
|
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.
|
|
82
|
+
"@akita-protocol/algomd-core": "1.0.0-alpha.3"
|
|
83
83
|
},
|
|
84
84
|
"exports": {
|
|
85
85
|
".": "./src/index.ts",
|
package/src/index.ts
CHANGED
|
@@ -135,7 +135,7 @@ export {
|
|
|
135
135
|
|
|
136
136
|
export { AppPresentationProvider } from "./presentation/runtime";
|
|
137
137
|
export { AssetSubjectProvider } from "./presentation/subject";
|
|
138
|
-
export type { AppPresentation, AppIdentity } from "./presentation/runtime";
|
|
138
|
+
export type { AppPresentation, AppIdentity, GuildVoteBlock, GuildVoteChoice } from "./presentation/runtime";
|
|
139
139
|
|
|
140
140
|
export * from "./presentation";
|
|
141
141
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Heroicons (MIT); see HEROICONS-LICENSE.txt.
|
|
2
2
|
import React from "react";
|
|
3
|
-
import Svg, { Path, Text as SvgText } from "react-native-svg";
|
|
3
|
+
import Svg, { Circle, Path, Text as SvgText } from "react-native-svg";
|
|
4
4
|
export function ArrowsRightLeftIcon({
|
|
5
5
|
size = 20,
|
|
6
6
|
color,
|
|
@@ -1176,3 +1176,110 @@ export function StakingPoolIcon({
|
|
|
1176
1176
|
</Svg>
|
|
1177
1177
|
);
|
|
1178
1178
|
}
|
|
1179
|
+
export function HandThumbUpIcon({
|
|
1180
|
+
size = 20,
|
|
1181
|
+
color,
|
|
1182
|
+
}: {
|
|
1183
|
+
size?: number;
|
|
1184
|
+
color?: string;
|
|
1185
|
+
}) {
|
|
1186
|
+
return (
|
|
1187
|
+
<Svg width={size} height={size} viewBox="0 0 20 20" fill={color}>
|
|
1188
|
+
<Path
|
|
1189
|
+
{...{
|
|
1190
|
+
d: "M1 8.25a1.25 1.25 0 112.5 0v7.5a1.25 1.25 0 11-2.5 0v-7.5zM11 3V1.7c0-.268.14-.526.395-.607A2 2 0 0114 3c0 .995-.182 1.948-.514 2.826-.204.54.166 1.174.744 1.174h2.52c1.243 0 2.261 1.01 2.146 2.247a23.864 23.864 0 01-1.341 5.974C17.153 16.323 16.072 17 14.9 17h-3.192a3 3 0 01-1.341-.317l-2.734-1.366A3 3 0 006.292 15H5V8h.963c.685 0 1.258-.483 1.612-1.068a4.011 4.011 0 012.166-1.73c.432-.143.853-.386 1.011-.814.16-.432.248-.9.248-1.388z",
|
|
1191
|
+
}}
|
|
1192
|
+
/>
|
|
1193
|
+
</Svg>
|
|
1194
|
+
);
|
|
1195
|
+
}
|
|
1196
|
+
export function HandThumbDownIcon({
|
|
1197
|
+
size = 20,
|
|
1198
|
+
color,
|
|
1199
|
+
}: {
|
|
1200
|
+
size?: number;
|
|
1201
|
+
color?: string;
|
|
1202
|
+
}) {
|
|
1203
|
+
return (
|
|
1204
|
+
<Svg width={size} height={size} viewBox="0 0 20 20" fill={color}>
|
|
1205
|
+
<Path
|
|
1206
|
+
{...{
|
|
1207
|
+
d: "M18.905 12.75a1.25 1.25 0 01-2.5 0v-7.5a1.25 1.25 0 112.5 0v7.5zM8.905 17v1.3c0 .268-.14.526-.395.607A2 2 0 015.905 17c0-.995.182-1.948.514-2.826.204-.54-.166-1.174-.744-1.174h-2.52c-1.242 0-2.26-1.01-2.146-2.247.193-2.08.652-4.082 1.341-5.974C2.752 3.678 3.833 3 5.005 3h3.192a3 3 0 011.342.317l2.733 1.366A3 3 0 0013.613 5h1.292v7h-.963c-.684 0-1.258.482-1.612 1.068a4.012 4.012 0 01-2.165 1.73c-.433.143-.854.386-1.012.814-.16.432-.248.9-.248 1.388z",
|
|
1208
|
+
}}
|
|
1209
|
+
/>
|
|
1210
|
+
</Svg>
|
|
1211
|
+
);
|
|
1212
|
+
}
|
|
1213
|
+
export function PuzzlePieceIcon({
|
|
1214
|
+
size = 20,
|
|
1215
|
+
color,
|
|
1216
|
+
}: {
|
|
1217
|
+
size?: number;
|
|
1218
|
+
color?: string;
|
|
1219
|
+
}) {
|
|
1220
|
+
return (
|
|
1221
|
+
<Svg width={size} height={size} viewBox="0 0 20 20" fill={color}>
|
|
1222
|
+
<Path
|
|
1223
|
+
{...{
|
|
1224
|
+
d: "M12 4.467c0-.405.262-.75.559-1.027.276-.257.441-.584.441-.94 0-.828-.895-1.5-2-1.5s-2 .672-2 1.5c0 .362.171.694.456.953.29.265.544.6.544.994a.968.968 0 01-1.024.974 39.655 39.655 0 01-3.014-.306.75.75 0 00-.847.847c.14.993.242 1.999.306 3.014A.968.968 0 014.447 10c-.393 0-.729-.253-.994-.544C3.194 9.17 2.862 9 2.5 9 1.672 9 1 9.895 1 11s.672 2 1.5 2c.356 0 .683-.165.94-.441.276-.297.622-.559 1.027-.559a.997.997 0 011.004 1.03 39.747 39.747 0 01-.319 3.734.75.75 0 00.64.842c1.05.146 2.111.252 3.184.318A.97.97 0 0010 16.948c0-.394-.254-.73-.545-.995C9.171 15.693 9 15.362 9 15c0-.828.895-1.5 2-1.5s2 .672 2 1.5c0 .356-.165.683-.441.94-.297.276-.559.622-.559 1.027a.998.998 0 001.03 1.005c1.337-.05 2.659-.162 3.961-.337a.75.75 0 00.644-.644c.175-1.302.288-2.624.337-3.961A.998.998 0 0016.967 12c-.405 0-.75.262-1.027.559-.257.276-.584.441-.94.441-.828 0-1.5-.895-1.5-2s.672-2 1.5-2c.362 0 .694.17.953.455.265.291.601.545.995.545a.97.97 0 00.976-1.024 41.159 41.159 0 00-.318-3.184.75.75 0 00-.842-.64c-1.228.164-2.473.271-3.734.319A.997.997 0 0112 4.467z",
|
|
1225
|
+
}}
|
|
1226
|
+
/>
|
|
1227
|
+
</Svg>
|
|
1228
|
+
);
|
|
1229
|
+
}
|
|
1230
|
+
export function ExclamationTriangleIcon({
|
|
1231
|
+
size = 20,
|
|
1232
|
+
color,
|
|
1233
|
+
}: {
|
|
1234
|
+
size?: number;
|
|
1235
|
+
color?: string;
|
|
1236
|
+
}) {
|
|
1237
|
+
return (
|
|
1238
|
+
<Svg width={size} height={size} viewBox="0 0 20 20" fill={color}>
|
|
1239
|
+
<Path
|
|
1240
|
+
{...{
|
|
1241
|
+
fillRule: "evenodd",
|
|
1242
|
+
d: "M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495zM10 5a.75.75 0 01.75.75v3.5a.75.75 0 01-1.5 0v-3.5A.75.75 0 0110 5zm0 9a1 1 0 100-2 1 1 0 000 2z",
|
|
1243
|
+
clipRule: "evenodd",
|
|
1244
|
+
}}
|
|
1245
|
+
/>
|
|
1246
|
+
</Svg>
|
|
1247
|
+
);
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
/** The Algorand mark, for ALGO amounts (not a Heroicon). */
|
|
1251
|
+
export function AlgoMarkIcon({
|
|
1252
|
+
size = 20,
|
|
1253
|
+
color,
|
|
1254
|
+
}: {
|
|
1255
|
+
size?: number;
|
|
1256
|
+
color?: string;
|
|
1257
|
+
}) {
|
|
1258
|
+
return (
|
|
1259
|
+
<Svg width={size} height={size} viewBox="0 0 113 113.4" fill={color}>
|
|
1260
|
+
<Path d="M19.6 113.4L36 85 52.4 56.7 68.7 28.3 71.4 23.8 72.6 28.3 77.6 47 72 56.7 55.6 85 39.3 113.4 58.9 113.4 75.3 85 83.8 70.3 87.8 85 95.4 113.4 113 113.4 105.4 85 97.8 56.7 95.8 49.4 108 28.3 90.2 28.3 89.6 26.2 83.4 3 82.6 0 65.5 0 65.1 0.6 49.1 28.3 32.7 56.7 16.4 85 0 113.4 19.6 113.4Z" />
|
|
1261
|
+
</Svg>
|
|
1262
|
+
);
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
/** A Guild: its banner with the Akita sparkle. Same art as akita-rn assets/icons/plugins/Guild.svg. */
|
|
1266
|
+
export function GuildIcon({
|
|
1267
|
+
size = 20,
|
|
1268
|
+
color,
|
|
1269
|
+
}: {
|
|
1270
|
+
size?: number;
|
|
1271
|
+
color?: string;
|
|
1272
|
+
}) {
|
|
1273
|
+
return (
|
|
1274
|
+
<Svg width={size} height={size} viewBox="0 0 250 250" fill="none" strokeLinecap="round" strokeLinejoin="round">
|
|
1275
|
+
<Path d="M40 48H210" fill="none" stroke={color} strokeWidth={6.25} />
|
|
1276
|
+
<Circle cx={30} cy={48} r={7} fill="none" stroke={color} strokeWidth={6.25} />
|
|
1277
|
+
<Circle cx={220} cy={48} r={7} fill="none" stroke={color} strokeWidth={6.25} />
|
|
1278
|
+
<Circle cx={125} cy={22} r={8} fill="none" stroke={color} strokeWidth={6.25} />
|
|
1279
|
+
<Path d="M74 48L119 27M176 48L131 27" fill="none" stroke={color} strokeWidth={6.25} />
|
|
1280
|
+
<Path d="M60 70H190" fill="none" stroke={color} strokeWidth={6.25} />
|
|
1281
|
+
<Path d="M125 78Q131.8 111.2 157 118Q131.8 124.8 125 158Q118.2 124.8 93 118Q118.2 111.2 125 78Z" fill={color} stroke={color} strokeWidth={5.4} />
|
|
1282
|
+
<Path d="M60 48V216L125 180L190 216V48" fill="none" stroke={color} strokeWidth={6.25} />
|
|
1283
|
+
</Svg>
|
|
1284
|
+
);
|
|
1285
|
+
}
|
|
@@ -68,6 +68,11 @@ export interface IdentityBadgeProps {
|
|
|
68
68
|
size?: number;
|
|
69
69
|
}
|
|
70
70
|
export type GuildVoteChoice = "approve" | "reject" | "abstain";
|
|
71
|
+
/**
|
|
72
|
+
* Why the viewer has no vote on this proposal, e.g. "You have no vote in this
|
|
73
|
+
* guild.". A returned reason makes the card read-only for voting.
|
|
74
|
+
*/
|
|
75
|
+
export type GuildVoteBlock = (guildAppId: string, proposalId: string) => string | undefined;
|
|
71
76
|
|
|
72
77
|
export type PresentationTextProps = TextProps & {
|
|
73
78
|
size?: keyof typeof sizes;
|
|
@@ -98,6 +103,11 @@ export interface AppPresentation {
|
|
|
98
103
|
resolveImageUrl?: (src: string, width: number) => string;
|
|
99
104
|
/** A human name for an application id, e.g. a known plugin. */
|
|
100
105
|
applicationLabel?: (appId: string) => string | undefined;
|
|
106
|
+
/**
|
|
107
|
+
* The host's icon for an application id, e.g. a known plugin's icon from
|
|
108
|
+
* the app's plugin list, drawn in `color` when given.
|
|
109
|
+
*/
|
|
110
|
+
applicationIcon?: (appId: string) => { Icon: React.ComponentType<{ size?: number; color?: string }>; color?: string } | undefined;
|
|
101
111
|
onOpenNfd?: (name: string) => void;
|
|
102
112
|
onOpenCollection?: (id: string) => void;
|
|
103
113
|
onOpenTransaction?: (txId: string) => void;
|
|
@@ -124,12 +134,28 @@ export interface AppPresentation {
|
|
|
124
134
|
guildSubmit?: (guildAppId: string, proposalId: string) => void | Promise<void>;
|
|
125
135
|
guildFinalize?: (guildAppId: string, proposalId: string) => void | Promise<void>;
|
|
126
136
|
guildExecute?: (guildAppId: string, proposalId: string) => void | Promise<void>;
|
|
137
|
+
/**
|
|
138
|
+
* Withdraws an approved proposal that can't be applied (Guild `cancelProposal`).
|
|
139
|
+
* Offered to its creator once applying it is late or has failed.
|
|
140
|
+
*/
|
|
141
|
+
guildCancel?: (guildAppId: string, proposalId: string) => void | Promise<void>;
|
|
127
142
|
};
|
|
128
143
|
/**
|
|
129
144
|
* Why the viewer can't act on this Guild's proposals here, e.g. a chat that
|
|
130
145
|
* only acts for its own Guild. A returned note replaces the card's actions.
|
|
131
146
|
*/
|
|
132
147
|
guildActionBlock?: (guildAppId: string) => string | undefined;
|
|
148
|
+
/**
|
|
149
|
+
* Whether the viewer can vote on a proposal: the host knows membership and
|
|
150
|
+
* voting power. Without it the card offers votes to every viewer.
|
|
151
|
+
*/
|
|
152
|
+
guildVoteBlock?: GuildVoteBlock;
|
|
153
|
+
/**
|
|
154
|
+
* The host closes settled guild votes and carries out approved proposals in
|
|
155
|
+
* the background. Cards then say so, and offer `guildFinalize` and
|
|
156
|
+
* `guildExecute` only once the automation is late.
|
|
157
|
+
*/
|
|
158
|
+
guildAutomation?: boolean;
|
|
133
159
|
/**
|
|
134
160
|
* Renders private content, which needs the viewer's keys to unlock. Without
|
|
135
161
|
* it, a private-content reference shows its public metadata only.
|
package/src/refs/AccountRef.tsx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Pressable, View } from "react-native";
|
|
3
|
-
import { formatAlgo, shortAddress, type NfdData } from "@akita-protocol/algomd-core";
|
|
3
|
+
import { formatAlgo, shortAddress, type IdentityData, type NfdData } from "@akita-protocol/algomd-core";
|
|
4
4
|
import { useAccount, useEntity, useIdentity } from "@akita-protocol/algomd-core/react";
|
|
5
5
|
import { ContractMenu } from "../presentation/ContractMenu";
|
|
6
6
|
import { ChevronRightIcon } from "../presentation/icons";
|
|
7
|
-
import { Text, useAppTheme, usePresentation } from "../presentation/runtime";
|
|
7
|
+
import { formatNfdName, Text, useAppTheme, usePresentation, useProfileDisplayPreferences } from "../presentation/runtime";
|
|
8
8
|
import {
|
|
9
9
|
Avatar,
|
|
10
10
|
Card,
|
|
@@ -36,8 +36,9 @@ export function AccountRef({ id: address, size = "large", onPress, visible }: Re
|
|
|
36
36
|
const identity = useIdentity(address, { visible });
|
|
37
37
|
const id = identity.data?.data;
|
|
38
38
|
const press = onPress ?? (presentation.onOpenAccount ? () => presentation.onOpenAccount!(address) : undefined);
|
|
39
|
-
const name = id
|
|
39
|
+
const name = useAccountName(id, address);
|
|
40
40
|
const verified = id?.nameVerified ?? false;
|
|
41
|
+
const nfd = useNfdLabel(id?.nfd);
|
|
41
42
|
|
|
42
43
|
if (size === "inline") {
|
|
43
44
|
return (
|
|
@@ -57,7 +58,7 @@ export function AccountRef({ id: address, size = "large", onPress, visible }: Re
|
|
|
57
58
|
<Row
|
|
58
59
|
leading={<Avatar uri={id?.avatar} size={36} initial={name} />}
|
|
59
60
|
title={<Title verified={verified}>{name}</Title>}
|
|
60
|
-
subtitle={id?.name ? (
|
|
61
|
+
subtitle={id?.name ? (nfd && id.nameSource !== "nfd" ? `${nfd} · ${id.short}` : id.short) : undefined}
|
|
61
62
|
onPress={press}
|
|
62
63
|
accessibilityLabel={`Open ${name}`}
|
|
63
64
|
/>
|
|
@@ -78,7 +79,7 @@ function AccountCard({ address, full, visible }: { address: string; full: boolea
|
|
|
78
79
|
|
|
79
80
|
if (identity.isPending && account.isPending) return <CardSkeleton full={full} />;
|
|
80
81
|
|
|
81
|
-
const name = id
|
|
82
|
+
const name = useAccountName(id, address);
|
|
82
83
|
const sourceLabel =
|
|
83
84
|
id?.nameSource === "nfd" ? "NFD (verified)" : id?.nameSource && id.nameSource !== "address" ? "Profile (self-chosen)" : "None";
|
|
84
85
|
const nfdName = nfd.data?.data?.name;
|
|
@@ -122,13 +123,26 @@ function AccountCard({ address, full, visible }: { address: string; full: boolea
|
|
|
122
123
|
);
|
|
123
124
|
}
|
|
124
125
|
|
|
125
|
-
|
|
126
|
+
/** An NFD as the viewer's settings show it: with or without the `.algo` suffix. */
|
|
127
|
+
export function useNfdLabel(nfd: string | undefined): string | undefined {
|
|
128
|
+
const { showNfdSuffix } = useProfileDisplayPreferences();
|
|
129
|
+
return nfd ? formatNfdName(nfd, { showNfdSuffix }) : undefined;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** An account's display name, with an NFD name shown per the viewer's suffix setting. */
|
|
133
|
+
export function useAccountName(id: IdentityData | null | undefined, address: string): string {
|
|
134
|
+
const nfdName = useNfdLabel(id?.nameSource === "nfd" ? id.name : undefined);
|
|
135
|
+
return nfdName ?? id?.name ?? shortAddress(address);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function useHandle(address: string, visible?: boolean) {
|
|
126
139
|
const identity = useIdentity(address, { visible });
|
|
127
140
|
const id = identity.data?.data;
|
|
128
|
-
const name = id
|
|
141
|
+
const name = useAccountName(id, address);
|
|
129
142
|
const short = id?.short ?? shortAddress(address);
|
|
130
143
|
// An unnamed account shows its short address once.
|
|
131
|
-
const
|
|
144
|
+
const nfd = useNfdLabel(id?.nfd);
|
|
145
|
+
const handle = nfd && nfd !== name ? `@${nfd}` : short !== name ? short : undefined;
|
|
132
146
|
return { id, name, handle, pending: identity.isPending };
|
|
133
147
|
}
|
|
134
148
|
|
|
@@ -154,7 +168,7 @@ export function PersonRow({ address, role, roleTone, visible }: PersonRowProps)
|
|
|
154
168
|
<Inset style={{ flexDirection: "row", alignItems: "center", gap: 10, paddingVertical: 10, paddingHorizontal: 12 }}>
|
|
155
169
|
<Avatar uri={id?.avatar} size={36} initial={name} />
|
|
156
170
|
<View style={{ flex: 1, minWidth: 0, gap: 1 }}>
|
|
157
|
-
<View style={{ flexDirection: "row", alignItems: "center", gap:
|
|
171
|
+
<View style={{ flexDirection: "row", alignItems: "center", gap: 3 }}>
|
|
158
172
|
<Text size="xs" weight="semiBold" numberOfLines={1} style={{ flexShrink: 1 }}>
|
|
159
173
|
{name}
|
|
160
174
|
</Text>
|
|
@@ -195,7 +209,7 @@ export function CreatorIdentity({ address, label = "Creator", visible }: { addre
|
|
|
195
209
|
<View style={{ flexDirection: "row", alignItems: "center", gap: 10 }}>
|
|
196
210
|
<Avatar uri={id?.avatar} size={40} initial={name} />
|
|
197
211
|
<View style={{ flex: 1, minWidth: 0, gap: 1 }}>
|
|
198
|
-
<View style={{ flexDirection: "row", alignItems: "center", gap:
|
|
212
|
+
<View style={{ flexDirection: "row", alignItems: "center", gap: 3 }}>
|
|
199
213
|
<Text size="sm" weight="bold" numberOfLines={1} style={{ flexShrink: 1 }}>
|
|
200
214
|
{name}
|
|
201
215
|
</Text>
|