2.3 KiB
2.3 KiB
Typing Preview - Summary
Muc tieu da thuc hien
- Tach logic
typingPreviewra class rieng de de tai su dung. - Lien ket lai logic giua
ChatInputHandlervaTypingPreviewController. - Dieu chinh co che hien/an theo yeu cau mobile keyboard.
Cac file da cap nhat
Assets/Scripts/TypingPreviewController.csAssets/Scripts/ChatInputHandler.cs
Noi dung da lam
1) Tach typing preview thanh class rieng
- Tao class
TypingPreviewControllerde quan ly:- Hien/an preview (
typingPreviewRoot) - Cap nhat text preview realtime (
typingPreviewText) - Dinh vi preview theo offset keyboard (
typingPreviewRect,previewVerticalOffset)
- Hien/an preview (
2) Lien ket voi ChatInputHandler
ChatInputHandlergiuSerializeField:TypingPreviewController typingPreview
- Moi khi input thay doi text,
ChatInputHandlerlay message body (bo prefix kenh/whisper) roi day sang controller de cap nhat preview. - Khi clear input, preview duoc cap nhat lai ngay de an dung trang thai.
3) Co che mobile keyboard (cap nhat moi nhat)
- Da chuyen logic check keyboard vao thang
TypingPreviewController:IsMobileKeyboardVisible()GetVisibleKeyboardHeight()
ChatInputHandlerda bo cac ham keyboard-check khong con dung.ChatInputHandlerchi can goitypingPreview.UpdatePreview(isFocused, body).ChatInputHandler.Update()van refresh moi frame de bat kip luc keyboard mo/dong.- Rule hien moi nhat:
- Keyboard mobile vua mo la preview show ngay (neu input dang focus), khong can cho co ky tu.
Hanh vi hien tai
- Preview chi hien khi:
- Dang o mobile
- Keyboard dang mo
- Input dang focus
- Khong con yeu cau body phai khong rong (show ngay khi keyboard mo).
- Khi tat keyboard, preview an ngay.
- Khi mo lai keyboard, noi dung da go truoc do van con trong input va preview hien lai dung noi dung.
Emoji tren preview
- Hien tai preview duoc set text truc tiep tu
body, nen neubodyco TMP sprite tag thi co the hien emoji. - Luu y cau hinh component:
typingPreviewTextdang de kieuTMP_InputFieldtrongTypingPreviewController.- Neu muon on dinh cho muc dich "preview display", nen doi sang
TMP_TexthoacTextMeshProUGUI.
Ghi chu
- Da kiem tra lint sau cac lan sua, khong phat hien loi lint moi tren cac file da chinh.