TF-2537 Fix app crash when user trying attach file to composer in web app
Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:core/utils/app_logger.dart';
|
import 'package:core/utils/app_logger.dart';
|
||||||
|
import 'package:core/utils/web_renderer/canvas_kit.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
|
|
||||||
abstract class PlatformInfo {
|
abstract class PlatformInfo {
|
||||||
@@ -13,7 +14,7 @@ abstract class PlatformInfo {
|
|||||||
static bool get isAndroid => !kIsWeb && Platform.isAndroid;
|
static bool get isAndroid => !kIsWeb && Platform.isAndroid;
|
||||||
static bool get isMobile => isAndroid || isIOS;
|
static bool get isMobile => isAndroid || isIOS;
|
||||||
static bool get isDesktop => isLinux || isWindows || isMacOS;
|
static bool get isDesktop => isLinux || isWindows || isMacOS;
|
||||||
static bool get isWebMobile => kIsWeb && (defaultTargetPlatform == TargetPlatform.iOS || defaultTargetPlatform == TargetPlatform.android);
|
static bool get isCanvasKit => isRendererCanvasKit;
|
||||||
|
|
||||||
static String get platformNameOS {
|
static String get platformNameOS {
|
||||||
var platformName = '';
|
var platformName = '';
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
export 'canvas_kit_stub.dart' if (dart.library.html) 'canvas_kit_web.dart';
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
/// Whether the CanvasKit renderer is being used on web.
|
||||||
|
///
|
||||||
|
/// Always returns `false` on non-web.
|
||||||
|
bool get isRendererCanvasKit => false;
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import 'dart:js' as js;
|
||||||
|
|
||||||
|
/// Whether the CanvasKit renderer is being used on web.
|
||||||
|
///
|
||||||
|
/// Always returns `false` on non-web.
|
||||||
|
bool get isRendererCanvasKit => js.context['flutterCanvasKit'] != null;
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:core/presentation/resources/image_paths.dart';
|
import 'package:core/presentation/resources/image_paths.dart';
|
||||||
import 'package:core/presentation/views/button/tmail_button_widget.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:extended_text/extended_text.dart';
|
||||||
import 'package:filesize/filesize.dart';
|
import 'package:filesize/filesize.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@@ -58,18 +59,25 @@ class AttachmentItemComposerWidget extends StatelessWidget with AppLoaderMixin {
|
|||||||
),
|
),
|
||||||
const SizedBox(width: AttachmentItemComposerWidgetStyle.space),
|
const SizedBox(width: AttachmentItemComposerWidgetStyle.space),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ExtendedText(
|
child: PlatformInfo.isCanvasKit
|
||||||
fileState.fileName,
|
? ExtendedText(
|
||||||
maxLines: 1,
|
fileState.fileName,
|
||||||
overflowWidget: const TextOverflowWidget(
|
maxLines: 1,
|
||||||
position: TextOverflowPosition.middle,
|
overflowWidget: const TextOverflowWidget(
|
||||||
child: Text(
|
position: TextOverflowPosition.middle,
|
||||||
'...',
|
child: Text(
|
||||||
style: AttachmentItemComposerWidgetStyle.dotsLabelTextStyle,
|
'...',
|
||||||
),
|
style: AttachmentItemComposerWidgetStyle.dotsLabelTextStyle,
|
||||||
),
|
),
|
||||||
style: AttachmentItemComposerWidgetStyle.labelTextStyle,
|
),
|
||||||
),
|
style: AttachmentItemComposerWidgetStyle.labelTextStyle,
|
||||||
|
)
|
||||||
|
: Text(
|
||||||
|
fileState.fileName,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: AttachmentItemComposerWidgetStyle.labelTextStyle,
|
||||||
|
)
|
||||||
),
|
),
|
||||||
const SizedBox(width: AttachmentItemComposerWidgetStyle.space),
|
const SizedBox(width: AttachmentItemComposerWidgetStyle.space),
|
||||||
Text(
|
Text(
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class RecipientTagItemWidget extends StatelessWidget {
|
|||||||
Flexible(
|
Flexible(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsetsDirectional.only(
|
padding: EdgeInsetsDirectional.only(
|
||||||
top: PlatformInfo.isWebMobile ? 0 : 8
|
top: !PlatformInfo.isCanvasKit ? 0 : 8
|
||||||
),
|
),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () => isCollapsed
|
onTap: () => isCollapsed
|
||||||
@@ -158,10 +158,10 @@ class RecipientTagItemWidget extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
EdgeInsetsGeometry? get _counterMargin {
|
EdgeInsetsGeometry? get _counterMargin {
|
||||||
if (PlatformInfo.isWebMobile) {
|
if (PlatformInfo.isWeb) {
|
||||||
return RecipientTagItemWidgetStyle.webMobileCounterMargin;
|
return PlatformInfo.isCanvasKit
|
||||||
} else if (PlatformInfo.isWeb) {
|
? RecipientTagItemWidgetStyle.webCounterMargin
|
||||||
return RecipientTagItemWidgetStyle.webCounterMargin;
|
: RecipientTagItemWidgetStyle.webMobileCounterMargin;
|
||||||
} else {
|
} else {
|
||||||
return RecipientTagItemWidgetStyle.counterMargin;
|
return RecipientTagItemWidgetStyle.counterMargin;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,18 +53,25 @@ class AttachmentItemWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
const SizedBox(width: AttachmentItemWidgetStyle.space),
|
const SizedBox(width: AttachmentItemWidgetStyle.space),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ExtendedText(
|
child: PlatformInfo.isCanvasKit
|
||||||
(attachment.name ?? ''),
|
? ExtendedText(
|
||||||
maxLines: 1,
|
(attachment.name ?? ''),
|
||||||
overflowWidget: const TextOverflowWidget(
|
maxLines: 1,
|
||||||
position: TextOverflowPosition.middle,
|
overflowWidget: const TextOverflowWidget(
|
||||||
child: Text(
|
position: TextOverflowPosition.middle,
|
||||||
"...",
|
child: Text(
|
||||||
style: AttachmentItemWidgetStyle.dotsLabelTextStyle,
|
"...",
|
||||||
),
|
style: AttachmentItemWidgetStyle.dotsLabelTextStyle,
|
||||||
),
|
),
|
||||||
style: AttachmentItemWidgetStyle.labelTextStyle,
|
),
|
||||||
),
|
style: AttachmentItemWidgetStyle.labelTextStyle,
|
||||||
|
)
|
||||||
|
: Text(
|
||||||
|
(attachment.name ?? ''),
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: AttachmentItemWidgetStyle.labelTextStyle,
|
||||||
|
)
|
||||||
),
|
),
|
||||||
const SizedBox(width: AttachmentItemWidgetStyle.space),
|
const SizedBox(width: AttachmentItemWidgetStyle.space),
|
||||||
Text(
|
Text(
|
||||||
|
|||||||
+19
-10
@@ -1,6 +1,7 @@
|
|||||||
import 'package:core/presentation/resources/image_paths.dart';
|
import 'package:core/presentation/resources/image_paths.dart';
|
||||||
import 'package:core/presentation/utils/style_utils.dart';
|
import 'package:core/presentation/utils/style_utils.dart';
|
||||||
import 'package:core/presentation/views/button/tmail_button_widget.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:extended_text/extended_text.dart';
|
||||||
import 'package:filesize/filesize.dart';
|
import 'package:filesize/filesize.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@@ -46,18 +47,26 @@ class AttachmentListItemWidget extends StatelessWidget {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
ExtendedText(
|
if (PlatformInfo.isCanvasKit)
|
||||||
(attachment.name ?? ''),
|
ExtendedText(
|
||||||
maxLines: 1,
|
(attachment.name ?? ''),
|
||||||
overflowWidget: const TextOverflowWidget(
|
maxLines: 1,
|
||||||
position: TextOverflowPosition.middle,
|
overflowWidget: const TextOverflowWidget(
|
||||||
child: Text(
|
position: TextOverflowPosition.middle,
|
||||||
"...",
|
child: Text(
|
||||||
style: AttachmentListItemWidgetStyle.dotsLabelTextStyle,
|
"...",
|
||||||
|
style: AttachmentListItemWidgetStyle.dotsLabelTextStyle,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
style: AttachmentListItemWidgetStyle.labelTextStyle,
|
||||||
|
)
|
||||||
|
else
|
||||||
|
Text(
|
||||||
|
(attachment.name ?? ''),
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: AttachmentListItemWidgetStyle.labelTextStyle,
|
||||||
),
|
),
|
||||||
style: AttachmentListItemWidgetStyle.labelTextStyle,
|
|
||||||
),
|
|
||||||
const SizedBox(height: AttachmentListItemWidgetStyle.fileTitleBottomSpace),
|
const SizedBox(height: AttachmentListItemWidgetStyle.fileTitleBottomSpace),
|
||||||
Text(
|
Text(
|
||||||
filesize(attachment.size?.value),
|
filesize(attachment.size?.value),
|
||||||
|
|||||||
+20
-12
@@ -1,4 +1,5 @@
|
|||||||
import 'package:core/presentation/resources/image_paths.dart';
|
import 'package:core/presentation/resources/image_paths.dart';
|
||||||
|
import 'package:core/utils/platform_info.dart';
|
||||||
import 'package:extended_text/extended_text.dart';
|
import 'package:extended_text/extended_text.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
@@ -43,20 +44,27 @@ class FeedbackDraggableAttachmentItemWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
const SizedBox(width: FeedbackDraggableAttachmentItemWidgetStyle.space),
|
const SizedBox(width: FeedbackDraggableAttachmentItemWidgetStyle.space),
|
||||||
Flexible(
|
Flexible(
|
||||||
child: DefaultTextStyle(
|
child: PlatformInfo.isCanvasKit
|
||||||
style: FeedbackDraggableAttachmentItemWidgetStyle.labelTextStyle,
|
? DefaultTextStyle(
|
||||||
child: ExtendedText(
|
style: FeedbackDraggableAttachmentItemWidgetStyle.labelTextStyle,
|
||||||
attachment.name ?? '',
|
child: ExtendedText(
|
||||||
maxLines: 1,
|
attachment.name ?? '',
|
||||||
overflowWidget: const TextOverflowWidget(
|
maxLines: 1,
|
||||||
position: TextOverflowPosition.middle,
|
overflowWidget: const TextOverflowWidget(
|
||||||
child: Text(
|
position: TextOverflowPosition.middle,
|
||||||
'...',
|
child: Text(
|
||||||
style: FeedbackDraggableAttachmentItemWidgetStyle.dotsLabelTextStyle,
|
'...',
|
||||||
|
style: FeedbackDraggableAttachmentItemWidgetStyle.dotsLabelTextStyle,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
)
|
||||||
|
: Text(
|
||||||
|
attachment.name ?? '',
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: FeedbackDraggableAttachmentItemWidgetStyle.labelTextStyle,
|
||||||
),
|
),
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user