refactor: remove flutter_highlight dependency and enhance code block styling

- Removed flutter_highlight as a dependency to streamline the codebase.
- Updated CodeBlockHeader to improve styling based on the current theme, enhancing visual consistency.
- Adjusted code block background and text colors to match GitHub/Atom themes for better readability.
- Refactored markdown processing logic to eliminate reliance on deprecated highlight features, improving maintainability.
This commit is contained in:
cogwheel0
2025-10-04 23:31:42 +05:30
parent a4319a1d9e
commit f4e4e86c38
5 changed files with 77 additions and 110 deletions

View File

@@ -14,16 +14,30 @@ class CodeBlockHeader extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = context.conduitTheme;
final label = language.isEmpty ? 'code' : language;
final materialTheme = Theme.of(context);
final isDark = materialTheme.brightness == Brightness.dark;
final label = language.isEmpty ? 'plaintext' : language;
// Match GitHub/Atom theme colors
final backgroundColor = isDark
? const Color(0xFF282c34) // Atom One Dark header
: const Color(0xFFf6f8fa); // GitHub light header
final textColor = isDark
? const Color(0xFF9da5b4) // Muted text for dark
: const Color(0xFF57606a); // GitHub gray for light
return Container(
padding: const EdgeInsets.symmetric(
horizontal: Spacing.sm,
horizontal: Spacing.md,
vertical: Spacing.xs,
),
decoration: BoxDecoration(
color: theme.surfaceContainer.withValues(alpha: 0.35),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(AppBorderRadius.sm),
color: backgroundColor,
border: Border(
bottom: BorderSide(
color: theme.cardBorder.withValues(alpha: 0.15),
width: 1,
),
),
),
child: Row(
@@ -31,16 +45,26 @@ class CodeBlockHeader extends StatelessWidget {
Text(
label,
style: AppTypography.codeStyle.copyWith(
color: theme.textSecondary,
fontWeight: FontWeight.w600,
color: textColor,
fontSize: 12,
fontWeight: FontWeight.w500,
),
),
const Spacer(),
IconButton(
icon: const Icon(Icons.copy_rounded, size: 18),
color: theme.iconPrimary,
tooltip: 'Copy code',
onPressed: onCopy,
Material(
color: Colors.transparent,
child: InkWell(
onTap: onCopy,
borderRadius: BorderRadius.circular(4),
child: Padding(
padding: const EdgeInsets.all(6),
child: Icon(
Icons.content_copy_rounded,
size: 16,
color: textColor,
),
),
),
),
],
),