Skip to content

Commit

Permalink
4
Browse files Browse the repository at this point in the history
  • Loading branch information
Ellet committed Dec 6, 2023
1 parent 0c4c6cd commit 9727fea
Show file tree
Hide file tree
Showing 11 changed files with 593 additions and 613 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@

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
* 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`
* 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
* Breaking Changes:
Expand Down
1 change: 0 additions & 1 deletion example/lib/presentation/quill/quill_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ class _QuillScreenState extends State<QuillScreen> {
MyQuillToolbar(
controller: _controller,
focusNode: _editorFocusNode,
sharedConfigurations: _sharedConfigurations,
),
Builder(
builder: (context) {
Expand Down
188 changes: 93 additions & 95 deletions example/lib/presentation/quill/quill_toolbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,11 @@ class MyQuillToolbar extends StatelessWidget {
const MyQuillToolbar({
required this.controller,
required this.focusNode,
required this.sharedConfigurations,
super.key,
});

final QuillController controller;
final FocusNode focusNode;
// TODO: Use it
final QuillSharedConfigurations sharedConfigurations;

Future<void> onImageInsertWithCropping(
String image,
Expand Down Expand Up @@ -104,105 +101,106 @@ class MyQuillToolbar extends StatelessWidget {
// https://github.com/singerdmx/flutter-quill/blob/master/doc/custom_toolbar.md
return QuillToolbar(
configurations: QuillToolbarConfigurations(
toolbarSize: 20 * 2,
multiRowsDisplay: false,
buttonOptions: const QuillToolbarButtonOptions(
base: QuillToolbarBaseButtonOptions(
globalIconSize: 20,
globalIconButtonFactor: 1.4,
),
),
childrenBuilder: (context) {
return [
IconButton(
onPressed: () => context
.read<SettingsCubit>()
.updateSettings(
state.copyWith(useCustomQuillToolbar: false)),
icon: const Icon(
Icons.width_normal,
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: [
IconButton(
onPressed: () => context
.read<SettingsCubit>()
.updateSettings(
state.copyWith(useCustomQuillToolbar: false)),
icon: const Icon(
Icons.width_normal,
),
),
),
QuillToolbarHistoryButton(
isUndo: true,
controller: controller,
),
QuillToolbarHistoryButton(
isUndo: false,
controller: controller,
),
QuillToolbarToggleStyleButton(
options: const QuillToolbarToggleStyleButtonOptions(),
controller: controller,
attribute: Attribute.bold,
),
QuillToolbarToggleStyleButton(
options: const QuillToolbarToggleStyleButtonOptions(),
controller: controller,
attribute: Attribute.italic,
),
QuillToolbarToggleStyleButton(
controller: controller,
attribute: Attribute.underline,
),
QuillToolbarClearFormatButton(
controller: controller,
),
const VerticalDivider(),
QuillToolbarImageButton(
controller: controller,
),
QuillToolbarCameraButton(
controller: controller,
),
QuillToolbarVideoButton(
controller: controller,
),
const VerticalDivider(),
QuillToolbarColorButton(
controller: controller,
isBackground: false,
),
QuillToolbarColorButton(
controller: controller,
isBackground: true,
),
const VerticalDivider(),
QuillToolbarSelectHeaderStyleButton(
controller: controller,
),
const VerticalDivider(),
QuillToolbarToggleCheckListButton(
controller: controller,
),
QuillToolbarToggleStyleButton(
controller: controller,
attribute: Attribute.list,
),
QuillToolbarToggleStyleButton(
controller: controller,
attribute: Attribute.ul,
),
QuillToolbarToggleStyleButton(
controller: controller,
attribute: Attribute.inlineCode,
),
QuillToolbarToggleStyleButton(
controller: controller,
attribute: Attribute.blockQuote,
),
QuillToolbarIndentButton(
controller: controller,
isIncrease: true,
),
QuillToolbarIndentButton(
controller: controller,
isIncrease: false,
),
const VerticalDivider(),
QuillToolbarLinkStyleButton(controller: controller),
];
},
QuillToolbarHistoryButton(
isUndo: true,
controller: controller,
),
QuillToolbarHistoryButton(
isUndo: false,
controller: controller,
),
QuillToolbarToggleStyleButton(
options: const QuillToolbarToggleStyleButtonOptions(),
controller: controller,
attribute: Attribute.bold,
),
QuillToolbarToggleStyleButton(
options: const QuillToolbarToggleStyleButtonOptions(),
controller: controller,
attribute: Attribute.italic,
),
QuillToolbarToggleStyleButton(
controller: controller,
attribute: Attribute.underline,
),
QuillToolbarClearFormatButton(
controller: controller,
),
const VerticalDivider(),
QuillToolbarImageButton(
controller: controller,
),
QuillToolbarCameraButton(
controller: controller,
),
QuillToolbarVideoButton(
controller: controller,
),
const VerticalDivider(),
QuillToolbarColorButton(
controller: controller,
isBackground: false,
),
QuillToolbarColorButton(
controller: controller,
isBackground: true,
),
const VerticalDivider(),
QuillToolbarSelectHeaderStyleButton(
controller: controller,
),
const VerticalDivider(),
QuillToolbarToggleCheckListButton(
controller: controller,
),
QuillToolbarToggleStyleButton(
controller: controller,
attribute: Attribute.ol,
),
QuillToolbarToggleStyleButton(
controller: controller,
attribute: Attribute.ul,
),
QuillToolbarToggleStyleButton(
controller: controller,
attribute: Attribute.inlineCode,
),
QuillToolbarToggleStyleButton(
controller: controller,
attribute: Attribute.blockQuote,
),
QuillToolbarIndentButton(
controller: controller,
isIncrease: true,
),
QuillToolbarIndentButton(
controller: controller,
isIncrease: false,
),
const VerticalDivider(),
QuillToolbarLinkStyleButton(controller: controller),
],
),
),
),
);
}
Expand Down
2 changes: 0 additions & 2 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ dependencies:
cross_file: ^0.3.3+6
cached_network_image: ^3.3.0

gal_linux: ^0.0.1-dev

# Bloc libraries
bloc: ^8.1.2
flutter_bloc: ^8.1.3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,8 @@ class QuillToolbarCameraButton extends StatelessWidget {
if (customCallback != null) {
return await customCallback(context);
}
final cameraAction = await showDialog<CameraAction>(
final cameraAction = await showSelectCameraActionDialog(
context: context,
builder: (ctx) => const FlutterQuillLocalizationsWidget(
child: SelectCameraActionDialog()),
);

return cameraAction;
Expand Down Expand Up @@ -171,12 +169,5 @@ class QuillToolbarCameraButton extends StatelessWidget {
await options.cameraConfigurations.onImageInsertedCallback
?.call(imageFile.path);
}

// final file = await switch (cameraAction) {
// CameraAction.image =>
// imagePickerService.pickImage(source: ImageSource.camera),
// CameraAction.video =>
// imagePickerService.pickVideo(source: ImageSource.camera),
// };
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_quill/extensions.dart';
import 'package:flutter_quill/translations.dart';

import 'camera_types.dart';
Expand All @@ -8,27 +9,46 @@ class SelectCameraActionDialog extends StatelessWidget {

@override
Widget build(BuildContext context) {
return AlertDialog(
contentPadding: EdgeInsets.zero,
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
TextButton.icon(
icon: const Icon(
Icons.camera,
return SizedBox(
height: 150,
width: double.infinity,
child: SingleChildScrollView(
child: Column(
children: [
ListTile(
title: Text(context.loc.photo),
subtitle: Text(
context.loc.takeAPhotoUsingYourCamera,
),
leading: const Icon(Icons.photo_sharp),
enabled: !isDesktop(supportWeb: false),
onTap: () => Navigator.of(context).pop(CameraAction.image),
),
label: Text(context.loc.photo),
onPressed: () => Navigator.pop(context, CameraAction.image),
),
TextButton.icon(
icon: const Icon(
Icons.video_call,
ListTile(
title: Text(context.loc.video),
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;
}
1 change: 1 addition & 0 deletions flutter_quill_extensions/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ dependencies:
url_launcher: ^6.2.1
super_clipboard: ^0.7.3
gal: ^2.1.3
gal_linux: ^0.0.1-dev-3
image_picker: ^1.0.4

dev_dependencies:
Expand Down
26 changes: 4 additions & 22 deletions lib/src/models/config/toolbar/toolbar_configurations.dart
Original file line number Diff line number Diff line change
@@ -1,41 +1,23 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'package:flutter/widgets.dart'
show Axis, WrapAlignment, WrapCrossAlignment, immutable;
show Axis, Widget, WrapAlignment, WrapCrossAlignment, immutable;

import '../../../widgets/toolbar/base_toolbar.dart';
import 'toolbar_shared_configurations.dart';

@immutable
class QuillToolbarConfigurations extends QuillSharedToolbarProperties {
const QuillToolbarConfigurations({
this.childrenBuilder,
super.axis = Axis.horizontal,
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,
required this.child,
super.sharedConfigurations,

/// Note this only used when you using the quill toolbar buttons like
/// `QuillToolbarHistoryButton` inside it
super.buttonOptions = const QuillToolbarButtonOptions(),
});

final QuillBaseToolbarChildrenBuilder? childrenBuilder;
final Widget child;

@override
List<Object?> get props => [];

QuillToolbarConfigurations copyWith({
QuillBaseToolbarChildrenBuilder? childrenBuilder,
}) {
return QuillToolbarConfigurations(
childrenBuilder: childrenBuilder ?? this.childrenBuilder,
);
}
}
Loading

0 comments on commit 9727fea

Please sign in to comment.