Skip to content

Commit

Permalink
Major update step 4 (#1454)
Browse files Browse the repository at this point in the history
  • Loading branch information
EchoEllet authored Oct 22, 2023
1 parent ac8c30d commit ee19189
Show file tree
Hide file tree
Showing 21 changed files with 947 additions and 371 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [7.8.0]
- **Important note**: this is not test release yet, it works but need more test and changes and breaking changes, we don't have development version and it will help us if you try the latest version and report the issues in Github but if you want a stable version please use `7.4.16`. this refactoring process will not take long and should be done less than three weeks with the testing.
- We managed to refactor most of the buttons configurations and customizations in the `QuillProvider`, only three lefts then will start on refactoring the toolbar configurations
- Code improvemenets

## [7.7.0]

- **Breaking change**: We have mirgrated more buttons in the toolbar configurations, you can do change them in the `QuillProvider`
Expand Down
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,37 @@ Pub: [FlutterQuill]

---

## Installation

```yaml
dependencies:
flutter_quill: ^<latest-version-here>
```
<p align="center">OR</p>
```yaml
dependencies:
flutter_quill:
git: https://github.com/singerdmx/flutter-quill.git
```
> **Important note**
>
> Currently, we're in the process of refactoring the library's configurations. We're actively working on this, and while we don't have a development version available at the moment, your feedback is essential to us.
>
> Using the latest version and reporting any issues you encounter on GitHub will greatly contribute to the improvement of the library. Your input and insights are valuable in shaping a stable and reliable version for all our users. Thank you for being part of the open-source community!
>
> if you want to use a more stable release, please use the followings:
>
> ```yaml
> flutter_quill: ^7.4.16
> flutter_quill_extensions: ^0.5.0
> ```
>
> instead of the latest version
>

## Usage

See the `example` directory for a minimal example of how to use FlutterQuill. You typically just need to instantiate a controller:
Expand Down
30 changes: 30 additions & 0 deletions lib/src/models/config/others/animations.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import 'package:equatable/equatable.dart';
import 'package:flutter/foundation.dart' show immutable;

import '../../../utils/experimental.dart';

@immutable
@Experimental('This class might removed')
class QuillAnimationConfigurations extends Equatable {
const QuillAnimationConfigurations({
required this.checkBoxPointItem,
});

factory QuillAnimationConfigurations.disableAll() =>
const QuillAnimationConfigurations(
checkBoxPointItem: false,
);

factory QuillAnimationConfigurations.enableAll() =>
const QuillAnimationConfigurations(
checkBoxPointItem: true,
);

/// This currently has issue which the whole checkbox list will rebuilt
/// and the animation will replay when some value changes
/// which is why disabled by default
final bool checkBoxPointItem;

@override
List<Object?> get props => [];
}
10 changes: 10 additions & 0 deletions lib/src/models/config/shared_configurations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart' show Color, Colors, Locale;
import './editor/configurations.dart' show QuillEditorConfigurations;
import './toolbar/configurations.dart' show QuillToolbarConfigurations;
import 'others/animations.dart';

export './others/animations.dart';

/// The shared configurations between [QuillEditorConfigurations] and
/// [QuillToolbarConfigurations] so we don't duplicate things
class QuillSharedConfigurations extends Equatable {
const QuillSharedConfigurations({
this.dialogBarrierColor = Colors.black54,
this.locale,
this.animationConfigurations = const QuillAnimationConfigurations(
checkBoxPointItem: false,
),
});

// This is just example or showcase of this major update to make the library
Expand All @@ -20,9 +26,13 @@ class QuillSharedConfigurations extends Equatable {
/// More https://github.com/singerdmx/flutter-quill#translation
final Locale? locale;

/// To configure which animations you want to be enabled
final QuillAnimationConfigurations animationConfigurations;

@override
List<Object?> get props => [
dialogBarrierColor,
locale,
animationConfigurations,
];
}
26 changes: 26 additions & 0 deletions lib/src/models/config/toolbar/buttons/clear_format.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import '../../quill_configurations.dart';

class QuillToolbarClearFormatButtonExtraOptions
extends QuillToolbarBaseButtonExtraOptions {
const QuillToolbarClearFormatButtonExtraOptions({
required super.controller,
required super.context,
required super.onPressed,
});
}

class QuillToolbarClearFormatButtonOptions
extends QuillToolbarBaseButtonOptions<QuillToolbarClearFormatButtonOptions,
QuillToolbarClearFormatButtonExtraOptions> {
const QuillToolbarClearFormatButtonOptions({
super.iconData,
super.afterButtonPressed,
super.childBuilder,
super.controller,
super.iconTheme,
super.tooltip,
this.iconSize,
});

final double? iconSize;
}
43 changes: 43 additions & 0 deletions lib/src/models/config/toolbar/buttons/color.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import 'package:flutter/widgets.dart' show Color;
import './../../shared_configurations.dart' show QuillSharedConfigurations;

import 'base.dart';

class QuillToolbarColorButtonExtraOptions
extends QuillToolbarBaseButtonExtraOptions {
const QuillToolbarColorButtonExtraOptions({
required super.controller,
required super.context,
required super.onPressed,
required this.iconColor,
required this.iconColorBackground,
required this.fillColor,
required this.fillColorBackground,
});

final Color? iconColor;
final Color? iconColorBackground;
final Color fillColor;
final Color fillColorBackground;
}

class QuillToolbarColorButtonOptions extends QuillToolbarBaseButtonOptions<
QuillToolbarColorButtonOptions, QuillToolbarColorButtonExtraOptions> {
const QuillToolbarColorButtonOptions({
this.dialogBarrierColor,
this.iconSize,
super.iconData,
super.afterButtonPressed,
super.childBuilder,
super.controller,
super.globalIconSize,
super.iconTheme,
super.tooltip,
});

final double? iconSize;

/// By default will use the default `dialogBarrierColor` from
/// [QuillSharedConfigurations]
final Color? dialogBarrierColor;
}
27 changes: 27 additions & 0 deletions lib/src/models/config/toolbar/buttons/indent.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import 'package:flutter/foundation.dart';

import 'base.dart';

class QuillToolbarIndentButtonExtraOptions
extends QuillToolbarBaseButtonExtraOptions {
const QuillToolbarIndentButtonExtraOptions({
required super.controller,
required super.context,
required super.onPressed,
});
}

@immutable
class QuillToolbarIndentButtonOptions extends QuillToolbarBaseButtonOptions {
const QuillToolbarIndentButtonOptions({
super.iconData,
super.afterButtonPressed,
super.childBuilder,
super.controller,
super.iconTheme,
super.tooltip,
this.iconSize,
});

final double? iconSize;
}
58 changes: 58 additions & 0 deletions lib/src/models/config/toolbar/buttons/select_alignment.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import 'package:flutter/widgets.dart' show IconData, immutable;
import 'base.dart';

class QuillToolbarSelectAlignmentButtonExtraOptions
extends QuillToolbarBaseButtonExtraOptions {
const QuillToolbarSelectAlignmentButtonExtraOptions({
required super.controller,
required super.context,
required super.onPressed,
});
}

class QuillToolbarSelectAlignmentButtonOptions
extends QuillToolbarBaseButtonOptions<
QuillToolbarSelectAlignmentButtonOptions,
QuillToolbarBaseButtonExtraOptions> {
const QuillToolbarSelectAlignmentButtonOptions({
this.iconsData,
this.tooltips,
this.iconSize,
super.afterButtonPressed,
super.childBuilder,
super.controller,
super.iconTheme,
});
final double? iconSize;

/// Default to
/// const QuillToolbarSelectAlignmentValues(
/// leftAlignment: Icons.format_align_left,
/// centerAlignment: Icons.format_align_center,
/// rightAlignment: Icons.format_align_right,
/// justifyAlignment: Icons.format_align_justify,
/// )
final QuillSelectAlignmentValues<IconData>? iconsData;

/// By default will use the localized tooltips
final QuillSelectAlignmentValues<String>? tooltips;
}

/// A helper class which hold all the values for the alignments of the
/// [QuillToolbarSelectAlignmentButtonOptions]
/// it's not really related to the toolbar so we called it just Quill without
/// toolbar but the name might change in the future
@immutable
class QuillSelectAlignmentValues<T> {
const QuillSelectAlignmentValues({
required this.leftAlignment,
required this.centerAlignment,
required this.rightAlignment,
required this.justifyAlignment,
});

final T leftAlignment;
final T centerAlignment;
final T rightAlignment;
final T justifyAlignment;
}
46 changes: 46 additions & 0 deletions lib/src/models/config/toolbar/buttons/toggle_check_list.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import 'package:flutter/foundation.dart' show immutable;
import 'package:flutter/widgets.dart' show Color;

import '../../../documents/attribute.dart';
import '../../quill_configurations.dart';

class QuillToolbarToggleCheckListButtonExtraOptions
extends QuillToolbarBaseButtonExtraOptions {
const QuillToolbarToggleCheckListButtonExtraOptions({
required super.controller,
required super.context,
required super.onPressed,
this.isToggled = false,
});
final bool isToggled;
}

@immutable
class QuillToolbarToggleCheckListButtonOptions
extends QuillToolbarBaseButtonOptions<
QuillToolbarToggleCheckListButtonOptions,
QuillToolbarToggleCheckListButtonExtraOptions> {
const QuillToolbarToggleCheckListButtonOptions({
this.iconSize,
this.fillColor,
this.attribute = Attribute.unchecked,
this.isShouldRequestKeyboard = false,
super.controller,
super.iconTheme,
super.tooltip,
super.iconData,
super.afterButtonPressed,
super.childBuilder,
});

final double? iconSize;

final Color? fillColor;

final Attribute attribute;

/// Should we request the keyboard when you press the toggle check list button
/// ? if true then we will request the keyboard, if false then we will not
/// but I think you already know that
final bool isShouldRequestKeyboard;
}
29 changes: 29 additions & 0 deletions lib/src/models/config/toolbar/configurations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,24 @@ import 'package:equatable/equatable.dart';
import 'package:flutter/foundation.dart' show immutable;

import 'buttons/base.dart';
import 'buttons/clear_format.dart';
import 'buttons/color.dart';
import 'buttons/font_family.dart';
import 'buttons/font_size.dart';
import 'buttons/history.dart';
import 'buttons/indent.dart';
import 'buttons/select_alignment.dart';
import 'buttons/toggle_check_list.dart';
import 'buttons/toggle_style.dart';

export './buttons/base.dart';
export './buttons/clear_format.dart';
export './buttons/color.dart';
export './buttons/font_family.dart';
export './buttons/font_size.dart';
export './buttons/history.dart';
export './buttons/select_alignment.dart';
export './buttons/toggle_check_list.dart';
export './buttons/toggle_style.dart';

/// The default size of the icon of a button.
Expand Down Expand Up @@ -120,6 +129,14 @@ class QuillToolbarButtonOptions extends Equatable {
this.listBullets = const QuillToolbarToggleStyleButtonOptions(),
this.codeBlock = const QuillToolbarToggleStyleButtonOptions(),
this.quote = const QuillToolbarToggleStyleButtonOptions(),
this.toggleCheckList = const QuillToolbarToggleCheckListButtonOptions(),
this.indentIncrease = const QuillToolbarIndentButtonOptions(),
this.indentDecrease = const QuillToolbarIndentButtonOptions(),
this.color = const QuillToolbarColorButtonOptions(),
this.backgroundColor = const QuillToolbarColorButtonOptions(),
this.clearFormat = const QuillToolbarClearFormatButtonOptions(),
this.selectAlignmentButtons =
const QuillToolbarSelectAlignmentButtonOptions(),
});

/// The base configurations for all the buttons which will apply to all
Expand All @@ -143,6 +160,18 @@ class QuillToolbarButtonOptions extends Equatable {
final QuillToolbarToggleStyleButtonOptions listBullets;
final QuillToolbarToggleStyleButtonOptions codeBlock;
final QuillToolbarToggleStyleButtonOptions quote;
final QuillToolbarToggleCheckListButtonOptions toggleCheckList;
final QuillToolbarIndentButtonOptions indentIncrease;
final QuillToolbarIndentButtonOptions indentDecrease;
final QuillToolbarColorButtonOptions color;
final QuillToolbarColorButtonOptions backgroundColor;
final QuillToolbarClearFormatButtonOptions clearFormat;

/// The reason we call this buttons in the end because this is responsible
/// for all the alignment buttons and not just one, you still
/// can customize the icons and tooltips
/// and you have child builder
final QuillToolbarSelectAlignmentButtonOptions selectAlignmentButtons;

@override
List<Object?> get props => [
Expand Down
7 changes: 7 additions & 0 deletions lib/src/utils/experimental.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import 'package:flutter/foundation.dart' show immutable;

@immutable
class Experimental {
const Experimental([this.reason = 'Experimental feature']);
final String reason;
}
Loading

0 comments on commit ee19189

Please sign in to comment.