@vvedantb/native-ui 0.25.1 → 0.25.2
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/dist/ai/conversation-context.js +27 -0
- package/dist/ai/conversation.jsx +62 -52
- package/dist/ai/message-context-menu.jsx +414 -329
- package/dist/ai/message.jsx +92 -74
- package/dist/primitives/keyboard-controller.jsx +32 -26
- package/package.json +1 -1
- package/src/ai/conversation-context.ts +56 -0
- package/src/ai/conversation.tsx +12 -42
- package/src/ai/message-context-menu.tsx +76 -32
- package/src/ai/message.tsx +10 -1
- package/src/primitives/keyboard-controller.tsx +3 -0
- package/src/primitives/keyboard-parts.tsx +3 -1
package/src/ai/message.tsx
CHANGED
|
@@ -20,6 +20,7 @@ import { useScheme } from "../useScheme";
|
|
|
20
20
|
import { META_TEXT_STYLE, chatTextSize } from "./chat-text";
|
|
21
21
|
import { ChatIconButton, type ChatIconButtonSize } from "./icon-button";
|
|
22
22
|
import { MESSAGE_ACTIONS_TITLE, MessageActionSheet, type MessageSheetAction } from "./message-action-sheet";
|
|
23
|
+
import { useOptionalConversation } from "./conversation-context";
|
|
23
24
|
import { MessageContextMenu } from "./message-context-menu";
|
|
24
25
|
import type { MessageMenu, MessageMenuRect } from "./message-menu-layout";
|
|
25
26
|
import { ChatTextColorContext, ResponseText } from "./response-text";
|
|
@@ -144,15 +145,22 @@ export function Message({
|
|
|
144
145
|
const pressable = useRef<View>(null);
|
|
145
146
|
const hasActions = actions != null && actions.length > 0;
|
|
146
147
|
const longPressable = onLongPress != null || hasActions || menu != null;
|
|
148
|
+
// In a thread, the menu freezes the list's keyboard handling until its close settles (see `overlay`).
|
|
149
|
+
const conversation = useOptionalConversation();
|
|
147
150
|
const longPress = () => {
|
|
148
151
|
// A medium tap on a hold, as iMessage; the sheet adds its own selection tick.
|
|
149
152
|
impactHaptic("medium");
|
|
150
153
|
onLongPress?.();
|
|
151
154
|
if (menu) {
|
|
152
155
|
const built = menu();
|
|
156
|
+
conversation?.openOverlay();
|
|
153
157
|
pressable.current?.measureInWindow((x, y, width, height) => setHeld({ anchor: { x, y, width, height }, menu: built }));
|
|
154
158
|
} else if (hasActions) setSheetOpen(true);
|
|
155
159
|
};
|
|
160
|
+
const closeMenu = () => {
|
|
161
|
+
setHeld(null);
|
|
162
|
+
conversation?.closeOverlay();
|
|
163
|
+
};
|
|
156
164
|
const layout: ViewProps["style"] = [
|
|
157
165
|
{ alignSelf: user ? "flex-end" : "flex-start", alignItems: user ? "flex-end" : "stretch" },
|
|
158
166
|
style,
|
|
@@ -192,7 +200,8 @@ export function Message({
|
|
|
192
200
|
{menu ? (
|
|
193
201
|
<MessageContextMenu
|
|
194
202
|
open={held !== null}
|
|
195
|
-
onClose={
|
|
203
|
+
onClose={closeMenu}
|
|
204
|
+
onDismissed={conversation?.settleOverlay}
|
|
196
205
|
anchor={held?.anchor ?? null}
|
|
197
206
|
align={user ? "end" : "start"}
|
|
198
207
|
preview={
|
|
@@ -43,6 +43,7 @@ function StickyView({ bottomOffset, ...props }: ComponentProps<KeyboardParts["St
|
|
|
43
43
|
function ChatScrollView({
|
|
44
44
|
bottomOffset,
|
|
45
45
|
inverted = false,
|
|
46
|
+
freeze = false,
|
|
46
47
|
onInsetChange,
|
|
47
48
|
onKeyboardMove,
|
|
48
49
|
...props
|
|
@@ -64,6 +65,8 @@ function ChatScrollView({
|
|
|
64
65
|
<KeyboardChatScrollView
|
|
65
66
|
{...props}
|
|
66
67
|
inverted={inverted}
|
|
68
|
+
// An overlay window (a hold menu) takes the focus on Android: its keyboard events must not scroll the list.
|
|
69
|
+
freeze={freeze}
|
|
67
70
|
offset={bottomOffset}
|
|
68
71
|
keyboardLiftBehavior="always"
|
|
69
72
|
onContentInsetChange={(insets) =>
|
|
@@ -31,12 +31,14 @@ export type KeyboardParts = {
|
|
|
31
31
|
* gets that extra space as the scroll offset sees it, which `onScroll` does
|
|
32
32
|
* not report: past the content's end, or when `inverted` before offset 0.
|
|
33
33
|
* `onKeyboardMove` is true from the start to the end of each keyboard
|
|
34
|
-
* move, while the keyboard, not the reader, scrolls the list.
|
|
34
|
+
* move, while the keyboard, not the reader, scrolls the list. With
|
|
35
|
+
* `freeze`, keyboard events change nothing (an overlay window is open).
|
|
35
36
|
*/
|
|
36
37
|
ChatScrollView: ComponentType<
|
|
37
38
|
ScrollViewProps & {
|
|
38
39
|
bottomOffset: number;
|
|
39
40
|
inverted?: boolean;
|
|
41
|
+
freeze?: boolean;
|
|
40
42
|
onInsetChange: (inset: number) => void;
|
|
41
43
|
onKeyboardMove: (moving: boolean) => void;
|
|
42
44
|
}
|