fix design request

This commit is contained in:
Phuoc Nguyen
2025-12-03 17:12:21 +07:00
parent 2dadcc5ce1
commit 2a14f82b72
3 changed files with 57 additions and 25 deletions

View File

@@ -4,12 +4,14 @@
library;
import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
/// Description Item Widget
///
/// Shows a label and value pair with:
/// - Inline layout (label: value) for single line
/// - Stacked layout for multi-line values
/// - HTML rendering support for rich text content
/// - Theme-aware colors
class DescriptionItem extends StatelessWidget {
const DescriptionItem({
@@ -17,11 +19,55 @@ class DescriptionItem extends StatelessWidget {
required this.label,
required this.value,
this.isMultiLine = false,
this.isHtml = false,
});
final String label;
final String value;
final bool isMultiLine;
final bool isHtml;
Widget _buildValueWidget(BuildContext context) {
final colorScheme = Theme.of(context).colorScheme;
if (isHtml) {
return Html(
data: value,
style: {
'body': Style(
fontSize: FontSize(15),
color: colorScheme.onSurface,
fontWeight: FontWeight.w500,
lineHeight: const LineHeight(1.6),
margin: Margins.zero,
padding: HtmlPaddings.zero,
),
'p': Style(
margin: Margins.only(bottom: 8),
),
'ul': Style(
margin: Margins.only(left: 16, bottom: 8),
),
'ol': Style(
margin: Margins.only(left: 16, bottom: 8),
),
'li': Style(
margin: Margins.only(bottom: 4),
),
},
);
}
return Text(
value,
style: TextStyle(
fontSize: 15,
color: colorScheme.onSurface,
fontWeight: FontWeight.w500,
height: 1.6,
),
);
}
@override
Widget build(BuildContext context) {
@@ -40,15 +86,7 @@ class DescriptionItem extends StatelessWidget {
),
),
const SizedBox(height: 4),
Text(
value,
style: TextStyle(
fontSize: 15,
color: colorScheme.onSurface,
fontWeight: FontWeight.w500,
height: 1.6,
),
),
_buildValueWidget(context),
],
);
}
@@ -75,15 +113,7 @@ class DescriptionItem extends StatelessWidget {
),
),
Expanded(
child: Text(
value,
style: TextStyle(
fontSize: 15,
color: colorScheme.onSurface,
fontWeight: FontWeight.w500,
height: 1.6,
),
),
child: _buildValueWidget(context),
),
],
),