mirror of
https://github.com/foss42/apidash.git
synced 2025-05-22 16:57:07 +08:00
84 lines
2.3 KiB
Dart
84 lines
2.3 KiB
Dart
import 'package:apidash/consts.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'dropdowns.dart';
|
|
|
|
class FormDataField extends StatefulWidget {
|
|
const FormDataField({
|
|
super.key,
|
|
required this.keyId,
|
|
this.initialValue,
|
|
this.hintText,
|
|
this.onChanged,
|
|
this.colorScheme,
|
|
this.formDataType,
|
|
this.onFormDataTypeChanged,
|
|
});
|
|
|
|
final String keyId;
|
|
final String? initialValue;
|
|
final String? hintText;
|
|
final void Function(String)? onChanged;
|
|
final ColorScheme? colorScheme;
|
|
final FormDataType? formDataType;
|
|
final void Function(FormDataType?)? onFormDataTypeChanged;
|
|
|
|
@override
|
|
State<FormDataField> createState() => _FormDataFieldState();
|
|
}
|
|
|
|
class _FormDataFieldState extends State<FormDataField> {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
var colorScheme = widget.colorScheme ?? Theme.of(context).colorScheme;
|
|
return Row(
|
|
children: [
|
|
Expanded(
|
|
flex: 1,
|
|
child: TextFormField(
|
|
initialValue: widget.initialValue,
|
|
key: Key(widget.keyId),
|
|
style: kCodeStyle.copyWith(
|
|
color: colorScheme.onSurface,
|
|
),
|
|
decoration: InputDecoration(
|
|
hintStyle: kCodeStyle.copyWith(
|
|
color: colorScheme.outline.withOpacity(
|
|
kHintOpacity,
|
|
),
|
|
),
|
|
hintText: widget.hintText,
|
|
contentPadding: const EdgeInsets.only(bottom: 16),
|
|
focusedBorder: UnderlineInputBorder(
|
|
borderSide: BorderSide(
|
|
color: colorScheme.primary.withOpacity(
|
|
kHintOpacity,
|
|
),
|
|
),
|
|
),
|
|
enabledBorder: UnderlineInputBorder(
|
|
borderSide: BorderSide(
|
|
color: colorScheme.surfaceVariant,
|
|
),
|
|
),
|
|
suffixIcon: DropdownButtonFormData(
|
|
formDataType: widget.formDataType,
|
|
onChanged: (p0) {
|
|
if (widget.onFormDataTypeChanged != null) {
|
|
widget.onFormDataTypeChanged!(p0);
|
|
}
|
|
},
|
|
),
|
|
),
|
|
onChanged: widget.onChanged,
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|