From f0e9f9ffea15a581d8d52c625f833782730e8785 Mon Sep 17 00:00:00 2001 From: Alexey Inkin Date: Tue, 25 Oct 2022 16:40:56 +0400 Subject: [PATCH 1/2] Use Akvelon editor (#23415) --- learning/tour-of-beam/frontend/pubspec.lock | 51 +++++++++++++--- learning/tour-of-beam/frontend/pubspec.yaml | 4 -- .../snippet_editing_controller.dart | 2 +- .../lib/src/theme/theme.dart | 4 +- .../lib/src/widgets/editor_textarea.dart | 28 +++++---- .../playground_components/pubspec.yaml | 5 +- playground/frontend/pubspec.lock | 60 +++++++++++++++---- 7 files changed, 111 insertions(+), 43 deletions(-) diff --git a/learning/tour-of-beam/frontend/pubspec.lock b/learning/tour-of-beam/frontend/pubspec.lock index f3d88fa9e0f3..9983b9bb5304 100644 --- a/learning/tour-of-beam/frontend/pubspec.lock +++ b/learning/tour-of-beam/frontend/pubspec.lock @@ -50,6 +50,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.9.0" + autotrie: + dependency: transitive + description: + name: autotrie + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" boolean_selector: dependency: transitive description: @@ -120,6 +127,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.1" + charcode: + dependency: transitive + description: + name: charcode + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.1" checked_yaml: dependency: transitive description: @@ -141,15 +155,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.2.0" - code_text_field: - dependency: "direct main" - description: - path: "." - ref: "9e2c9fe52a69481f038f4b6609e8a0a776429437" - resolved-ref: "9e2c9fe52a69481f038f4b6609e8a0a776429437" - url: "https://github.com/BertrandBev/code_field.git" - source: git - version: "1.0.3" collection: dependency: transitive description: @@ -267,6 +272,13 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_code_editor: + dependency: transitive + description: + name: flutter_code_editor + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.1" flutter_driver: dependency: transitive description: flutter @@ -390,6 +402,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.7.0" + hive: + dependency: transitive + description: + name: hive + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.3" http: dependency: "direct main" description: @@ -668,6 +687,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.27.5" + scrollable_positioned_list: + dependency: transitive + description: + name: scrollable_positioned_list + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.5" shared_preferences: dependency: "direct main" description: @@ -834,6 +860,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.17.4" + tuple: + dependency: transitive + description: + name: tuple + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" typed_data: dependency: transitive description: diff --git a/learning/tour-of-beam/frontend/pubspec.yaml b/learning/tour-of-beam/frontend/pubspec.yaml index da6c4c74ffa4..a6e829542e0c 100644 --- a/learning/tour-of-beam/frontend/pubspec.yaml +++ b/learning/tour-of-beam/frontend/pubspec.yaml @@ -28,10 +28,6 @@ environment: dependencies: app_state: ^0.8.1 - code_text_field: - git: - url: https://github.com/BertrandBev/code_field.git - ref: 9e2c9fe52a69481f038f4b6609e8a0a776429437 easy_localization: ^3.0.1 easy_localization_ext: ^0.1.0 easy_localization_loader: ^1.0.0 diff --git a/playground/frontend/playground_components/lib/src/controllers/snippet_editing_controller.dart b/playground/frontend/playground_components/lib/src/controllers/snippet_editing_controller.dart index 9e36eed809bf..1ff20ecfcd1b 100644 --- a/playground/frontend/playground_components/lib/src/controllers/snippet_editing_controller.dart +++ b/playground/frontend/playground_components/lib/src/controllers/snippet_editing_controller.dart @@ -16,8 +16,8 @@ * limitations under the License. */ -import 'package:code_text_field/code_text_field.dart'; import 'package:flutter/widgets.dart'; +import 'package:flutter_code_editor/flutter_code_editor.dart'; import '../enums/complexity.dart'; import '../models/example.dart'; diff --git a/playground/frontend/playground_components/lib/src/theme/theme.dart b/playground/frontend/playground_components/lib/src/theme/theme.dart index fed70dee36b2..14c811abe931 100644 --- a/playground/frontend/playground_components/lib/src/theme/theme.dart +++ b/playground/frontend/playground_components/lib/src/theme/theme.dart @@ -16,8 +16,8 @@ * limitations under the License. */ -import 'package:code_text_field/code_text_field.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_code_editor/flutter_code_editor.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; import 'package:google_fonts/google_fonts.dart'; @@ -138,7 +138,6 @@ final kLightTheme = ThemeData( secondaryBackgroundColor: BeamLightThemeColors.secondaryBackground, codeBackgroundColor: BeamLightThemeColors.codeBackground, codeRootStyle: GoogleFonts.sourceCodePro( - backgroundColor: BeamLightThemeColors.primaryBackground, color: BeamLightThemeColors.text, fontSize: codeFontSize, ), @@ -212,7 +211,6 @@ final kDarkTheme = ThemeData( secondaryBackgroundColor: BeamDarkThemeColors.secondaryBackground, codeBackgroundColor: BeamDarkThemeColors.codeBackground, codeRootStyle: GoogleFonts.sourceCodePro( - backgroundColor: BeamDarkThemeColors.primaryBackground, color: BeamDarkThemeColors.text, fontSize: codeFontSize, ), diff --git a/playground/frontend/playground_components/lib/src/widgets/editor_textarea.dart b/playground/frontend/playground_components/lib/src/widgets/editor_textarea.dart index 05231d0ee8b7..9714177ec945 100644 --- a/playground/frontend/playground_components/lib/src/widgets/editor_textarea.dart +++ b/playground/frontend/playground_components/lib/src/widgets/editor_textarea.dart @@ -18,8 +18,8 @@ // TODO(alexeyinkin): Refactor this, merge into snippet_editor.dart -import 'package:code_text_field/code_text_field.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_code_editor/flutter_code_editor.dart'; import '../models/example.dart'; import '../models/sdk.dart'; @@ -58,7 +58,7 @@ class EditorTextArea extends StatefulWidget { class _EditorTextAreaState extends State { var focusNode = FocusNode(); - final GlobalKey codeFieldKey = LabeledGlobalKey('CodeFieldKey'); + final GlobalKey _sizeKey = LabeledGlobalKey('CodeFieldKey'); @override void dispose() { @@ -82,16 +82,21 @@ class _EditorTextAreaState extends State { readOnly: widget.enabled, label: 'widgets.codeEditor.label', child: FocusScope( + key: _sizeKey, node: FocusScopeNode(canRequestFocus: widget.isEditable), child: CodeTheme( data: ext.codeTheme, - child: CodeField( - key: codeFieldKey, - focusNode: focusNode, - enabled: widget.enabled, - controller: widget.codeController, - textStyle: ext.codeRootStyle, - expands: true, + child: Container( + color: ext.codeTheme.styles['root']?.backgroundColor, + child: SingleChildScrollView( + child: CodeField( + key: ValueKey(widget.codeController), + focusNode: focusNode, + enabled: widget.enabled, + controller: widget.codeController, + textStyle: ext.codeRootStyle, + ), + ), ), ), ), @@ -137,9 +142,8 @@ class _EditorTextAreaState extends State { } int _getQntOfStringsOnScreen() { - RenderBox rBox = - codeFieldKey.currentContext?.findRenderObject() as RenderBox; - double height = rBox.size.height * .75; + final renderBox = _sizeKey.currentContext!.findRenderObject()! as RenderBox; + final height = renderBox.size.height * .75; return height ~/ codeFontSize; } diff --git a/playground/frontend/playground_components/pubspec.yaml b/playground/frontend/playground_components/pubspec.yaml index 1a4c91197a0c..72f6b7a99356 100644 --- a/playground/frontend/playground_components/pubspec.yaml +++ b/playground/frontend/playground_components/pubspec.yaml @@ -26,16 +26,13 @@ environment: dependencies: aligned_dialog: ^0.0.6 - code_text_field: - git: - url: https://github.com/BertrandBev/code_field.git - ref: 9e2c9fe52a69481f038f4b6609e8a0a776429437 collection: ^1.16.0 easy_localization: ^3.0.1 easy_localization_ext: ^0.1.1 easy_localization_loader: ^1.0.0 equatable: ^2.0.5 flutter: { sdk: flutter } + flutter_code_editor: ^0.1.1 flutter_markdown: ^0.6.12 flutter_svg: ^1.0.3 google_fonts: ^3.0.1 diff --git a/playground/frontend/pubspec.lock b/playground/frontend/pubspec.lock index 7b3186dbd6bd..2c8d8a7c5fd9 100644 --- a/playground/frontend/pubspec.lock +++ b/playground/frontend/pubspec.lock @@ -50,6 +50,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.9.0" + autotrie: + dependency: transitive + description: + name: autotrie + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" boolean_selector: dependency: transitive description: @@ -148,15 +155,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.1.0" - code_text_field: - dependency: transitive - description: - path: "." - ref: "9e2c9fe52a69481f038f4b6609e8a0a776429437" - resolved-ref: "9e2c9fe52a69481f038f4b6609e8a0a776429437" - url: "https://github.com/BertrandBev/code_field.git" - source: git - version: "1.0.3" collection: dependency: "direct main" description: @@ -274,6 +272,13 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_code_editor: + dependency: transitive + description: + name: flutter_code_editor + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.1" flutter_highlight: dependency: transitive description: @@ -293,6 +298,13 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_markdown: + dependency: transitive + description: + name: flutter_markdown + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.12" flutter_svg: dependency: "direct main" description: @@ -359,6 +371,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.7.0" + hive: + dependency: transitive + description: + name: hive + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.3" html: dependency: transitive description: @@ -421,7 +440,7 @@ packages: name: json_annotation url: "https://pub.dartlang.org" source: hosted - version: "4.5.0" + version: "4.7.0" linked_scroll_controller: dependency: transitive description: @@ -443,6 +462,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.2" + markdown: + dependency: transitive + description: + name: markdown + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.1" matcher: dependency: transitive description: @@ -639,6 +665,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0" + scrollable_positioned_list: + dependency: transitive + description: + name: scrollable_positioned_list + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.5" shared_preferences: dependency: "direct main" description: @@ -777,6 +810,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.0" + tuple: + dependency: transitive + description: + name: tuple + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" typed_data: dependency: transitive description: From d17b1299e8a294c5ccc32f3fe31f0ca35329c642 Mon Sep 17 00:00:00 2001 From: Alexey Inkin Date: Wed, 26 Oct 2022 19:56:28 +0400 Subject: [PATCH 2/2] Upgrade Akvelon editor (#23415) --- playground/frontend/playground_components/pubspec.yaml | 2 +- playground/frontend/pubspec.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/playground/frontend/playground_components/pubspec.yaml b/playground/frontend/playground_components/pubspec.yaml index 72f6b7a99356..27d09cc81da6 100644 --- a/playground/frontend/playground_components/pubspec.yaml +++ b/playground/frontend/playground_components/pubspec.yaml @@ -32,7 +32,7 @@ dependencies: easy_localization_loader: ^1.0.0 equatable: ^2.0.5 flutter: { sdk: flutter } - flutter_code_editor: ^0.1.1 + flutter_code_editor: ^0.1.2 flutter_markdown: ^0.6.12 flutter_svg: ^1.0.3 google_fonts: ^3.0.1 diff --git a/playground/frontend/pubspec.lock b/playground/frontend/pubspec.lock index 2c8d8a7c5fd9..f9c577ab7df2 100644 --- a/playground/frontend/pubspec.lock +++ b/playground/frontend/pubspec.lock @@ -278,7 +278,7 @@ packages: name: flutter_code_editor url: "https://pub.dartlang.org" source: hosted - version: "0.1.1" + version: "0.1.2" flutter_highlight: dependency: transitive description: