mirror of
https://github.com/foss42/apidash.git
synced 2025-12-02 18:57:05 +08:00
Refactor SSE display widget styling and layout
Updated the SSE display widget to use ListView with improved padding and card styling. Switched to consistent use of kCodeStyle and theme-based colors, and simplified font size and color handling for better dark/light mode support.
This commit is contained in:
@@ -14,19 +14,23 @@ class _SSEDisplayState extends State<SSEDisplay> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final fontSizeMedium = theme.textTheme.bodyMedium?.fontSize;
|
||||
final isDark = theme.brightness == Brightness.dark;
|
||||
List<dynamic> sse;
|
||||
try {
|
||||
sse = jsonDecode(widget.sseOutput);
|
||||
} catch (e) {
|
||||
return Text(
|
||||
'Invalid SSE output',
|
||||
style: theme.textTheme.bodyMedium?.copyWith(color: Colors.red),
|
||||
style: kCodeStyle.copyWith(
|
||||
fontSize: fontSizeMedium,
|
||||
color: isDark ? kColorDarkDanger : kColorLightDanger,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
return ListView(
|
||||
padding: kP1,
|
||||
children: sse.reversed.where((e) => e != '').map<Widget>((chunk) {
|
||||
Map<String, dynamic>? parsedJson;
|
||||
try {
|
||||
@@ -34,16 +38,12 @@ class _SSEDisplayState extends State<SSEDisplay> {
|
||||
} catch (_) {}
|
||||
|
||||
return Card(
|
||||
color: Theme.of(context).brightness == Brightness.light
|
||||
? Colors.white
|
||||
: const Color.fromARGB(255, 14, 20, 27),
|
||||
margin: const EdgeInsets.symmetric(vertical: 6, horizontal: 8),
|
||||
elevation: 2,
|
||||
color: theme.colorScheme.surfaceContainerLowest,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderRadius: kBorderRadius6,
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
padding: kP8,
|
||||
child: parsedJson != null
|
||||
? Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -55,9 +55,10 @@ class _SSEDisplayState extends State<SSEDisplay> {
|
||||
children: [
|
||||
Text(
|
||||
'${entry.key}: ',
|
||||
style: theme.textTheme.bodyMedium?.copyWith(
|
||||
style: kCodeStyle.copyWith(
|
||||
fontSize: fontSizeMedium,
|
||||
color: isDark ? kColorGQL.toDark : kColorGQL,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: kColorGQL,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
@@ -74,14 +75,13 @@ class _SSEDisplayState extends State<SSEDisplay> {
|
||||
)
|
||||
: Text(
|
||||
chunk.toString().trim(),
|
||||
style: theme.textTheme.bodyMedium?.copyWith(
|
||||
fontFamily: 'monospace',
|
||||
style: kCodeStyle.copyWith(
|
||||
fontSize: fontSizeMedium,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user