mirror of
https://github.com/foss42/apidash.git
synced 2025-08-06 13:51:20 +08:00
wip: history panes
This commit is contained in:
82
lib/widgets/table_map.dart
Normal file
82
lib/widgets/table_map.dart
Normal file
@ -0,0 +1,82 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:apidash/utils/utils.dart';
|
||||
import 'package:apidash/consts.dart';
|
||||
|
||||
class MapTable extends StatelessWidget {
|
||||
const MapTable(
|
||||
{super.key,
|
||||
required this.map,
|
||||
required this.colNames,
|
||||
this.firstColumnHeaderCase = false});
|
||||
|
||||
final Map map;
|
||||
final List<String> colNames;
|
||||
final bool firstColumnHeaderCase;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Table(
|
||||
border: TableBorder(
|
||||
horizontalInside: BorderSide(
|
||||
color: Theme.of(context).colorScheme.surfaceContainerHighest,
|
||||
),
|
||||
),
|
||||
columnWidths: const <int, TableColumnWidth>{
|
||||
0: FlexColumnWidth(),
|
||||
1: FlexColumnWidth(),
|
||||
},
|
||||
defaultVerticalAlignment: TableCellVerticalAlignment.middle,
|
||||
children: [
|
||||
TableRow(
|
||||
children: colNames
|
||||
.map<TableCell>(
|
||||
(e) => TableCell(
|
||||
verticalAlignment: TableCellVerticalAlignment.top,
|
||||
child: Padding(
|
||||
padding: kP1,
|
||||
child: SelectableText(
|
||||
e,
|
||||
style: kCodeStyle.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
...map.entries.map<TableRow>(
|
||||
(entry) => TableRow(
|
||||
children: [
|
||||
TableCell(
|
||||
verticalAlignment: TableCellVerticalAlignment.top,
|
||||
child: Padding(
|
||||
padding: kP1,
|
||||
child: SelectableText(
|
||||
firstColumnHeaderCase
|
||||
? formatHeaderCase(entry.key)
|
||||
: entry.key,
|
||||
style: kCodeStyle.copyWith(
|
||||
color: Theme.of(context).colorScheme.tertiary,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
TableCell(
|
||||
verticalAlignment: TableCellVerticalAlignment.top,
|
||||
child: Padding(
|
||||
padding: kP1,
|
||||
child: SelectableText(
|
||||
entry.value,
|
||||
style: kCodeStyle,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user