TF-1694 Upgrade dropdown_button2 to version 2.0.0
(cherry picked from commit 84694b719bcd94a90282146bdc1c173c0e3fbd7e)
This commit is contained in:
+47
-33
@@ -1,47 +1,50 @@
|
||||
|
||||
import 'package:core/core.dart';
|
||||
import 'package:core/presentation/extensions/color_extension.dart';
|
||||
import 'package:core/presentation/resources/image_paths.dart';
|
||||
import 'package:core/presentation/utils/style_utils.dart';
|
||||
import 'package:dropdown_button2/dropdown_button2.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
||||
import 'package:model/extensions/email_address_extension.dart';
|
||||
|
||||
typedef OnSelectEmailAddressDropListAction = Function(EmailAddress? emailAddress);
|
||||
|
||||
class IdentityDropListFieldBuilder {
|
||||
class IdentityDropListFieldBuilder extends StatelessWidget {
|
||||
|
||||
final ImagePaths _imagePaths;
|
||||
final String _label;
|
||||
final EmailAddress? _emailAddressSelected;
|
||||
final List<EmailAddress> _listEmailAddress;
|
||||
final OnSelectEmailAddressDropListAction? onSelectItemDropList;
|
||||
|
||||
OnSelectEmailAddressDropListAction? onSelectItemDropList;
|
||||
|
||||
IdentityDropListFieldBuilder(
|
||||
const IdentityDropListFieldBuilder(
|
||||
this._imagePaths,
|
||||
this._label,
|
||||
this._emailAddressSelected,
|
||||
this._listEmailAddress,
|
||||
);
|
||||
this._listEmailAddress, {
|
||||
super.key,
|
||||
this.onSelectItemDropList
|
||||
});
|
||||
|
||||
void addOnSelectEmailAddressDropListAction(OnSelectEmailAddressDropListAction action) {
|
||||
onSelectItemDropList = action;
|
||||
}
|
||||
|
||||
Widget build() {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
Text(_label, style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: AppColor.colorContentEmail)),
|
||||
Text(
|
||||
_label,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: AppColor.colorContentEmail)),
|
||||
const SizedBox(height: 8),
|
||||
DropdownButtonHideUnderline(
|
||||
child: DropdownButton2<EmailAddress>(
|
||||
isExpanded: true,
|
||||
hint: Row(
|
||||
children: [
|
||||
children: const [
|
||||
Expanded(child: Text(
|
||||
_emailAddressSelected?.email ?? '',
|
||||
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.normal, color: Colors.black),
|
||||
'',
|
||||
style: TextStyle(fontSize: 16, fontWeight: FontWeight.normal, color: Colors.black),
|
||||
maxLines: 1,
|
||||
overflow: CommonTextStyle.defaultTextOverFlow,
|
||||
softWrap: CommonTextStyle.defaultSoftWrap,
|
||||
@@ -51,7 +54,7 @@ class IdentityDropListFieldBuilder {
|
||||
items: _listEmailAddress.map((item) => DropdownMenuItem<EmailAddress>(
|
||||
value: item,
|
||||
child: Text(
|
||||
item.email ?? '',
|
||||
item.emailAddress,
|
||||
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.normal, color: Colors.black),
|
||||
maxLines: 1,
|
||||
overflow: CommonTextStyle.defaultTextOverFlow,
|
||||
@@ -59,24 +62,35 @@ class IdentityDropListFieldBuilder {
|
||||
),
|
||||
)).toList(),
|
||||
value: _emailAddressSelected,
|
||||
onChanged: (newEmailAddress) => onSelectItemDropList?.call(newEmailAddress),
|
||||
icon: SvgPicture.asset(_imagePaths.icDropDown),
|
||||
buttonPadding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
buttonDecoration: BoxDecoration(
|
||||
onChanged: onSelectItemDropList,
|
||||
buttonStyleData: ButtonStyleData(
|
||||
height: 44,
|
||||
padding: const EdgeInsets.only(right: 8),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(color: AppColor.colorInputBorderCreateMailbox, width: 0.5),
|
||||
color: AppColor.colorInputBackgroundCreateMailbox),
|
||||
itemHeight: 44,
|
||||
buttonHeight: 44,
|
||||
selectedItemHighlightColor: Colors.black12,
|
||||
itemPadding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
dropdownMaxHeight: 200,
|
||||
dropdownDecoration: BoxDecoration(
|
||||
),
|
||||
dropdownStyleData: DropdownStyleData(
|
||||
maxHeight: 200,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: Colors.white),
|
||||
dropdownElevation: 4,
|
||||
scrollbarRadius: const Radius.circular(40),
|
||||
scrollbarThickness: 6,
|
||||
elevation: 4,
|
||||
scrollbarTheme: ScrollbarThemeData(
|
||||
radius: const Radius.circular(40),
|
||||
thickness: MaterialStateProperty.all<double>(6),
|
||||
thumbVisibility: MaterialStateProperty.all<bool>(true),
|
||||
),
|
||||
),
|
||||
iconStyleData: IconStyleData(
|
||||
icon: SvgPicture.asset(_imagePaths.icDropDown),
|
||||
iconSize: 14,
|
||||
),
|
||||
menuItemStyleData: const MenuItemStyleData(
|
||||
height: 44,
|
||||
padding: EdgeInsets.symmetric(horizontal: 12),
|
||||
),
|
||||
),
|
||||
)
|
||||
]);
|
||||
|
||||
+34
-25
@@ -1,40 +1,49 @@
|
||||
|
||||
import 'package:core/core.dart';
|
||||
import 'package:core/presentation/extensions/color_extension.dart';
|
||||
import 'package:core/presentation/utils/style_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
||||
|
||||
class IdentityFieldNoEditableBuilder {
|
||||
class IdentityFieldNoEditableBuilder extends StatelessWidget {
|
||||
|
||||
final String _label;
|
||||
final EmailAddress? _emailAddressSelected;
|
||||
|
||||
IdentityFieldNoEditableBuilder(this._label, this._emailAddressSelected);
|
||||
const IdentityFieldNoEditableBuilder(
|
||||
this._label,
|
||||
this._emailAddressSelected,
|
||||
{super.key}
|
||||
);
|
||||
|
||||
Widget build() {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
Text(_label, style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: AppColor.colorContentEmail)),
|
||||
Text(
|
||||
_label,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: AppColor.colorContentEmail)),
|
||||
const SizedBox(height: 8),
|
||||
Container(
|
||||
height: 44,
|
||||
alignment: Alignment.centerLeft,
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(color: AppColor.colorInputBorderCreateMailbox, width: 0.5),
|
||||
color: AppColor.colorInputBackgroundCreateMailbox),
|
||||
child: Text(
|
||||
_emailAddressSelected?.email ?? '',
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: AppColor.colorInputBorderCreateMailbox),
|
||||
maxLines: 1,
|
||||
overflow: BuildUtils.isWeb ? null : TextOverflow.ellipsis,
|
||||
)
|
||||
height: 44,
|
||||
alignment: Alignment.centerLeft,
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(color: AppColor.colorInputBorderCreateMailbox, width: 0.5),
|
||||
color: AppColor.colorInputBackgroundCreateMailbox),
|
||||
child: Text(
|
||||
_emailAddressSelected?.email ?? '',
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: AppColor.colorInputBorderCreateMailbox),
|
||||
maxLines: 1,
|
||||
overflow: CommonTextStyle.defaultTextOverFlow,
|
||||
softWrap: CommonTextStyle.defaultSoftWrap
|
||||
)
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
+11
-11
@@ -1,11 +1,13 @@
|
||||
|
||||
import 'package:core/core.dart';
|
||||
import 'package:core/presentation/extensions/color_extension.dart';
|
||||
import 'package:core/presentation/views/text/text_field_builder.dart';
|
||||
import 'package:core/utils/build_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:tmail_ui_user/features/identity_creator/presentation/widgets/identity_input_decoration_builder.dart';
|
||||
|
||||
typedef OnChangeInputNameAction = Function(String? value);
|
||||
|
||||
class IdentityInputFieldBuilder {
|
||||
class IdentityInputFieldBuilder extends StatelessWidget {
|
||||
|
||||
final String _label;
|
||||
final String? _error;
|
||||
@@ -14,24 +16,22 @@ class IdentityInputFieldBuilder {
|
||||
final FocusNode? focusNode;
|
||||
final TextInputType? inputType;
|
||||
final bool isMandatory;
|
||||
final OnChangeInputNameAction? onChangeInputNameAction;
|
||||
|
||||
OnChangeInputNameAction? onChangeInputNameAction;
|
||||
|
||||
IdentityInputFieldBuilder(
|
||||
const IdentityInputFieldBuilder(
|
||||
this._label,
|
||||
this._error,
|
||||
this.requiredIndicator, {
|
||||
super.key,
|
||||
this.isMandatory = false,
|
||||
this.editingController,
|
||||
this.focusNode,
|
||||
this.inputType
|
||||
this.inputType,
|
||||
this.onChangeInputNameAction
|
||||
});
|
||||
|
||||
void addOnChangeInputNameAction(OnChangeInputNameAction action) {
|
||||
onChangeInputNameAction = action;
|
||||
}
|
||||
|
||||
Widget build() {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
Text(
|
||||
isMandatory
|
||||
|
||||
+34
-42
@@ -9,44 +9,36 @@ typedef OnSelectedSuggestionAction = Function(EmailAddress? emailAddress);
|
||||
typedef OnSuggestionCallbackAction = Function(String? pattern);
|
||||
typedef OnChangeInputSuggestionAction = Function(String? pattern);
|
||||
|
||||
class IdentityInputWithDropListFieldBuilder {
|
||||
class IdentityInputWithDropListFieldBuilder extends StatelessWidget {
|
||||
|
||||
final String _label;
|
||||
final String? _error;
|
||||
final TextEditingController? editingController;
|
||||
final FocusNode? focusNode;
|
||||
final OnSelectedSuggestionAction? onSelectedSuggestionAction;
|
||||
final OnSuggestionCallbackAction? onSuggestionCallbackAction;
|
||||
final OnChangeInputSuggestionAction? onChangeInputSuggestionAction;
|
||||
|
||||
OnSelectedSuggestionAction? _onSelectedSuggestionAction;
|
||||
OnSuggestionCallbackAction? _onSuggestionCallbackAction;
|
||||
OnChangeInputSuggestionAction? _onChangeInputSuggestionAction;
|
||||
|
||||
IdentityInputWithDropListFieldBuilder(
|
||||
const IdentityInputWithDropListFieldBuilder(
|
||||
this._label,
|
||||
this._error,
|
||||
this.editingController,
|
||||
{
|
||||
this.focusNode,
|
||||
}
|
||||
);
|
||||
this.editingController, {
|
||||
super.key,
|
||||
this.focusNode,
|
||||
this.onSelectedSuggestionAction,
|
||||
this.onSuggestionCallbackAction,
|
||||
this.onChangeInputSuggestionAction,
|
||||
});
|
||||
|
||||
void addOnSelectedSuggestionAction(OnSelectedSuggestionAction action) {
|
||||
_onSelectedSuggestionAction = action;
|
||||
}
|
||||
|
||||
void addOnSuggestionCallbackAction(OnSuggestionCallbackAction action) {
|
||||
_onSuggestionCallbackAction = action;
|
||||
}
|
||||
|
||||
void addOnChangeInputSuggestionAction(OnChangeInputSuggestionAction action) {
|
||||
_onChangeInputSuggestionAction = action;
|
||||
}
|
||||
|
||||
Widget build() {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
Text(_label, style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: AppColor.colorContentEmail)),
|
||||
Text(
|
||||
_label,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: AppColor.colorContentEmail)),
|
||||
const SizedBox(height: 8),
|
||||
TypeAheadFormField<EmailAddress>(
|
||||
textFieldConfiguration: TextFieldConfiguration(
|
||||
@@ -55,18 +47,18 @@ class IdentityInputWithDropListFieldBuilder {
|
||||
textInputAction: TextInputAction.done,
|
||||
decoration: (IdentityInputDecorationBuilder()
|
||||
..setContentPadding(const EdgeInsets.symmetric(
|
||||
vertical: BuildUtils.isWeb ? 16 : 12,
|
||||
horizontal: 12))
|
||||
vertical: BuildUtils.isWeb ? 16 : 12,
|
||||
horizontal: 12))
|
||||
..setErrorText(_error))
|
||||
.build()
|
||||
.build()
|
||||
),
|
||||
debounceDuration: const Duration(milliseconds: 500),
|
||||
suggestionsCallback: (pattern) async {
|
||||
if (_onChangeInputSuggestionAction != null) {
|
||||
_onChangeInputSuggestionAction!(pattern);
|
||||
if (onChangeInputSuggestionAction != null) {
|
||||
onChangeInputSuggestionAction!(pattern);
|
||||
}
|
||||
if (_onSuggestionCallbackAction != null) {
|
||||
return _onSuggestionCallbackAction!(pattern);
|
||||
if (onSuggestionCallbackAction != null) {
|
||||
return onSuggestionCallbackAction!(pattern);
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
@@ -74,16 +66,16 @@ class IdentityInputWithDropListFieldBuilder {
|
||||
itemBuilder: (BuildContext context, emailAddress) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
||||
child: Text(emailAddress.email ?? '',
|
||||
child: Text(
|
||||
emailAddress.email ?? '',
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Colors.black)),
|
||||
);
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Colors.black)));
|
||||
},
|
||||
onSuggestionSelected: (emailSelected) {
|
||||
if (_onSelectedSuggestionAction != null) {
|
||||
_onSelectedSuggestionAction!(emailSelected);
|
||||
if (onSelectedSuggestionAction != null) {
|
||||
onSelectedSuggestionAction!(emailSelected);
|
||||
}
|
||||
},
|
||||
suggestionsBoxDecoration: SuggestionsBoxDecoration(
|
||||
|
||||
Reference in New Issue
Block a user