diff --git a/assets/images/ic_connected_internet.svg b/assets/images/ic_connected_internet.svg
new file mode 100644
index 000000000..15017ad6c
--- /dev/null
+++ b/assets/images/ic_connected_internet.svg
@@ -0,0 +1,5 @@
+
diff --git a/core/lib/presentation/resources/image_paths.dart b/core/lib/presentation/resources/image_paths.dart
index 61bd47931..f21ac42af 100644
--- a/core/lib/presentation/resources/image_paths.dart
+++ b/core/lib/presentation/resources/image_paths.dart
@@ -189,6 +189,7 @@ class ImagePaths {
String get icMenuMailbox => _getImagePath('ic_menu_mailbox.svg');
String get icDelivering => _getImagePath('ic_delivering.svg');
String get icError => _getImagePath('ic_error.svg');
+ String get icConnectedInternet => _getImagePath('ic_connected_internet.svg');
String _getImagePath(String imageName) {
return AssetsPaths.images + imageName;
diff --git a/core/lib/presentation/utils/app_toast.dart b/core/lib/presentation/utils/app_toast.dart
index beea665c0..b1bbf0aa5 100644
--- a/core/lib/presentation/utils/app_toast.dart
+++ b/core/lib/presentation/utils/app_toast.dart
@@ -15,7 +15,8 @@ class AppToast {
String message,
{
Color? leadingSVGIconColor,
- String? leadingSVGIcon
+ String? leadingSVGIcon,
+ Duration? duration,
}
) {
final imagePaths = Get.find();
@@ -25,7 +26,8 @@ class AppToast {
backgroundColor: AppColor.toastErrorBackgroundColor,
textColor: Colors.white,
leadingSVGIconColor: leadingSVGIconColor ?? (leadingSVGIcon == null ? Colors.white : null),
- leadingSVGIcon: leadingSVGIcon ?? imagePaths.icNotConnection
+ leadingSVGIcon: leadingSVGIcon ?? imagePaths.icNotConnection,
+ duration: duration
);
}
@@ -35,6 +37,7 @@ class AppToast {
{
Color? leadingSVGIconColor,
String? leadingSVGIcon,
+ Duration? duration,
}
) {
final imagePaths = Get.find();
@@ -44,7 +47,8 @@ class AppToast {
backgroundColor: AppColor.toastSuccessBackgroundColor,
textColor: Colors.white,
leadingSVGIconColor: leadingSVGIconColor ?? (leadingSVGIcon == null ? Colors.white : null),
- leadingSVGIcon: leadingSVGIcon ?? imagePaths.icToastSuccessMessage
+ leadingSVGIcon: leadingSVGIcon ?? imagePaths.icToastSuccessMessage,
+ duration: duration
);
}
@@ -54,6 +58,7 @@ class AppToast {
{
Color? leadingSVGIconColor,
String? leadingSVGIcon,
+ Duration? duration,
}
) {
final imagePaths = Get.find();
@@ -63,7 +68,8 @@ class AppToast {
backgroundColor: AppColor.toastWarningBackgroundColor,
textColor: Colors.white,
leadingSVGIconColor: leadingSVGIconColor ?? (leadingSVGIcon == null ? Colors.white : null),
- leadingSVGIcon: leadingSVGIcon ?? imagePaths.icInfoCircleOutline
+ leadingSVGIcon: leadingSVGIcon ?? imagePaths.icInfoCircleOutline,
+ duration: duration
);
}
@@ -84,7 +90,8 @@ class AppToast {
Color? textActionColor,
TextStyle? textStyle,
EdgeInsets? padding,
- TextAlign? textAlign
+ TextAlign? textAlign,
+ Duration? duration,
}
) {
final responsiveUtils = Get.find();
@@ -160,7 +167,7 @@ class AppToast {
TMailToast.showToast(
message,
context,
- width: maxWidth ?? responsiveUtils.getMaxWidthToast(context),
+ maxWidth: maxWidth ?? responsiveUtils.getMaxWidthToast(context),
toastPosition: ToastPosition.BOTTOM,
textStyle: textStyle ?? TextStyle(
fontSize: 15,
@@ -172,7 +179,9 @@ class AppToast {
leading: leadingWidget,
padding: padding,
textAlign: textAlign,
- toastDuration: infinityToast ? null : 3,
+ toastDuration: infinityToast
+ ? null
+ : (duration ?? const Duration(seconds: 3)),
);
}
}
diff --git a/core/lib/presentation/views/toast/tmail_toast.dart b/core/lib/presentation/views/toast/tmail_toast.dart
index 45645089d..f4c69003b 100644
--- a/core/lib/presentation/views/toast/tmail_toast.dart
+++ b/core/lib/presentation/views/toast/tmail_toast.dart
@@ -5,62 +5,25 @@ import 'package:core/presentation/views/toast/toast_position.dart';
import 'package:flutter/material.dart';
class TMailToast {
- /// text of type [String] display on toast
- String? text;
-
- /// defines the duration of time toast display over screen
- int? toastDuration;
-
- /// defines the position of toast over the screen
- ToastPosition? toastPosition;
-
- /// defines the background color of the toast
- Color? backgroundColor;
-
- /// defines the test style of the toast text
- TextStyle? textStyle;
-
- /// defines the border radius of the toast
- double? toastBorderRadius;
-
- /// defines the border of the toast
- Border? border;
-
- /// defines the trailing widget of the toast
- Widget? trailing;
-
- /// defines the leading widget of the toast
- Widget? leading;
-
- /// defines the size width widget of the toast
- double? width;
-
- /// defines the padding widget of the toast
- EdgeInsets? padding;
-
- /// defines the align text of the toast
- TextAlign? textAlign;
-
static showToast(
- text,
- BuildContext context, {
- toastDuration,
- toastPosition,
- backgroundColor,
- textStyle = const TextStyle(
- fontSize: 15,
- color: Colors.white,
- fontWeight: FontWeight.normal
- ),
- toastBorderRadius = 10.0,
- border,
- trailing,
- leading,
- width,
- padding,
- textAlign
- }) {
- assert(text != null);
+ String text,
+ BuildContext context, {
+ Duration? toastDuration,
+ ToastPosition? toastPosition,
+ Color? backgroundColor,
+ TextStyle textStyle = const TextStyle(
+ fontSize: 15,
+ color: Colors.white,
+ fontWeight: FontWeight.normal
+ ),
+ double toastBorderRadius = 10.0,
+ Border? border,
+ Widget? trailing,
+ Widget? leading,
+ double maxWidth = 424,
+ EdgeInsets? padding,
+ TextAlign? textAlign
+ }) {
ToastView.dismiss();
ToastView.createView(
text,
@@ -72,7 +35,7 @@ class TMailToast {
border,
trailing,
leading,
- width,
+ maxWidth,
padding,
textAlign,
toastDuration: toastDuration,
@@ -99,18 +62,17 @@ class ToastView {
Border? border,
Widget? trailing,
Widget? leading,
- double? width,
+ double maxWidth,
EdgeInsets? padding,
TextAlign? textAlign,
- {int? toastDuration}
+ {Duration? toastDuration}
) async {
overlayState = Overlay.of(context, rootOverlay: false);
-
final Widget child = Center(
child: Material(
color: Colors.transparent,
child: Container(
- width: width,
+ constraints: BoxConstraints(maxWidth: maxWidth),
decoration: BoxDecoration(
color: backgroundColor ?? Colors.white,
borderRadius: BorderRadius.circular(toastBorderRadius),
@@ -126,8 +88,7 @@ class ToastView {
offset: Offset.zero),
]
),
- margin: const EdgeInsets.symmetric(horizontal: 16),
- padding: padding ?? const EdgeInsets.all(12),
+ padding: padding ?? const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
child: trailing == null && leading == null
? Text(
text,
@@ -140,21 +101,39 @@ class ToastView {
textAlign: textAlign
)
: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ mainAxisSize: MainAxisSize.min,
children: [
if (leading != null) leading,
- Expanded(child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 12),
- child: Text(
- text,
- style: textStyle ?? const TextStyle(
- fontSize: 15,
- color: Colors.white,
- fontWeight: FontWeight.normal
+ if (trailing != null)
+ Expanded(child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 12),
+ child: Text(
+ text,
+ style: textStyle ?? const TextStyle(
+ fontSize: 15,
+ color: Colors.white,
+ fontWeight: FontWeight.normal
+ ),
+ textAlign: textAlign
+ )
+ ))
+ else
+ Container(
+ constraints: BoxConstraints(maxWidth: _getMaxWidthTitleByLeadingTrailingSize(
+ currentMaxWidth: maxWidth,
+ leading: leading
+ )),
+ padding: const EdgeInsets.symmetric(horizontal: 12),
+ child: Text(
+ text,
+ style: textStyle ?? const TextStyle(
+ fontSize: 15,
+ color: Colors.white,
+ fontWeight: FontWeight.normal
+ ),
+ textAlign: textAlign
),
- textAlign: textAlign
- )
- )),
+ ),
if (trailing != null) trailing
],
),
@@ -166,7 +145,7 @@ class ToastView {
_overlayEntry = OverlayEntry(builder: (context) =>
_showWidgetBasedOnPosition(
toastDuration != null
- ? ToastCard(child, Duration(seconds: toastDuration))
+ ? ToastCard(child, toastDuration)
: child,
toastPosition,
)
@@ -175,22 +154,29 @@ class ToastView {
_isVisible = true;
overlayState!.insert(_overlayEntry!);
if (toastDuration != null) {
- await Future.delayed(Duration(seconds: toastDuration));
+ await Future.delayed(toastDuration);
await dismiss();
}
}
+ static double _getMaxWidthTitleByLeadingTrailingSize({
+ required double currentMaxWidth,
+ Widget? leading
+ }) {
+ return leading == null ? currentMaxWidth : currentMaxWidth - 90;
+ }
+
static Positioned _showWidgetBasedOnPosition(
Widget child,
ToastPosition? toastPosition
) {
switch (toastPosition) {
case ToastPosition.BOTTOM:
- return Positioned(bottom: 60, left: 18, right: 18, child: child);
+ return Positioned(bottom: 80, left: 18, right: 18, child: child);
case ToastPosition.BOTTOM_LEFT:
- return Positioned(bottom: 60, left: 18, child: child);
+ return Positioned(bottom: 80, left: 18, child: child);
case ToastPosition.BOTTOM_RIGHT:
- return Positioned(bottom: 60, right: 18, child: child);
+ return Positioned(bottom: 80, right: 18, child: child);
case ToastPosition.CENTER:
return Positioned(top: 60, bottom: 60, left: 18, right: 18, child: child);
case ToastPosition.CENTER_LEFT:
diff --git a/lib/features/network_status_handle/presentation/network_connnection_controller.dart b/lib/features/network_status_handle/presentation/network_connnection_controller.dart
index 047f0a236..0fd4ba695 100644
--- a/lib/features/network_status_handle/presentation/network_connnection_controller.dart
+++ b/lib/features/network_status_handle/presentation/network_connnection_controller.dart
@@ -58,6 +58,8 @@ class NetworkConnectionController extends BaseController {
_setNetworkConnectivityState(result);
if (_isEnableShowToastDisconnection && !isNetworkConnectionAvailable()) {
_showToastLostConnection();
+ } else if (isNetworkConnectionAvailable()) {
+ _showToastConnectedToTheNetwork();
} else {
ToastView.dismiss();
}
@@ -94,4 +96,18 @@ class NetworkConnectionController extends BaseController {
);
}
}
+
+ void _showToastConnectedToTheNetwork() {
+ if (currentContext != null && currentOverlayContext != null) {
+ _appToast.showToastMessage(
+ currentOverlayContext!,
+ AppLocalizations.of(currentContext!).connectedToTheInternet,
+ leadingSVGIcon: _imagePaths.icConnectedInternet,
+ backgroundColor: AppColor.primaryColor,
+ textColor: Colors.white,
+ padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 12),
+ duration: const Duration(seconds: 5)
+ );
+ }
+ }
}
\ No newline at end of file
diff --git a/lib/l10n/intl_messages.arb b/lib/l10n/intl_messages.arb
index 597f6553f..99dd19621 100644
--- a/lib/l10n/intl_messages.arb
+++ b/lib/l10n/intl_messages.arb
@@ -1,5 +1,5 @@
{
- "@@last_modified": "2023-06-08T15:15:04.969556",
+ "@@last_modified": "2023-06-08T16:53:26.593398",
"initializing_data": "Initializing data...",
"@initializing_data": {
"type": "text",
@@ -2899,5 +2899,11 @@
"type": "text",
"placeholders_order": [],
"placeholders": {}
+ },
+ "connectedToTheInternet": "Connected to the internet",
+ "@connectedToTheInternet": {
+ "type": "text",
+ "placeholders_order": [],
+ "placeholders": {}
}
}
\ No newline at end of file
diff --git a/lib/main/localizations/app_localizations.dart b/lib/main/localizations/app_localizations.dart
index 003e9084f..56bbaad97 100644
--- a/lib/main/localizations/app_localizations.dart
+++ b/lib/main/localizations/app_localizations.dart
@@ -2988,4 +2988,11 @@ class AppLocalizations {
name: 'error',
);
}
+
+ String get connectedToTheInternet {
+ return Intl.message(
+ 'Connected to the internet',
+ name: 'connectedToTheInternet'
+ );
+ }
}
\ No newline at end of file