aman-satu-flutter/lib/widgets/fields/dropdown_field.dart

100 lines
3.1 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import 'package:flutter/material.dart';
import 'package:satu/shared/shared_styles.dart';
import 'package:satu/shared/ui_helpers.dart';
import 'note_text.dart';
class DropDownField extends StatefulWidget {
const DropDownField(
{required this.placeholder,
this.fieldFocusNode,
this.nextFocusNode,
this.additionalNote,
this.onChanged,
this.initialValue,
this.validationMessage,
this.isReadOnly = false,
this.smallVersion = false,
this.labelText});
final bool isReadOnly;
final String placeholder;
final String? validationMessage;
final bool smallVersion;
final FocusNode? fieldFocusNode;
final FocusNode? nextFocusNode;
final String? additionalNote;
final Function(String)? onChanged;
final String? initialValue;
final String? labelText;
@override
_DropDownFieldState createState() => _DropDownFieldState();
}
class _DropDownFieldState extends State<DropDownField> {
double fieldHeight = 55;
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
if (widget.labelText != null) NoteText(widget.labelText ?? ''),
Container(
//height: widget.smallVersion ? 40 : fieldHeight,
constraints:
BoxConstraints(minHeight: widget.smallVersion ? 40 : fieldHeight),
alignment: Alignment.centerLeft,
padding: fieldPadding,
decoration:
widget.isReadOnly ? disabledFieldDecoration : fieldDecoration,
child: Expanded(child: Container()
// SearchableDropdown.single(
// items: <String>['Частное лицо', 'ИП Иванов',
// 'ТО "Рога и копыта"', 'Network Energy']
// .map<DropdownMenuItem<String>>((String value) {
// return DropdownMenuItem<String>(
// value: value,
// child: Text(value),
// );
// }).toList(),
// value: widget.initialValue,
// readOnly: widget.isReadOnly,
// hint: "Контрагент",
// searchHint: "Укажите контрагента",
// underline: Container(
// height: 1.0,
// decoration: BoxDecoration(
// border: Border(bottom:
// BorderSide(color: yellowColor, width: 3.0))
// ),
// ),
// onChanged: (value) {
// print(value);
// },
// isExpanded: true,
// ),
),
),
if (widget.validationMessage != null)
NoteText(
widget.validationMessage ?? '',
color: Colors.red,
),
if (widget.additionalNote != null) verticalSpace(5),
if (widget.additionalNote != null)
NoteText(widget.additionalNote ?? ''),
verticalSpaceSmall
],
);
}
}