Update toast color depending on the theme

This commit is contained in:
vishnukvmd 2022-06-10 20:03:43 +05:30
parent 2ecd872f3d
commit 172bb68bfe
2 changed files with 13 additions and 5 deletions

View file

@ -110,6 +110,13 @@ extension CustomColorScheme on ColorScheme {
Color get dotsIndicatorInactiveColor => brightness == Brightness.light
? Colors.black.withOpacity(0.12)
: Colors.white.withOpacity(0.12);
Color get toastTextColor =>
brightness == Brightness.light ? Colors.white : Colors.black;
Color get toastBackgroundColor => brightness == Brightness.light
? Color.fromRGBO(24, 24, 24, 0.95)
: Color.fromRGBO(255, 255, 255, 0.95);
}
OutlinedButtonThemeData buildOutlinedButtonThemeData(

View file

@ -3,6 +3,7 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:photos/ente_theme_data.dart';
Future<void> showToast(
BuildContext context,
@ -16,14 +17,14 @@ Future<void> showToast(
toastLength: toastLength,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 1,
backgroundColor: Color.fromRGBO(127, 127, 127, 0.8),
textColor: Colors.white,
backgroundColor: Theme.of(context).colorScheme.toastBackgroundColor,
textColor: Theme.of(context).colorScheme.toastTextColor,
fontSize: 16.0);
} else {
EasyLoading.instance
..backgroundColor = Color.fromRGBO(127, 127, 127, 0.8)
..indicatorColor = Color.fromRGBO(127, 127, 127, 0.8)
..textColor = Colors.white
..backgroundColor = Theme.of(context).colorScheme.toastBackgroundColor
..indicatorColor = Theme.of(context).colorScheme.toastBackgroundColor
..textColor = Theme.of(context).colorScheme.toastTextColor
..userInteractions = true
..loadingStyle = EasyLoadingStyle.custom;
return EasyLoading.showToast(