TF-2717 Display attachment bar below subject field on tablet

This commit is contained in:
dab246
2024-03-19 14:08:03 +07:00
committed by Dat H. Pham
parent 867e758d88
commit 0cdf89f0f9
2 changed files with 78 additions and 76 deletions
@@ -6,5 +6,6 @@ class MobileAttachmentComposerWidgetStyle {
static const double listItemHeight = 50; static const double listItemHeight = 50;
static const EdgeInsetsGeometry padding = EdgeInsetsDirectional.symmetric(vertical: 8, horizontal: 16); static const EdgeInsetsGeometry padding = EdgeInsetsDirectional.symmetric(vertical: 8, horizontal: 16);
static const EdgeInsetsGeometry tabletPadding = EdgeInsetsDirectional.only(start: 16, end: 16, bottom: 8);
static const EdgeInsetsGeometry itemMargin = EdgeInsetsDirectional.only(top: 8); static const EdgeInsetsGeometry itemMargin = EdgeInsetsDirectional.only(top: 8);
} }
@@ -53,21 +53,76 @@ class _MobileAttachmentComposerWidgetState extends State<MobileAttachmentCompose
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
padding: MobileAttachmentComposerWidgetStyle.padding, padding: _responsiveUtils.isPortraitMobile(context)
? MobileAttachmentComposerWidgetStyle.padding
: MobileAttachmentComposerWidgetStyle.tabletPadding,
width: double.infinity, width: double.infinity,
child: Column( child: _responsiveUtils.isPortraitMobile(context)
? Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
if (_responsiveUtils.isLandscapeMobile(context))
Row( Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Flexible(child: SizedBox(
width: AttachmentItemComposerWidgetStyle.width,
child: ListView.builder(
shrinkWrap: true,
primary: false,
itemCount: _listFileDisplayed.length,
itemBuilder: (context, index) {
return AttachmentItemComposerWidget(
fileState: _listFileDisplayed[index],
itemMargin: MobileAttachmentComposerWidgetStyle.itemMargin,
onDeleteAttachmentAction: widget.onDeleteAttachmentAction
);
}
),
)),
if (!_isCollapsed && _isExceededDisplayedAttachments)
TMailButtonWidget(
text: AppLocalizations.of(context).showLess,
icon: _imagePaths.icChevronUp,
iconAlignment: TextDirection.rtl,
iconSpace: 2,
iconSize: 24,
iconColor: AppColor.primaryColor,
backgroundColor: Colors.transparent,
textStyle: Theme.of(context).textTheme.labelSmall?.copyWith(
fontSize: 15,
color: AppColor.primaryColor
),
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 8),
margin: const EdgeInsetsDirectional.only(start: 8),
onTapActionCallback: _toggleListAttachments
)
],
),
if (_isCollapsed && _isExceededDisplayedAttachments)
TMailButtonWidget.fromText(
text: AppLocalizations.of(context).showMoreAttachment(_countRemainingAttachments),
backgroundColor: Colors.transparent,
textStyle: Theme.of(context).textTheme.labelSmall?.copyWith(
fontSize: 15,
color: AppColor.primaryColor
),
margin: const EdgeInsetsDirectional.only(top: 5),
onTapActionCallback: _toggleListAttachments
)
]
)
: Row(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [ children: [
Flexible( Flexible(
flex: 7, flex: 7,
child: GridView.builder( child: GridView.builder(
primary: false, primary: false,
shrinkWrap: true, shrinkWrap: true,
padding: EdgeInsets.zero,
itemCount: _listFileDisplayed.length, itemCount: _listFileDisplayed.length,
gridDelegate: const SliverGridDelegateFixedHeight( gridDelegate: const SliverGridDelegateFixedHeight(
height: MobileAttachmentComposerWidgetStyle.listItemHeight, height: MobileAttachmentComposerWidgetStyle.listItemHeight,
@@ -125,60 +180,6 @@ class _MobileAttachmentComposerWidgetState extends State<MobileAttachmentCompose
) )
], ],
) )
else
...[
Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Flexible(child: SizedBox(
width: AttachmentItemComposerWidgetStyle.width,
child: ListView.builder(
shrinkWrap: true,
primary: false,
itemCount: _listFileDisplayed.length,
itemBuilder: (context, index) {
return AttachmentItemComposerWidget(
fileState: _listFileDisplayed[index],
itemMargin: MobileAttachmentComposerWidgetStyle.itemMargin,
onDeleteAttachmentAction: widget.onDeleteAttachmentAction
);
}
),
)),
if (!_isCollapsed && _isExceededDisplayedAttachments)
TMailButtonWidget(
text: AppLocalizations.of(context).showLess,
icon: _imagePaths.icChevronUp,
iconAlignment: TextDirection.rtl,
iconSpace: 2,
iconSize: 24,
iconColor: AppColor.primaryColor,
backgroundColor: Colors.transparent,
textStyle: Theme.of(context).textTheme.labelSmall?.copyWith(
fontSize: 15,
color: AppColor.primaryColor
),
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 8),
margin: const EdgeInsetsDirectional.only(start: 8),
onTapActionCallback: _toggleListAttachments
)
],
),
if (_isCollapsed && _isExceededDisplayedAttachments)
TMailButtonWidget.fromText(
text: AppLocalizations.of(context).showMoreAttachment(_countRemainingAttachments),
backgroundColor: Colors.transparent,
textStyle: Theme.of(context).textTheme.labelSmall?.copyWith(
fontSize: 15,
color: AppColor.primaryColor
),
margin: const EdgeInsetsDirectional.only(top: 5),
onTapActionCallback: _toggleListAttachments
)
]
]
),
); );
} }
@@ -194,7 +195,7 @@ class _MobileAttachmentComposerWidgetState extends State<MobileAttachmentCompose
void _updateListFileDisplayed() { void _updateListFileDisplayed() {
final reversedList = widget.listFileUploaded.reversed.toList(); final reversedList = widget.listFileUploaded.reversed.toList();
if (_isCollapsed) { if (_isCollapsed && reversedList.length > _maxCountDisplayedAttachments) {
_listFileDisplayed = reversedList.sublist(0, _maxCountDisplayedAttachments); _listFileDisplayed = reversedList.sublist(0, _maxCountDisplayedAttachments);
} else { } else {
_listFileDisplayed = reversedList; _listFileDisplayed = reversedList;