mirror of
https://github.com/foss42/apidash.git
synced 2025-05-29 12:59:58 +08:00
feat: history of requests
This commit is contained in:
60
lib/widgets/button_group_filled.dart
Normal file
60
lib/widgets/button_group_filled.dart
Normal file
@ -0,0 +1,60 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:apidash/consts.dart';
|
||||
|
||||
class FilledButtonGroup extends StatelessWidget {
|
||||
const FilledButtonGroup({super.key, required this.buttons});
|
||||
|
||||
final List<ButtonData> buttons;
|
||||
|
||||
Widget buildButton(ButtonData buttonData, {bool showLabel = true}) {
|
||||
final icon = Icon(buttonData.icon, size: 20);
|
||||
final label = Text(
|
||||
buttonData.label,
|
||||
style: kTextStyleButton,
|
||||
);
|
||||
return Tooltip(
|
||||
message: buttonData.tooltip,
|
||||
child: FilledButton.icon(
|
||||
style: FilledButton.styleFrom(
|
||||
minimumSize: const Size(44, 44),
|
||||
padding: kPh12,
|
||||
shape: const ContinuousRectangleBorder()),
|
||||
onPressed: buttonData.onPressed,
|
||||
label: showLabel
|
||||
? Row(
|
||||
children: [
|
||||
icon,
|
||||
kHSpacer4,
|
||||
label,
|
||||
],
|
||||
)
|
||||
: icon,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(builder: (context, constraints) {
|
||||
final showLabel = constraints.maxWidth > buttons.length * 110;
|
||||
List<Widget> buttonWidgets = buttons
|
||||
.map((button) => buildButton(button, showLabel: showLabel))
|
||||
.toList();
|
||||
|
||||
List<Widget> buttonsWithSpacers = [];
|
||||
for (int i = 0; i < buttonWidgets.length; i++) {
|
||||
buttonsWithSpacers.add(buttonWidgets[i]);
|
||||
if (i < buttonWidgets.length - 1) {
|
||||
buttonsWithSpacers.add(kHSpacer2);
|
||||
}
|
||||
}
|
||||
return ClipRRect(
|
||||
borderRadius: kBorderRadius20,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: buttonsWithSpacers,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
@ -1,20 +1,27 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:apidash/consts.dart';
|
||||
|
||||
class RequestResponseTabbar extends StatelessWidget {
|
||||
const RequestResponseTabbar({
|
||||
class SegmentedTabbar extends StatelessWidget {
|
||||
const SegmentedTabbar({
|
||||
super.key,
|
||||
required this.controller,
|
||||
required this.tabs,
|
||||
this.tabWidth = kSegmentedTabWidth,
|
||||
this.tabHeight = kSegmentedTabHeight,
|
||||
});
|
||||
|
||||
final TabController controller;
|
||||
final List<Widget> tabs;
|
||||
final double tabWidth;
|
||||
final double tabHeight;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(
|
||||
child: Container(
|
||||
width: kReqResTabWidth,
|
||||
height: kReqResTabHeight,
|
||||
margin: kPh4,
|
||||
width: tabWidth * tabs.length,
|
||||
height: tabHeight,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: kBorderRadius20,
|
||||
border: Border.all(
|
||||
@ -40,14 +47,7 @@ class RequestResponseTabbar extends StatelessWidget {
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
controller: controller,
|
||||
tabs: const <Widget>[
|
||||
Tab(
|
||||
text: kLabelRequest,
|
||||
),
|
||||
Tab(
|
||||
text: kLabelResponse,
|
||||
),
|
||||
],
|
||||
tabs: tabs,
|
||||
),
|
||||
),
|
||||
),
|
@ -20,6 +20,10 @@ class RequestDataTable extends StatelessWidget {
|
||||
final clrScheme = Theme.of(context).colorScheme;
|
||||
|
||||
final List<DataColumn> columns = [
|
||||
const DataColumn2(
|
||||
label: Text(''),
|
||||
fixedWidth: 8,
|
||||
),
|
||||
DataColumn2(
|
||||
label: Text(keyName ?? kNameField),
|
||||
),
|
||||
@ -30,6 +34,10 @@ class RequestDataTable extends StatelessWidget {
|
||||
DataColumn2(
|
||||
label: Text(valueName ?? kNameValue),
|
||||
),
|
||||
const DataColumn2(
|
||||
label: Text(''),
|
||||
fixedWidth: 8,
|
||||
),
|
||||
];
|
||||
|
||||
final fieldDecoration = InputDecoration(
|
||||
@ -52,6 +60,7 @@ class RequestDataTable extends StatelessWidget {
|
||||
.map<DataRow>(
|
||||
(MapEntry<String, String> entry) => DataRow(
|
||||
cells: <DataCell>[
|
||||
const DataCell(kHSpacer5),
|
||||
DataCell(
|
||||
ReadOnlyTextField(
|
||||
initialValue: entry.key,
|
||||
@ -67,6 +76,7 @@ class RequestDataTable extends StatelessWidget {
|
||||
decoration: fieldDecoration,
|
||||
),
|
||||
),
|
||||
const DataCell(kHSpacer5),
|
||||
],
|
||||
),
|
||||
)
|
||||
|
@ -1,6 +1,7 @@
|
||||
export 'button_clear_response.dart';
|
||||
export 'button_copy.dart';
|
||||
export 'button_discord.dart';
|
||||
export 'button_group_filled.dart';
|
||||
export 'button_repo.dart';
|
||||
export 'button_save_download.dart';
|
||||
export 'button_send.dart';
|
||||
@ -48,7 +49,7 @@ export 'splitview_drawer.dart';
|
||||
export 'splitview_dashboard.dart';
|
||||
export 'splitview_equal.dart';
|
||||
export 'splitview_history.dart';
|
||||
export 'tabbar_request_response.dart';
|
||||
export 'tabbar_segmented.dart';
|
||||
export 'table_map.dart';
|
||||
export 'table_request.dart';
|
||||
export 'tabs.dart';
|
||||
|
Reference in New Issue
Block a user