mirror of
https://github.com/foss42/apidash.git
synced 2025-06-23 16:18:14 +08:00
Update HTTPVerb
This commit is contained in:
@ -28,27 +28,14 @@ Color getResponseStatusCodeColor(int? statusCode,
|
|||||||
|
|
||||||
Color getHTTPMethodColor(HTTPVerb method,
|
Color getHTTPMethodColor(HTTPVerb method,
|
||||||
{Brightness brightness = Brightness.light}) {
|
{Brightness brightness = Brightness.light}) {
|
||||||
Color col;
|
Color col = switch (method) {
|
||||||
switch (method) {
|
HTTPVerb.get => kColorHttpMethodGet,
|
||||||
case HTTPVerb.get:
|
HTTPVerb.head => kColorHttpMethodHead,
|
||||||
col = kColorHttpMethodGet;
|
HTTPVerb.post => kColorHttpMethodPost,
|
||||||
break;
|
HTTPVerb.put => kColorHttpMethodPut,
|
||||||
case HTTPVerb.head:
|
HTTPVerb.patch => kColorHttpMethodPatch,
|
||||||
col = kColorHttpMethodHead;
|
HTTPVerb.delete => kColorHttpMethodDelete,
|
||||||
break;
|
};
|
||||||
case HTTPVerb.post:
|
|
||||||
col = kColorHttpMethodPost;
|
|
||||||
break;
|
|
||||||
case HTTPVerb.put:
|
|
||||||
col = kColorHttpMethodPut;
|
|
||||||
break;
|
|
||||||
case HTTPVerb.patch:
|
|
||||||
col = kColorHttpMethodPatch;
|
|
||||||
break;
|
|
||||||
case HTTPVerb.delete:
|
|
||||||
col = kColorHttpMethodDelete;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (brightness == Brightness.dark) {
|
if (brightness == Brightness.dark) {
|
||||||
col = getDarkModeColor(col);
|
col = getDarkModeColor(col);
|
||||||
}
|
}
|
||||||
@ -73,12 +60,9 @@ double? getJsonPreviewerMaxRootNodeWidth(double w) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GlobalKey<ScaffoldState> getScaffoldKey(int railIdx) {
|
GlobalKey<ScaffoldState> getScaffoldKey(int railIdx) {
|
||||||
switch (railIdx) {
|
return switch (railIdx) {
|
||||||
case 1:
|
1 => kEnvScaffoldKey,
|
||||||
return kEnvScaffoldKey;
|
2 => kHisScaffoldKey,
|
||||||
case 2:
|
_ => kHomeScaffoldKey,
|
||||||
return kHisScaffoldKey;
|
};
|
||||||
default:
|
|
||||||
return kHomeScaffoldKey;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,22 +4,18 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:apidash/utils/utils.dart';
|
import 'package:apidash/utils/utils.dart';
|
||||||
|
|
||||||
class MethodBox extends StatelessWidget {
|
class MethodBox extends StatelessWidget {
|
||||||
const MethodBox({super.key, required this.method});
|
const MethodBox({
|
||||||
|
super.key,
|
||||||
|
required this.method,
|
||||||
|
});
|
||||||
final HTTPVerb method;
|
final HTTPVerb method;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
String text = method.name.toUpperCase();
|
|
||||||
if (method == HTTPVerb.delete) {
|
|
||||||
text = "DEL";
|
|
||||||
}
|
|
||||||
if (method == HTTPVerb.patch) {
|
|
||||||
text = "PAT";
|
|
||||||
}
|
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
width: 24,
|
width: 24,
|
||||||
child: Text(
|
child: Text(
|
||||||
text,
|
method.abbr,
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 8,
|
fontSize: 8,
|
||||||
|
@ -7,7 +7,17 @@ enum APIType {
|
|||||||
final String label;
|
final String label;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum HTTPVerb { get, head, post, put, patch, delete }
|
enum HTTPVerb {
|
||||||
|
get("GET"),
|
||||||
|
head("HEAD"),
|
||||||
|
post("POST"),
|
||||||
|
put("PUT"),
|
||||||
|
patch("PAT"),
|
||||||
|
delete("DEL");
|
||||||
|
|
||||||
|
const HTTPVerb(this.abbr);
|
||||||
|
final String abbr;
|
||||||
|
}
|
||||||
|
|
||||||
enum SupportedUriSchemes { https, http }
|
enum SupportedUriSchemes { https, http }
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user