TF-4171 Display tag in mailbox list
This commit is contained in:
@@ -18,6 +18,7 @@ export 'presentation/extensions/map_extensions.dart';
|
||||
export 'presentation/extensions/either_view_state_extension.dart';
|
||||
export 'presentation/extensions/media_type_extension.dart';
|
||||
export 'presentation/extensions/scroll_controller_extension.dart';
|
||||
export 'presentation/extensions/hex_color_extension.dart';
|
||||
|
||||
// Exceptions
|
||||
export 'domain/exceptions/download_file_exception.dart';
|
||||
@@ -63,6 +64,7 @@ export 'utils/web_link_generator.dart';
|
||||
export 'utils/sentry/sentry_manager.dart';
|
||||
export 'utils/config/env_loader.dart';
|
||||
export 'utils/sentry/sentry_dio_helper.dart';
|
||||
export 'utils/widget_utils.dart';
|
||||
|
||||
// Views
|
||||
export 'presentation/views/text/slogan_builder.dart';
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
extension HexColorExtension on String {
|
||||
Color toColor({Color fallback = Colors.transparent}) {
|
||||
try {
|
||||
final hex = replaceAll('#', '');
|
||||
|
||||
if (hex.length != 6 && hex.length != 8) {
|
||||
return fallback;
|
||||
}
|
||||
|
||||
final fullHex = hex.length == 6 ? 'FF$hex' : hex;
|
||||
return Color(int.parse(fullHex, radix: 16));
|
||||
} catch (_) {
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class WidgetUtils {
|
||||
WidgetUtils._();
|
||||
|
||||
static double measureTextWidth({
|
||||
required String text,
|
||||
double fallbackWidth = 0,
|
||||
TextStyle? style,
|
||||
Locale? locale,
|
||||
double? horizontalPadding,
|
||||
}) {
|
||||
try {
|
||||
final textPainter = TextPainter(
|
||||
text: TextSpan(
|
||||
text: text,
|
||||
style: style,
|
||||
locale: locale,
|
||||
),
|
||||
maxLines: 1,
|
||||
textDirection: TextDirection.ltr,
|
||||
)..layout();
|
||||
|
||||
if (horizontalPadding != null) {
|
||||
return textPainter.width + horizontalPadding * 2;
|
||||
} else {
|
||||
return textPainter.width;
|
||||
}
|
||||
} catch (e) {
|
||||
return fallbackWidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user