Toolbar dividers fixes + Docs updates (#2071)

* Simple toolbar buttons + dividers fixes

* Simple toolbar buttons + dividers fixes

* readme update

* Toolbar buttons fix
pull/2074/head^2^2 v10.1.1
Raman Rasliuk 8 months ago committed by GitHub
parent 8589b856e8
commit e028ccf59e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      README.md
  2. 9
      flutter_quill_extensions/README.md
  3. 96
      lib/src/toolbar/simple_toolbar.dart

@ -94,7 +94,8 @@ dependencies:
```yaml
dependencies:
flutter_quill:
git: https://github.com/singerdmx/flutter-quill.git
git:
url: https://github.com/singerdmx/flutter-quill.git
ref: v<latest-version-here>
```

@ -50,9 +50,10 @@ dependencies:
```yaml
dependencies:
flutter_quill_extensions:
git: https://github.com/singerdmx/flutter-quill.git
path: flutter_quill_extensions
git:
url: https://github.com/singerdmx/flutter-quill.git
ref: v<latest-version-here>
path: flutter_quill_extensions
```
## 🛠 Platform Specific Configurations
@ -103,8 +104,8 @@ Set the `embedBuilders` and `embedToolbar` params in configurations of `QuillEdi
**Quill Toolbar**:
```dart
QuillToolbar(
configurations: QuillToolbarConfigurations(
QuillToolbar.simple(
configurations: QuillSimpleToolbarConfigurations(
embedButtons: FlutterQuillEmbeds.toolbarButtons(),
),
),

@ -23,34 +23,6 @@ class QuillSimpleToolbar extends StatelessWidget
Widget build(BuildContext context) {
final theEmbedButtons = configurations.embedButtons;
final isButtonGroupShown = [
configurations.showFontFamily ||
configurations.showFontSize ||
configurations.showBoldButton ||
configurations.showItalicButton ||
configurations.showSmallButton ||
configurations.showUnderLineButton ||
configurations.showLineHeightButton ||
configurations.showStrikeThrough ||
configurations.showInlineCode ||
configurations.showColorButton ||
configurations.showBackgroundColorButton ||
configurations.showClearFormat ||
theEmbedButtons?.isNotEmpty == true,
configurations.showLeftAlignment ||
configurations.showCenterAlignment ||
configurations.showRightAlignment ||
configurations.showJustifyAlignment ||
configurations.showDirection,
configurations.showHeaderStyle,
configurations.showListNumbers ||
configurations.showListBullets ||
configurations.showListCheck ||
configurations.showCodeBlock,
configurations.showQuote || configurations.showIndent,
configurations.showLink || configurations.showSearchButton
];
List<Widget> childrenBuilder(BuildContext context) {
final toolbarConfigurations =
context.requireQuillSimpleToolbarConfigurations;
@ -68,7 +40,8 @@ class QuillSimpleToolbar extends StatelessWidget
space: configurations.sectionDividerSpace,
));
return [
final groups = [
[
if (configurations.showUndo)
QuillToolbarHistoryButton(
isUndo: true,
@ -163,18 +136,13 @@ class QuillSimpleToolbar extends StatelessWidget
globalIconSize ?? kDefaultIconSize,
context.quillToolbarBaseButtonOptions?.iconTheme,
configurations.dialogTheme),
if (configurations.showDividers &&
isButtonGroupShown[0] &&
(isButtonGroupShown[1] ||
isButtonGroupShown[2] ||
isButtonGroupShown[3] ||
isButtonGroupShown[4] ||
isButtonGroupShown[5]))
divider,
],
[
if (configurations.showAlignmentButtons)
QuillToolbarSelectAlignmentButtons(
controller: globalController,
options: toolbarConfigurations.buttonOptions.selectAlignmentButtons
options: toolbarConfigurations
.buttonOptions.selectAlignmentButtons
.copyWith(
showLeftAlignment: configurations.showLeftAlignment,
showCenterAlignment: configurations.showCenterAlignment,
@ -188,13 +156,8 @@ class QuillSimpleToolbar extends StatelessWidget
options: toolbarConfigurations.buttonOptions.direction,
controller: globalController,
),
if (configurations.showDividers &&
isButtonGroupShown[1] &&
(isButtonGroupShown[2] ||
isButtonGroupShown[3] ||
isButtonGroupShown[4] ||
isButtonGroupShown[5]))
divider,
],
[
if (configurations.showLineHeightButton)
QuillToolbarSelectLineHeightStyleDropdownButton(
controller: globalController,
@ -211,17 +174,12 @@ class QuillSimpleToolbar extends StatelessWidget
else
QuillToolbarSelectHeaderStyleButtons(
controller: globalController,
options:
toolbarConfigurations.buttonOptions.selectHeaderStyleButtons,
options: toolbarConfigurations
.buttonOptions.selectHeaderStyleButtons,
),
],
if (configurations.showDividers &&
configurations.showHeaderStyle &&
isButtonGroupShown[2] &&
(isButtonGroupShown[3] ||
isButtonGroupShown[4] ||
isButtonGroupShown[5]))
divider,
],
[
if (configurations.showListNumbers)
QuillToolbarToggleStyleButton(
attribute: Attribute.ol,
@ -245,11 +203,8 @@ class QuillSimpleToolbar extends StatelessWidget
options: toolbarConfigurations.buttonOptions.codeBlock,
controller: globalController,
),
if (configurations.showDividers &&
isButtonGroupShown[3] &&
(isButtonGroupShown[4] || isButtonGroupShown[5])) ...[
divider,
],
[
if (configurations.showQuote)
QuillToolbarToggleStyleButton(
options: toolbarConfigurations.buttonOptions.quote,
@ -268,10 +223,8 @@ class QuillSimpleToolbar extends StatelessWidget
isIncrease: false,
options: toolbarConfigurations.buttonOptions.indentDecrease,
),
if (configurations.showDividers &&
isButtonGroupShown[4] &&
isButtonGroupShown[5])
divider,
],
[
if (configurations.showLink)
toolbarConfigurations.linkStyleType.isOriginal
? QuillToolbarLinkStyleButton(
@ -311,8 +264,8 @@ class QuillSimpleToolbar extends StatelessWidget
controller: globalController,
clipboardAction: ClipboardAction.paste,
),
if (configurations.customButtons.isNotEmpty) ...[
if (configurations.showDividers) divider,
],
[
for (final customButton in configurations.customButtons)
QuillToolbarCustomButton(
options: customButton,
@ -320,6 +273,21 @@ class QuillSimpleToolbar extends StatelessWidget
),
],
];
final buttonsAll = <Widget>[];
for (var i = 0; i < groups.length; i++) {
final buttons = groups[i];
if (buttons.isNotEmpty) {
if (buttonsAll.isNotEmpty) {
buttonsAll.add(divider);
}
buttonsAll.addAll(buttons);
}
}
return buttonsAll;
}
return QuillSimpleToolbarProvider(

Loading…
Cancel
Save