pull/1566/head
Ellet 1 year ago
parent 0c4c6cd775
commit 9727fea996
No known key found for this signature in database
GPG Key ID: C488CC70BBCEF0D1
  1. 6
      CHANGELOG.md
  2. 1
      example/lib/presentation/quill/quill_screen.dart
  3. 18
      example/lib/presentation/quill/quill_toolbar.dart
  4. 2
      example/pubspec.yaml
  5. 11
      flutter_quill_extensions/lib/embeds/others/camera_button/camera_button.dart
  6. 50
      flutter_quill_extensions/lib/embeds/others/camera_button/select_camera_action.dart
  7. 1
      flutter_quill_extensions/pubspec.yaml
  8. 26
      lib/src/models/config/toolbar/toolbar_configurations.dart
  9. 82
      lib/src/widgets/toolbar/base_toolbar.dart
  10. 197
      lib/src/widgets/toolbar/simple_toolbar.dart
  11. 2
      version.dart

@ -2,9 +2,15 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
## 9.0.0-dev-5
* The `QuillToolbar` is now accepting only `child` with no configurations so you can customize everything you wants, the `QuillToolbar.simple()` or `QuillSimpleToolbar` implements a simple toolbar that is based on `QuillToolbar`, you are free to use it but it just an example and not standard
* Flutter Quill Extensions:
* Improve the camera button
## 9.0.0-dev-4 ## 9.0.0-dev-4
* The options parameter in all of the buttons is no longer required which can be useful to create custom toolbar with minimal efforts * The options parameter in all of the buttons is no longer required which can be useful to create custom toolbar with minimal efforts
* Toolbar buttons fixes in both `flutter_quill` and `flutter_quill_extensions` * Toolbar buttons fixes in both `flutter_quill` and `flutter_quill_extensions`
* The `QuillProvider` has been dropped and no longer used, the providers will be used only internally from now on and we will not using them as much as possible
## 9.0.0-dev-3 ## 9.0.0-dev-3
* Breaking Changes: * Breaking Changes:

