mirror of
https://github.com/foss42/apidash.git
synced 2025-06-04 01:13:30 +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:apidash_design_system/apidash_design_system.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
@ -60,6 +61,11 @@ class RequestEditorTopBar extends ConsumerWidget {
|
|||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
|
DropdownButtonProtocol(
|
||||||
|
protocol: Protocol.http,
|
||||||
|
onChanged: (protocol) {},
|
||||||
|
),
|
||||||
|
kHSpacer10,
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
name ?? "",
|
name ?? "",
|
||||||
@ -68,9 +74,7 @@ class RequestEditorTopBar extends ConsumerWidget {
|
|||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
kHSpacer10,
|
||||||
width: 6,
|
|
||||||
),
|
|
||||||
EditorTitleActions(
|
EditorTitleActions(
|
||||||
onRenamePressed: () {
|
onRenamePressed: () {
|
||||||
showRenameDialog(context, "Rename Request", name, (val) {
|
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_formdata.dart';
|
||||||
export 'dropdown_http_method.dart';
|
export 'dropdown_http_method.dart';
|
||||||
export 'dropdown_import_format.dart';
|
export 'dropdown_import_format.dart';
|
||||||
|
export 'dropdown_protocol.dart';
|
||||||
export 'editor_json.dart';
|
export 'editor_json.dart';
|
||||||
export 'editor.dart';
|
export 'editor.dart';
|
||||||
export 'error_message.dart';
|
export 'error_message.dart';
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
|
enum Protocol {
|
||||||
|
http("HTTP");
|
||||||
|
|
||||||
|
const Protocol(this.label);
|
||||||
|
final String label;
|
||||||
|
}
|
||||||
|
|
||||||
enum HTTPVerb { get, head, post, put, patch, delete }
|
enum HTTPVerb { get, head, post, put, patch, delete }
|
||||||
|
|
||||||
enum SupportedUriSchemes { https, http }
|
enum SupportedUriSchemes { https, http }
|
||||||
|
@ -8,6 +8,7 @@ class ADDropdownButton<T> extends StatelessWidget {
|
|||||||
required this.values,
|
required this.values,
|
||||||
this.onChanged,
|
this.onChanged,
|
||||||
this.isExpanded = false,
|
this.isExpanded = false,
|
||||||
|
this.isDense = false,
|
||||||
this.iconSize,
|
this.iconSize,
|
||||||
this.dropdownMenuItemPadding = kPs8,
|
this.dropdownMenuItemPadding = kPs8,
|
||||||
this.dropdownMenuItemtextStyle,
|
this.dropdownMenuItemtextStyle,
|
||||||
@ -17,6 +18,7 @@ class ADDropdownButton<T> extends StatelessWidget {
|
|||||||
final Iterable<(T, String?)> values;
|
final Iterable<(T, String?)> values;
|
||||||
final void Function(T?)? onChanged;
|
final void Function(T?)? onChanged;
|
||||||
final bool isExpanded;
|
final bool isExpanded;
|
||||||
|
final bool isDense;
|
||||||
final double? iconSize;
|
final double? iconSize;
|
||||||
final EdgeInsetsGeometry dropdownMenuItemPadding;
|
final EdgeInsetsGeometry dropdownMenuItemPadding;
|
||||||
final TextStyle? Function(T)? dropdownMenuItemtextStyle;
|
final TextStyle? Function(T)? dropdownMenuItemtextStyle;
|
||||||
@ -26,6 +28,7 @@ class ADDropdownButton<T> extends StatelessWidget {
|
|||||||
final surfaceColor = Theme.of(context).colorScheme.surface;
|
final surfaceColor = Theme.of(context).colorScheme.surface;
|
||||||
return DropdownButton<T>(
|
return DropdownButton<T>(
|
||||||
isExpanded: isExpanded,
|
isExpanded: isExpanded,
|
||||||
|
isDense: isDense,
|
||||||
focusColor: surfaceColor,
|
focusColor: surfaceColor,
|
||||||
value: value,
|
value: value,
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
|
Reference in New Issue
Block a user