Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Enable BoxDecoration for DefaultTextBlockStyle of header Attribute #2438

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

satotoshitaka11
Copy link

Description

Add support for BoxDecoration in DefaultTextBlockStyle for the header attribute. This allows developers to customize headers with borders, background colors, and other styles. Related to #2428.

Related Issues

Type of Change

  • Feature: New functionality without breaking existing features.
  • 🛠️ Bug fix: Resolves an issue without altering current behavior.
  • 🧹 Refactor: Code reorganization, no behavior change.
  • Breaking: Alters existing functionality and requires updates.
  • 🧪 Tests: New or modified tests
  • 📝 Documentation: Updates or additions to documentation.
  • 🗑️ Chore: Routine tasks, or maintenance.
  • Build configuration change: Build/configuration changes.

Copy link
Collaborator

@EchoEllet EchoEllet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution.

Unfortunately, we can't accept PRs that change too much to add new features as explained in the contributing guide, mainly because we have too many issues, and regressions and we don't have a good coverage.

Comment on lines +177 to +183
line,
_buildLeading(
context: context,
line: line,
index: index,
indentLevelCounts: indentLevelCounts,
count: count,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you minimize the changes and remove any formatting or changes that not related to this functionality, reverting the changes to the example and sample data json, mainly because we want a cleaner commit history that's organized and also to avoid any possible regressions.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@EchoEllet
thank you for your review.

I have fixed

4eb8652

Comment on lines 149 to 204
customStyles: DefaultStyles(
h1: DefaultTextBlockStyle(
DefaultTextStyle.of(context).style.copyWith(
fontSize: 34,
color: DefaultTextStyle.of(context).style.color,
letterSpacing: -0.5,
height: 1.083,
fontWeight: FontWeight.bold,
decoration: TextDecoration.none,
),
HorizontalSpacing(16, 16),
const VerticalSpacing(16, 16),
VerticalSpacing.zero,
BoxDecoration(
border: Border.all(
width: 3,
color: Colors.red,
),
)),
h2: DefaultTextBlockStyle(
DefaultTextStyle.of(context).style.copyWith(
fontSize: 30,
color: DefaultTextStyle.of(context).style.color,
letterSpacing: -0.8,
height: 1.067,
fontWeight: FontWeight.bold,
decoration: TextDecoration.none,
),
HorizontalSpacing(8, 8),
const VerticalSpacing(8, 8),
VerticalSpacing.zero,
BoxDecoration(
border: Border.all(
width: 3,
color: Colors.blue,
),
)),
h3: DefaultTextBlockStyle(
DefaultTextStyle.of(context).style.copyWith(
fontSize: 24,
color: DefaultTextStyle.of(context).style.color,
letterSpacing: -0.5,
height: 1.083,
fontWeight: FontWeight.bold,
decoration: TextDecoration.none,
),
HorizontalSpacing(8, 8),
const VerticalSpacing(8, 8),
VerticalSpacing.zero,
BoxDecoration(
border: Border.all(
width: 3,
color: Colors.green,
),
)),
),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example should be minimal without much configuration.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@EchoEllet
thank you for your review.

I have fixed
d9c6a7b

@@ -9,6 +9,7 @@ const kQuillDefaultSample = [
'style': 'width:500px; height:350px;'
}
},
{"insert": "\n"},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be reverted as it's unrelated.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@EchoEllet
thank you for your review.

I have fixed
d9c6a7b

color: Colors.blue,
),
)),
),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example should not be edited and remain minimal, we don't want to use all features with complex code in the example, it's confusing and doesn't help users to get started by documenting all possible features without much organization, we did this with the previous example, instead any code snippets sample should be somewhere else (other than README.md, like in the doc directory).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reverted the file.

7ac5d93
edd05bc

Comment on lines 1304 to 1306
if (decoration != null) {
final paintRect = offset & size;
decoration!.createBoxPainter().paint(
Copy link
Collaborator

@EchoEllet EchoEllet Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid using the null assertion operator (!), instead:

fix boxDecoration = decoration;
if (boxDecoration != null) {
  boxDecoration.createBoxPainter();
// ...
}

Our codebase extensively uses this and we're trying to avoid it for future code.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@EchoEllet
I have fixed it.

45e8551

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants