showToast theme (#6603)

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages 2023-12-03 09:56:47 -05:00 committed by GitHub
parent bcb0a7822a
commit b9a5c6ff31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -106,6 +106,8 @@ class ColorThemeExtension extends ThemeExtension<ColorThemeExtension> {
required this.shadow, required this.shadow,
required this.errorBannerBg, required this.errorBannerBg,
required this.me, required this.me,
required this.toastBg,
required this.toastText,
}); });
final Color? border; final Color? border;
@ -115,6 +117,8 @@ class ColorThemeExtension extends ThemeExtension<ColorThemeExtension> {
final Color? shadow; final Color? shadow;
final Color? errorBannerBg; final Color? errorBannerBg;
final Color? me; final Color? me;
final Color? toastBg;
final Color? toastText;
static final light = ColorThemeExtension( static final light = ColorThemeExtension(
border: Color(0xFFCCCCCC), border: Color(0xFFCCCCCC),
@ -124,6 +128,8 @@ class ColorThemeExtension extends ThemeExtension<ColorThemeExtension> {
shadow: Colors.black, shadow: Colors.black,
errorBannerBg: Color(0xFFFDEEEB), errorBannerBg: Color(0xFFFDEEEB),
me: Colors.green, me: Colors.green,
toastBg: Colors.black.withOpacity(0.6),
toastText: Colors.white,
); );
static final dark = ColorThemeExtension( static final dark = ColorThemeExtension(
@ -134,6 +140,8 @@ class ColorThemeExtension extends ThemeExtension<ColorThemeExtension> {
shadow: Colors.grey, shadow: Colors.grey,
errorBannerBg: Color(0xFF470F2D), errorBannerBg: Color(0xFF470F2D),
me: Colors.greenAccent, me: Colors.greenAccent,
toastBg: Colors.white.withOpacity(0.6),
toastText: Colors.black,
); );
@override @override
@ -145,6 +153,8 @@ class ColorThemeExtension extends ThemeExtension<ColorThemeExtension> {
Color? shadow, Color? shadow,
Color? errorBannerBg, Color? errorBannerBg,
Color? me, Color? me,
Color? toastBg,
Color? toastText,
}) { }) {
return ColorThemeExtension( return ColorThemeExtension(
border: border ?? this.border, border: border ?? this.border,
@ -154,6 +164,8 @@ class ColorThemeExtension extends ThemeExtension<ColorThemeExtension> {
shadow: shadow ?? this.shadow, shadow: shadow ?? this.shadow,
errorBannerBg: errorBannerBg ?? this.errorBannerBg, errorBannerBg: errorBannerBg ?? this.errorBannerBg,
me: me ?? this.me, me: me ?? this.me,
toastBg: toastBg ?? this.toastBg,
toastText: toastText ?? this.toastText,
); );
} }
@ -171,6 +183,8 @@ class ColorThemeExtension extends ThemeExtension<ColorThemeExtension> {
shadow: Color.lerp(shadow, other.shadow, t), shadow: Color.lerp(shadow, other.shadow, t),
errorBannerBg: Color.lerp(shadow, other.errorBannerBg, t), errorBannerBg: Color.lerp(shadow, other.errorBannerBg, t),
me: Color.lerp(shadow, other.me, t), me: Color.lerp(shadow, other.me, t),
toastBg: Color.lerp(shadow, other.toastBg, t),
toastText: Color.lerp(shadow, other.toastText, t),
); );
} }
} }
@ -851,13 +865,13 @@ class OverlayDialogManager {
void showToast(String text, {Duration timeout = const Duration(seconds: 3)}) { void showToast(String text, {Duration timeout = const Duration(seconds: 3)}) {
final overlayState = globalKey.currentState?.overlay; final overlayState = globalKey.currentState?.overlay;
if (overlayState == null) return; if (overlayState == null) return;
final entry = OverlayEntry(builder: (_) { final entry = OverlayEntry(builder: (context) {
return IgnorePointer( return IgnorePointer(
child: Align( child: Align(
alignment: const Alignment(0.0, 0.8), alignment: const Alignment(0.0, 0.8),
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.black.withOpacity(0.6), color: MyTheme.color(context).toastBg,
borderRadius: const BorderRadius.all( borderRadius: const BorderRadius.all(
Radius.circular(20), Radius.circular(20),
), ),
@ -866,11 +880,11 @@ void showToast(String text, {Duration timeout = const Duration(seconds: 3)}) {
child: Text( child: Text(
text, text,
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: const TextStyle( style: TextStyle(
decoration: TextDecoration.none, decoration: TextDecoration.none,
fontWeight: FontWeight.w300, fontWeight: FontWeight.w300,
fontSize: 18, fontSize: 18,
color: Colors.white), color: MyTheme.color(context).toastText),
), ),
))); )));
}); });
@ -2733,7 +2747,8 @@ Future<List<Rect>> getScreenRectList() async {
: await getScreenListNotWayland(); : await getScreenListNotWayland();
} }
openMonitorInTheSameTab(int i, FFI ffi, PeerInfo pi, {bool updateCursorPos = true}) { openMonitorInTheSameTab(int i, FFI ffi, PeerInfo pi,
{bool updateCursorPos = true}) {
final displays = i == kAllDisplayValue final displays = i == kAllDisplayValue
? List.generate(pi.displays.length, (index) => index) ? List.generate(pi.displays.length, (index) => index)
: [i]; : [i];
@ -2742,7 +2757,8 @@ openMonitorInTheSameTab(int i, FFI ffi, PeerInfo pi, {bool updateCursorPos = tru
sessionId: ffi.sessionId, sessionId: ffi.sessionId,
value: Int32List.fromList(displays), value: Int32List.fromList(displays),
); );
ffi.ffiModel.switchToNewDisplay(i, ffi.sessionId, ffi.id, updateCursorPos: updateCursorPos); ffi.ffiModel.switchToNewDisplay(i, ffi.sessionId, ffi.id,
updateCursorPos: updateCursorPos);
} }
// Open new tab or window to show this monitor. // Open new tab or window to show this monitor.
@ -2858,9 +2874,7 @@ class _ReconnectCountDownButtonState extends State<_ReconnectCountDownButton> {
} }
} }
importConfig( importConfig(List<TextEditingController>? controllers, List<RxString>? errMsgs,
List<TextEditingController>? controllers,
List<RxString>? errMsgs,
String? text) { String? text) {
if (text != null && text.isNotEmpty) { if (text != null && text.isNotEmpty) {
try { try {
@ -2869,8 +2883,7 @@ importConfig(
Future<bool> success = setServerConfig(controllers, errMsgs, sc); Future<bool> success = setServerConfig(controllers, errMsgs, sc);
success.then((value) { success.then((value) {
if (value) { if (value) {
showToast( showToast(translate('Import server configuration successfully'));
translate('Import server configuration successfully'));
} else { } else {
showToast(translate('Invalid server configuration')); showToast(translate('Invalid server configuration'));
} }