TF-2179 Add maxLines/mainAxisSize properties for TMailButtonWidget
(cherry picked from commit 7e8dca0b363f602952c5c5126a1a6939ebb7dbca)
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
import 'package:core/presentation/action/action_callback_define.dart';
|
import 'package:core/presentation/action/action_callback_define.dart';
|
||||||
import 'package:core/presentation/extensions/color_extension.dart';
|
import 'package:core/presentation/extensions/color_extension.dart';
|
||||||
|
import 'package:core/presentation/utils/style_utils.dart';
|
||||||
import 'package:core/presentation/views/container/tmail_container_widget.dart';
|
import 'package:core/presentation/views/container/tmail_container_widget.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';
|
||||||
@@ -34,6 +35,8 @@ class TMailButtonWidget extends StatelessWidget {
|
|||||||
final bool flexibleText;
|
final bool flexibleText;
|
||||||
final BoxBorder? border;
|
final BoxBorder? border;
|
||||||
final TextDirection iconAlignment;
|
final TextDirection iconAlignment;
|
||||||
|
final int? maxLines;
|
||||||
|
final MainAxisSize mainAxisSize;
|
||||||
|
|
||||||
const TMailButtonWidget({
|
const TMailButtonWidget({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -63,6 +66,8 @@ class TMailButtonWidget extends StatelessWidget {
|
|||||||
this.flexibleText = false,
|
this.flexibleText = false,
|
||||||
this.border,
|
this.border,
|
||||||
this.iconAlignment = TextDirection.ltr,
|
this.iconAlignment = TextDirection.ltr,
|
||||||
|
this.maxLines,
|
||||||
|
this.mainAxisSize = MainAxisSize.max,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory TMailButtonWidget.fromIcon({
|
factory TMailButtonWidget.fromIcon({
|
||||||
@@ -131,6 +136,7 @@ class TMailButtonWidget extends StatelessWidget {
|
|||||||
TextAlign? textAlign,
|
TextAlign? textAlign,
|
||||||
bool flexibleText = false,
|
bool flexibleText = false,
|
||||||
BoxBorder? border,
|
BoxBorder? border,
|
||||||
|
int? maxLines,
|
||||||
}) {
|
}) {
|
||||||
return TMailButtonWidget(
|
return TMailButtonWidget(
|
||||||
key: key,
|
key: key,
|
||||||
@@ -151,6 +157,7 @@ class TMailButtonWidget extends StatelessWidget {
|
|||||||
textAlign: textAlign,
|
textAlign: textAlign,
|
||||||
flexibleText: flexibleText,
|
flexibleText: flexibleText,
|
||||||
border: border,
|
border: border,
|
||||||
|
maxLines: maxLines,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,6 +168,7 @@ class TMailButtonWidget extends StatelessWidget {
|
|||||||
if (icon != null && text.isNotEmpty) {
|
if (icon != null && text.isNotEmpty) {
|
||||||
if (verticalDirection) {
|
if (verticalDirection) {
|
||||||
childWidget = Column(
|
childWidget = Column(
|
||||||
|
mainAxisSize: mainAxisSize,
|
||||||
children: [
|
children: [
|
||||||
SvgPicture.asset(
|
SvgPicture.asset(
|
||||||
icon!,
|
icon!,
|
||||||
@@ -177,6 +185,9 @@ class TMailButtonWidget extends StatelessWidget {
|
|||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
color: AppColor.colorTextButtonHeaderThread
|
color: AppColor.colorTextButtonHeaderThread
|
||||||
),
|
),
|
||||||
|
maxLines: maxLines,
|
||||||
|
overflow: maxLines == 1 ? CommonTextStyle.defaultTextOverFlow : null,
|
||||||
|
softWrap: maxLines == 1 ? CommonTextStyle.defaultSoftWrap : null,
|
||||||
),
|
),
|
||||||
if (trailingIcon != null)
|
if (trailingIcon != null)
|
||||||
Padding(
|
Padding(
|
||||||
@@ -195,6 +206,7 @@ class TMailButtonWidget extends StatelessWidget {
|
|||||||
if (iconAlignment == TextDirection.ltr) {
|
if (iconAlignment == TextDirection.ltr) {
|
||||||
childWidget = Row(
|
childWidget = Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
mainAxisSize: mainAxisSize,
|
||||||
children: [
|
children: [
|
||||||
SvgPicture.asset(
|
SvgPicture.asset(
|
||||||
icon!,
|
icon!,
|
||||||
@@ -213,6 +225,9 @@ class TMailButtonWidget extends StatelessWidget {
|
|||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
color: AppColor.colorTextButtonHeaderThread
|
color: AppColor.colorTextButtonHeaderThread
|
||||||
),
|
),
|
||||||
|
maxLines: maxLines,
|
||||||
|
overflow: maxLines == 1 ? CommonTextStyle.defaultTextOverFlow : null,
|
||||||
|
softWrap: maxLines == 1 ? CommonTextStyle.defaultSoftWrap : null,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
@@ -223,6 +238,9 @@ class TMailButtonWidget extends StatelessWidget {
|
|||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
color: AppColor.colorTextButtonHeaderThread
|
color: AppColor.colorTextButtonHeaderThread
|
||||||
),
|
),
|
||||||
|
maxLines: maxLines,
|
||||||
|
overflow: maxLines == 1 ? CommonTextStyle.defaultTextOverFlow : null,
|
||||||
|
softWrap: maxLines == 1 ? CommonTextStyle.defaultSoftWrap : null,
|
||||||
),
|
),
|
||||||
if (trailingIcon != null)
|
if (trailingIcon != null)
|
||||||
Padding(
|
Padding(
|
||||||
@@ -240,6 +258,7 @@ class TMailButtonWidget extends StatelessWidget {
|
|||||||
} else {
|
} else {
|
||||||
childWidget = Row(
|
childWidget = Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
mainAxisSize: mainAxisSize,
|
||||||
children: [
|
children: [
|
||||||
if (flexibleText)
|
if (flexibleText)
|
||||||
Flexible(
|
Flexible(
|
||||||
@@ -250,6 +269,9 @@ class TMailButtonWidget extends StatelessWidget {
|
|||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
color: AppColor.colorTextButtonHeaderThread
|
color: AppColor.colorTextButtonHeaderThread
|
||||||
),
|
),
|
||||||
|
maxLines: maxLines,
|
||||||
|
overflow: maxLines == 1 ? CommonTextStyle.defaultTextOverFlow : null,
|
||||||
|
softWrap: maxLines == 1 ? CommonTextStyle.defaultSoftWrap : null,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
@@ -260,6 +282,9 @@ class TMailButtonWidget extends StatelessWidget {
|
|||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
color: AppColor.colorTextButtonHeaderThread
|
color: AppColor.colorTextButtonHeaderThread
|
||||||
),
|
),
|
||||||
|
maxLines: maxLines,
|
||||||
|
overflow: maxLines == 1 ? CommonTextStyle.defaultTextOverFlow : null,
|
||||||
|
softWrap: maxLines == 1 ? CommonTextStyle.defaultSoftWrap : null,
|
||||||
),
|
),
|
||||||
SizedBox(width: iconSpace),
|
SizedBox(width: iconSpace),
|
||||||
SvgPicture.asset(
|
SvgPicture.asset(
|
||||||
@@ -289,6 +314,9 @@ class TMailButtonWidget extends StatelessWidget {
|
|||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
color: AppColor.colorTextButtonHeaderThread
|
color: AppColor.colorTextButtonHeaderThread
|
||||||
),
|
),
|
||||||
|
maxLines: maxLines,
|
||||||
|
overflow: maxLines == 1 ? CommonTextStyle.defaultTextOverFlow : null,
|
||||||
|
softWrap: maxLines == 1 ? CommonTextStyle.defaultSoftWrap : null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user