From 02b8c3eae63bb67cd3db9608714ad5672202ce81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?vail=20=E7=8E=8B=E5=86=9B=E5=B9=B3?= Date: Mon, 1 Aug 2022 15:12:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=BE=93=E5=85=A5=E6=A1=86?= =?UTF-8?q?=E6=94=AF=E6=8C=81iOS=E5=B9=B3=E5=8F=B0=E8=81=94=E6=83=B3?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: vail 王军平 --- .../core/components/camera/camera_element.cpp | 10 ++++++ .../text_field/flutter_render_text_field.cpp | 34 +++++++++++++++++-- .../text_field/flutter_render_text_field.h | 4 +++ 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/frameworks/core/components/camera/camera_element.cpp b/frameworks/core/components/camera/camera_element.cpp index 4f4d59d9da3..b2ffe8b4417 100644 --- a/frameworks/core/components/camera/camera_element.cpp +++ b/frameworks/core/components/camera/camera_element.cpp @@ -400,6 +400,11 @@ void CameraElement::UpdateCamera(const RefPtr &cameraComponent) if (texture_) { cameraComponent->SetTextureId(texture_->GetId()); cameraComponent->SetFit(ImageFit::CONTAIN); + +#if defined(IOS_PLATFORM) + cameraComponent->SetFit(ImageFit::COVER); +#endif + cameraComponent->SetSrcWidth(preViewWidth_); cameraComponent->SetSrcHeight(preViewHeight_); } @@ -451,6 +456,11 @@ void CameraElement::OnPreViewSizeChange(int32_t preViewWidth, int32_t preViewHei auto camera = AceType::MakeRefPtr(); camera->SetTextureId(texture_->GetId()); camera->SetFit(ImageFit::CONTAIN); + +#if defined(IOS_PLATFORM) + camera->SetFit(ImageFit::COVER); +#endif + camera->SetSrcWidth(preViewWidth); camera->SetSrcHeight(preViewHeight); preViewWidth_ = preViewWidth; diff --git a/frameworks/core/components/text_field/flutter_render_text_field.cpp b/frameworks/core/components/text_field/flutter_render_text_field.cpp index 52567ec6f5e..d9f179abc6c 100644 --- a/frameworks/core/components/text_field/flutter_render_text_field.cpp +++ b/frameworks/core/components/text_field/flutter_render_text_field.cpp @@ -261,16 +261,23 @@ void FlutterRenderTextField::PaintSelection(SkCanvas* canvas) const if (!IsSelectiveDevice()) { return; } - using namespace Constants; if (!paragraph_ || (canvas == nullptr)) { return; } + const auto& selection = GetEditingValue().selection; if (GetEditingValue().text.empty() || selection.GetStart() == selection.GetEnd()) { return; } - const auto& boxes = paragraph_->GetRectsForRange(selection.GetStart(), selection.GetEnd(), + + DrawSelection(selection.GetStart(), selection.GetEnd(), canvas); +} + +void FlutterRenderTextField::DrawSelection(unsigned start, unsigned end, SkCanvas* canvas) const +{ + using namespace Constants; + const auto& boxes = paragraph_->GetRectsForRange(start, end, txt::Paragraph::RectHeightStyle::kMax, txt::Paragraph::RectWidthStyle::kTight); if (boxes.empty()) { return; @@ -293,6 +300,26 @@ void FlutterRenderTextField::PaintSelection(SkCanvas* canvas) const canvas->restore(); } +#if defined(IOS_PLATFORM) +void FlutterRenderTextField::PaintCompose(SkCanvas* canvas) const +{ + if (SystemProperties::GetDeviceType() != DeviceType::PHONE) { + return; + } + + if (!paragraph_ || (canvas == nullptr)) { + return; + } + + const auto& compose = GetEditingValue().compose; + if (GetEditingValue().text.empty() || compose.GetStart() == compose.GetEnd()) { + return; + } + + DrawSelection(compose.GetStart(), compose.GetEnd(), canvas); +} +#endif + void FlutterRenderTextField::PaintTextAndPlaceholder(SkCanvas* canvas) const { // Offset for the painting area of text @@ -1384,6 +1411,9 @@ void FlutterRenderTextField::PaintTextField( canvas->clipRect(SkRect::MakeLTRB(innerRect_.Left(), innerRect_.Top(), innerRect_.Right(), innerRect_.Bottom()), SkClipOp::kIntersect); PaintSelection(canvas); +#if defined(IOS_PLATFORM) + PaintCompose(canvas); +#endif // Paint cursor. PaintCaret(*canvas, caretRect_); PaintTextAndPlaceholder(canvas); diff --git a/frameworks/core/components/text_field/flutter_render_text_field.h b/frameworks/core/components/text_field/flutter_render_text_field.h index 86dbfe8634e..aa95b29856b 100644 --- a/frameworks/core/components/text_field/flutter_render_text_field.h +++ b/frameworks/core/components/text_field/flutter_render_text_field.h @@ -115,6 +115,10 @@ private: void PaintSelectCaret(SkCanvas* canvas); void PaintIcon(const Offset& offset, RenderContext& context); void PaintSelection(SkCanvas* canvas) const; + void DrawSelection(unsigned start, unsigned end, SkCanvas* canvas) const; +#if defined(IOS_PLATFORM) + void PaintCompose(SkCanvas* canvas) const; +#endif void PaintTextAndPlaceholder(SkCanvas* canvas) const; void PaintErrorText(SkCanvas* canvas) const; void PaintCountText(SkCanvas* canvas) const; -- Gitee