mirror of
https://github.com/foss42/apidash.git
synced 2025-06-05 01:46:21 +08:00
Add protocol dropdown UI closes #307
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import 'package:apidash_core/apidash_core.dart';
|
||||
import 'package:apidash_design_system/apidash_design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
@ -60,6 +61,11 @@ class RequestEditorTopBar extends ConsumerWidget {
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
DropdownButtonProtocol(
|
||||
protocol: Protocol.http,
|
||||
onChanged: (protocol) {},
|
||||
),
|
||||
kHSpacer10,
|
||||
Expanded(
|
||||
child: Text(
|
||||
name ?? "",
|
||||
@ -68,9 +74,7 @@ class RequestEditorTopBar extends ConsumerWidget {
|
||||
maxLines: 1,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 6,
|
||||
),
|
||||
kHSpacer10,
|
||||
EditorTitleActions(
|
||||
onRenamePressed: () {
|
||||
showRenameDialog(context, "Rename Request", name, (val) {
|
||||
|
24
lib/widgets/dropdown_protocol.dart
Normal file
24
lib/widgets/dropdown_protocol.dart
Normal file
@ -0,0 +1,24 @@
|
||||
import 'package:apidash_core/apidash_core.dart';
|
||||
import 'package:apidash_design_system/apidash_design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class DropdownButtonProtocol extends StatelessWidget {
|
||||
const DropdownButtonProtocol({
|
||||
super.key,
|
||||
this.protocol,
|
||||
this.onChanged,
|
||||
});
|
||||
|
||||
final Protocol? protocol;
|
||||
final void Function(Protocol?)? onChanged;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ADDropdownButton<Protocol>(
|
||||
value: protocol,
|
||||
values: Protocol.values.map((e) => (e, e.label)),
|
||||
onChanged: onChanged,
|
||||
isDense: true,
|
||||
);
|
||||
}
|
||||
}
|
@ -25,6 +25,7 @@ export 'dropdown_content_type.dart';
|
||||
export 'dropdown_formdata.dart';
|
||||
export 'dropdown_http_method.dart';
|
||||
export 'dropdown_import_format.dart';
|
||||
export 'dropdown_protocol.dart';
|
||||
export 'editor_json.dart';
|
||||
export 'editor.dart';
|
||||
export 'error_message.dart';
|
||||
|
@ -1,5 +1,12 @@
|
||||
import 'dart:convert';
|
||||
|
||||
enum Protocol {
|
||||
http("HTTP");
|
||||
|
||||
const Protocol(this.label);
|
||||
final String label;
|
||||
}
|
||||
|
||||
enum HTTPVerb { get, head, post, put, patch, delete }
|
||||
|
||||
enum SupportedUriSchemes { https, http }
|
||||
|
@ -8,6 +8,7 @@ class ADDropdownButton<T> extends StatelessWidget {
|
||||
required this.values,
|
||||
this.onChanged,
|
||||
this.isExpanded = false,
|
||||
this.isDense = false,
|
||||
this.iconSize,
|
||||
this.dropdownMenuItemPadding = kPs8,
|
||||
this.dropdownMenuItemtextStyle,
|
||||
@ -17,6 +18,7 @@ class ADDropdownButton<T> extends StatelessWidget {
|
||||
final Iterable<(T, String?)> values;
|
||||
final void Function(T?)? onChanged;
|
||||
final bool isExpanded;
|
||||
final bool isDense;
|
||||
final double? iconSize;
|
||||
final EdgeInsetsGeometry dropdownMenuItemPadding;
|
||||
final TextStyle? Function(T)? dropdownMenuItemtextStyle;
|
||||
@ -26,6 +28,7 @@ class ADDropdownButton<T> extends StatelessWidget {
|
||||
final surfaceColor = Theme.of(context).colorScheme.surface;
|
||||
return DropdownButton<T>(
|
||||
isExpanded: isExpanded,
|
||||
isDense: isDense,
|
||||
focusColor: surfaceColor,
|
||||
value: value,
|
||||
icon: Icon(
|
||||
|
Reference in New Issue
Block a user