CW-511-Tablet-iPad-keyboard-issue (#1143)
* fix keyboard issue * Update responsive_layout_util.dart * fix close button color * minor fix * [skip ci] Update pin_code_widget.dart * Update main.dart * fix qr widget overflow issue * Fix minor UI issue --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>wow-support
parent
7710a19e82
commit
2d454e0e48
@ -1,46 +1,53 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
|
||||
class ResponsiveLayoutUtil {
|
||||
part 'responsive_layout_util.g.dart';
|
||||
|
||||
class _ResponsiveLayoutUtil = ResponsiveLayoutUtilBase with _$_ResponsiveLayoutUtil;
|
||||
|
||||
abstract class ResponsiveLayoutUtilBase with Store, WidgetsBindingObserver {
|
||||
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;
|
||||
}
|
||||
ResponsiveLayoutUtilBase() {
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
final initialMediaQuery = MediaQueryData.fromView(WidgetsBinding.instance!.window);
|
||||
updateDeviceInfo(initialMediaQuery);
|
||||
}
|
||||
|
||||
/// 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();
|
||||
@override
|
||||
void didChangeMetrics() {
|
||||
final mediaQuery = MediaQueryData.fromView(WidgetsBinding.instance!.window);
|
||||
updateDeviceInfo(mediaQuery);
|
||||
}
|
||||
|
||||
@observable
|
||||
double screenWidth = 0.0;
|
||||
|
||||
@observable
|
||||
double screenHeight = 0.0;
|
||||
|
||||
@observable
|
||||
Orientation orientation = Orientation.portrait;
|
||||
|
||||
@action
|
||||
void updateDeviceInfo(MediaQueryData mediaQuery) {
|
||||
orientation = mediaQuery.orientation;
|
||||
screenWidth = mediaQuery.size.width;
|
||||
screenHeight = mediaQuery.size.height;
|
||||
}
|
||||
|
||||
@computed
|
||||
bool get shouldRenderMobileUI {
|
||||
return (screenWidth <= _kMobileThreshold) ||
|
||||
(orientation == Orientation.portrait && screenWidth < screenHeight) ||
|
||||
(orientation == Orientation.landscape && screenWidth < screenHeight);
|
||||
}
|
||||
}
|
||||
|
||||
_ResponsiveLayoutUtil _singletonResponsiveLayoutUtil = _ResponsiveLayoutUtil();
|
||||
|
||||
_ResponsiveLayoutUtil get responsiveLayoutUtil => _singletonResponsiveLayoutUtil;
|
||||
|
Loading…
Reference in new issue