fixed toast color

wala_plus_with_dialog_removal
FaizHashmi 2 weeks ago
parent 2a4cd36ba9
commit 9bcb6c6b8a

@ -33,8 +33,10 @@ class Utils {
// longDuration is accepted but no longer varies the duration - every caller already used the // longDuration is accepted but no longer varies the duration - every caller already used the
// default (true), so AppToast.plainSeconds covers both cases with one fixed value. // default (true), so AppToast.plainSeconds covers both cases with one fixed value.
// Soft red bg + red text - same combo already used elsewhere in the app for
// expired/inactive-style chips (e.g. dependent_details_screen.dart's "Access Off" badge).
static void showToast(String message, {bool longDuration = true}) { static void showToast(String message, {bool longDuration = true}) {
AppToast.show(message, seconds: AppToast.plainSeconds, showIcon: false, showCountdownText: false); AppToast.show( message, seconds: AppToast.plainSeconds, showIcon: false, showCountdownText: true, bgColor: const Color(0xFFF1CECE), textColor: const Color(0xFFC53030));
} }
static dynamic getNotNullValue(List<dynamic> list, int index) { static dynamic getNotNullValue(List<dynamic> list, int index) {

@ -520,42 +520,42 @@ class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingOb
return model.isOffersLoading return model.isOffersLoading
? const OffersShimmerWidget() ? const OffersShimmerWidget()
: InkWell( : InkWell(
onTap: () { onTap: () {
navigateToDetails(data.getOffersList[index]); navigateToDetails(data.getOffersList[index]);
}, },
child: SizedBox( child: SizedBox(
width: 73, width: 73,
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Container( Container(
width: 73, width: 73,
height: 73, height: 73,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(100)), borderRadius: const BorderRadius.all(Radius.circular(100)),
border: Border.all(color: MyColors.lightGreyE3Color, width: 1), border: Border.all(color: MyColors.lightGreyE3Color, width: 1),
),
child: ClipRRect(
borderRadius: const BorderRadius.all(Radius.circular(50)),
child: Hero(
tag: "ItemImage" + data.getOffersList[index].offersDiscountId.toString(),
transitionOnUserGestures: true,
child: Image.network(data.getOffersList[index].logo ?? "", fit: BoxFit.contain),
),
),
), ),
4.height, child: ClipRRect(
Expanded( borderRadius: const BorderRadius.all(Radius.circular(50)),
child: child: Hero(
AppState().isArabic(context) tag: "ItemImage" + data.getOffersList[index].offersDiscountId.toString(),
? data.getOffersList[index].titleAr!.toText12(isCenter: true, maxLine: 1) transitionOnUserGestures: true,
: data.getOffersList[index].titleEn!.toText12(isCenter: true, maxLine: 1), child: Image.network(data.getOffersList[index].logo ?? "", fit: BoxFit.contain),
),
), ),
], ),
), 4.height,
Expanded(
child:
AppState().isArabic(context)
? data.getOffersList[index].titleAr!.toText12(isCenter: true, maxLine: 1)
: data.getOffersList[index].titleEn!.toText12(isCenter: true, maxLine: 1),
),
],
), ),
); ),
);
}, },
separatorBuilder: (BuildContext cxt, int index) => 8.width, separatorBuilder: (BuildContext cxt, int index) => 8.width,
itemCount: model.isOffersLoading ? 9 : (data.getOffersList.length > 9 ? 9 : data.getOffersList.length), itemCount: model.isOffersLoading ? 9 : (data.getOffersList.length > 9 ? 9 : data.getOffersList.length),

@ -18,7 +18,7 @@ class AppToast {
// change this single value to retune it everywhere that uses it. // change this single value to retune it everywhere that uses it.
static const int plainSeconds = 3; static const int plainSeconds = 3;
static void show(String message, {int seconds = 5, VoidCallback? onComplete, bool showIcon = true, bool showCountdownText = true}) { static void show(String message, {int seconds = 5, VoidCallback? onComplete, bool showIcon = true, bool showCountdownText = true, Color? bgColor, Color? textColor}) {
OverlayState? overlay = AppRoutes.navigatorKey.currentState?.overlay; OverlayState? overlay = AppRoutes.navigatorKey.currentState?.overlay;
if (overlay == null) return; if (overlay == null) return;
@ -30,13 +30,16 @@ class AppToast {
late OverlayEntry entry; late OverlayEntry entry;
entry = OverlayEntry( entry = OverlayEntry(
builder: (BuildContext context) => _CountdownToast( builder:
message: message, (BuildContext context) => _CountdownToast(
seconds: seconds, message: message,
showIcon: showIcon, seconds: seconds,
showCountdownText: showCountdownText, showIcon: showIcon,
onDismiss: () => _dismiss(entry, onComplete), showCountdownText: showCountdownText,
), bgColor: bgColor,
textColor: textColor,
onDismiss: () => _dismiss(entry, onComplete),
),
); );
_entry = entry; _entry = entry;
overlay.insert(entry); overlay.insert(entry);
@ -60,14 +63,10 @@ class _CountdownToast extends StatefulWidget {
final VoidCallback onDismiss; final VoidCallback onDismiss;
final bool showIcon; final bool showIcon;
final bool showCountdownText; final bool showCountdownText;
final Color? bgColor;
final Color? textColor;
const _CountdownToast({ const _CountdownToast({required this.message, required this.seconds, required this.onDismiss, this.showIcon = true, this.showCountdownText = true, this.bgColor, this.textColor});
required this.message,
required this.seconds,
required this.onDismiss,
this.showIcon = true,
this.showCountdownText = true,
});
@override @override
State<_CountdownToast> createState() => _CountdownToastState(); State<_CountdownToast> createState() => _CountdownToastState();
@ -97,6 +96,9 @@ class _CountdownToastState extends State<_CountdownToast> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Color bgColor = widget.bgColor ?? MyColors.darkTextColor;
Color textColor = widget.textColor ?? Colors.white;
return Positioned( return Positioned(
left: 16, left: 16,
right: 16, right: 16,
@ -110,23 +112,23 @@ class _CountdownToastState extends State<_CountdownToast> {
child: Container( child: Container(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
decoration: BoxDecoration( decoration: BoxDecoration(
color: MyColors.darkTextColor, color: bgColor,
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(10),
boxShadow: const <BoxShadow>[BoxShadow(color: Color(0x33000000), blurRadius: 12, offset: Offset(0, 4))], boxShadow: const <BoxShadow>[BoxShadow(color: Color(0x33000000), blurRadius: 12, offset: Offset(0, 4))],
), ),
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
if (widget.showIcon) ...<Widget>[const Icon(Icons.error_outline, color: Colors.white, size: 20), const SizedBox(width: 10)], if (widget.showIcon) ...<Widget>[Icon(Icons.error_outline, color: textColor, size: 20), const SizedBox(width: 10)],
Expanded( Expanded(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
Text(widget.message, style: const TextStyle(color: Colors.white, fontSize: 14, height: 1.3)), Text(widget.message, style: TextStyle(color: textColor, fontSize: 14, height: 1.3, fontWeight: FontWeight.w600)),
if (widget.showCountdownText) ...<Widget>[ if (widget.showCountdownText) ...<Widget>[
const SizedBox(height: 4), const SizedBox(height: 4),
Text("Dismissing in ${_remaining}s", style: const TextStyle(color: Colors.white70, fontSize: 11)), Text("Dismissing in ${_remaining}s", style: TextStyle(color: textColor.withOpacity(0.7), fontSize: 12, fontWeight: FontWeight.w500)),
], ],
], ],
), ),

Loading…
Cancel
Save