Skip to content

Commit

Permalink
Adapt to Flutter 3.16 API changes (#176)
Browse files Browse the repository at this point in the history
* Adapt to Flutter API changes

* Fix tests

* Disable lookup, search and share

* Format

* Suppress linter for textScaleFactor usages

* Upgrade action flutter version

* Remove use of deprecated member textScaleFactor

---------

Co-authored-by: Amir Panahandeh <[email protected]>
  • Loading branch information
amantoux and Amir-P authored Dec 1, 2023
1 parent cd88559 commit 5bac76d
Show file tree
Hide file tree
Showing 12 changed files with 282 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/fleather.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: "3.13.0"
flutter-version: "3.16.0"
cache: true
# Manually Update this `key`
cache-key: "20230512"
Expand Down
4 changes: 2 additions & 2 deletions packages/fleather/example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
url_launcher_ios: fb12c43172927bb5cf75aeebd073f883801f1993
url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4

PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3

COCOAPODS: 1.11.3
COCOAPODS: 1.14.2
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down Expand Up @@ -213,6 +213,7 @@
files = (
);
inputPaths = (
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
name = "Thin Binary";
outputPaths = (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
10 changes: 5 additions & 5 deletions packages/fleather/lib/src/rendering/paragraph_proxy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class RenderParagraphProxy extends RenderProxyBox
implements RenderContentProxyBox {
RenderParagraphProxy({
required TextStyle textStyle,
required double textScaleFactor,
required TextScaler textScaler,
required TextWidthBasis textWidthBasis,
RenderParagraph? child,
TextDirection? textDirection,
Expand All @@ -21,7 +21,7 @@ class RenderParagraphProxy extends RenderProxyBox
text: TextSpan(text: ' ', style: textStyle),
textAlign: TextAlign.left,
textDirection: textDirection,
textScaleFactor: textScaleFactor,
textScaler: textScaler,
strutStyle: strutStyle,
locale: locale,
textWidthBasis: textWidthBasis,
Expand All @@ -48,9 +48,9 @@ class RenderParagraphProxy extends RenderProxyBox
markNeedsLayout();
}

set textScaleFactor(double value) {
if (_prototypePainter.textScaleFactor == value) return;
_prototypePainter.textScaleFactor = value;
set textScaler(TextScaler value) {
if (_prototypePainter.textScaler == value) return;
_prototypePainter.textScaler = value;
markNeedsLayout();
}

Expand Down
12 changes: 12 additions & 0 deletions packages/fleather/lib/src/widgets/editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,15 @@ class RawEditor extends StatefulWidget {
///
abstract class EditorState extends State<RawEditor>
implements TextSelectionDelegate {
@override
bool lookUpEnabled = false;

@override
bool shareEnabled = false;

@override
bool searchWebEnabled = false;

ClipboardStatusNotifier? get clipboardStatus;

ScrollController get scrollController;
Expand Down Expand Up @@ -1637,6 +1646,9 @@ class RawEditorState extends EditorState
onSelectAll: selectAllEnabled
? () => selectAll(SelectionChangedCause.toolbar)
: null,
onLookUp: null,
onSearchWeb: null,
onShare: null,
onLiveTextInput: null);
}

Expand Down
8 changes: 4 additions & 4 deletions packages/fleather/lib/src/widgets/rich_text_proxy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ class RichTextProxy extends SingleChildRenderObjectWidget {
required this.locale,
required this.strutStyle,
required this.textAlign,
this.textScaleFactor = 1.0,
this.textScaler = TextScaler.noScaling,
this.textWidthBasis = TextWidthBasis.parent,
this.textHeightBehavior,
}) : super(key: key, child: child);

final TextStyle textStyle;
final TextAlign textAlign;
final double textScaleFactor;
final TextScaler textScaler;
final Locale? locale;
final StrutStyle strutStyle;
final TextWidthBasis textWidthBasis;
Expand All @@ -29,7 +29,7 @@ class RichTextProxy extends SingleChildRenderObjectWidget {
return RenderParagraphProxy(
textStyle: textStyle,
textDirection: Directionality.of(context),
textScaleFactor: textScaleFactor,
textScaler: textScaler,
locale: locale,
strutStyle: strutStyle,
textWidthBasis: textWidthBasis,
Expand All @@ -43,7 +43,7 @@ class RichTextProxy extends SingleChildRenderObjectWidget {
renderObject.textStyle = textStyle;
renderObject.textDirection = Directionality.of(context);
renderObject.textAlign = textAlign;
renderObject.textScaleFactor = textScaleFactor;
renderObject.textScaler = textScaler;
renderObject.locale = locale;
renderObject.strutStyle = strutStyle;
renderObject.textWidthBasis = textWidthBasis;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,8 @@ class _RenderSingleChildViewport extends RenderBox

@override
RevealedOffset getOffsetToReveal(RenderObject target, double alignment,
{Rect? rect}) {
{Rect? rect, Axis? axis}) {
// axis is ignored as we only support SingleDimensionViewport
rect ??= target.paintBounds;
if (target is! RenderBox) {
return RevealedOffset(offset: offset.pixels, rect: rect);
Expand Down
2 changes: 1 addition & 1 deletion packages/fleather/lib/src/widgets/text_line.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class _TextLineState extends State<TextLine> {
text: text,
textAlign: textAlign,
strutStyle: strutStyle,
textScaleFactor: MediaQuery.textScaleFactorOf(context),
textScaler: MediaQuery.textScalerOf(context),
),
);
}
Expand Down
6 changes: 3 additions & 3 deletions packages/fleather/test/rendering/editable_text_line_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void main() {
inlineCodeTheme: InlineCodeThemeData(style: const TextStyle()));
renderBox.body = RenderParagraphProxy(
textStyle: const TextStyle(),
textScaleFactor: 1,
textScaler: TextScaler.noScaling,
child: RenderParagraph(
const TextSpan(
text: 'A text with that will be broken into multiple lines'),
Expand Down Expand Up @@ -82,7 +82,7 @@ void main() {
renderBox.body = RenderParagraphProxy(
child: renderParagraph,
textStyle: const TextStyle(),
textScaleFactor: 1,
textScaler: TextScaler.noScaling,
textDirection: TextDirection.ltr,
textWidthBasis: TextWidthBasis.parent);
layout(renderBox);
Expand Down Expand Up @@ -118,7 +118,7 @@ void main() {
renderBox.body = RenderParagraphProxy(
child: renderParagraph,
textStyle: const TextStyle(),
textScaleFactor: 1,
textScaler: TextScaler.noScaling,
textDirection: TextDirection.ltr,
textWidthBasis: TextWidthBasis.parent);
layout(renderBox);
Expand Down
Loading

0 comments on commit 5bac76d

Please sign in to comment.