fix: Avoid using MediaQuery.of()
This commit is contained in:
parent
92c5549f74
commit
d2c2fd48d4
13 changed files with 20 additions and 21 deletions
|
|
@ -14,10 +14,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,
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -274,8 +274,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(),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -463,8 +463,8 @@ class Message extends StatelessWidget {
|
|||
colors: colors,
|
||||
ignore: noBubble ||
|
||||
!ownMessage ||
|
||||
MediaQuery.of(context)
|
||||
.highContrast,
|
||||
MediaQuery.highContrastOf(
|
||||
context),
|
||||
scrollController:
|
||||
scrollController,
|
||||
child: Container(
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ class EventVideoPlayerState extends State<EventVideoPlayer> {
|
|||
final infoMap = widget.event.content.tryGetMap<String, Object?>('info');
|
||||
final videoWidth = infoMap?.tryGet<int>('w') ?? 400;
|
||||
final videoHeight = infoMap?.tryGet<int>('h') ?? 300;
|
||||
final height = MediaQuery.of(context).size.height - 52;
|
||||
final height = MediaQuery.sizeOf(context).height - 52;
|
||||
final width = videoWidth * (height / videoHeight);
|
||||
|
||||
final chewieController = _chewieController;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -73,7 +73,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;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,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();
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue