Skip to content

Commit

Permalink
Merge pull request #36 from archethic-foundation/35-use-mediaquerysiz…
Browse files Browse the repository at this point in the history
…eof-instead-of-mediaqueryofcontextsize

chore: ⚡ Use MediaQuery.sizeOf(context) instead of MediaQuery.of(…
  • Loading branch information
redDwarf03 authored Nov 2, 2024
2 parents 7c515e9 + bfc3664 commit 27290ac
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 3.2.2

* Use MediaQuery.sizeOf(context) instead of MediaQuery.of(context).size

# 3.2.1

* Coin price notifier starts auto updates on creation.
Expand Down
6 changes: 3 additions & 3 deletions lib/src/ui/util/components/app_text_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ class _AppTextFieldState extends ConsumerState<AppTextField> {
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(
left: widget.leftMargin ?? MediaQuery.of(context).size.width * 0.105,
right: widget.rightMargin ?? MediaQuery.of(context).size.width * 0.105,
left: widget.leftMargin ?? MediaQuery.sizeOf(context).width * 0.105,
right: widget.rightMargin ?? MediaQuery.sizeOf(context).width * 0.105,
top: widget.topMargin!,
),
padding: widget.padding,
Expand Down Expand Up @@ -167,7 +167,7 @@ class _AppTextFieldState extends ConsumerState<AppTextField> {
bottom: 1,
child: SizedBox(
height: 1,
width: MediaQuery.of(context).size.width,
width: MediaQuery.sizeOf(context).width,
),
),
// Buttons
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,30 @@ class InProgressInfosBanner extends StatelessWidget {
return InfoBanner(
failureMessage!,
InfoBannerType.error,
width: MediaQuery.of(context).size.width * 0.9,
width: MediaQuery.sizeOf(context).width * 0.9,
);
}

if (walletConfirmation == true) {
return InfoBanner(
walletConfirmationTxt,
InfoBannerType.request,
width: MediaQuery.of(context).size.width * 0.9,
width: MediaQuery.sizeOf(context).width * 0.9,
);
}

if (failure == null && isProcessInProgress == false) {
return InfoBanner(
successTxt,
InfoBannerType.success,
width: MediaQuery.of(context).size.width * 0.9,
width: MediaQuery.sizeOf(context).width * 0.9,
);
}

return InfoBanner(
inProgressTxt,
InfoBannerType.request,
width: MediaQuery.of(context).size.width * 0.9,
width: MediaQuery.sizeOf(context).width * 0.9,
waitAnimation: true,
);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/ui/util/components/scale_size.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class ScaleSize {
BuildContext context, {
double maxTextScaleFactor = 2,
}) {
final width = MediaQuery.of(context).size.width - 40;
final width = MediaQuery.sizeOf(context).width - 40;
final val = (width / 1400) * maxTextScaleFactor;
return max(0.5, min(val, maxTextScaleFactor));
}
Expand Down
8 changes: 4 additions & 4 deletions lib/src/ui/util/generic/responsive.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ class Responsive extends StatelessWidget {
final Widget desktop;

static bool isMobile(BuildContext context) =>
MediaQuery.of(context).size.width < 650;
MediaQuery.sizeOf(context).width < 650;

static bool isTablet(BuildContext context) =>
MediaQuery.of(context).size.width < 1100 &&
MediaQuery.of(context).size.width >= 650;
MediaQuery.sizeOf(context).width < 1100 &&
MediaQuery.sizeOf(context).width >= 650;

static bool isDesktop(BuildContext context) =>
MediaQuery.of(context).size.width >= 1100;
MediaQuery.sizeOf(context).width >= 1100;

static double fontSizeFromTextStyle(
BuildContext context,
Expand Down
8 changes: 4 additions & 4 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -580,18 +580,18 @@ packages:
dependency: transitive
description:
name: material_color_utilities
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
url: "https://pub.dev"
source: hosted
version: "0.11.1"
version: "0.8.0"
meta:
dependency: transitive
description:
name: meta
sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
url: "https://pub.dev"
source: hosted
version: "1.15.0"
version: "1.12.0"
mime:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: archethic_dapp_framework_flutter
description: An internal framework for archethic flutter development
homepage: https://github.com/archethic-foundation/archethic-dapp-framework-flutter

version: 3.2.1
version: 3.2.2

environment:
sdk: ">=3.3.0 <4.0.0"
Expand Down

0 comments on commit 27290ac

Please sign in to comment.