@ -106,7 +106,6 @@ class _QuillScreenState extends State<QuillScreen> {
MyQuillToolbar( MyQuillToolbar(
controller: _controller, controller: _controller,
focusNode: _editorFocusNode, focusNode: _editorFocusNode,
sharedConfigurations: _sharedConfigurations,
), ),
Builder( Builder(
builder: (context) { builder: (context) {

@ -17,14 +17,11 @@ class MyQuillToolbar extends StatelessWidget {
const MyQuillToolbar({ const MyQuillToolbar({
required this.controller, required this.controller,
required this.focusNode, required this.focusNode,
required this.sharedConfigurations,
super.key, super.key,
}); });
final QuillController controller; final QuillController controller;
final FocusNode focusNode; final FocusNode focusNode;
// TODO: Use it
final QuillSharedConfigurations sharedConfigurations;
Future<void> onImageInsertWithCropping( Future<void> onImageInsertWithCropping(
String image, String image,
@ -104,16 +101,16 @@ class MyQuillToolbar extends StatelessWidget {
// https://github.com/singerdmx/flutter-quill/blob/master/doc/custom_toolbar.md // https://github.com/singerdmx/flutter-quill/blob/master/doc/custom_toolbar.md
return QuillToolbar( return QuillToolbar(
configurations: QuillToolbarConfigurations( configurations: QuillToolbarConfigurations(
toolbarSize: 20 * 2,
multiRowsDisplay: false,
buttonOptions: const QuillToolbarButtonOptions( buttonOptions: const QuillToolbarButtonOptions(
base: QuillToolbarBaseButtonOptions( base: QuillToolbarBaseButtonOptions(
globalIconSize: 20, globalIconSize: 20,
globalIconButtonFactor: 1.4, globalIconButtonFactor: 1.4,
), ),
), ),
childrenBuilder: (context) { child: SingleChildScrollView(
return [ scrollDirection: Axis.horizontal,
child: Row(
children: [
IconButton( IconButton(
onPressed: () => context onPressed: () => context
.read<SettingsCubit>() .read<SettingsCubit>()
@ -177,7 +174,7 @@ class MyQuillToolbar extends StatelessWidget {
), ),
QuillToolbarToggleStyleButton( QuillToolbarToggleStyleButton(
controller: controller, controller: controller,
attribute: Attribute.list, attribute: Attribute.ol,
), ),
QuillToolbarToggleStyleButton( QuillToolbarToggleStyleButton(
controller: controller, controller: controller,
@ -201,8 +198,9 @@ class MyQuillToolbar extends StatelessWidget {
), ),
const VerticalDivider(), const VerticalDivider(),
QuillToolbarLinkStyleButton(controller: controller), QuillToolbarLinkStyleButton(controller: controller),
]; ],
}, ),
),
), ),
); );
} }

@ -24,8 +24,6 @@ dependencies:
cross_file: ^0.3.3+6 cross_file: ^0.3.3+6
cached_network_image: ^3.3.0 cached_network_image: ^3.3.0
gal_linux: ^0.0.1-dev
# Bloc libraries # Bloc libraries
bloc: ^8.1.2 bloc: ^8.1.2
flutter_bloc: ^8.1.3 flutter_bloc: ^8.1.3

@ -120,10 +120,8 @@ class QuillToolbarCameraButton extends StatelessWidget {
if (customCallback != null) { if (customCallback != null) {
return await customCallback(context); return await customCallback(context);
} }
final cameraAction = await showDialog<CameraAction>( final cameraAction = await showSelectCameraActionDialog(
context: context, context: context,
builder: (ctx) => const FlutterQuillLocalizationsWidget(
child: SelectCameraActionDialog()),
); );
return cameraAction; return cameraAction;
@ -171,12 +169,5 @@ class QuillToolbarCameraButton extends StatelessWidget {
await options.cameraConfigurations.onImageInsertedCallback await options.cameraConfigurations.onImageInsertedCallback
?.call(imageFile.path); ?.call(imageFile.path);
} }
// final file = await switch (cameraAction) {
// CameraAction.image =>
// imagePickerService.pickImage(source: ImageSource.camera),
// CameraAction.video =>
// imagePickerService.pickVideo(source: ImageSource.camera),
// };
} }
} }

@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_quill/extensions.dart';
import 'package:flutter_quill/translations.dart'; import 'package:flutter_quill/translations.dart';
import 'camera_types.dart'; import 'camera_types.dart';
@ -8,27 +9,46 @@ class SelectCameraActionDialog extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AlertDialog( return SizedBox(
contentPadding: EdgeInsets.zero, height: 150,
content: Column( width: double.infinity,
mainAxisSize: MainAxisSize.min, child: SingleChildScrollView(
child: Column(
children: [ children: [
TextButton.icon( ListTile(
icon: const Icon( title: Text(context.loc.photo),
Icons.camera, subtitle: Text(
context.loc.takeAPhotoUsingYourCamera,
), ),
label: Text(context.loc.photo), leading: const Icon(Icons.photo_sharp),
onPressed: () => Navigator.pop(context, CameraAction.image), enabled: !isDesktop(supportWeb: false),
onTap: () => Navigator.of(context).pop(CameraAction.image),
), ),
TextButton.icon( ListTile(
icon: const Icon( title: Text(context.loc.video),
Icons.video_call, subtitle: Text(
context.loc.recordAVideoUsingYourCamera,
),
leading: const Icon(Icons.camera),
enabled: !isDesktop(supportWeb: false),
onTap: () => Navigator.of(context).pop(CameraAction.video),
), ),
label: Text(context.loc.video),
onPressed: () => Navigator.pop(context, CameraAction.video),
)
], ],
), ),
),
); );
} }
} }
Future<CameraAction?> showSelectCameraActionDialog({
required BuildContext context,
}) async {
final imageSource = await showModalBottomSheet<CameraAction>(
showDragHandle: true,
context: context,
constraints: const BoxConstraints(maxWidth: 640),
builder: (context) => const FlutterQuillLocalizationsWidget(
child: SelectCameraActionDialog()),
);
return imageSource;
}

@ -44,6 +44,7 @@ dependencies:
url_launcher: ^6.2.1 url_launcher: ^6.2.1
super_clipboard: ^0.7.3 super_clipboard: ^0.7.3
gal: ^2.1.3 gal: ^2.1.3
gal_linux: ^0.0.1-dev-3
image_picker: ^1.0.4 image_picker: ^1.0.4
dev_dependencies: dev_dependencies:

@ -1,6 +1,6 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first // ignore_for_file: public_member_api_docs, sort_constructors_first
import 'package:flutter/widgets.dart' import 'package:flutter/widgets.dart'
show Axis, WrapAlignment, WrapCrossAlignment, immutable; show Axis, Widget, WrapAlignment, WrapCrossAlignment, immutable;
import '../../../widgets/toolbar/base_toolbar.dart'; import '../../../widgets/toolbar/base_toolbar.dart';
import 'toolbar_shared_configurations.dart'; import 'toolbar_shared_configurations.dart';
@ -8,34 +8,16 @@ import 'toolbar_shared_configurations.dart';
@immutable @immutable
class QuillToolbarConfigurations extends QuillSharedToolbarProperties { class QuillToolbarConfigurations extends QuillSharedToolbarProperties {
const QuillToolbarConfigurations({ const QuillToolbarConfigurations({
this.childrenBuilder, required this.child,
super.axis = Axis.horizontal, super.sharedConfigurations,
super.toolbarSize = kDefaultIconSize * 2,
super.toolbarSectionSpacing = kToolbarSectionSpacing,
super.toolbarIconAlignment = WrapAlignment.center,
super.toolbarIconCrossAlignment = WrapCrossAlignment.center,
super.color,
super.sectionDividerColor,
super.sectionDividerSpace,
super.linkDialogAction,
super.multiRowsDisplay = true,
super.decoration,
/// Note this only used when you using the quill toolbar buttons like /// Note this only used when you using the quill toolbar buttons like
/// `QuillToolbarHistoryButton` inside it /// `QuillToolbarHistoryButton` inside it
super.buttonOptions = const QuillToolbarButtonOptions(), super.buttonOptions = const QuillToolbarButtonOptions(),
}); });
final QuillBaseToolbarChildrenBuilder? childrenBuilder; final Widget child;
@override @override
List<Object?> get props => []; List<Object?> get props => [];
QuillToolbarConfigurations copyWith({
QuillBaseToolbarChildrenBuilder? childrenBuilder,
}) {
return QuillToolbarConfigurations(
childrenBuilder: childrenBuilder ?? this.childrenBuilder,
);
}
} }

@ -5,7 +5,6 @@ import '../../../flutter_quill.dart'
import '../../l10n/widgets/localizations.dart'; import '../../l10n/widgets/localizations.dart';
import '../../models/config/toolbar/simple_toolbar_configurations.dart'; import '../../models/config/toolbar/simple_toolbar_configurations.dart';
import '../../models/config/toolbar/toolbar_configurations.dart'; import '../../models/config/toolbar/toolbar_configurations.dart';
import 'buttons/arrow_indicated_list_button.dart';
import 'simple_toolbar.dart'; import 'simple_toolbar.dart';
export '../../models/config/toolbar/buttons/base_configurations.dart'; export '../../models/config/toolbar/buttons/base_configurations.dart';
@ -56,90 +55,11 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final toolbarSize = configurations.toolbarSize;
return FlutterQuillLocalizationsWidget( return FlutterQuillLocalizationsWidget(
child: QuillBaseToolbarProvider( child: QuillBaseToolbarProvider(
toolbarConfigurations: configurations, toolbarConfigurations: configurations,
child: Builder( child: configurations.child,
builder: (context) {
if (configurations.multiRowsDisplay) {
return Wrap(
direction: configurations.axis,
alignment: configurations.toolbarIconAlignment,
crossAxisAlignment: configurations.toolbarIconCrossAlignment,
runSpacing: 4,
spacing: configurations.toolbarSectionSpacing,
children: configurations.childrenBuilder?.call(context) ?? [],
);
}
return Container(
decoration: configurations.decoration ??
BoxDecoration(
color:
configurations.color ?? Theme.of(context).canvasColor,
),
constraints: BoxConstraints.tightFor(
height:
configurations.axis == Axis.horizontal ? toolbarSize : null,
width:
configurations.axis == Axis.vertical ? toolbarSize : null,
),
child: QuillToolbarArrowIndicatedButtonList(
axis: configurations.axis,
buttons: configurations.childrenBuilder?.call(context) ?? [],
),
);
},
), ),
),
);
}
}
/// The divider which is used for separation of buttons in the toolbar.
///
/// It can be used outside of this package, for example when user does not use
/// [QuillToolbar.basic] and compose toolbar's children on its own.
class QuillToolbarDivider extends StatelessWidget {
const QuillToolbarDivider(
this.axis, {
super.key,
this.color,
this.space,
});
/// Provides a horizontal divider for vertical toolbar.
const QuillToolbarDivider.horizontal({Key? key, Color? color, double? space})
: this(Axis.horizontal, color: color, space: space, key: key);
/// Provides a horizontal divider for horizontal toolbar.
const QuillToolbarDivider.vertical({Key? key, Color? color, double? space})
: this(Axis.vertical, color: color, space: space, key: key);
/// The axis along which the toolbar is.
final Axis axis;
/// The color to use when painting this divider's line.
final Color? color;
/// The divider's space (width or height) depending of [axis].
final double? space;
@override
Widget build(BuildContext context) {
// Vertical toolbar requires horizontal divider, and vice versa
return axis == Axis.vertical
? Divider(
height: space,
color: color,
indent: 12,
endIndent: 12,
)
: VerticalDivider(
width: space,
color: color,
indent: 12,
endIndent: 12,
); );
} }
} }

