import 'package:flutter/material.dart'; import 'package:apidash/utils/utils.dart'; import 'package:apidash/consts.dart'; class DropdownButtonHttpMethod extends StatelessWidget { const DropdownButtonHttpMethod({ super.key, this.method, this.onChanged, }); final HTTPVerb? method; final void Function(HTTPVerb? value)? onChanged; @override Widget build(BuildContext context) { final surfaceColor = Theme.of(context).colorScheme.surface; return DropdownButton( focusColor: surfaceColor, value: method, icon: const Icon(Icons.unfold_more_rounded), elevation: 4, underline: Container( height: 0, ), borderRadius: kBorderRadius12, onChanged: onChanged, items: HTTPVerb.values.map>((HTTPVerb value) { return DropdownMenuItem( value: value, child: Padding( padding: const EdgeInsets.only(left: 16), child: Text( value.name.toUpperCase(), style: kCodeStyle.copyWith( fontWeight: FontWeight.bold, color: getHTTPMethodColor( value, brightness: Theme.of(context).brightness, ), ), ), ), ); }).toList(), ); } } class DropdownButtonContentType extends StatelessWidget { const DropdownButtonContentType({ super.key, this.contentType, this.onChanged, }); final ContentType? contentType; final void Function(ContentType?)? onChanged; @override Widget build(BuildContext context) { final surfaceColor = Theme.of(context).colorScheme.surface; return DropdownButton( focusColor: surfaceColor, value: contentType, icon: const Icon( Icons.unfold_more_rounded, size: 16, ), elevation: 4, style: kCodeStyle.copyWith( color: Theme.of(context).colorScheme.primary, ), underline: Container( height: 0, ), onChanged: onChanged, borderRadius: kBorderRadius12, items: ContentType.values .map>((ContentType value) { return DropdownMenuItem( value: value, child: Padding( padding: kPs8, child: Text( value.name, style: kTextStyleButton, ), ), ); }).toList(), ); } } class DropdownButtonFormData extends StatefulWidget { const DropdownButtonFormData({ super.key, this.formDataType, this.onChanged, }); final FormDataType? formDataType; final void Function(FormDataType?)? onChanged; @override State createState() => _DropdownButtonFormData(); } class _DropdownButtonFormData extends State { @override Widget build(BuildContext context) { final surfaceColor = Theme.of(context).colorScheme.surface; return DropdownButton( dropdownColor: surfaceColor, focusColor: surfaceColor, value: widget.formDataType, icon: const Icon( Icons.unfold_more_rounded, size: 16, ), elevation: 4, style: kCodeStyle.copyWith( color: Theme.of(context).colorScheme.primary, ), underline: const IgnorePointer(), onChanged: widget.onChanged, borderRadius: kBorderRadius12, items: FormDataType.values .map>((FormDataType value) { return DropdownMenuItem( value: value, child: Padding( padding: kPs8, child: Text( value.name, style: kTextStyleButton, ), ), ); }).toList(), ); } } class DropdownButtonCodegenLanguage extends StatelessWidget { const DropdownButtonCodegenLanguage({ super.key, this.codegenLanguage, this.onChanged, }); final CodegenLanguage? codegenLanguage; final void Function(CodegenLanguage?)? onChanged; @override Widget build(BuildContext context) { final surfaceColor = Theme.of(context).colorScheme.surface; return DropdownButton( focusColor: surfaceColor, value: codegenLanguage, icon: const Icon( Icons.unfold_more_rounded, size: 16, ), elevation: 4, style: kCodeStyle.copyWith( color: Theme.of(context).colorScheme.primary, ), underline: Container( height: 0, ), onChanged: onChanged, borderRadius: kBorderRadius12, items: CodegenLanguage.values .map>((CodegenLanguage value) { return DropdownMenuItem( value: value, child: Padding( padding: kPs8, child: Text( value.label, style: kTextStyleButton, ), ), ); }).toList(), ); } }