From bd78a9b21567daa3823d0b1039390c9411b8ce2d Mon Sep 17 00:00:00 2001 From: Ellet Date: Wed, 15 Nov 2023 03:34:06 +0300 Subject: [PATCH] Update the example --- example/android/app/src/main/AndroidManifest.xml | 3 ++- example/lib/presentation/quill/quill_screen.dart | 5 ++++- example/lib/presentation/quill/quill_toolbar.dart | 14 +++++++++++++- lib/src/models/config/toolbar/configurations.dart | 4 ++-- lib/src/utils/platform.dart | 3 ++- 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index fcb9147b..e047f006 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -5,7 +5,8 @@ + android:maxSdkVersion="32" + tools:ignore="ScopedStorage" /> diff --git a/example/lib/presentation/quill/quill_screen.dart b/example/lib/presentation/quill/quill_screen.dart index c091beb5..aab91c83 100644 --- a/example/lib/presentation/quill/quill_screen.dart +++ b/example/lib/presentation/quill/quill_screen.dart @@ -115,7 +115,10 @@ class _QuillScreenState extends State { ), child: Column( children: [ - if (!_isReadOnly) const MyQuillToolbar(), + if (!_isReadOnly) + MyQuillToolbar( + focusNode: _editorFocusNode, + ), Builder( builder: (context) { return Expanded( diff --git a/example/lib/presentation/quill/quill_toolbar.dart b/example/lib/presentation/quill/quill_toolbar.dart index a0f16677..b0257dc1 100644 --- a/example/lib/presentation/quill/quill_toolbar.dart +++ b/example/lib/presentation/quill/quill_toolbar.dart @@ -15,7 +15,12 @@ import '../settings/cubit/settings_cubit.dart'; import 'embeds/timestamp_embed.dart'; class MyQuillToolbar extends StatelessWidget { - const MyQuillToolbar({super.key}); + const MyQuillToolbar({ + required this.focusNode, + super.key, + }); + + final FocusNode focusNode; Future onImageInsertWithCropping( String image, @@ -211,6 +216,13 @@ class MyQuillToolbar extends StatelessWidget { } return QuillToolbar( configurations: QuillToolbarConfigurations( + showAlignmentButtons: true, + buttonOptions: QuillToolbarButtonOptions( + base: QuillToolbarBaseButtonOptions( + // Request editor focus when any button is pressed + afterButtonPressed: focusNode.requestFocus, + ), + ), customButtons: [ QuillToolbarCustomButtonOptions( icon: const Icon(Icons.add_alarm_rounded), diff --git a/lib/src/models/config/toolbar/configurations.dart b/lib/src/models/config/toolbar/configurations.dart index c609cd80..63d1a3c2 100644 --- a/lib/src/models/config/toolbar/configurations.dart +++ b/lib/src/models/config/toolbar/configurations.dart @@ -154,7 +154,7 @@ class QuillToolbarConfigurations extends Equatable { /// 'Nunito': 'nunito', /// 'Pacifico': 'pacifico', /// 'Roboto Mono': 'roboto-mono', - /// 'Clear'.i18n: 'Clear' + /// 'Clear'.loc: 'Clear' /// }; /// ``` final Map? fontFamilyValues; @@ -165,7 +165,7 @@ class QuillToolbarConfigurations extends Equatable { /// 'Small'.i18n: 'small', /// 'Large'.i18n: 'large', /// 'Huge'.i18n: 'huge', - /// 'Clear'.i18n: '0' + /// 'Clear'.loc: '0' /// } /// ``` final Map? fontSizesValues; diff --git a/lib/src/utils/platform.dart b/lib/src/utils/platform.dart index a06db05c..d248b369 100644 --- a/lib/src/utils/platform.dart +++ b/lib/src/utils/platform.dart @@ -4,7 +4,8 @@ import 'package:device_info_plus/device_info_plus.dart'; import 'package:flutter/foundation.dart' show TargetPlatform, defaultTargetPlatform, kIsWeb, visibleForTesting; -/// If you want to override the [kIsWeb] use [overrideIsWeb] +/// If you want to override the [kIsWeb] use [overrideIsWeb] but it's only +/// for testing bool isWeb({ @visibleForTesting bool? overrideIsWeb, }) {