Skip to content

Commit

Permalink
TF-2237 Add loading circular for send button
Browse files Browse the repository at this point in the history
(cherry picked from commit d9db8f4)
  • Loading branch information
hieutbui authored and hoangdat committed Oct 31, 2023
1 parent d26f86c commit f7baf72
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
26 changes: 19 additions & 7 deletions core/lib/presentation/views/button/tmail_button_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class TMailButtonWidget extends StatelessWidget {
final TextDirection iconAlignment;
final int? maxLines;
final MainAxisSize mainAxisSize;
final bool? isLoading;

const TMailButtonWidget({
super.key,
Expand Down Expand Up @@ -68,6 +69,7 @@ class TMailButtonWidget extends StatelessWidget {
this.iconAlignment = TextDirection.ltr,
this.maxLines,
this.mainAxisSize = MainAxisSize.max,
this.isLoading = false,
});

factory TMailButtonWidget.fromIcon({
Expand Down Expand Up @@ -287,13 +289,23 @@ class TMailButtonWidget extends StatelessWidget {
softWrap: maxLines == 1 ? CommonTextStyle.defaultSoftWrap : null,
),
SizedBox(width: iconSpace),
SvgPicture.asset(
icon!,
width: iconSize,
height: iconSize,
fit: BoxFit.fill,
colorFilter: iconColor?.asFilter()
),
if (!isLoading!)
SvgPicture.asset(
icon!,
width: iconSize,
height: iconSize,
fit: BoxFit.fill,
colorFilter: iconColor?.asFilter()
)
else
SizedBox(
width: iconSize,
height: iconSize,
child: const CircularProgressIndicator(
color: Colors.white,
strokeWidth: 2,
)
),
]
);
}
Expand Down
1 change: 1 addition & 0 deletions lib/features/composer/presentation/composer_view_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ class ComposerView extends GetWidget<ComposerController> {
radius: ComposerStyle.popupMenuRadius
);
},
isSending: controller.isSendEmailLoading.value,
)),
]);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class BottomBarComposerWidget extends StatelessWidget {
final VoidCallback saveToDraftAction;
final VoidCallback sendMessageAction;
final OnRequestReadReceiptAction? requestReadReceiptAction;
final bool? isSending;

final _imagePaths = Get.find<ImagePaths>();

Expand All @@ -34,6 +35,7 @@ class BottomBarComposerWidget extends StatelessWidget {
required this.saveToDraftAction,
required this.sendMessageAction,
this.requestReadReceiptAction,
this.isSending,
});

@override
Expand Down Expand Up @@ -126,7 +128,7 @@ class BottomBarComposerWidget extends StatelessWidget {
),
const SizedBox(width: BottomBarComposerWidgetStyle.sendButtonSpace),
TMailButtonWidget(
text: AppLocalizations.of(context).send,
text: isSending! ? AppLocalizations.of(context).sending : AppLocalizations.of(context).send,
icon: _imagePaths.icSend,
iconAlignment: TextDirection.rtl,
padding: BottomBarComposerWidgetStyle.sendButtonPadding,
Expand All @@ -136,6 +138,7 @@ class BottomBarComposerWidget extends StatelessWidget {
backgroundColor: BottomBarComposerWidgetStyle.sendButtonBackgroundColor,
borderRadius: BottomBarComposerWidgetStyle.sendButtonRadius,
onTapActionCallback: sendMessageAction,
isLoading: isSending,
)
]
),
Expand Down

0 comments on commit f7baf72

Please sign in to comment.