mirror of
https://github.com/foss42/apidash.git
synced 2025-06-04 17:37:05 +08:00
fix: settings dropdown issue
This commit is contained in:
53
lib/widgets/popup_menu_codegen.dart
Normal file
53
lib/widgets/popup_menu_codegen.dart
Normal file
@ -0,0 +1,53 @@
|
||||
import 'package:apidash/consts.dart';
|
||||
import 'package:apidash/extensions/extensions.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class CodegenPopupMenu extends StatelessWidget {
|
||||
const CodegenPopupMenu({
|
||||
super.key,
|
||||
required this.value,
|
||||
this.onChanged,
|
||||
this.items,
|
||||
});
|
||||
|
||||
final CodegenLanguage value;
|
||||
final void Function(CodegenLanguage? value)? onChanged;
|
||||
final List<CodegenLanguage>? items;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final textClipLength = context.isCompactWindow ? 12 : 22;
|
||||
final double boxLength = context.isCompactWindow ? 150 : 220;
|
||||
return PopupMenuButton<CodegenLanguage>(
|
||||
tooltip: "Select Code Generation Language",
|
||||
surfaceTintColor: kColorTransparent,
|
||||
constraints: BoxConstraints(minWidth: boxLength),
|
||||
itemBuilder: (BuildContext context) => items!
|
||||
.map((item) => PopupMenuItem<CodegenLanguage>(
|
||||
value: item,
|
||||
child: Text(
|
||||
item.label,
|
||||
style: kTextStylePopupMenuItem,
|
||||
),
|
||||
))
|
||||
.toList(),
|
||||
onSelected: onChanged,
|
||||
child: Container(
|
||||
width: boxLength,
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
value.label.clip(textClipLength),
|
||||
style: kTextStylePopupMenuItem,
|
||||
),
|
||||
const Icon(
|
||||
Icons.unfold_more,
|
||||
size: 16,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
52
lib/widgets/popup_menu_uri.dart
Normal file
52
lib/widgets/popup_menu_uri.dart
Normal file
@ -0,0 +1,52 @@
|
||||
import 'package:apidash/consts.dart';
|
||||
import 'package:apidash/extensions/extensions.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class URIPopupMenu extends StatelessWidget {
|
||||
const URIPopupMenu({
|
||||
super.key,
|
||||
required this.value,
|
||||
this.onChanged,
|
||||
this.items,
|
||||
});
|
||||
|
||||
final String value;
|
||||
final void Function(String? value)? onChanged;
|
||||
final List<String>? items;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final double boxLength = context.isCompactWindow ? 90 : 130;
|
||||
return PopupMenuButton(
|
||||
tooltip: "Select URI Scheme",
|
||||
surfaceTintColor: kColorTransparent,
|
||||
constraints: BoxConstraints(minWidth: boxLength),
|
||||
itemBuilder: (BuildContext context) => items!
|
||||
.map((item) => PopupMenuItem(
|
||||
value: item,
|
||||
child: Text(
|
||||
item,
|
||||
style: kTextStylePopupMenuItem,
|
||||
),
|
||||
))
|
||||
.toList(),
|
||||
onSelected: onChanged,
|
||||
child: Container(
|
||||
width: boxLength,
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
value,
|
||||
style: kTextStylePopupMenuItem,
|
||||
),
|
||||
const Icon(
|
||||
Icons.unfold_more,
|
||||
size: 16,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -31,7 +31,9 @@ export 'json_previewer.dart';
|
||||
export 'markdown.dart';
|
||||
export 'menus.dart';
|
||||
export 'overlay_widget.dart';
|
||||
export 'popup_menus.dart';
|
||||
export 'popup_menu_codegen.dart';
|
||||
export 'popup_menu_env.dart';
|
||||
export 'popup_menu_uri.dart';
|
||||
export 'previewer.dart';
|
||||
export 'request_widgets.dart';
|
||||
export 'response_widgets.dart';
|
||||
|
Reference in New Issue
Block a user