From 695a4a1f3b744b5017ba3c541c6d8848bd890797 Mon Sep 17 00:00:00 2001 From: Prashant Sawant Date: Thu, 17 Oct 2024 20:15:02 -0400 Subject: [PATCH] - quill editor color picker improvements --- .../Flutter/GeneratedPluginRegistrant.swift | 2 + example/macos/Podfile.lock | 10 +- .../organisms/quill_editor/color_button.dart | 255 ++++++------ .../quill_editor/material_picker.dart | 388 ++++++++++++++++++ .../theme/theme_builders/divider_theme.dart | 2 +- 5 files changed, 535 insertions(+), 122 deletions(-) create mode 100644 lib/src/components/organisms/quill_editor/material_picker.dart diff --git a/example/macos/Flutter/GeneratedPluginRegistrant.swift b/example/macos/Flutter/GeneratedPluginRegistrant.swift index c267112..a5fa519 100644 --- a/example/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/example/macos/Flutter/GeneratedPluginRegistrant.swift @@ -15,6 +15,7 @@ import irondash_engine_context import just_audio import package_info_plus import path_provider_foundation +import quill_native_bridge_macos import record_darwin import share_plus import shared_preferences_foundation @@ -36,6 +37,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { JustAudioPlugin.register(with: registry.registrar(forPlugin: "JustAudioPlugin")) FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) + QuillNativeBridgePlugin.register(with: registry.registrar(forPlugin: "QuillNativeBridgePlugin")) RecordPlugin.register(with: registry.registrar(forPlugin: "RecordPlugin")) SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) diff --git a/example/macos/Podfile.lock b/example/macos/Podfile.lock index 5e55529..db5b26e 100644 --- a/example/macos/Podfile.lock +++ b/example/macos/Podfile.lock @@ -24,6 +24,8 @@ PODS: - path_provider_foundation (0.0.1): - Flutter - FlutterMacOS + - quill_native_bridge_macos (0.0.1): + - FlutterMacOS - record_darwin (1.0.0): - Flutter - FlutterMacOS @@ -59,6 +61,7 @@ DEPENDENCIES: - just_audio (from `Flutter/ephemeral/.symlinks/plugins/just_audio/macos`) - package_info_plus (from `Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos`) - path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`) + - quill_native_bridge_macos (from `Flutter/ephemeral/.symlinks/plugins/quill_native_bridge_macos/macos`) - record_darwin (from `Flutter/ephemeral/.symlinks/plugins/record_darwin/macos`) - share_plus (from `Flutter/ephemeral/.symlinks/plugins/share_plus/macos`) - shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin`) @@ -96,6 +99,8 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos path_provider_foundation: :path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin + quill_native_bridge_macos: + :path: Flutter/ephemeral/.symlinks/plugins/quill_native_bridge_macos/macos record_darwin: :path: Flutter/ephemeral/.symlinks/plugins/record_darwin/macos share_plus: @@ -126,10 +131,11 @@ SPEC CHECKSUMS: irondash_engine_context: da62996ee25616d2f01bbeb85dc115d813359478 just_audio: 9b67ca7b97c61cfc9784ea23cd8cc55eb226d489 OrderedSet: e539b66b644ff081c73a262d24ad552a69be3a94 - package_info_plus: d2f71247aab4b6521434f887276093acc70d214c + package_info_plus: f5790acc797bf17c3e959e9d6cf162cc68ff7523 path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46 + quill_native_bridge_macos: f90985c5269ac7ba84d933605b463d96e5f544fe record_darwin: df0a677188e5fed18472550298e675f19ddaffbe - share_plus: a182a58e04e51647c0481aadabbc4de44b3a2bce + share_plus: fd717ef89a2801d3491e737630112b80c310640e shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78 sqflite_darwin: a553b1fd6fe66f53bbb0fe5b4f5bab93f08d7a13 super_native_extensions: 85efee3a7495b46b04befcfc86ed12069264ebf3 diff --git a/lib/src/components/organisms/quill_editor/color_button.dart b/lib/src/components/organisms/quill_editor/color_button.dart index 4b04ee7..8a4cc2d 100644 --- a/lib/src/components/organisms/quill_editor/color_button.dart +++ b/lib/src/components/organisms/quill_editor/color_button.dart @@ -4,11 +4,15 @@ import 'dart:async'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_colorpicker/flutter_colorpicker.dart'; +import 'package:flutter_colorpicker/flutter_colorpicker.dart' hide ColorExtension1; import 'package:flutter_quill/flutter_quill.dart'; import 'package:flutter_quill/translations.dart'; import '../../../utils/localizations/translation.dart'; +import '../../../utils/tools/utils.dart'; +import '../../atoms.dart'; +import '../../molecules.dart'; +import 'material_picker.dart'; /// Controls color styles. /// @@ -212,19 +216,18 @@ class ZdsQuillToolbarColorButtonState extends State await customCallback(_controller, widget.isBackground); return; } - unawaited( - showDialog( - context: context, - barrierColor: - _options.dialogBarrierColor ?? context.quillSharedConfigurations?.dialogBarrierColor ?? Colors.black54, - builder: (_) => _ColorPickerDialog( - isBackground: widget.isBackground, - onRequestChangeColor: _changeColor, - isToggledColor: _isToggledColor, - selectionStyle: _selectionStyle, - ), + + final color = await showZdsBottomSheet( + context: context, + enableDrag: false, + builder: (_) => _ColorPickerDialog( + isBackground: widget.isBackground, + isToggledColor: _isToggledColor, + selectionStyle: _selectionStyle, ), ); + + _changeColor(context, color); } @override @@ -251,7 +254,6 @@ enum _PickerType { class _ColorPickerDialog extends StatefulWidget { const _ColorPickerDialog({ required this.isBackground, - required this.onRequestChangeColor, required this.isToggledColor, required this.selectionStyle, }); @@ -259,7 +261,6 @@ class _ColorPickerDialog extends StatefulWidget { final bool isBackground; final bool isToggledColor; - final void Function(BuildContext context, Color? color) onRequestChangeColor; final Style selectionStyle; @override @@ -269,12 +270,6 @@ class _ColorPickerDialog extends StatefulWidget { void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); properties - ..add( - ObjectFlagProperty.has( - 'onRequestChangeColor', - onRequestChangeColor, - ), - ) ..add(DiagnosticsProperty('isBackground', isBackground)) ..add(DiagnosticsProperty('isToggledColor', isToggledColor)) ..add(DiagnosticsProperty