Reuse widgets for advanced search form view
Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
import 'package:core/presentation/extensions/color_extension.dart';
|
||||
import 'package:core/presentation/utils/theme_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
|
||||
class DefaultButtonArrowDownFieldWidget extends StatelessWidget {
|
||||
final String text;
|
||||
final String iconArrowDown;
|
||||
final VoidCallback onTap;
|
||||
|
||||
const DefaultButtonArrowDownFieldWidget({
|
||||
super.key,
|
||||
required this.text,
|
||||
required this.iconArrowDown,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Material(
|
||||
type: MaterialType.transparency,
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
||||
focusColor: AppColor.colorMailboxHovered,
|
||||
child: Container(
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
||||
border: Border.all(
|
||||
color: AppColor.m3Neutral90,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
padding: const EdgeInsetsDirectional.only(start: 12, end: 8),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
text,
|
||||
style: ThemeUtils.textStyleBodyBody3(
|
||||
color: AppColor.m3SurfaceBackground,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
SvgPicture.asset(iconArrowDown),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:tmail_ui_user/features/base/widget/default_field/default_button_arrow_down_field_widget.dart';
|
||||
|
||||
class DefaultButtonArrowDownFieldWithTabKeyWidget extends StatelessWidget {
|
||||
final String text;
|
||||
final String iconArrowDown;
|
||||
final VoidCallback onTap;
|
||||
final FocusNode currentFocusNode;
|
||||
final FocusNode nextFocusNode;
|
||||
|
||||
const DefaultButtonArrowDownFieldWithTabKeyWidget({
|
||||
super.key,
|
||||
required this.text,
|
||||
required this.iconArrowDown,
|
||||
required this.onTap,
|
||||
required this.currentFocusNode,
|
||||
required this.nextFocusNode,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return KeyboardListener(
|
||||
focusNode: currentFocusNode,
|
||||
onKeyEvent: _onKeyEvent,
|
||||
child: DefaultButtonArrowDownFieldWidget(
|
||||
text: text,
|
||||
iconArrowDown: iconArrowDown,
|
||||
onTap: onTap,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _onKeyEvent(KeyEvent event) {
|
||||
if (event is KeyDownEvent &&
|
||||
event.logicalKey == LogicalKeyboardKey.tab) {
|
||||
nextFocusNode.requestFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import 'package:core/presentation/resources/image_paths.dart';
|
||||
import 'package:core/presentation/views/button/tmail_button_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/model/search/email_receive_time_type.dart';
|
||||
import 'package:tmail_ui_user/features/base/widget/default_field/date_drop_down_button.dart';
|
||||
import 'package:tmail_ui_user/features/base/widget/default_field/default_date_drop_down_button.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
|
||||
typedef OnOpenDatPicker = void Function();
|
||||
|
||||
@@ -8,7 +8,7 @@ typedef OnTextChange = void Function(String text);
|
||||
class DefaultInputFieldWithTabKeyWidget extends StatelessWidget {
|
||||
final TextEditingController textEditingController;
|
||||
final FocusNode currentFocusNode;
|
||||
final FocusNode? nextFocusNode;
|
||||
final FocusNode nextFocusNode;
|
||||
final String? hintText;
|
||||
final OnTextChange? onTextChange;
|
||||
final OnTextSubmitted? onTextSubmitted;
|
||||
@@ -18,7 +18,7 @@ class DefaultInputFieldWithTabKeyWidget extends StatelessWidget {
|
||||
super.key,
|
||||
required this.textEditingController,
|
||||
required this.currentFocusNode,
|
||||
this.nextFocusNode,
|
||||
required this.nextFocusNode,
|
||||
this.hintText,
|
||||
this.onTextChange,
|
||||
this.onTextSubmitted,
|
||||
@@ -29,7 +29,7 @@ class DefaultInputFieldWithTabKeyWidget extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final bodyWidget = KeyboardListener(
|
||||
focusNode: currentFocusNode,
|
||||
onKeyEvent: nextFocusNode == null ? null : _onKeyEvent,
|
||||
onKeyEvent: _onKeyEvent,
|
||||
child: DefaultInputFieldWidget(
|
||||
textEditingController: textEditingController,
|
||||
hintText: hintText,
|
||||
@@ -48,7 +48,7 @@ class DefaultInputFieldWithTabKeyWidget extends StatelessWidget {
|
||||
void _onKeyEvent(KeyEvent event) {
|
||||
if (event is KeyDownEvent &&
|
||||
event.logicalKey == LogicalKeyboardKey.tab) {
|
||||
nextFocusNode?.requestFocus();
|
||||
nextFocusNode.requestFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user