8000 ## 6.0.0 by zmtzawqlp · Pull Request #103 · fluttercandies/extended_text · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

## 6.0.0 #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
## 6.0.0

* Add [TextOverflowWidget.position] to support show overflow at start, middle or end.
https://github.com/flutter/flutter/issues/45336
* Add [ExtendedText.joinZeroWidthSpace] to make line breaking and overflow style better.
https://github.com/flutter/flutter/issues/18761
* Fix strutStyle not work.
* Breaking change: remove [TextOverflowWidget.fixedOffset]
* Breaking change: [SpecialText.getContent] is not include endflag now.(please check if you call getContent and your endflag length is more than 1)

## 5.0.5

* Fix issue that childIndex == children.length assert false in assembleSemanticsNode when use overflowWidget and text is not overflow.

## 5.0.4

* Fix issue that the overflowWidget is not layout #97

## 5.0.3

* Fix null-safety error #96
Expand All @@ -28,13 +38,13 @@

* Support keyboard copy on web/desktop
* Fix wrong position of caret

## 4.0.1

* Change handleSpecialText to hasSpecialInlineSpanBase(extended_text_library)
* Add hasPlaceholderSpan(extended_text_library)
* Fix wrong offset of WidgetSpan #86

## 4.0.0

* Merge from Flutter v1.20
Expand Down
116 changes: 93 additions & 23 deletions README-ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,33 +318,103 @@ Text背景相关的issue[24335](https://github.com/flutter/flutter/issues/24335)
| child | The widget of TextOverflow. | @required |
| maxHeight | Widget的最大高度,默认为 TextPaint计算出来的行高 preferredLineHeight. | preferredLineHeight |
| align | left,靠近最后裁剪文本;right,靠近文本的右下角 | right |
| fixedOffset | 调整Widget的位置 | - |
| position | 溢出文本出现的地方. | TextOverflowPosition.end |

```dart
ExtendedText(...
overFlowWidget:
TextOverflowWidget(
//maxHeight: double.infinity,
//align: TextOverflowAlign.right,
//fixedOffset: Offset.zero,
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const Text('\u2026 '),
RaisedButton(
child: const Text('more'),
onPressed: () {
launch(
'https://github.com/fluttercandies/extended_text');
},
)
],
),
),
...
)
ExtendedText(
overflowWidget: TextOverflowWidget(
position: TextOverflowPosition.end,
align: TextOverflowAlign.center,
// just for debug
debugOverflowRectColor: Colors.red.withOpacity(0.1),
child: Container(
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const Text('\u2026 '),
InkWell(
child: const Text(
'more',
),
onTap: () {
launch(
'https://github.com/fluttercandies/extended_text');
},
)
],
),
),
),
)
```

## Join Zero-Width Space

![](https://github.com/fluttercandies/Flutter_Candies/blob/master/gif/extended_text/JoinZeroWidthSpace.jpg)

相关问题 [18761](https://github.com/flutter/flutter/issues/18761)

如果[ExtendedText.joinZeroWidthSpace] 为 true, 将会添加'\u{200B}' 到文本中, 让换行或者文本溢出看起来更好。

```dart
ExtendedText(
joinZeroWidthSpace: true,
)
```

或者你也可以通过下面的方法自己转换

1. 文本

```dart
String input='abc'.joinChar();
```

2. InlineSpan

```dart
InlineSpan innerTextSpan;
innerTextSpan = joinChar(
innerTextSpan,
Accumulator(),
zeroWidthSpace,
);
```
注意以下问题:

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

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

``` dart

class MyTextSelectionControls extends TextSelectionControls {

@override
void handleCopy(TextSelectionDelegate delegate,
ClipboardStatusNotifier? clipboardStatus) {
final TextEditingValue value = delegate.textEditingValue;

String data = value.selection.textInside(value.text);
// remove zeroWidthSpace
data = data.replaceAll(zeroWidthSpace, '');

Clipboard.setData(ClipboardData(
text: value.selection.textInside(value.text),
));
clipboardStatus?.update();
delegate.textEditingValue = TextEditingValue(
text: value.text,
selection: TextSelection.collapsed(offset: value.selection.end),
);
delegate.bringIntoView(delegate.textEditingValue.selection.extent);
delegate.hideToolbar();
}
}

```


## ☕️Buy me a coffee

![img](http://zmtzawqlp.gitee.io/my_images/images/qrcode.png)
116 changes: 93 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Extended official text to build special text like inline image or @somebody quic
- [Custom Behavior](#custom-behavior)
- [Custom Background](#custom-background)
- [Custom Overflow](#custom-overflow)
- [Join Zero-Width Space](#join-zero-width-space)

## Speical Text

Expand Down Expand Up @@ -295,32 +296,101 @@ refer to issue [26748](https://github.com/flutter/flutter/issues/26748)
| child | The widget of TextOverflow. | @required |
| maxHeight | The maxHeight of [ F438 TextOverflowWidget], default is preferredLineHeight. | preferredLineHeight |
| align | The Align of [TextOverflowWidget], left/right. | right |
| fixedOffset | Fixed offset refer to the Text Overflow Rect and [child]. | - |
| position | The position which TextOverflowWidget should be shown. | TextOverflowPosition.end |

```dart
ExtendedText(...
overFlowWidget:
TextOverflowWidget(
//maxHeight: double.infinity,
//align: TextOverflowAlign.right,
//fixedOffset: Offset.zero,
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const Text('\u2026 '),
RaisedButton(
child: const Text('more'),
onPressed: () {
launch(
'https://github.com/fluttercandies/extended_text');
},
)
],
),
),
...
)
ExtendedText(
overflowWidget: TextOverflowWidget(
position: TextOverflowPosition.end,
align: TextOverflowAlign.center,
// just for debug
debugOverflowRectColor: Colors.red.withOpacity(0.1),
child: Container(
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const Text('\u2026 '),
InkWell(
child: const Text(
'more',
),
onTap: () {
launch(
'https://github.com/fluttercandies/extended_text');
},
)
],
),
),
),
)
```

## Join Zero-Width Space

![](https://github.com/fluttercandies/Flutter_Candies/blob/master/gif/extended_text/JoinZeroWidthSpace.jpg)

refer to issue [18761](https://github.com/flutter/flutter/issues/18761)

if [ExtendedText.joinZeroWidthSpace] is true, it will join '\u{200B}' into text, make line breaking and overflow style better.


```dart
ExtendedText(
joinZeroWidthSpace: true,
)
```

or you can convert by following method:

1. String

```dart
String input='abc'.joinChar();
```

2. InlineSpan

```dart
InlineSpan innerTextSpan;
innerTextSpan = joinChar(
innerTextSpan,
Accumulator(),
zeroWidthSpace,
);
```

Take care of following things:

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

2. text is changed, if [ExtendedText.selectionEnabled] is true, you should override TextSelectionControls and remove zeroWidthSpace.

``` dart

class MyTextSelectionControls extends TextSelectionControls {

@override
void handleCopy(TextSelectionDelegate delegate,
ClipboardStatusNotifier? clipboardStatus) {
final TextEditingValue value = delegate.textEditingValue;

String data = value.selection.textInside(value.text);
// remove zeroWidthSpace
data = data.replaceAll(zeroWidthSpace, '');

Clipboard.setData(ClipboardData(
text: value.selection.textInside(value.text),
));
clipboardStatus?.update();
delegate.textEditingValue = TextEditingValue(
text: value.text,
selection: TextSelection.collapsed(offset: value.selection.end),
);
delegate.bringIntoView(delegate.textEditingValue.selection.extent);
delegate.hideToolbar();
}
}

```

2 changes: 1 addition & 1 deletion example/.flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"url_launcher","path":"E:\\\\Flutter\\\\flutter_source\\\\stable\\\\.pub-cache\\\\hosted\\\\pub.flutter-io.cn\\\\url_launcher-5.3.0\\\\","dependencies":[]}],"android":[{"name":"url_launcher","path":"E:\\\\Flutter\\\\flutter_source\\\\stable\\\\.pub-cache\\\\hosted\\\\pub.flutter-io.cn\\\\url_launcher-5.3.0\\\\","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[{"name":"url_launcher_web","path":"E:\\\\Flutter\\\\flutter_source\\\\stable\\\\.pub-cache\\\\hosted\\\\pub.flutter-io.cn\\\\url_launcher_web-0.1.4+1\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"url_launcher","dependencies":["url_launcher_web"]},{"name":"url_launcher_web","dependencies":[]}],"date_created":"2021-03-07 12:35:22.683060","version":"2.0.0"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"url_launcher","path":"/Users/zmt/Documents/flutter/stable/.pub-cache/hosted/pub.flutter-io.cn/url_launcher-6.0.3/","dependencies":[]}],"android":[{"name":"url_launcher","path":"/Users/zmt/Documents/flutter/stable/.pub-cache/hosted/pub.flutter-io.cn/url_launcher-6.0.3/","dependencies":[]}],"macos":[{"name":"url_launcher_macos","path":"/Users/zmt/Documents/flutter/stable/.pub-cache/hosted/pub.flutter-io.cn/url_launcher_macos-2.0.0/","dependencies":[]}],"linux":[{"name":"url_launcher_linux","path":"/Users/zmt/Documents/flutter/stable/.pub-cache/hosted/pub.flutter-io.cn/url_launcher_linux-2.0.0/","dependencies":[]}],"windows":[{"name":"url_launcher_windows","path":"/Users/zmt/Documents/flutter/stable/.pub-cache/hosted/pub.flutter-io.cn/url_launcher_windows-2.0.0/","dependencies":[]}],"web":[{"name":"url_launcher_web","path":"/Users/zmt/Documents/flutter/stable/.pub-cache/hosted/pub.flutter-io.cn/url_launcher_web-2.0.0/","dependencies":[]}]},"dependencyGraph":[{"name":"url_launcher","dependencies":["url_launcher_linux","url_launcher_macos","url_launcher_windows","url_launcher_web"]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]},{"name":"url_launcher_windows","dependencies":[]}],"date_created":"2021-04-22 20:22:07.471258","version":"2.0.3"}
11 changes: 6 additions & 5 deletions example/lib/example_route.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions example/lib/example_routes.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions example/lib/pages/background_text_demo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ class BackgroundTextDemo extends StatelessWidget {
if (backgroundTextSpan.clipBorderRadius != null) {
canvas.save();
canvas.clipPath(Path()
..addRRect(backgroundTextSpan.clipBorderRadius!
..addRRect(backgroundTextSpan
.clipBorderRadius!
.resolve(painter.textDirection)
.toRRect(lastLineRect)));
}
Expand All @@ -184,7 +185,8 @@ class BackgroundTextDemo extends StatelessWidget {
if (backgroundTextSpan.clipBorderRadius != null) {
canvas.save();
canvas.clipPath(Path()
..addRRect(backgroundTextSpan.clipBorderRadius!
..addRRect(backgroundTextSpan
.clipBorderRadius!
.resolve(painter.textDirection)
.toRRect(fullLineRect)));
}
Expand Down
Loading
0