102 lines
3.2 KiB
Dart
102 lines
3.2 KiB
Dart
import 'package:flutter/material.dart';
|
||
import 'package:flutter/services.dart';
|
||
import 'package:satu/shared/app_colors.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
|
||
],
|
||
);
|
||
}
|
||
}
|