not use MediaQuery.of everywhere (stolen from upstream btw)

add reason input when kicking or banning an user
This commit is contained in:
OfficialDakari 2025-08-02 19:29:28 +05:00
parent 58a9b17988
commit 195b84cef8
15 changed files with 39 additions and 33 deletions

View File

@ -12,10 +12,10 @@ abstract class FluffyThemes {
width > columnWidth * 2 + navRailWidth;
static bool isColumnMode(BuildContext context) =>
isColumnModeByWidth(MediaQuery.of(context).size.width);
isColumnModeByWidth(MediaQuery.sizeOf(context).width);
static bool isThreeColumnMode(BuildContext context) =>
MediaQuery.of(context).size.width > FluffyThemes.columnWidth * 3.5;
MediaQuery.sizeOf(context).width > FluffyThemes.columnWidth * 3.5;
static LinearGradient backgroundGradient(
BuildContext context,

View File

@ -21,7 +21,7 @@ class ChatEmojiPicker extends StatelessWidget {
clipBehavior: Clip.hardEdge,
decoration: const BoxDecoration(),
height: controller.showEmojiPicker
? MediaQuery.of(context).size.height / 2
? MediaQuery.sizeOf(context).height / 2
: 0,
child: controller.showEmojiPicker
? DefaultTabController(

View File

@ -288,8 +288,8 @@ class ChatView extends StatelessWidget {
cacheKey: accountConfig.wallpaperUrl.toString(),
uri: accountConfig.wallpaperUrl,
fit: BoxFit.cover,
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
height: MediaQuery.sizeOf(context).height,
width: MediaQuery.sizeOf(context).width,
isThumbnail: false,
placeholder: (_) => Container(),
),

View File

@ -364,7 +364,8 @@ class Message extends StatelessWidget {
colors: colors,
ignore: noBubble ||
!ownMessage ||
!gradient,
!gradient ||
MediaQuery.highContrastOf(context),
scrollController: scrollController,
child: Container(
decoration: BoxDecoration(

View File

@ -238,18 +238,18 @@ class MyCallingPage extends State<Calling> {
void _resizeLocalVideo(Orientation orientation) {
final shortSide = min(
MediaQuery.of(widget.context).size.width,
MediaQuery.of(widget.context).size.height,
MediaQuery.sizeOf(widget.context).width,
MediaQuery.sizeOf(widget.context).height,
);
_localVideoMargin = remoteStream != null
? const EdgeInsets.only(top: 20.0, right: 20.0)
: EdgeInsets.zero;
_localVideoWidth = remoteStream != null
? shortSide / 3
: MediaQuery.of(widget.context).size.width;
: MediaQuery.sizeOf(widget.context).width;
_localVideoHeight = remoteStream != null
? shortSide / 4
: MediaQuery.of(widget.context).size.height;
: MediaQuery.sizeOf(widget.context).height;
}
void _handleCallState(CallState state) {

View File

@ -138,10 +138,9 @@ class PIPViewState extends State<PIPView> with TickerProviderStateMixin {
@override
Widget build(BuildContext context) {
final mediaQuery = MediaQuery.of(context);
var windowPadding = mediaQuery.padding;
var windowPadding = MediaQuery.paddingOf(context);
if (widget.avoidKeyboard) {
windowPadding += mediaQuery.viewInsets;
windowPadding += MediaQuery.viewInsetsOf(context);
}
final isFloating = _floating;

View File

@ -111,7 +111,7 @@ class ImageViewerController extends State<ImageViewer> {
void onInteractionEnds(ScaleEndDetails endDetails) {
if (PlatformInfos.usesTouchscreen == false) {
if (endDetails.velocity.pixelsPerSecond.dy >
MediaQuery.of(context).size.height * maxScaleFactor) {
MediaQuery.sizeOf(context).height * maxScaleFactor) {
Navigator.of(context, rootNavigator: false).pop();
}
}

View File

@ -54,7 +54,7 @@ Future<T?> showAdaptiveBottomSheet<T>({
isDismissible: isDismissible,
isScrollControlled: isScrollControlled,
constraints: BoxConstraints(
maxHeight: min(MediaQuery.of(context).size.height - 32, 600),
maxHeight: min(MediaQuery.sizeOf(context).height - 32, 600),
maxWidth: FluffyThemes.columnWidth * 1.25,
),
backgroundColor: Colors.transparent,

View File

@ -23,7 +23,7 @@ Future<T?> showModalActionPopup<T>({
clipBehavior: Clip.hardEdge,
constraints: BoxConstraints(
maxWidth: 512,
maxHeight: MediaQuery.of(context).size.height - 32,
maxHeight: MediaQuery.sizeOf(context).height - 32,
),
builder: (context) => ListView(
shrinkWrap: true,

View File

@ -7,7 +7,7 @@ class EmptyPage extends StatelessWidget {
const EmptyPage({super.key});
@override
Widget build(BuildContext context) {
final width = min(MediaQuery.of(context).size.width, EmptyPage._width) / 2;
final width = min(MediaQuery.sizeOf(context).width, EmptyPage._width) / 2;
final theme = Theme.of(context);
return Scaffold(
// Add invisible appbar to make status bar on Android tablets bright.

View File

@ -1,3 +1,4 @@
import 'package:fluffychat/widgets/matrix.dart';
import 'package:flutter/material.dart';
import 'package:fluffychat/generated/l10n/l10n.dart';
@ -15,6 +16,7 @@ void showMemberActionsPopupMenu({
required User user,
void Function()? onMention,
}) async {
final mx = Matrix.of(context);
final theme = Theme.of(context);
final displayname = user.calcDisplayname();
final isMe = user.room.client.userID == user.id;
@ -220,32 +222,36 @@ void showMemberActionsPopupMenu({
);
return;
case _MemberActions.kick:
if (await showOkCancelAlertDialog(
final reason = await showTextInputDialog(
context: context,
title: L10n.of(context).areYouSure,
okLabel: L10n.of(context).yes,
cancelLabel: L10n.of(context).no,
message: L10n.of(context).kickUserDescription,
) ==
OkCancelResult.ok) {
hintText: L10n.of(context).reason,
isDestructive: true
);
if (reason != null) {
await showFutureLoadingDialog(
context: context,
future: () => user.kick(),
future: () => mx.client.kick(user.room.id, user.id, reason: reason)
);
}
return;
case _MemberActions.ban:
if (await showOkCancelAlertDialog(
final reason = await showTextInputDialog(
context: context,
title: L10n.of(context).areYouSure,
okLabel: L10n.of(context).yes,
cancelLabel: L10n.of(context).no,
message: L10n.of(context).banUserDescription,
) ==
OkCancelResult.ok) {
hintText: L10n.of(context).reason,
isDestructive: true
);
if (reason != null) {
await showFutureLoadingDialog(
context: context,
future: () => user.ban(),
future: () => mx.client.ban(user.room.id, user.id, reason: reason)
);
}
return;

View File

@ -72,7 +72,7 @@ class _MxcImageState extends State<MxcImage> {
final event = widget.event;
if (uri != null) {
final devicePixelRatio = MediaQuery.of(context).devicePixelRatio;
final devicePixelRatio = MediaQuery.devicePixelRatioOf(context);
final width = widget.width;
final realWidth = width == null ? null : width * devicePixelRatio;
final height = widget.height;

View File

@ -36,7 +36,7 @@ class MxcImageViewer extends StatelessWidget {
maxScale: 10.0,
onInteractionEnd: (endDetails) {
if (endDetails.velocity.pixelsPerSecond.dy >
MediaQuery.of(context).size.height * 1.5) {
MediaQuery.sizeOf(context).height * 1.5) {
Navigator.of(context, rootNavigator: false).pop();
}
},

View File

@ -333,10 +333,10 @@ packages:
dependency: "direct main"
description:
name: dynamic_color
sha256: eae98052fa6e2826bdac3dd2e921c6ce2903be15c6b7f8b6d8a5d49b5086298d
sha256: "43a5a6679649a7731ab860334a5812f2067c2d9ce6452cf069c5e0c25336c17c"
url: "https://pub.dev"
source: hosted
version: "1.7.0"
version: "1.8.1"
emoji_picker_flutter:
dependency: "direct main"
description:
@ -389,10 +389,10 @@ packages:
dependency: "direct main"
description:
name: file_picker
sha256: ab13ae8ef5580a411c458d6207b6774a6c237d77ac37011b13994879f68a8810
sha256: "13ba4e627ef24503a465d1d61b32596ce10eb6b8903678d362a528f9939b4aa8"
url: "https://pub.dev"
source: hosted
version: "8.3.7"
version: "10.2.1"
file_selector:
dependency: "direct main"
description:

View File

@ -21,11 +21,11 @@ dependencies:
desktop_drop: ^0.4.4
desktop_notifications: ^0.6.3
device_info_plus: ^10.0.1
dynamic_color: ^1.7.0
dynamic_color: ^1.8.1
emoji_picker_flutter: ^3.1.0
emojis: ^0.9.9
#fcm_shared_isolate: ^0.2.0
file_picker: ^8.1.2
file_picker: ^10.2.1
file_selector: ^1.0.3
flutter:
sdk: flutter