Skip to content

Commit

Permalink
ref: add VerticalSpacing.zero and HorizontalSpacing.zero named co…
Browse files Browse the repository at this point in the history
…nstants (#2083)

* feat: add named constants to HorizontalSpacing/VerticalSpacing

* ref: use VerticalSpacing.zero across code
  • Loading branch information
adil192 authored Aug 1, 2024
1 parent 9a7421a commit e11af21
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 27 deletions.
4 changes: 2 additions & 2 deletions example/lib/screens/quill/my_quill_editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ class MyQuillEditor extends StatelessWidget {
height: 1.15,
fontWeight: FontWeight.w300,
),
const HorizontalSpacing(0, 0),
HorizontalSpacing.zero,
const VerticalSpacing(16, 0),
const VerticalSpacing(0, 0),
VerticalSpacing.zero,
null,
),
sizeSmall: defaultTextStyle.style.copyWith(fontSize: 9),
Expand Down
2 changes: 2 additions & 0 deletions lib/src/common/structs/horizontal_spacing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ class HorizontalSpacing {

final double left;
final double right;

static const zero = HorizontalSpacing(0, 0);
}
2 changes: 2 additions & 0 deletions lib/src/common/structs/vertical_spacing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ class VerticalSpacing {

final double top;
final double bottom;

static const zero = VerticalSpacing(0, 0);
}
4 changes: 2 additions & 2 deletions lib/src/editor/raw_editor/raw_editor_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,7 @@ class QuillRawEditorState extends EditorState
} else if (attrs.containsKey(Attribute.align.key)) {
return defaultStyles!.align!.horizontalSpacing;
}
return const HorizontalSpacing(0, 0);
return HorizontalSpacing.zero;
}

VerticalSpacing _getVerticalSpacingForBlock(
Expand All @@ -1162,7 +1162,7 @@ class QuillRawEditorState extends EditorState
} else if (attrs.containsKey(Attribute.align.key)) {
return defaultStyles!.align!.verticalSpacing;
}
return const VerticalSpacing(0, 0);
return VerticalSpacing.zero;
}

void _didChangeTextEditingValueListener() {
Expand Down
46 changes: 23 additions & 23 deletions lib/src/editor/widgets/default_styles.dart
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ class DefaultStyles {
),
baseHorizontalSpacing,
const VerticalSpacing(16, 0),
const VerticalSpacing(0, 0),
VerticalSpacing.zero,
null),
h2: DefaultTextBlockStyle(
defaultTextStyle.style.copyWith(
Expand All @@ -284,7 +284,7 @@ class DefaultStyles {
),
baseHorizontalSpacing,
const VerticalSpacing(8, 0),
const VerticalSpacing(0, 0),
VerticalSpacing.zero,
null),
h3: DefaultTextBlockStyle(
defaultTextStyle.style.copyWith(
Expand All @@ -297,7 +297,7 @@ class DefaultStyles {
),
baseHorizontalSpacing,
const VerticalSpacing(8, 0),
const VerticalSpacing(0, 0),
VerticalSpacing.zero,
null,
),
h4: DefaultTextBlockStyle(
Expand All @@ -311,7 +311,7 @@ class DefaultStyles {
),
baseHorizontalSpacing,
const VerticalSpacing(6, 0),
const VerticalSpacing(0, 0),
VerticalSpacing.zero,
null,
),
h5: DefaultTextBlockStyle(
Expand All @@ -325,7 +325,7 @@ class DefaultStyles {
),
baseHorizontalSpacing,
const VerticalSpacing(6, 0),
const VerticalSpacing(0, 0),
VerticalSpacing.zero,
null,
),
h6: DefaultTextBlockStyle(
Expand All @@ -339,42 +339,42 @@ class DefaultStyles {
),
baseHorizontalSpacing,
const VerticalSpacing(4, 0),
const VerticalSpacing(0, 0),
VerticalSpacing.zero,
null,
),
lineHeightNormal: DefaultTextBlockStyle(
baseStyle.copyWith(height: 1.15),
baseHorizontalSpacing,
const VerticalSpacing(0, 0),
const VerticalSpacing(0, 0),
VerticalSpacing.zero,
VerticalSpacing.zero,
null,
),
lineHeightTight: DefaultTextBlockStyle(
baseStyle.copyWith(height: 1.30),
baseHorizontalSpacing,
const VerticalSpacing(0, 0),
const VerticalSpacing(0, 0),
VerticalSpacing.zero,
VerticalSpacing.zero,
null,
),
lineHeightOneAndHalf: DefaultTextBlockStyle(
baseStyle.copyWith(height: 1.55),
baseHorizontalSpacing,
const VerticalSpacing(0, 0),
const VerticalSpacing(0, 0),
VerticalSpacing.zero,
VerticalSpacing.zero,
null,
),
lineHeightDouble: DefaultTextBlockStyle(
baseStyle.copyWith(height: 2),
baseHorizontalSpacing,
const VerticalSpacing(0, 0),
const VerticalSpacing(0, 0),
VerticalSpacing.zero,
VerticalSpacing.zero,
null,
),
paragraph: DefaultTextBlockStyle(
baseStyle,
baseHorizontalSpacing,
const VerticalSpacing(0, 0),
const VerticalSpacing(0, 0),
VerticalSpacing.zero,
VerticalSpacing.zero,
null,
),
bold: const TextStyle(fontWeight: FontWeight.bold),
Expand Down Expand Up @@ -422,8 +422,8 @@ class DefaultStyles {
color: Colors.grey.withOpacity(0.6),
),
baseHorizontalSpacing,
const VerticalSpacing(0, 0),
const VerticalSpacing(0, 0),
VerticalSpacing.zero,
VerticalSpacing.zero,
null),
lists: DefaultListBlockStyle(
baseStyle,
Expand Down Expand Up @@ -453,7 +453,7 @@ class DefaultStyles {
),
baseHorizontalSpacing,
baseVerticalSpacing,
const VerticalSpacing(0, 0),
VerticalSpacing.zero,
BoxDecoration(
color: Colors.grey.shade50,
borderRadius: BorderRadius.circular(2),
Expand All @@ -468,15 +468,15 @@ class DefaultStyles {
align: DefaultTextBlockStyle(
baseStyle,
baseHorizontalSpacing,
const VerticalSpacing(0, 0),
const VerticalSpacing(0, 0),
VerticalSpacing.zero,
VerticalSpacing.zero,
null,
),
leading: DefaultTextBlockStyle(
baseStyle,
baseHorizontalSpacing,
const VerticalSpacing(0, 0),
const VerticalSpacing(0, 0),
VerticalSpacing.zero,
VerticalSpacing.zero,
null,
),
sizeSmall: const TextStyle(fontSize: 10),
Expand Down

0 comments on commit e11af21

Please sign in to comment.