Skip to content

Commit

Permalink
fix: use MediaQuery.sizeOf instead .of (#944)
Browse files Browse the repository at this point in the history
  • Loading branch information
Feichtmeier authored Oct 11, 2024
1 parent 42d61ee commit f1a11c5
Show file tree
Hide file tree
Showing 77 changed files with 110 additions and 108 deletions.
2 changes: 1 addition & 1 deletion lib/app/view/master_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class __PlayAbleMasterTileState extends State<_PlayAbleMasterTile> {
icon: Icon(
isPlaying && isEnQueued ? Iconz.pause : Iconz.playFilled,
size: kTinyButtonIconSize,
color: context.t.colorScheme.primary,
color: context.theme.colorScheme.primary,
),
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/app/view/scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class _MusicPodScaffoldState extends State<MusicPodScaffold> {

@override
Widget build(BuildContext context) {
final playerToTheRight = context.m.size.width > kSideBarThreshHold;
final playerToTheRight = context.mediaQuerySize.width > kSideBarThreshHold;
final isFullScreen = watchPropertyValue((AppModel m) => m.fullWindowMode);

return Stack(
Expand Down
3 changes: 1 addition & 2 deletions lib/app/view/splash_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class SplashScreen extends StatelessWidget {

@override
Widget build(BuildContext context) {
final theme = context.t;
return Scaffold(
appBar: const HeaderBar(adaptive: false, title: Text('')),
body: Center(
Expand All @@ -25,7 +24,7 @@ class SplashScreen extends StatelessWidget {
width: 250,
height: 250,
decoration: BoxDecoration(
color: theme.colorScheme.primary,
color: context.colorScheme.primary,
borderRadius: BorderRadius.circular(30),
),
child: Icon(
Expand Down
9 changes: 5 additions & 4 deletions lib/common/view/audio_autocomplete.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class AudioAutoComplete extends StatelessWidget {

@override
Widget build(BuildContext context) {
final theme = context.t;
final theme = context.theme;
final colorScheme = context.colorScheme;
final fallBackTextStyle = theme.textTheme.bodyMedium?.copyWith(
fontWeight: FontWeight.w500,
);
Expand Down Expand Up @@ -66,7 +67,7 @@ class AudioAutoComplete extends StatelessWidget {
hintText: hintText,
)
: createMaterialDecoration(
colorScheme: theme.colorScheme,
colorScheme: colorScheme,
hintText: hintText,
),
controller: textEditingController,
Expand All @@ -89,8 +90,8 @@ class AudioAutoComplete extends StatelessWidget {
borderRadius: BorderRadius.circular(6),
child: Material(
color: theme.isLight
? theme.colorScheme.surface
: theme.colorScheme.surfaceContainerHighest,
? colorScheme.surface
: colorScheme.surfaceContainerHighest,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(6),
side: BorderSide(
Expand Down
4 changes: 2 additions & 2 deletions lib/common/view/audio_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class _AudioCardState extends State<AudioCard> {
bool _hovered = false;
@override
Widget build(BuildContext context) {
final theme = context.t;
final theme = context.theme;
final light = theme.isLight;

return Column(
Expand Down Expand Up @@ -127,7 +127,7 @@ class _AudioCard extends StatelessWidget {

@override
Widget build(BuildContext context) {
final theme = context.t;
final theme = context.theme;
final light = theme.isLight;

return SizedBox(
Expand Down
2 changes: 1 addition & 1 deletion lib/common/view/audio_card_bottom.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class AudioCardBottom extends StatelessWidget {

@override
Widget build(BuildContext context) {
final theme = context.t;
final theme = context.theme;
final light = theme.isLight;

return SizedBox(
Expand Down
4 changes: 2 additions & 2 deletions lib/common/view/audio_page_header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class AudioPageHeader extends StatelessWidget {

@override
Widget build(BuildContext context) {
final theme = context.t;
final theme = context.theme;
final radius = imageRadius ?? BorderRadius.circular(10);

return Padding(
Expand Down Expand Up @@ -103,7 +103,7 @@ class _AudioPageHeaderSubTitle extends StatelessWidget {

@override
Widget build(BuildContext context) {
final theme = context.t;
final theme = context.theme;

final style = theme.pageHeaderSubtitleStyle;
return Row(
Expand Down
2 changes: 1 addition & 1 deletion lib/common/view/audio_page_header_html_description.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class AudioPageHeaderHtmlDescription extends StatelessWidget {

@override
Widget build(BuildContext context) {
final descriptionStyle = context.t.pageHeaderDescription;
final descriptionStyle = context.theme.pageHeaderDescription;
return Padding(
padding: const EdgeInsets.symmetric(horizontal: kYaruPagePadding),
child: ConstrainedBox(
Expand Down
8 changes: 4 additions & 4 deletions lib/common/view/audio_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class _AudioTileState extends State<AudioTile> {

@override
Widget build(BuildContext context) {
final theme = context.t;
final theme = context.theme;
final l10n = context.l10n;
final playerModel = di<PlayerModel>();
final liked = watchPropertyValue((LibraryModel m) => m.liked(widget.audio));
Expand Down Expand Up @@ -199,7 +199,7 @@ class _AudioTileTrail extends StatelessWidget with WatchItMixin {
color: selected && isPlayerPlaying ? selectedColor : null,
),
_ => SizedBox.square(
dimension: context.t.buttonTheme.height,
dimension: context.theme.buttonTheme.height,
),
},
),
Expand All @@ -215,7 +215,7 @@ class _AudioTileTrail extends StatelessWidget with WatchItMixin {
child: Text(
Duration(milliseconds: audio.durationMs!.toInt())
.formattedTime,
style: context.t.textTheme.labelMedium?.copyWith(
style: context.theme.textTheme.labelMedium?.copyWith(
color: selected && isPlayerPlaying ? selectedColor : null,
),
),
Expand Down Expand Up @@ -243,7 +243,7 @@ class AlbumTileLead extends StatelessWidget {
widthFactor: 1,
child: Text(
trackNumber?.toString() ?? '0',
style: context.t.textTheme.labelMedium,
style: context.theme.textTheme.labelMedium,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Expand Down
2 changes: 1 addition & 1 deletion lib/common/view/audio_tile_option_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class AudioTileOptionButton extends StatelessWidget {

@override
Widget build(BuildContext context) {
final theme = context.t;
final theme = context.theme;
final libraryModel = di<LibraryModel>();

return PopupMenuButton(
Expand Down
2 changes: 1 addition & 1 deletion lib/common/view/avatar_play_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class AvatarPlayButton extends StatelessWidget with WatchItMixin {

@override
Widget build(BuildContext context) {
final theme = context.t;
final theme = context.theme;
final playerModel = di<PlayerModel>();
final isPlayerPlaying = watchPropertyValue((PlayerModel m) => m.isPlaying);
final pageIsQueue = watchPropertyValue(
Expand Down
2 changes: 1 addition & 1 deletion lib/common/view/back_gesture.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class _BackGestureState extends State<BackGesture>
onPressed: () {},
style: OutlinedButton.styleFrom(
padding: EdgeInsets.zero,
backgroundColor: context.t.isLight
backgroundColor: context.theme.isLight
? Colors.grey[100]
: Colors.grey[900],
shape: RoundedRectangleBorder(
Expand Down
2 changes: 1 addition & 1 deletion lib/common/view/copy_clipboard_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class _CopyClipboardContentState extends State<CopyClipboardContent> {

@override
Widget build(BuildContext context) {
final theme = context.t;
final theme = context.theme;
final textColor =
theme.snackBarTheme.contentTextStyle?.color?.withOpacity(0.8);
return Padding(
Expand Down
2 changes: 1 addition & 1 deletion lib/common/view/country_auto_complete.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class CountryAutoComplete extends StatelessWidget {

@override
Widget build(BuildContext context) {
final theme = context.t;
final theme = context.theme;

return SizedBox(
height: height ?? inputHeight,
Expand Down
2 changes: 1 addition & 1 deletion lib/common/view/fall_back_header_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class FallBackHeaderImage extends StatelessWidget {

@override
Widget build(BuildContext context) {
final baseColor = color ?? context.t.colorScheme.primary;
final baseColor = color ?? context.theme.colorScheme.primary;
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6),
Expand Down
3 changes: 1 addition & 2 deletions lib/common/view/header_bar.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:phoenix_theme/phoenix_theme.dart';
import 'package:watch_it/watch_it.dart';
import 'package:yaru/yaru.dart';

Expand Down Expand Up @@ -84,7 +83,7 @@ class HeaderBar extends StatelessWidget
}

return Theme(
data: context.t.copyWith(
data: context.theme.copyWith(
appBarTheme: AppBarTheme.of(context).copyWith(
scrolledUnderElevation: 0,
),
Expand Down
2 changes: 1 addition & 1 deletion lib/common/view/language_autocomplete.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class LanguageAutoComplete extends StatelessWidget {

@override
Widget build(BuildContext context) {
final theme = context.t;
final theme = context.theme;

return SizedBox(
height: height ?? inputHeight,
Expand Down
2 changes: 1 addition & 1 deletion lib/common/view/limit_popup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class LimitPopup extends StatelessWidget {

@override
Widget build(BuildContext context) {
final theme = context.t;
final theme = context.theme;

final fallBackTextStyle =
theme.textTheme.bodyMedium?.copyWith(fontWeight: FontWeight.w500);
Expand Down
2 changes: 1 addition & 1 deletion lib/common/view/no_search_result_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class NoSearchResultPage extends StatelessWidget {

@override
Widget build(BuildContext context) {
final theme = context.t;
final theme = context.theme;
final style = theme.textTheme.headlineSmall?.copyWith(
fontWeight: largeTextWeight,
color: theme.colorScheme.onSurface,
Expand Down
2 changes: 1 addition & 1 deletion lib/common/view/offline_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class OfflineBody extends StatelessWidget {

@override
Widget build(BuildContext context) {
final theme = context.t;
final theme = context.theme;

return Center(
child: Column(
Expand Down
2 changes: 1 addition & 1 deletion lib/common/view/progress.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Progress extends StatelessWidget {
backgroundColor: value == null
? null
: (backgroundColor ??
context.t.colorScheme.primary.withOpacity(0.3)),
context.theme.colorScheme.primary.withOpacity(0.3)),
),
);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/common/view/round_image_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class RoundImageContainer extends StatelessWidget {

@override
Widget build(BuildContext context) {
final theme = context.t;
final theme = context.theme;
final boxShadow = BoxShadow(
offset: const Offset(0, 0),
spreadRadius: 1,
Expand Down Expand Up @@ -98,7 +98,7 @@ class ArtistVignette extends StatelessWidget {

@override
Widget build(BuildContext context) {
final theme = context.t;
final theme = context.theme;

return Center(
child: Container(
Expand Down
2 changes: 1 addition & 1 deletion lib/common/view/safe_network_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class SafeNetworkImage extends StatelessWidget {
Icon(
Iconz.imageMissing,
size: height != null ? height! * 0.7 : null,
color: context.t.hintColor,
color: context.theme.hintColor,
),
);

Expand Down
2 changes: 1 addition & 1 deletion lib/common/view/search_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class SearchButton extends StatelessWidget {
selectedIcon: icon ??
Icon(
Iconz.search,
color: context.t.colorScheme.primary,
color: context.theme.colorScheme.primary,
size: iconSize,
),
icon: icon ??
Expand Down
2 changes: 1 addition & 1 deletion lib/common/view/search_input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class _SearchInputState extends State<SearchInput> {

@override
Widget build(BuildContext context) {
final theme = context.t;
final theme = context.theme;
return SizedBox(
height: yaruStyled ? null : 38,
child: TextField(
Expand Down
2 changes: 1 addition & 1 deletion lib/common/view/side_bar_fall_back_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class SideBarFallBackImage extends StatelessWidget {

@override
Widget build(BuildContext context) {
final baseColor = color ?? context.t.colorScheme.primary;
final baseColor = color ?? context.theme.colorScheme.primary;
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6),
Expand Down
3 changes: 2 additions & 1 deletion lib/common/view/sliver_audio_page_control_panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class SliverAudioPageControlPanel extends StatelessWidget {
sliver: SliverAppBar(
shape: const RoundedRectangleBorder(side: BorderSide.none),
elevation: 0,
backgroundColor: backgroundColor ?? context.t.scaffoldBackgroundColor,
backgroundColor:
backgroundColor ?? context.theme.scaffoldBackgroundColor,
automaticallyImplyLeading: false,
pinned: true,
centerTitle: true,
Expand Down
2 changes: 1 addition & 1 deletion lib/common/view/sliver_filter_app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class SliverFilterAppBar extends StatelessWidget {
sliver: SliverAppBar(
shape: const RoundedRectangleBorder(side: BorderSide.none),
elevation: 0,
backgroundColor: context.t.scaffoldBackgroundColor,
backgroundColor: context.theme.scaffoldBackgroundColor,
automaticallyImplyLeading: false,
pinned: true,
centerTitle: true,
Expand Down
2 changes: 1 addition & 1 deletion lib/common/view/tapable_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class TapAbleText extends StatelessWidget {

@override
Widget build(BuildContext context) {
final theme = context.t;
final theme = context.theme;

final inkWell = InkWell(
hoverColor: (style?.color ?? theme.colorScheme.primary).withOpacity(0.3),
Expand Down
11 changes: 6 additions & 5 deletions lib/extensions/build_context_x.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import 'package:flutter/material.dart';
import '../constants.dart';

extension BuildContextX on BuildContext {
ThemeData get t => Theme.of(this);
ThemeData get theme => Theme.of(this);
ColorScheme get colorScheme => theme.colorScheme;

MediaQueryData get m => MediaQuery.of(this);
Size get mediaQuerySize => MediaQuery.sizeOf(this);

bool get smallWindow => m.size.width < kMasterDetailBreakPoint;
bool get wideWindow => m.size.width < kAdaptivContainerBreakPoint;
bool get showMasterPanel => m.size.width > kMasterDetailBreakPoint;
bool get smallWindow => mediaQuerySize.width < kMasterDetailBreakPoint;
bool get wideWindow => mediaQuerySize.width < kAdaptivContainerBreakPoint;
bool get showMasterPanel => mediaQuerySize.width > kMasterDetailBreakPoint;
}
2 changes: 1 addition & 1 deletion lib/local_audio/view/album_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class AlbumPageImage extends StatelessWidget {
children: [
Container(
decoration: BoxDecoration(
color: context.t.cardColor,
color: context.theme.cardColor,
image: const DecorationImage(
image: AssetImage('assets/images/media-optical.png'),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/local_audio/view/failed_imports_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class FailedImportsContent extends StatelessWidget {

@override
Widget build(BuildContext context) {
final theme = context.t;
final theme = context.theme;
return SizedBox(
height: 400,
width: 400,
Expand Down
2 changes: 1 addition & 1 deletion lib/local_audio/view/local_audio_control_panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class LocalAudioControlPanel extends StatelessWidget with WatchItMixin {

@override
Widget build(BuildContext context) {
final theme = context.t;
final theme = context.theme;
final index = watchPropertyValue((LocalAudioModel m) => m.localAudioindex);

return Align(
Expand Down
Loading

0 comments on commit f1a11c5

Please sign in to comment.