@akita-protocol/algomd-rn 1.0.0-alpha.4 → 1.0.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akita-protocol/algomd-rn",
3
- "version": "1.0.0-alpha.4",
3
+ "version": "1.0.0-alpha.5",
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.4"
82
+ "@akita-protocol/algomd-core": "1.0.0-alpha.5"
83
83
  },
84
84
  "exports": {
85
85
  ".": "./src/index.ts",
@@ -9,6 +9,7 @@ import {
9
9
  EllipsisVerticalIcon,
10
10
  ArrowTopRightOnSquareIcon,
11
11
  Square2StackIcon,
12
+ OutlineDocumentTextIcon,
12
13
  } from "./icons";
13
14
  import * as Clipboard from "expo-clipboard";
14
15
  import * as Haptics from "expo-haptics";
@@ -60,6 +61,39 @@ const LABELS: Record<EntityType, string> = {
60
61
  tx: "Transaction",
61
62
  };
62
63
 
64
+ /** The AlgoMD tag Copy Embed copies and Quote starts a post with, or undefined when there is none. */
65
+ export function buildEmbed({
66
+ appId,
67
+ type = "application",
68
+ embedType,
69
+ embedProp,
70
+ embedValue,
71
+ }: Pick<ContractMenuProps, "appId" | "type" | "embedType" | "embedProp" | "embedValue">): string | undefined {
72
+ const componentName =
73
+ embedType ??
74
+ (type === "asset"
75
+ ? "ASA"
76
+ : type === "account"
77
+ ? "Account"
78
+ : type === "tx"
79
+ ? "Transaction"
80
+ : undefined);
81
+ if (!componentName) return undefined;
82
+
83
+ const idProp =
84
+ embedProp ??
85
+ (componentName === "NFDProfile"
86
+ ? "name"
87
+ : componentName === "DualStakePool"
88
+ ? "appId"
89
+ : type === "account"
90
+ ? "address"
91
+ : "id");
92
+ const value = embedValue ?? appId;
93
+ const compactProp = componentName === "Account" ? " compact" : "";
94
+ return `<${componentName} ${idProp}="${String(value)}"${compactProp} />`;
95
+ }
96
+
63
97
  export function ContractMenu({
64
98
  appId,
65
99
  type = "application",
@@ -94,40 +128,25 @@ export function ContractMenu({
94
128
  sheetRef.current?.dismiss();
95
129
  }, [appId]);
96
130
 
131
+ const embed = buildEmbed({ appId, type, embedType, embedProp, embedValue });
132
+
97
133
  const handleCopyEmbed = useCallback(() => {
98
- const componentName =
99
- embedType ??
100
- (type === "asset"
101
- ? "ASA"
102
- : type === "account"
103
- ? "Account"
104
- : type === "tx"
105
- ? "Transaction"
106
- : undefined);
107
- if (!componentName) return;
108
-
109
- const idProp =
110
- embedProp ??
111
- (componentName === "NFDProfile"
112
- ? "name"
113
- : componentName === "DualStakePool"
114
- ? "appId"
115
- : type === "account"
116
- ? "address"
117
- : "id");
118
- const value = embedValue ?? appId;
119
-
120
- const compactProp = componentName === "Account" ? " compact" : "";
121
- Clipboard.setStringAsync(
122
- `<${componentName} ${idProp}="${String(value)}"${compactProp} />`,
123
- );
134
+ if (!embed) return;
135
+ Clipboard.setStringAsync(embed);
124
136
  Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success);
125
137
  sheetRef.current?.dismiss();
126
- }, [appId, embedProp, embedType, embedValue, type]);
138
+ }, [embed]);
139
+
140
+ const { onQuoteEmbed } = presentation;
141
+ const handleQuote = useCallback(() => {
142
+ if (!embed || !onQuoteEmbed) return;
143
+ Haptics.selectionAsync();
144
+ sheetRef.current?.dismiss();
145
+ onQuoteEmbed(embed);
146
+ }, [embed, onQuoteEmbed]);
127
147
 
128
148
  const label = LABELS[type];
129
- const canCopyEmbed =
130
- !!embedType || type === "asset" || type === "account" || type === "tx";
149
+ const canCopyEmbed = !!embed;
131
150
 
132
151
  return (
133
152
  <>
@@ -234,6 +253,26 @@ export function ContractMenu({
234
253
  </View>
235
254
  </SquishyPressable>
236
255
  )}
256
+
257
+ {canCopyEmbed && onQuoteEmbed && (
258
+ <SquishyPressable onPress={handleQuote} pressedScale={0.98}>
259
+ <View
260
+ style={{
261
+ flexDirection: "row",
262
+ alignItems: "center",
263
+ gap: 12,
264
+ paddingVertical: 14,
265
+ paddingHorizontal: 8,
266
+ borderRadius: 12,
267
+ }}
268
+ >
269
+ <OutlineDocumentTextIcon size={18} color={theme.colors.text} />
270
+ <Text size="sm" weight="medium">
271
+ Quote
272
+ </Text>
273
+ </View>
274
+ </SquishyPressable>
275
+ )}
237
276
  </BottomSheetView>
238
277
  </AppPresentationProvider>
239
278
  </PortalProvider>
@@ -109,6 +109,11 @@ export interface AppPresentation {
109
109
  */
110
110
  applicationIcon?: (appId: string) => { Icon: React.ComponentType<{ size?: number; color?: string }>; color?: string } | undefined;
111
111
  onOpenNfd?: (name: string) => void;
112
+ /**
113
+ * Starts a new post that quotes an embed (e.g. `<ASA id="31566704" />`). Menus that offer
114
+ * Copy Embed also offer Quote when the host provides this.
115
+ */
116
+ onQuoteEmbed?: (embed: string) => void;
112
117
  onOpenCollection?: (id: string) => void;
113
118
  onOpenTransaction?: (txId: string) => void;
114
119
  /** Opens a contract reference (listing, auction, raffle, poll) in the host. */