Skip to content

Commit ee2893e

Browse files
committed
Add TextOverflowPosition.auto and SearchHighlightDemo; Improve the algorithm efficiency of [findNoOverflow]
1 parent 2c462c9 commit ee2893e

28 files changed

+1135
-727
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 14.2.0
2+
3+
* Add TextOverflowPosition.auto and SearchHighlightDemo
4+
* Improve the algorithm efficiency of [findNoOverflow]
5+
16
## 14.1.0
27

38
* Support gradient text

README-ZH.md

Lines changed: 28 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
- [Flutter RichText 支持自定义文本溢出效果](https://juejin.im/post/5c8ca608f265da2dd6394001)
1313
- [Flutter RichText 支持自定义文字背景](https://juejin.im/post/5c8bf9516fb9a049c9669204)
1414
- [Flutter RichText 支持特殊文字效果](https://juejin.im/post/5c8bf4fce51d451066008fa2)
15-
- [Flutter RichText支持文本选择](https://juejin.im/post/5cff71d46fb9a07ea6486a0e)
15+
- [Flutter RichText 支持文本选择](https://juejin.im/post/5cff71d46fb9a07ea6486a0e)
16+
- [Flutter Text: 扶我起来](https://juejin.cn/post/6955095562215489573)
17+
- [Flutter 我就要五彩斑斓渐进的黑](https://juejin.cn/post/7411799494415728674)
1618

1719

1820
ExtendedText 是 Flutter 官方 Text 的三方扩展库,主要扩展功能如下:
@@ -26,25 +28,29 @@ ExtendedText 是 Flutter 官方 Text 的三方扩展库,主要扩展功能如
2628
2729
```yaml
2830
dependencies:
29-
extended_text: 10.0.1-ohos
31+
extended_text: 10.0.1-ohos // 3.7.12
32+
extended_text: 13.0.2 // 3.22.0
3033
```
3134
3235
## 目录
33-
- [extended_text](#extendedtext)
34-
- [目录](#%e7%9b%ae%e5%bd%95)
35-
- [特殊文本](#%e7%89%b9%e6%ae%8a%e6%96%87%e6%9c%ac)
36-
- [创建特殊文本](#%e5%88%9b%e5%bb%ba%e7%89%b9%e6%ae%8a%e6%96%87%e6%9c%ac)
37-
- [特殊文本Builder](#%e7%89%b9%e6%ae%8a%e6%96%87%e6%9c%acbuilder)
38-
- [图片](#%e5%9b%be%e7%89%87)
36+
37+
- [extended\_text](#extended_text)
38+
- [目录](#目录)
39+
- [特殊文本](#特殊文本)
40+
- [创建特殊文本](#创建特殊文本)
41+
- [特殊文本Builder](#特殊文本builder)
42+
- [图片](#图片)
3943
- [ImageSpan](#imagespan)
40-
- [缓存图片](#%e7%bc%93%e5%ad%98%e5%9b%be%e7%89%87)
41-
- [文本选择](#%e6%96%87%e6%9c%ac%e9%80%89%e6%8b%a9)
42-
- [文本选择控制器](#%e6%96%87%e6%9c%ac%e9%80%89%e6%8b%a9%e6%8e%a7%e5%88%b6%e5%99%a8)
43-
- [工具栏和选择器的控制](#%e5%b7%a5%e5%85%b7%e6%a0%8f%e5%92%8c%e9%80%89%e6%8b%a9%e5%99%a8%e7%9a%84%e6%8e%a7%e5%88%b6)
44-
- [默认行为](#%e9%bb%98%e8%ae%a4%e8%a1%8c%e4%b8%ba)
45-
- [自定义行为](#%e8%87%aa%e5%ae%9a%e4%b9%89%e8%a1%8c%e4%b8%ba)
46-
- [自定义背景](#%e8%87%aa%e5%ae%9a%e4%b9%89%e8%83%8c%e6%99%af)
47-
- [自定义文本溢出](#%e8%87%aa%e5%ae%9a%e4%b9%89%e6%96%87%e6%9c%ac%e6%ba%a2%e5%87%ba)
44+
- [文本选择](#文本选择)
45+
- [文本选择控制器](#文本选择控制器)
46+
- [自定义背景](#自定义背景)
47+
- [自定义文本溢出](#自定义文本溢出)
48+
- [Join Zero-Width Space](#join-zero-width-space)
49+
- [Gradient](#gradient)
50+
- [GradientConfig](#gradientconfig)
51+
- [IgnoreGradientSpan](#ignoregradientspan)
52+
- [☕️Buy me a coffee](#️buy-me-a-coffee)
53+
4854
4955
## 特殊文本
5056
@@ -216,14 +222,7 @@ ImageSpan(AssetImage("xxx.jpg"),
216222

217223
## 文本选择
218224

219-
![](https://github.com/fluttercandies/Flutter_Candies/blob/master/gif/extended_text/selection.gif)
220-
221-
| 参数 | 描述 | 默认 |
222-
| --------------------- | ---------------------------------------------------- | ---------------------------------------------------------------------------- |
223-
| selectionEnabled | 是否开启文本选择功能 | false |
224-
| selectionColor | 文本选择的颜色 | Theme.of(context).textSelectionColor |
225-
| dragStartBehavior | 文本选择的拖拽行为 | DragStartBehavior.start |
226-
| textSelectionControls | 文本选择控制器,你可以通过重写,来定义工具栏和选择器 | extendedMaterialTextSelectionControls/extendedCupertinoTextSelectionControls |
225+
现在它和 `SelectionArea` 一起工作。
227226

228227
### 文本选择控制器
229228

@@ -424,56 +423,7 @@ class CommonSelectionArea extends StatelessWidget {
424423
}
425424
```
426425

427-
### 工具栏和选择器的控制
428-
429-
你可以通过将你的页面包裹到ExtendedTextSelectionPointerHandler里面来定义不同的行为效果。
430-
431-
#### 默认行为
432-
433-
通过赋值ExtendedTextSelectionPointerHandler的child为你的页面,将会有默认的行为
434-
435-
```dart
436-
return ExtendedTextSelectionPointerHandler(
437-
//default behavior
438-
child: result,
439-
);
440-
```
441-
442-
- 当点击extended_text之外的区域的时候,关闭工具栏和选择器
443-
- 滚动的时候,关闭工具栏和选择器
444-
445-
#### 自定义行为
446-
447-
你可以通过builder方法获取到页面上面的全部的selectionStates(ExtendedTextSelectionState),并且通过自己获取点击事件来处理工具栏和选择器
448-
449-
```dart
450-
return ExtendedTextSelectionPointerHandler(
451-
//default behavior
452-
// child: result,
453-
//custom your behavior
454-
builder: (states) {
455-
return Listener(
456-
child: result,
457-
behavior: HitTestBehavior.translucent,
458-
onPointerDown: (value) {
459-
for (var state in states) {
460-
if (!state.containsPosition(value.position)) {
461-
//clear other selection
462-
state.clearSelection();
463-
}
464-
}
465-
},
466-
onPointerMove: (value) {
467-
//clear other selection
468-
for (var state in states) {
469-
state.clearSelection();
470-
}
471-
},
472-
);
473-
},
474-
);
475-
```
476-
426+
477427
## 自定义背景
478428

479429
![](https://github.com/fluttercandies/Flutter_Candies/blob/master/gif/extended_text/background.png)
@@ -495,7 +445,9 @@ Text背景相关的issue[24335](https://github.com/flutter/flutter/issues/24335)
495445

496446
## 自定义文本溢出
497447

498-
![](https://github.com/fluttercandies/Flutter_Candies/blob/master/gif/extended_text/overflow.jpg)
448+
| ![](https://github.com/fluttercandies/Flutter_Candies/blob/master/gif/extended_text/overflow.jpg) | ![](https://github.com/HarmonyCandies/HarmonyCandies/blob/main/gif/extended_text/textOverflowPosition_auto.png) |
449+
| ------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
450+
| | |
499451

500452
文本溢出相关issue [26748](https://github.com/flutter/flutter/issues/26748)
501453

@@ -570,7 +522,7 @@ Text背景相关的issue[24335](https://github.com/flutter/flutter/issues/24335)
570522

571523
1. word 不再是 word,你将无法通过双击选择 word。
572524

573-
2. 文本被修改了, 如果 [ExtendedText.selectionEnabled] 为 true, 你需要重写 TextSelectionControls,将字符串还原。
525+
2. 文本被修改了, 你需要重写 TextSelectionControls,将字符串还原。
574526

575527
``` dart
576528

README.md

Lines changed: 14 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ ExtendedText is a third-party extension library for Flutter's official Text comp
2020
2121
```yaml
2222
dependencies:
23-
extended_text: 10.0.1-ohos
23+
extended_text: 10.0.1-ohos // 3.7.12
24+
extended_text: 13.0.2 // 3.22.0
2425
```
2526
2627
@@ -34,16 +35,14 @@ dependencies:
3435
- [ImageSpan](#imagespan)
3536
- [Selection](#selection)
3637
- [TextSelectionControls](#textselectioncontrols)
37-
- [Control ToolBar Handle](#control-toolbar-handle)
38-
- [Default Behavior](#default-behavior)
39-
- [Custom Behavior](#custom-behavior)
4038
- [Custom Background](#custom-background)
4139
- [Custom Overflow](#custom-overflow)
4240
- [Join Zero-Width Space](#join-zero-width-space)
4341
- [Gradient](#gradient)
4442
- [GradientConfig](#gradientconfig)
4543
- [IgnoreGradientSpan](#ignoregradientspan)
4644
45+
4746
## Speical Text
4847
4948
![](https://github.com/fluttercandies/Flutter_Candies/blob/master/gif/extended_text/special_text.jpg)
@@ -201,12 +200,8 @@ class ImageSpan extends ExtendedWidgetSpan {
201200

202201
![](https://github.com/fluttercandies/Flutter_Candies/blob/master/gif/extended_text/selection.gif)
203202

204-
| parameter | description | default |
205-
| --------------------- | -------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
206-
| selectionEnabled | Whether enable selection | false |
207-
| selectionColor | Color of selection | Theme.of(context).textSelectionColor |
208-
| dragStartBehavior | DragStartBehavior for text selection | DragStartBehavior.start |
209-
| textSelectionControls | An interface for building the selection UI, to be provided by the implementor of the toolbar widget or handle widget | extendedMaterialTextSelectionControls/extendedCupertinoTextSelectionControls |
203+
It works with `SelectionArea` now.
204+
210205

211206
### TextSelectionControls
212207

@@ -408,56 +403,6 @@ class CommonSelectionArea extends StatelessWidget {
408403
409404
```
410405

411-
### Control ToolBar Handle
412-
413-
contain your page into ExtendedTextSelectionPointerHandler, so you can control toolbar and handle.
414-
415-
#### Default Behavior
416-
417-
set your page as child of ExtendedTextSelectionPointerHandler
418-
419-
```dart
420-
return ExtendedTextSelectionPointerHandler(
421-
//default behavior
422-
child: result,
423-
);
424-
```
425-
426-
- tap region outside of extended text, hide toolbar and handle
427-
- scorll, hide toolbar and handle
428-
429-
#### Custom Behavior
430-
431-
get selectionStates(ExtendedTextSelectionState) by builder call back, and handle by your self.
432-
433-
```dart
434-
return ExtendedTextSelectionPointerHandler(
435-
//default behavior
436-
// child: result,
437-
//custom your behavior
438-
builder: (states) {
439-
return Listener(
440-
child: result,
441-
behavior: HitTestBehavior.translucent,
442-
onPointerDown: (value) {
443-
for (var state in states) {
444-
if (!state.containsPosition(value.position)) {
445-
//clear other selection
446-
state.clearSelection();
447-
}
448-
}
449-
},
450-
onPointerMove: (value) {
451-
//clear other selection
452-
for (var state in states) {
453-
state.clearSelection();
454-
}
455-
},
456-
);
457-
},
458-
);
459-
```
460-
461406
## Custom Background
462407

463408
![](https://github.com/fluttercandies/Flutter_Candies/blob/master/gif/extended_text/background.png)
@@ -480,7 +425,14 @@ refer to issues [24335](https://github.com/flutter/flutter/issues/24335)/[24337]
480425

481426
## Custom Overflow
482427

483-
![](https://github.com/fluttercandies/Flutter_Candies/blob/master/gif/extended_text/overflow.jpg)
428+
429+
430+
431+
432+
| ![](https://github.com/fluttercandies/Flutter_Candies/blob/master/gif/extended_text/overflow.jpg) | ![](https://github.com/HarmonyCandies/HarmonyCandies/blob/main/gif/extended_text/textOverflowPosition_auto.png) |
433+
| ------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
434+
| | |
435+
484436

485437
refer to issue [26748](https://github.com/flutter/flutter/issues/26748)
486438

@@ -557,7 +509,7 @@ Take care of following things:
557509

558510
1. the word is not a word, it will not working when you want to double tap to select a word.
559511

560-
2. text is changed, if [ExtendedText.selectionEnabled] is true, you should override TextSelectionControls and remove zeroWidthSpace.
512+
2. text is changed, you should override TextSelectionControls and remove zeroWidthSpace.
561513

562514
``` dart
563515

example/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,5 @@ build/
6969
!**/ios/**/default.pbxuser
7070
!**/ios/**/default.perspectivev3
7171
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
72-
.flutter-plugins-dependencies
72+
.flutter-plugins-dependencies
73+
assets.preview.dart

example/ios/Flutter/AppFrameworkInfo.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
<key>CFBundleVersion</key>
2222
<string>1.0</string>
2323
<key>MinimumOSVersion</key>
24-
<string>11.0</string>
24+
<string>12.0</string>
2525
</dict>
2626
</plist>

example/ios/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Uncomment this line to define a global platform for your project
2-
# platform :ios, '11.0'
2+
# platform :ios, '12.0'
33

44
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
55
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@
215215
97C146E61CF9000F007C117D /* Project object */ = {
216216
isa = PBXProject;
217217
attributes = {
218-
LastUpgradeCheck = 1300;
218+
LastUpgradeCheck = 1510;
219219
ORGANIZATIONNAME = "";
220220
TargetAttributes = {
221221
331C8080294A63A400263BE5 = {
@@ -452,7 +452,7 @@
452452
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
453453
GCC_WARN_UNUSED_FUNCTION = YES;
454454
GCC_WARN_UNUSED_VARIABLE = YES;
455-
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
455+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
456456
MTL_ENABLE_DEBUG_INFO = NO;
457457
SDKROOT = iphoneos;
458458
SUPPORTED_PLATFORMS = iphoneos;
@@ -579,7 +579,7 @@
579579
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
580580
GCC_WARN_UNUSED_FUNCTION = YES;
581581
GCC_WARN_UNUSED_VARIABLE = YES;
582-
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
582+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
583583
MTL_ENABLE_DEBUG_INFO = YES;
584584
ONLY_ACTIVE_ARCH = YES;
585585
SDKROOT = iphoneos;
@@ -628,7 +628,7 @@
628628
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
629629
GCC_WARN_UNUSED_FUNCTION = YES;
630630
GCC_WARN_UNUSED_VARIABLE = YES;
631-
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
631+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
632632
MTL_ENABLE_DEBUG_INFO = NO;
633633
SDKROOT = iphoneos;
634634
SUPPORTED_PLATFORMS = iphoneos;

example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1300"
3+
LastUpgradeVersion = "1510"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

example/ios/Runner/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import UIKit
22
import Flutter
33

4-
@UIApplicationMain
4+
@main
55
@objc class AppDelegate: FlutterAppDelegate {
66
override func application(
77
_ application: UIApplication,

example/lib/example_route.dart

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)