Implement `dialogTheme` for `QuillEditor`

pull/1185/head
bambinoua 2 years ago
parent 14eecfa1a0
commit c81eb9448c
  1. 5
      lib/src/widgets/editor.dart
  2. 8
      lib/src/widgets/raw_editor.dart
  3. 9
      lib/src/widgets/toolbar/link_style_button2.dart

@ -15,6 +15,7 @@ import '../models/documents/nodes/container.dart' as container_node;
import '../models/documents/nodes/leaf.dart';
import '../models/documents/style.dart';
import '../models/structs/offset_value.dart';
import '../models/themes/quill_dialog_theme.dart';
import '../utils/platform.dart';
import 'box.dart';
import 'controller.dart';
@ -184,6 +185,7 @@ class QuillEditor extends StatefulWidget {
this.detectWordBoundary = true,
this.enableUnfocusOnTapOutside = true,
this.customLinkPrefixes = const <String>[],
this.dialogTheme,
Key? key,
}) : super(key: key);
@ -420,6 +422,9 @@ class QuillEditor extends StatefulWidget {
/// Useful for deeplinks
final List<String> customLinkPrefixes;
/// Configures the dialog theme.
final QuillDialogTheme? dialogTheme;
@override
QuillEditorState createState() => QuillEditorState();
}

@ -2,8 +2,6 @@ import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'dart:math' as math;
// ignore: unnecessary_import
import 'dart:typed_data';
import 'dart:ui' as ui hide TextStyle;
import 'package:flutter/foundation.dart';
@ -24,6 +22,7 @@ import '../models/documents/nodes/node.dart';
import '../models/documents/style.dart';
import '../models/structs/offset_value.dart';
import '../models/structs/vertical_spacing.dart';
import '../models/themes/quill_dialog_theme.dart';
import '../utils/cast.dart';
import '../utils/delta.dart';
import '../utils/embeds.dart';
@ -82,6 +81,7 @@ class RawEditor extends StatefulWidget {
this.floatingCursorDisabled = false,
this.onImagePaste,
this.customLinkPrefixes = const <String>[],
this.dialogTheme,
}) : assert(maxHeight == null || maxHeight > 0, 'maxHeight cannot be null'),
assert(minHeight == null || minHeight >= 0, 'minHeight cannot be null'),
assert(maxHeight == null || minHeight == null || maxHeight >= minHeight,
@ -264,6 +264,9 @@ class RawEditor extends StatefulWidget {
final bool floatingCursorDisabled;
final List<String> customLinkPrefixes;
/// Configures the dialog theme.
final QuillDialogTheme? dialogTheme;
@override
State<StatefulWidget> createState() => RawEditorState();
}
@ -2591,6 +2594,7 @@ class ApplyLinkAction extends Action<ApplyLinkIntent> {
return LinkStyleDialog(
text: initialTextLink.text,
link: initialTextLink.link,
dialogTheme: state.widget.dialogTheme,
);
},
);

@ -247,9 +247,16 @@ class _LinkStyleDialogState extends State<LinkStyleDialog> {
kIsWeb ? mediaQuery.size.width / 4 : mediaQuery.size.width - 80;
return BoxConstraints(maxWidth: maxWidth, maxHeight: 80);
}();
final buttonStyle = Theme.of(context).elevatedButtonTheme.style?.copyWith(
var buttonStyle = widget.dialogTheme?.buttonStyle;
if (buttonStyle == null) {
if (widget.buttonSize != null) {
buttonStyle = Theme.of(context).elevatedButtonTheme.style?.copyWith(
fixedSize: MaterialStatePropertyAll(widget.buttonSize),
);
}
}
return Dialog(
backgroundColor: widget.dialogTheme?.dialogBackgroundColor,
shape: widget.dialogTheme?.shape ??

Loading…
Cancel
Save