瀏覽代碼

Update toast color depending on the theme

vishnukvmd 3 年之前
父節點
當前提交
172bb68bfe
共有 2 個文件被更改,包括 13 次插入5 次删除
  1. 7 0
      lib/ente_theme_data.dart
  2. 6 5
      lib/utils/toast_util.dart

+ 7 - 0
lib/ente_theme_data.dart

@@ -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(

+ 6 - 5
lib/utils/toast_util.dart

@@ -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),
-        textColor: Colors.white,
+        backgroundColor: Theme.of(context).colorScheme.toastBackgroundColor,
+        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)
-      ..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
       ..userInteractions = true
       ..loadingStyle = EasyLoadingStyle.custom;
       ..loadingStyle = EasyLoadingStyle.custom;
     return EasyLoading.showToast(
     return EasyLoading.showToast(