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 Color get dotsIndicatorInactiveColor => brightness == Brightness.light
? Colors.black.withOpacity(0.12) ? Colors.black.withOpacity(0.12)
: Colors.white.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( OutlinedButtonThemeData buildOutlinedButtonThemeData(

View file

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