Rename QuillCustomIcon to QuillCustomButton

pull/882/head
X Code 3 years ago
parent dd469176ed
commit 14f8866528
  1. 18
      README.md
  2. 2
      lib/flutter_quill.dart
  3. 4
      lib/src/models/themes/quill_custom_button.dart
  4. 20
      lib/src/widgets/toolbar.dart

@ -112,12 +112,12 @@ fontSizeValues: const {'Small': '8', 'Medium': '24.5', 'Large': '46', 'Clear': '
### Font Family ### Font Family
To use your own fonts, update your [assets folder](https://github.com/singerdmx/flutter-quill/tree/master/example/assets/fonts) and pass in `fontFamilyValues`. More details at [this change](https://github.com/singerdmx/flutter-quill/commit/71d06f6b7be1b7b6dba2ea48e09fed0d7ff8bbaa), [this article](https://stackoverflow.com/questions/55075834/fontfamily-property-not-working-properly-in-flutter) and [this](https://www.flutterbeads.com/change-font-family-flutter/). To use your own fonts, update your [assets folder](https://github.com/singerdmx/flutter-quill/tree/master/example/assets/fonts) and pass in `fontFamilyValues`. More details at [this change](https://github.com/singerdmx/flutter-quill/commit/71d06f6b7be1b7b6dba2ea48e09fed0d7ff8bbaa), [this article](https://stackoverflow.com/questions/55075834/fontfamily-property-not-working-properly-in-flutter) and [this](https://www.flutterbeads.com/change-font-family-flutter/).
### Custom Icons ### Custom Buttons
You may add custom icons to the _end_ of the toolbar, via the `customIcons` option, which is a `List` of `QuillCustomIcon`. You may add custom buttons to the _end_ of the toolbar, via the `customButtons` option, which is a `List` of `QuillCustomButton`.
To add an Icon, we should use a new QuillCustomIcon class To add an Icon, we should use a new QuillCustomButton class
``` ```
QuillCustomIcon( QuillCustomButton(
icon:Icons.ac_unit, icon:Icons.ac_unit,
onTap: () { onTap: () {
debugPrint('snowflake'); debugPrint('snowflake');
@ -125,26 +125,26 @@ To add an Icon, we should use a new QuillCustomIcon class
), ),
``` ```
Each `QuillCustomIcon` is used as part of the `customIcons` option as follows: Each `QuillCustomButton` is used as part of the `customButtons` option as follows:
``` ```
QuillToolbar.basic( QuillToolbar.basic(
(...), (...),
customIcons: [ customButtons: [
QuillCustomIcon( QuillCustomButton(
icon:Icons.ac_unit, icon:Icons.ac_unit,
onTap: () { onTap: () {
debugPrint('snowflake1'); debugPrint('snowflake1');
} }
), ),
QuillCustomIcon( QuillCustomButton(
icon:Icons.ac_unit, icon:Icons.ac_unit,
onTap: () { onTap: () {
debugPrint('snowflake2'); debugPrint('snowflake2');
} }
), ),
QuillCustomIcon( QuillCustomButton(
icon:Icons.ac_unit, icon:Icons.ac_unit,
onTap: () { onTap: () {
debugPrint('snowflake3'); debugPrint('snowflake3');

@ -6,7 +6,7 @@ export 'src/models/documents/nodes/embeddable.dart';
export 'src/models/documents/nodes/leaf.dart'; export 'src/models/documents/nodes/leaf.dart';
export 'src/models/documents/style.dart'; export 'src/models/documents/style.dart';
export 'src/models/quill_delta.dart'; export 'src/models/quill_delta.dart';
export 'src/models/themes/quill_custom_icon.dart'; export 'src/models/themes/quill_custom_button.dart';
export 'src/models/themes/quill_dialog_theme.dart'; export 'src/models/themes/quill_dialog_theme.dart';
export 'src/models/themes/quill_icon_theme.dart'; export 'src/models/themes/quill_icon_theme.dart';
export 'src/utils/embeds.dart'; export 'src/utils/embeds.dart';

@ -1,7 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class QuillCustomIcon { class QuillCustomButton {
const QuillCustomIcon({this.icon, this.onTap}); const QuillCustomButton({this.icon, this.onTap});
///The icon widget ///The icon widget
final IconData? icon; final IconData? icon;

@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
import 'package:i18n_extension/i18n_widget.dart'; import 'package:i18n_extension/i18n_widget.dart';
import '../models/documents/attribute.dart'; import '../models/documents/attribute.dart';
import '../models/themes/quill_custom_icon.dart'; import '../models/themes/quill_custom_button.dart';
import '../models/themes/quill_dialog_theme.dart'; import '../models/themes/quill_dialog_theme.dart';
import '../models/themes/quill_icon_theme.dart'; import '../models/themes/quill_icon_theme.dart';
import '../translations/toolbar.i18n.dart'; import '../translations/toolbar.i18n.dart';
@ -68,7 +68,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget {
this.multiRowsDisplay = true, this.multiRowsDisplay = true,
this.color, this.color,
this.filePickImpl, this.filePickImpl,
this.customIcons = const [], this.customButtons = const [],
this.locale, this.locale,
Key? key, Key? key,
}) : super(key: key); }) : super(key: key);
@ -116,7 +116,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget {
FilePickImpl? filePickImpl, FilePickImpl? filePickImpl,
WebImagePickImpl? webImagePickImpl, WebImagePickImpl? webImagePickImpl,
WebVideoPickImpl? webVideoPickImpl, WebVideoPickImpl? webVideoPickImpl,
List<QuillCustomIcon> customIcons = const [], List<QuillCustomButton> customButtons = const [],
///Map of font sizes in string ///Map of font sizes in string
Map<String, String>? fontSizeValues, Map<String, String>? fontSizeValues,
@ -185,7 +185,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget {
toolbarSectionSpacing: toolbarSectionSpacing, toolbarSectionSpacing: toolbarSectionSpacing,
toolbarIconAlignment: toolbarIconAlignment, toolbarIconAlignment: toolbarIconAlignment,
multiRowsDisplay: multiRowsDisplay, multiRowsDisplay: multiRowsDisplay,
customIcons: customIcons, customButtons: customButtons,
locale: locale, locale: locale,
children: [ children: [
if (showUndo) if (showUndo)
@ -492,21 +492,21 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget {
iconTheme: iconTheme, iconTheme: iconTheme,
dialogTheme: dialogTheme, dialogTheme: dialogTheme,
), ),
if (customIcons.isNotEmpty) if (customButtons.isNotEmpty)
if (showDividers) if (showDividers)
VerticalDivider( VerticalDivider(
indent: 12, indent: 12,
endIndent: 12, endIndent: 12,
color: Colors.grey.shade400, color: Colors.grey.shade400,
), ),
for (var customIcon in customIcons) for (var customButton in customButtons)
QuillIconButton( QuillIconButton(
highlightElevation: 0, highlightElevation: 0,
hoverElevation: 0, hoverElevation: 0,
size: toolbarIconSize * kIconButtonFactor, size: toolbarIconSize * kIconButtonFactor,
icon: Icon(customIcon.icon, size: toolbarIconSize), icon: Icon(customButton.icon, size: toolbarIconSize),
borderRadius: iconTheme?.borderRadius ?? 2, borderRadius: iconTheme?.borderRadius ?? 2,
onPressed: customIcon.onTap), onPressed: customButton.onTap),
], ],
); );
} }
@ -529,8 +529,8 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget {
/// More https://github.com/singerdmx/flutter-quill#translation /// More https://github.com/singerdmx/flutter-quill#translation
final Locale? locale; final Locale? locale;
/// List of custom icons /// List of custom buttons
final List<QuillCustomIcon> customIcons; final List<QuillCustomButton> customButtons;
@override @override
Size get preferredSize => Size.fromHeight(toolbarHeight); Size get preferredSize => Size.fromHeight(toolbarHeight);

Loading…
Cancel
Save