cake_wallet/lib/utils/responsive_layout_util.dart
Godwin Asuquo ff420c7c7e
Cw 430 find a better way to decide when to show the desktop UI (#977)
* Find a better way to decide when to show the desktop UI

* fix UI issue for tablet view

* fix trocar invoice issue for landscape layout

* fix present receive option piker UI issue

* fix dascktop layout

* - Fix AnonPay Navigation
- Fix Wallet changing on Mobile

---------

Co-authored-by: Serhii <borodenko.sv@gmail.com>
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
2023-07-13 16:05:52 +03:00

46 lines
1.4 KiB
Dart

import 'package:flutter/material.dart';
class ResponsiveLayoutUtil {
static const double _kMobileThreshold = 550;
static const double kDesktopMaxWidthConstraint = 400;
static const double kDesktopMaxDashBoardWidthConstraint = 900;
static const double kPopupWidth = 400;
static const double kPopupSpaceHeight = 100;
const ResponsiveLayoutUtil._();
static final instance = ResponsiveLayoutUtil._();
bool get isMobile =>
MediaQueryData.fromWindow(WidgetsBinding.instance.window).size.shortestSide <=
_kMobileThreshold;
bool shouldRenderMobileUI() {
final mediaQuery = MediaQueryData.fromWindow(WidgetsBinding.instance.window);
final orientation = mediaQuery.orientation;
final width = mediaQuery.size.width;
final height = mediaQuery.size.height;
if (isMobile ||
(orientation == Orientation.portrait && width < height) ||
(orientation == Orientation.landscape && width < height)) {
return true;
} else {
return false;
}
}
/// 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();
}
}