update logic check height typingPreview
This commit is contained in:
@@ -2044,10 +2044,10 @@ RectTransform:
|
||||
- {fileID: 2130739312226787242}
|
||||
m_Father: {fileID: 806170753671297629}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0.5}
|
||||
m_AnchorMax: {x: 1, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 100}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: -100}
|
||||
m_SizeDelta: {x: 0, y: 450.9249}
|
||||
m_Pivot: {x: 0.5, y: 1}
|
||||
--- !u!222 &1622721548801034628
|
||||
CanvasRenderer:
|
||||
|
||||
@@ -997,30 +997,13 @@ namespace BrewMonster.Scripts.ChatUI
|
||||
inputField.ActivateInputField();
|
||||
}
|
||||
|
||||
float GetVisibleKeyboardHeight()
|
||||
{
|
||||
if (!TouchScreenKeyboard.visible)
|
||||
return 0f;
|
||||
|
||||
Rect area = TouchScreenKeyboard.area;
|
||||
return area.height > 0f ? area.height : 0f;
|
||||
}
|
||||
|
||||
void UpdateTypingPreviewFromInput()
|
||||
{
|
||||
if (inputField == null)
|
||||
return;
|
||||
|
||||
string body = ExtractMessageBodyFromVisual(inputField.text ?? "");
|
||||
typingPreview?.UpdatePreview(inputField.isFocused, body, CanShowTypingPreviewNow());
|
||||
}
|
||||
|
||||
bool CanShowTypingPreviewNow()
|
||||
{
|
||||
if (!Application.isMobilePlatform)
|
||||
return false;
|
||||
|
||||
return TouchScreenKeyboard.visible;
|
||||
typingPreview?.UpdatePreview(inputField.isFocused, body);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -44,16 +44,33 @@ namespace BrewMonster.Scripts.ChatUI
|
||||
typingPreviewRect.anchoredPosition = previewPos;
|
||||
}
|
||||
|
||||
public void UpdatePreview(bool isInputFocused, string body, bool canShowPreview)
|
||||
public void UpdatePreview(bool isInputFocused, string body)
|
||||
{
|
||||
if (typingPreviewRoot == null || typingPreviewText == null)
|
||||
return;
|
||||
|
||||
string trimmedBody = (body ?? string.Empty).Trim();
|
||||
bool shouldShow = canShowPreview && isInputFocused && !string.IsNullOrEmpty(trimmedBody);
|
||||
bool keyboardVisible = IsMobileKeyboardVisible();
|
||||
bool shouldShow = keyboardVisible && isInputFocused && !string.IsNullOrEmpty(trimmedBody);
|
||||
typingPreviewRoot.SetActive(shouldShow);
|
||||
if (shouldShow)
|
||||
typingPreviewText.text = trimmedBody;
|
||||
}
|
||||
|
||||
bool IsMobileKeyboardVisible()
|
||||
{
|
||||
if (!Application.isMobilePlatform)
|
||||
return false;
|
||||
return GetVisibleKeyboardHeight() > 0f || TouchScreenKeyboard.visible;
|
||||
}
|
||||
|
||||
float GetVisibleKeyboardHeight()
|
||||
{
|
||||
if (!TouchScreenKeyboard.visible)
|
||||
return 0f;
|
||||
|
||||
Rect area = TouchScreenKeyboard.area;
|
||||
return area.height > 0f ? area.height : 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user