cake_wallet/lib/utils/responsive_layout_util.dart
Omar Hatem c4926ae63a
V4.6.6 fixes (#970)
* Fix popping wrong context in exchange page

* Pass exception handler to wallets code

* Fix mobile UI with iPad view

* Set iPhone deployment target to 11 [skip ci]

* Update Macos deployment target [skip ci]
2023-06-16 04:14:01 +03:00

36 lines
1 KiB
Dart

import 'package:flutter/material.dart';
class ResponsiveLayoutUtil {
static const double _kMobileThreshold = 768;
static const double kDesktopMaxWidthConstraint = 400;
static const double kPopupWidth = 400;
static const double kPopupSpaceHeight = 100;
static const _kIpadMaxWidth = 2560.0;
const ResponsiveLayoutUtil._();
static final instance = ResponsiveLayoutUtil._();
bool get isMobile =>
MediaQueryData.fromWindow(WidgetsBinding.instance.window).size.width < _kMobileThreshold;
bool get isIpad {
final width = MediaQueryData.fromWindow(WidgetsBinding.instance.window).size.width;
return width >= _kMobileThreshold && !(width > _kIpadMaxWidth);
}
/// Returns dynamic size.
///
/// If screen size is mobile, it returns 66% ([scale]) of the [originalValue].
double getDynamicSize(
double originalValue, {
double? mobileSize,
double? scale,
}) {
scale ??= 2 / 3;
mobileSize ??= originalValue * scale;
final value = isMobile ? mobileSize : originalValue;
return value.roundToDouble();
}
}