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; width > columnWidth * 2 + navRailWidth;
static bool isColumnMode(BuildContext context) => static bool isColumnMode(BuildContext context) =>
isColumnModeByWidth(MediaQuery.of(context).size.width); isColumnModeByWidth(MediaQuery.sizeOf(context).width);
static bool isThreeColumnMode(BuildContext context) => 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( static LinearGradient backgroundGradient(
BuildContext context, BuildContext context,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -7,7 +7,7 @@ class EmptyPage extends StatelessWidget {
const EmptyPage({super.key}); const EmptyPage({super.key});
@override @override
Widget build(BuildContext context) { 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); final theme = Theme.of(context);
return Scaffold( return Scaffold(
// Add invisible appbar to make status bar on Android tablets bright. // 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:flutter/material.dart';
import 'package:fluffychat/generated/l10n/l10n.dart'; import 'package:fluffychat/generated/l10n/l10n.dart';
@ -15,6 +16,7 @@ void showMemberActionsPopupMenu({
required User user, required User user,
void Function()? onMention, void Function()? onMention,
}) async { }) async {
final mx = Matrix.of(context);
final theme = Theme.of(context); final theme = Theme.of(context);
final displayname = user.calcDisplayname(); final displayname = user.calcDisplayname();
final isMe = user.room.client.userID == user.id; final isMe = user.room.client.userID == user.id;
@ -220,32 +222,36 @@ void showMemberActionsPopupMenu({
); );
return; return;
case _MemberActions.kick: case _MemberActions.kick:
if (await showOkCancelAlertDialog( final reason = await showTextInputDialog(
context: context, context: context,
title: L10n.of(context).areYouSure, title: L10n.of(context).areYouSure,
okLabel: L10n.of(context).yes, okLabel: L10n.of(context).yes,
cancelLabel: L10n.of(context).no, cancelLabel: L10n.of(context).no,
message: L10n.of(context).kickUserDescription, message: L10n.of(context).kickUserDescription,
) == hintText: L10n.of(context).reason,
OkCancelResult.ok) { isDestructive: true
);
if (reason != null) {
await showFutureLoadingDialog( await showFutureLoadingDialog(
context: context, context: context,
future: () => user.kick(), future: () => mx.client.kick(user.room.id, user.id, reason: reason)
); );
} }
return; return;
case _MemberActions.ban: case _MemberActions.ban:
if (await showOkCancelAlertDialog( final reason = await showTextInputDialog(
context: context, context: context,
title: L10n.of(context).areYouSure, title: L10n.of(context).areYouSure,
okLabel: L10n.of(context).yes, okLabel: L10n.of(context).yes,
cancelLabel: L10n.of(context).no, cancelLabel: L10n.of(context).no,
message: L10n.of(context).banUserDescription, message: L10n.of(context).banUserDescription,
) == hintText: L10n.of(context).reason,
OkCancelResult.ok) { isDestructive: true
);
if (reason != null) {
await showFutureLoadingDialog( await showFutureLoadingDialog(
context: context, context: context,
future: () => user.ban(), future: () => mx.client.ban(user.room.id, user.id, reason: reason)
); );
} }
return; return;

View File

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

View File

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

View File

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

View File

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