TF-2510 Fix padding/style attachment item
Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
|
||||
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:core/presentation/utils/responsive_utils.dart';
|
||||
import 'package:core/presentation/views/button/tmail_button_widget.dart';
|
||||
import 'package:core/utils/platform_info.dart';
|
||||
import 'package:extended_text/extended_text.dart';
|
||||
import 'package:filesize/filesize.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -19,6 +19,7 @@ class AttachmentItemWidget extends StatelessWidget {
|
||||
final OnDownloadAttachmentFileActionClick? downloadAttachmentAction;
|
||||
|
||||
final _imagePaths = Get.find<ImagePaths>();
|
||||
final _responsiveUtils = Get.find<ResponsiveUtils>();
|
||||
|
||||
AttachmentItemWidget({
|
||||
Key? key,
|
||||
@@ -41,73 +42,63 @@ class AttachmentItemWidget extends StatelessWidget {
|
||||
borderRadius: const BorderRadius.all(Radius.circular(AttachmentItemWidgetStyle.radius)),
|
||||
border: Border.all(color: AttachmentItemWidgetStyle.borderColor),
|
||||
),
|
||||
width: AttachmentItemWidgetStyle.width,
|
||||
height: AttachmentItemWidgetStyle.height,
|
||||
child: Stack(
|
||||
width: _getMaxWidthItem(context),
|
||||
child: Row(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: Row(
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
attachment.getIcon(_imagePaths),
|
||||
width: AttachmentItemWidgetStyle.iconSize,
|
||||
height: AttachmentItemWidgetStyle.iconSize,
|
||||
fit: BoxFit.fill
|
||||
SvgPicture.asset(
|
||||
attachment.getIcon(_imagePaths),
|
||||
width: AttachmentItemWidgetStyle.iconSize,
|
||||
height: AttachmentItemWidgetStyle.iconSize,
|
||||
fit: BoxFit.fill
|
||||
),
|
||||
const SizedBox(width: AttachmentItemWidgetStyle.space),
|
||||
Expanded(
|
||||
child: ExtendedText(
|
||||
(attachment.name ?? ''),
|
||||
maxLines: 1,
|
||||
overflowWidget: const TextOverflowWidget(
|
||||
position: TextOverflowPosition.middle,
|
||||
child: Text(
|
||||
"...",
|
||||
style: AttachmentItemWidgetStyle.dotsLabelTextStyle,
|
||||
),
|
||||
const SizedBox(width: AttachmentItemWidgetStyle.space),
|
||||
Expanded(child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: AttachmentItemWidgetStyle.attachmentNameMaxWidth,
|
||||
child: ExtendedText(
|
||||
(attachment.name ?? ''),
|
||||
maxLines: 1,
|
||||
overflow: CommonTextStyle.defaultTextOverFlow,
|
||||
softWrap: CommonTextStyle.defaultSoftWrap,
|
||||
overflowWidget: TextOverflowWidget(
|
||||
position: Directionality.maybeOf(context) == TextDirection.rtl
|
||||
? TextOverflowPosition.start
|
||||
: TextOverflowPosition.end,
|
||||
child: const Text(
|
||||
"...",
|
||||
style: AttachmentItemWidgetStyle.dotsLabelTextStyle,
|
||||
),
|
||||
),
|
||||
style: AttachmentItemWidgetStyle.labelTextStyle,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
filesize(attachment.size?.value),
|
||||
maxLines: 1,
|
||||
overflow: CommonTextStyle.defaultTextOverFlow,
|
||||
softWrap: CommonTextStyle.defaultSoftWrap,
|
||||
style: AttachmentItemWidgetStyle.sizeLabelTextStyle,
|
||||
)
|
||||
]
|
||||
)),
|
||||
Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
customBorder: const CircleBorder(),
|
||||
child: SvgPicture.asset(
|
||||
_imagePaths.icDownloadAttachment,
|
||||
width: AttachmentItemWidgetStyle.downloadIconSize,
|
||||
height: AttachmentItemWidgetStyle.downloadIconSize,
|
||||
colorFilter: AttachmentItemWidgetStyle.downloadIconColor.asFilter(),
|
||||
fit: BoxFit.fill
|
||||
),
|
||||
onTap: () => downloadAttachmentAction?.call(attachment)
|
||||
),
|
||||
),
|
||||
]
|
||||
),
|
||||
style: AttachmentItemWidgetStyle.labelTextStyle,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: AttachmentItemWidgetStyle.space),
|
||||
Text(
|
||||
filesize(attachment.size?.value),
|
||||
maxLines: 1,
|
||||
style: AttachmentItemWidgetStyle.sizeLabelTextStyle,
|
||||
),
|
||||
TMailButtonWidget.fromIcon(
|
||||
icon: _imagePaths.icDownloadAttachment,
|
||||
backgroundColor: Colors.transparent,
|
||||
padding: const EdgeInsets.all(5),
|
||||
iconSize: AttachmentItemWidgetStyle.downloadIconSize,
|
||||
onTapActionCallback: () => downloadAttachmentAction?.call(attachment)
|
||||
)
|
||||
]
|
||||
)
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
double _getMaxWidthItem(BuildContext context) {
|
||||
if (PlatformInfo.isMobile) {
|
||||
return _responsiveUtils.isMobile(context)
|
||||
? AttachmentItemWidgetStyle.maxWidthMobile
|
||||
: AttachmentItemWidgetStyle.maxWidthTablet;
|
||||
} else {
|
||||
if (_responsiveUtils.isTabletLarge(context)) {
|
||||
return AttachmentItemWidgetStyle.maxWidthTabletLarge;
|
||||
} else if (_responsiveUtils.isTablet(context)) {
|
||||
return AttachmentItemWidgetStyle.maxWidthTablet;
|
||||
} else {
|
||||
return AttachmentItemWidgetStyle.maxWidthMobile;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user