mirror of
https://github.com/foss42/apidash.git
synced 2025-06-20 14:09:28 +08:00
wip: history popup menu
This commit is contained in:
@ -22,8 +22,8 @@ class EnvironmentDropdown extends ConsumerWidget {
|
||||
borderRadius: kBorderRadius8,
|
||||
),
|
||||
child: EnvironmentPopupMenu(
|
||||
activeEnvironment: environments?[activeEnvironment],
|
||||
environments: environmentsList,
|
||||
value: environments?[activeEnvironment],
|
||||
items: environmentsList,
|
||||
onChanged: (value) {
|
||||
ref.read(activeEnvironmentIdStateProvider.notifier).state =
|
||||
value?.id;
|
||||
|
@ -81,27 +81,6 @@ class SettingsPage extends ConsumerWidget {
|
||||
},
|
||||
items: kSupportedUriSchemes,
|
||||
),
|
||||
// DropdownButtonHideUnderline(
|
||||
// child: DropdownButton<String>(
|
||||
// borderRadius: kBorderRadius8,
|
||||
// onChanged: (value) {
|
||||
// ref
|
||||
// .read(settingsProvider.notifier)
|
||||
// .update(defaultUriScheme: value);
|
||||
// },
|
||||
// value: settings.defaultUriScheme,
|
||||
// items: kSupportedUriSchemes
|
||||
// .map<DropdownMenuItem<String>>((String value) {
|
||||
// return DropdownMenuItem<String>(
|
||||
// value: value,
|
||||
// child: Padding(
|
||||
// padding: kP10,
|
||||
// child: Text(value),
|
||||
// ),
|
||||
// );
|
||||
// }).toList(),
|
||||
// ),
|
||||
// ),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
@ -123,26 +102,6 @@ class SettingsPage extends ConsumerWidget {
|
||||
},
|
||||
items: CodegenLanguage.values,
|
||||
),
|
||||
// DropdownButtonHideUnderline(
|
||||
// child: DropdownButton<CodegenLanguage>(
|
||||
// borderRadius: kBorderRadius8,
|
||||
// value: settings.defaultCodeGenLang,
|
||||
// onChanged: (value) {
|
||||
// ref
|
||||
// .read(settingsProvider.notifier)
|
||||
// .update(defaultCodeGenLang: value);
|
||||
// },
|
||||
// items: CodegenLanguage.values.map((value) {
|
||||
// return DropdownMenuItem<CodegenLanguage>(
|
||||
// value: value,
|
||||
// child: Padding(
|
||||
// padding: kP10,
|
||||
// child: Text(value.label),
|
||||
// ),
|
||||
// );
|
||||
// }).toList(),
|
||||
// ),
|
||||
// ),
|
||||
),
|
||||
),
|
||||
CheckboxListTile(
|
||||
@ -186,6 +145,29 @@ class SettingsPage extends ConsumerWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
hoverColor: kColorTransparent,
|
||||
title: const Text('History Retention Period'),
|
||||
subtitle: Text(
|
||||
'Your request history will be retained for ${settings.historyRetentionPeriod.label}'),
|
||||
trailing: Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
borderRadius: kBorderRadius8,
|
||||
),
|
||||
child: HistoryRetentionPopupMenu(
|
||||
value: settings.historyRetentionPeriod,
|
||||
onChanged: (value) {
|
||||
ref
|
||||
.read(settingsProvider.notifier)
|
||||
.update(historyRetentionPeriod: value);
|
||||
},
|
||||
items: HistoryRetentionPeriod.values,
|
||||
),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
hoverColor: kColorTransparent,
|
||||
title: const Text('Clear Data'),
|
||||
|
@ -1,6 +1,6 @@
|
||||
import 'package:apidash/consts.dart';
|
||||
import 'package:apidash/extensions/extensions.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:apidash/extensions/extensions.dart';
|
||||
import 'package:apidash/consts.dart';
|
||||
|
||||
class CodegenPopupMenu extends StatelessWidget {
|
||||
const CodegenPopupMenu({
|
||||
|
@ -1,24 +1,24 @@
|
||||
import 'package:apidash/consts.dart';
|
||||
import 'package:apidash/extensions/extensions.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:apidash/extensions/extensions.dart';
|
||||
import 'package:apidash/models/models.dart';
|
||||
import 'package:apidash/utils/utils.dart';
|
||||
import 'package:apidash/consts.dart';
|
||||
|
||||
class EnvironmentPopupMenu extends StatelessWidget {
|
||||
const EnvironmentPopupMenu({
|
||||
super.key,
|
||||
this.activeEnvironment,
|
||||
this.value,
|
||||
this.onChanged,
|
||||
this.environments,
|
||||
this.items,
|
||||
});
|
||||
|
||||
final EnvironmentModel? activeEnvironment;
|
||||
final EnvironmentModel? value;
|
||||
final void Function(EnvironmentModel? value)? onChanged;
|
||||
final List<EnvironmentModel>? environments;
|
||||
final List<EnvironmentModel>? items;
|
||||
final EnvironmentModel? noneEnvironmentModel = null;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final activeEnvironmentName = getEnvironmentTitle(activeEnvironment?.name);
|
||||
final valueName = getEnvironmentTitle(value?.name);
|
||||
final textClipLength = context.isCompactWindow ? 6 : 10;
|
||||
final double boxLength = context.isCompactWindow ? 100 : 130;
|
||||
return PopupMenuButton(
|
||||
@ -34,7 +34,7 @@ class EnvironmentPopupMenu extends StatelessWidget {
|
||||
},
|
||||
child: const Text("None"),
|
||||
),
|
||||
...environments!.map((EnvironmentModel environment) {
|
||||
...items!.map((EnvironmentModel environment) {
|
||||
final name = getEnvironmentTitle(environment.name).clip(30);
|
||||
return PopupMenuItem(
|
||||
value: environment,
|
||||
@ -55,9 +55,7 @@ class EnvironmentPopupMenu extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
activeEnvironment == null
|
||||
? "None"
|
||||
: activeEnvironmentName.clip(textClipLength),
|
||||
value == null ? "None" : valueName.clip(textClipLength),
|
||||
softWrap: false,
|
||||
),
|
||||
const Icon(
|
||||
|
57
lib/widgets/popup_menu_history.dart
Normal file
57
lib/widgets/popup_menu_history.dart
Normal file
@ -0,0 +1,57 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:apidash/extensions/extensions.dart';
|
||||
import 'package:apidash/consts.dart';
|
||||
|
||||
class HistoryRetentionPopupMenu extends StatelessWidget {
|
||||
const HistoryRetentionPopupMenu({
|
||||
super.key,
|
||||
required this.value,
|
||||
required this.onChanged,
|
||||
this.items,
|
||||
});
|
||||
|
||||
final HistoryRetentionPeriod value;
|
||||
final void Function(HistoryRetentionPeriod value) onChanged;
|
||||
final List<HistoryRetentionPeriod>? items;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final double boxLength = context.isCompactWindow ? 110 : 130;
|
||||
return PopupMenuButton(
|
||||
tooltip: "Select retention period",
|
||||
surfaceTintColor: kColorTransparent,
|
||||
constraints: BoxConstraints(minWidth: boxLength),
|
||||
itemBuilder: (BuildContext context) {
|
||||
return [
|
||||
...items!.map((period) {
|
||||
return PopupMenuItem(
|
||||
value: period,
|
||||
child: Text(
|
||||
period.label,
|
||||
softWrap: false,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
);
|
||||
})
|
||||
];
|
||||
},
|
||||
onSelected: onChanged,
|
||||
child: Container(
|
||||
width: boxLength,
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
value.label,
|
||||
style: kTextStylePopupMenuItem,
|
||||
),
|
||||
const Icon(
|
||||
Icons.unfold_more,
|
||||
size: 16,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
import 'package:apidash/consts.dart';
|
||||
import 'package:apidash/extensions/extensions.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:apidash/extensions/extensions.dart';
|
||||
import 'package:apidash/consts.dart';
|
||||
|
||||
class URIPopupMenu extends StatelessWidget {
|
||||
const URIPopupMenu({
|
||||
|
@ -42,6 +42,7 @@ export 'menu_sidebar_top.dart';
|
||||
export 'overlay_widget.dart';
|
||||
export 'popup_menu_codegen.dart';
|
||||
export 'popup_menu_env.dart';
|
||||
export 'popup_menu_history.dart';
|
||||
export 'popup_menu_uri.dart';
|
||||
export 'previewer.dart';
|
||||
export 'request_widgets.dart';
|
||||
|
Reference in New Issue
Block a user