@ -6,6 +6,7 @@ import '../../models/config/toolbar/toolbar_configurations.dart';
import '../../models/documents/attribute.dart'; import '../../models/documents/attribute.dart';
import '../utils/provider.dart'; import '../utils/provider.dart';
import 'base_toolbar.dart'; import 'base_toolbar.dart';
import 'buttons/arrow_indicated_list_button.dart';
import 'buttons/select_alignment_buttons.dart'; import 'buttons/select_alignment_buttons.dart';
import 'buttons/select_header_style_button.dart'; import 'buttons/select_header_style_button.dart';
@ -50,22 +51,7 @@ class QuillSimpleToolbar extends StatelessWidget
configurations.showLink || configurations.showSearchButton configurations.showLink || configurations.showSearchButton
]; ];
return QuillToolbarProvider( List<Widget> childrenBuilder(context) {
toolbarConfigurations: configurations,
child: QuillToolbar(
configurations: QuillToolbarConfigurations(
color: configurations.color,
decoration: configurations.decoration,
toolbarSectionSpacing: configurations.toolbarSectionSpacing,
toolbarIconAlignment: configurations.toolbarIconAlignment,
toolbarIconCrossAlignment: configurations.toolbarIconCrossAlignment,
linkDialogAction: configurations.linkDialogAction,
multiRowsDisplay: configurations.multiRowsDisplay,
sectionDividerColor: configurations.sectionDividerColor,
axis: configurations.axis,
sectionDividerSpace: configurations.sectionDividerSpace,
toolbarSize: configurations.toolbarSize,
childrenBuilder: (context) {
final toolbarConfigurations = final toolbarConfigurations =
context.requireQuillSimpleToolbarConfigurations; context.requireQuillSimpleToolbarConfigurations;
@ -83,8 +69,8 @@ class QuillSimpleToolbar extends StatelessWidget
QuillToolbarHistoryButton( QuillToolbarHistoryButton(
isUndo: true, isUndo: true,
options: toolbarConfigurations.buttonOptions.undoHistory, options: toolbarConfigurations.buttonOptions.undoHistory,
controller: toolbarConfigurations controller:
.buttonOptions.undoHistory.controller ?? toolbarConfigurations.buttonOptions.undoHistory.controller ??
globalController, globalController,
), ),
spacerWidget, spacerWidget,
@ -93,8 +79,8 @@ class QuillSimpleToolbar extends StatelessWidget
QuillToolbarHistoryButton( QuillToolbarHistoryButton(
isUndo: false, isUndo: false,
options: toolbarConfigurations.buttonOptions.redoHistory, options: toolbarConfigurations.buttonOptions.redoHistory,
controller: toolbarConfigurations controller:
.buttonOptions.redoHistory.controller ?? toolbarConfigurations.buttonOptions.redoHistory.controller ??
globalController, globalController,
), ),
spacerWidget, spacerWidget,
@ -102,8 +88,8 @@ class QuillSimpleToolbar extends StatelessWidget
if (configurations.showFontFamily) ...[ if (configurations.showFontFamily) ...[
QuillToolbarFontFamilyButton( QuillToolbarFontFamilyButton(
options: toolbarConfigurations.buttonOptions.fontFamily, options: toolbarConfigurations.buttonOptions.fontFamily,
controller: toolbarConfigurations controller:
.buttonOptions.fontFamily.controller ?? toolbarConfigurations.buttonOptions.fontFamily.controller ??
globalController, globalController,
defaultDispalyText: context.loc.font, defaultDispalyText: context.loc.font,
), ),
@ -112,8 +98,8 @@ class QuillSimpleToolbar extends StatelessWidget
if (configurations.showFontSize) ...[ if (configurations.showFontSize) ...[
QuillToolbarFontSizeButton( QuillToolbarFontSizeButton(
options: toolbarConfigurations.buttonOptions.fontSize, options: toolbarConfigurations.buttonOptions.fontSize,
controller: toolbarConfigurations controller:
.buttonOptions.fontFamily.controller ?? toolbarConfigurations.buttonOptions.fontFamily.controller ??
globalController, globalController,
defaultDisplayText: context.loc.fontSize, defaultDisplayText: context.loc.fontSize,
), ),
@ -123,8 +109,7 @@ class QuillSimpleToolbar extends StatelessWidget
QuillToolbarToggleStyleButton( QuillToolbarToggleStyleButton(
attribute: Attribute.bold, attribute: Attribute.bold,
options: toolbarConfigurations.buttonOptions.bold, options: toolbarConfigurations.buttonOptions.bold,
controller: controller: toolbarConfigurations.buttonOptions.bold.controller ??
toolbarConfigurations.buttonOptions.bold.controller ??
globalController, globalController,
), ),
spacerWidget, spacerWidget,
@ -133,8 +118,7 @@ class QuillSimpleToolbar extends StatelessWidget
QuillToolbarToggleStyleButton( QuillToolbarToggleStyleButton(
attribute: Attribute.italic, attribute: Attribute.italic,
options: toolbarConfigurations.buttonOptions.italic, options: toolbarConfigurations.buttonOptions.italic,
controller: controller: toolbarConfigurations.buttonOptions.italic.controller ??
toolbarConfigurations.buttonOptions.italic.controller ??
globalController, globalController,
), ),
spacerWidget, spacerWidget,
@ -143,8 +127,8 @@ class QuillSimpleToolbar extends StatelessWidget
QuillToolbarToggleStyleButton( QuillToolbarToggleStyleButton(
attribute: Attribute.underline, attribute: Attribute.underline,
options: toolbarConfigurations.buttonOptions.underLine, options: toolbarConfigurations.buttonOptions.underLine,
controller: toolbarConfigurations controller:
.buttonOptions.underLine.controller ?? toolbarConfigurations.buttonOptions.underLine.controller ??
globalController, globalController,
), ),
spacerWidget, spacerWidget,
@ -153,8 +137,8 @@ class QuillSimpleToolbar extends StatelessWidget
QuillToolbarToggleStyleButton( QuillToolbarToggleStyleButton(
attribute: Attribute.inlineCode, attribute: Attribute.inlineCode,
options: toolbarConfigurations.buttonOptions.inlineCode, options: toolbarConfigurations.buttonOptions.inlineCode,
controller: toolbarConfigurations controller:
.buttonOptions.inlineCode.controller ?? toolbarConfigurations.buttonOptions.inlineCode.controller ??
globalController, globalController,
), ),
spacerWidget, spacerWidget,
@ -163,8 +147,8 @@ class QuillSimpleToolbar extends StatelessWidget
QuillToolbarToggleStyleButton( QuillToolbarToggleStyleButton(
attribute: Attribute.subscript, attribute: Attribute.subscript,
options: toolbarConfigurations.buttonOptions.subscript, options: toolbarConfigurations.buttonOptions.subscript,
controller: toolbarConfigurations controller:
.buttonOptions.subscript.controller ?? toolbarConfigurations.buttonOptions.subscript.controller ??
globalController, globalController,
), ),
spacerWidget, spacerWidget,
@ -173,8 +157,8 @@ class QuillSimpleToolbar extends StatelessWidget
QuillToolbarToggleStyleButton( QuillToolbarToggleStyleButton(
attribute: Attribute.superscript, attribute: Attribute.superscript,
options: toolbarConfigurations.buttonOptions.superscript, options: toolbarConfigurations.buttonOptions.superscript,
controller: toolbarConfigurations controller:
.buttonOptions.superscript.controller ?? toolbarConfigurations.buttonOptions.superscript.controller ??
globalController, globalController,
), ),
spacerWidget, spacerWidget,
@ -183,8 +167,7 @@ class QuillSimpleToolbar extends StatelessWidget
QuillToolbarToggleStyleButton( QuillToolbarToggleStyleButton(
attribute: Attribute.small, attribute: Attribute.small,
options: toolbarConfigurations.buttonOptions.small, options: toolbarConfigurations.buttonOptions.small,
controller: controller: toolbarConfigurations.buttonOptions.small.controller ??
toolbarConfigurations.buttonOptions.small.controller ??
globalController, globalController,
), ),
spacerWidget, spacerWidget,
@ -193,16 +176,15 @@ class QuillSimpleToolbar extends StatelessWidget
QuillToolbarToggleStyleButton( QuillToolbarToggleStyleButton(
attribute: Attribute.strikeThrough, attribute: Attribute.strikeThrough,
options: toolbarConfigurations.buttonOptions.strikeThrough, options: toolbarConfigurations.buttonOptions.strikeThrough,
controller: toolbarConfigurations controller:
.buttonOptions.strikeThrough.controller ?? toolbarConfigurations.buttonOptions.strikeThrough.controller ??
globalController, globalController,
), ),
spacerWidget, spacerWidget,
], ],
if (configurations.showColorButton) ...[ if (configurations.showColorButton) ...[
QuillToolbarColorButton( QuillToolbarColorButton(
controller: controller: toolbarConfigurations.buttonOptions.color.controller ??
toolbarConfigurations.buttonOptions.color.controller ??
globalController, globalController,
isBackground: false, isBackground: false,
options: toolbarConfigurations.buttonOptions.color, options: toolbarConfigurations.buttonOptions.color,
@ -212,8 +194,7 @@ class QuillSimpleToolbar extends StatelessWidget
if (configurations.showBackgroundColorButton) ...[ if (configurations.showBackgroundColorButton) ...[
QuillToolbarColorButton( QuillToolbarColorButton(
options: toolbarConfigurations.buttonOptions.backgroundColor, options: toolbarConfigurations.buttonOptions.backgroundColor,
controller: controller: toolbarConfigurations.buttonOptions.color.controller ??
toolbarConfigurations.buttonOptions.color.controller ??
globalController, globalController,
isBackground: true, isBackground: true,
), ),
@ -221,8 +202,8 @@ class QuillSimpleToolbar extends StatelessWidget
], ],
if (configurations.showClearFormat) ...[ if (configurations.showClearFormat) ...[
QuillToolbarClearFormatButton( QuillToolbarClearFormatButton(
controller: toolbarConfigurations controller:
.buttonOptions.clearFormat.controller ?? toolbarConfigurations.buttonOptions.clearFormat.controller ??
globalController, globalController,
options: toolbarConfigurations.buttonOptions.clearFormat, options: toolbarConfigurations.buttonOptions.clearFormat,
), ),
@ -252,8 +233,7 @@ class QuillSimpleToolbar extends StatelessWidget
controller: toolbarConfigurations controller: toolbarConfigurations
.buttonOptions.selectAlignmentButtons.controller ?? .buttonOptions.selectAlignmentButtons.controller ??
globalController, globalController,
options: toolbarConfigurations options: toolbarConfigurations.buttonOptions.selectAlignmentButtons,
.buttonOptions.selectAlignmentButtons,
showLeftAlignment: configurations.showLeftAlignment, showLeftAlignment: configurations.showLeftAlignment,
showCenterAlignment: configurations.showCenterAlignment, showCenterAlignment: configurations.showCenterAlignment,
showRightAlignment: configurations.showRightAlignment, showRightAlignment: configurations.showRightAlignment,
@ -265,8 +245,8 @@ class QuillSimpleToolbar extends StatelessWidget
QuillToolbarToggleStyleButton( QuillToolbarToggleStyleButton(
attribute: Attribute.rtl, attribute: Attribute.rtl,
options: toolbarConfigurations.buttonOptions.direction, options: toolbarConfigurations.buttonOptions.direction,
controller: toolbarConfigurations controller:
.buttonOptions.direction.controller ?? toolbarConfigurations.buttonOptions.direction.controller ??
globalController, globalController,
), ),
spacerWidget, spacerWidget,
@ -287,8 +267,8 @@ class QuillSimpleToolbar extends StatelessWidget
controller: toolbarConfigurations controller: toolbarConfigurations
.buttonOptions.selectHeaderStyleButtons.controller ?? .buttonOptions.selectHeaderStyleButtons.controller ??
globalController, globalController,
options: toolbarConfigurations options:
.buttonOptions.selectHeaderStyleButtons, toolbarConfigurations.buttonOptions.selectHeaderStyleButtons,
), ),
spacerWidget, spacerWidget,
], ],
@ -307,8 +287,8 @@ class QuillSimpleToolbar extends StatelessWidget
QuillToolbarToggleStyleButton( QuillToolbarToggleStyleButton(
attribute: Attribute.ol, attribute: Attribute.ol,
options: toolbarConfigurations.buttonOptions.listNumbers, options: toolbarConfigurations.buttonOptions.listNumbers,
controller: toolbarConfigurations controller:
.buttonOptions.listNumbers.controller ?? toolbarConfigurations.buttonOptions.listNumbers.controller ??
globalController, globalController,
), ),
spacerWidget, spacerWidget,
@ -317,8 +297,8 @@ class QuillSimpleToolbar extends StatelessWidget
QuillToolbarToggleStyleButton( QuillToolbarToggleStyleButton(
attribute: Attribute.ul, attribute: Attribute.ul,
options: toolbarConfigurations.buttonOptions.listBullets, options: toolbarConfigurations.buttonOptions.listBullets,
controller: toolbarConfigurations controller:
.buttonOptions.listBullets.controller ?? toolbarConfigurations.buttonOptions.listBullets.controller ??
globalController, globalController,
), ),
spacerWidget, spacerWidget,
@ -336,8 +316,8 @@ class QuillSimpleToolbar extends StatelessWidget
QuillToolbarToggleStyleButton( QuillToolbarToggleStyleButton(
attribute: Attribute.codeBlock, attribute: Attribute.codeBlock,
options: toolbarConfigurations.buttonOptions.codeBlock, options: toolbarConfigurations.buttonOptions.codeBlock,
controller: toolbarConfigurations controller:
.buttonOptions.codeBlock.controller ?? toolbarConfigurations.buttonOptions.codeBlock.controller ??
globalController, globalController,
), ),
spacerWidget, spacerWidget,
@ -354,8 +334,7 @@ class QuillSimpleToolbar extends StatelessWidget
if (configurations.showQuote) ...[ if (configurations.showQuote) ...[
QuillToolbarToggleStyleButton( QuillToolbarToggleStyleButton(
options: toolbarConfigurations.buttonOptions.quote, options: toolbarConfigurations.buttonOptions.quote,
controller: controller: toolbarConfigurations.buttonOptions.quote.controller ??
toolbarConfigurations.buttonOptions.quote.controller ??
globalController, globalController,
attribute: Attribute.blockQuote, attribute: Attribute.blockQuote,
), ),
@ -363,8 +342,8 @@ class QuillSimpleToolbar extends StatelessWidget
], ],
if (configurations.showIndent) ...[ if (configurations.showIndent) ...[
QuillToolbarIndentButton( QuillToolbarIndentButton(
controller: toolbarConfigurations controller:
.buttonOptions.indentIncrease.controller ?? toolbarConfigurations.buttonOptions.indentIncrease.controller ??
globalController, globalController,
isIncrease: true, isIncrease: true,
options: toolbarConfigurations.buttonOptions.indentIncrease, options: toolbarConfigurations.buttonOptions.indentIncrease,
@ -373,8 +352,8 @@ class QuillSimpleToolbar extends StatelessWidget
], ],
if (configurations.showIndent) ...[ if (configurations.showIndent) ...[
QuillToolbarIndentButton( QuillToolbarIndentButton(
controller: toolbarConfigurations controller:
.buttonOptions.indentDecrease.controller ?? toolbarConfigurations.buttonOptions.indentDecrease.controller ??
globalController, globalController,
isIncrease: false, isIncrease: false,
options: toolbarConfigurations.buttonOptions.indentDecrease, options: toolbarConfigurations.buttonOptions.indentDecrease,
@ -407,8 +386,7 @@ class QuillSimpleToolbar extends StatelessWidget
], ],
if (configurations.showSearchButton) ...[ if (configurations.showSearchButton) ...[
QuillToolbarSearchButton( QuillToolbarSearchButton(
controller: controller: toolbarConfigurations.buttonOptions.search.controller ??
toolbarConfigurations.buttonOptions.search.controller ??
globalController, globalController,
options: toolbarConfigurations.buttonOptions.search, options: toolbarConfigurations.buttonOptions.search,
), ),
@ -443,9 +421,48 @@ class QuillSimpleToolbar extends StatelessWidget
spacerWidget, spacerWidget,
], ],
]; ];
}
return QuillToolbarProvider(
toolbarConfigurations: configurations,
child: QuillToolbar(
configurations: QuillToolbarConfigurations(
buttonOptions: configurations.buttonOptions,
child: Builder(
builder: (context) {
if (configurations.multiRowsDisplay) {
return Wrap(
direction: configurations.axis,
alignment: configurations.toolbarIconAlignment,
crossAxisAlignment: configurations.toolbarIconCrossAlignment,
runSpacing: 4,
spacing: configurations.toolbarSectionSpacing,
children: childrenBuilder(context),
);
}
return Container(
decoration: configurations.decoration ??
BoxDecoration(
color:
configurations.color ?? Theme.of(context).canvasColor,
),
constraints: BoxConstraints.tightFor(
height: configurations.axis == Axis.horizontal
? configurations.toolbarSize
: null,
width: configurations.axis == Axis.vertical
? configurations.toolbarSize
: null,
),
child: QuillToolbarArrowIndicatedButtonList(
axis: configurations.axis,
buttons: childrenBuilder(context),
),
);
}, },
), ),
), ),
),
); );
} }
@ -454,3 +471,51 @@ class QuillSimpleToolbar extends StatelessWidget
? const Size.fromHeight(defaultToolbarSize) ? const Size.fromHeight(defaultToolbarSize)
: const Size.fromWidth(defaultToolbarSize); : const Size.fromWidth(defaultToolbarSize);
} }
/// The divider which is used for separation of buttons in the toolbar.
///
/// It can be used outside of this package, for example when user does not use
/// [QuillToolbar.basic] and compose toolbar's children on its own.
class QuillToolbarDivider extends StatelessWidget {
const QuillToolbarDivider(
this.axis, {
super.key,
this.color,
this.space,
});
/// Provides a horizontal divider for vertical toolbar.
const QuillToolbarDivider.horizontal({Key? key, Color? color, double? space})
: this(Axis.horizontal, color: color, space: space, key: key);
/// Provides a horizontal divider for horizontal toolbar.
const QuillToolbarDivider.vertical({Key? key, Color? color, double? space})
: this(Axis.vertical, color: color, space: space, key: key);
/// The axis along which the toolbar is.
final Axis axis;
/// The color to use when painting this divider's line.
final Color? color;
/// The divider's space (width or height) depending of [axis].
final double? space;
@override
Widget build(BuildContext context) {
// Vertical toolbar requires horizontal divider, and vice versa
return axis == Axis.vertical
? Divider(
height: space,
color: color,
indent: 12,
endIndent: 12,
)
: VerticalDivider(
width: space,
color: color,
indent: 12,
endIndent: 12,
);
}
}

@ -1 +1 @@
const version = '9.0.0-dev-4'; const version = '9.0.0-dev-5';

Loading…
Cancel
Save