From bd1e59ffba5ea09e746052e7ecc8ea1b31d6b809 Mon Sep 17 00:00:00 2001 From: lumavpn Date: Mon, 25 Sep 2023 09:56:27 -0700 Subject: [PATCH] Add back deleted file --- lib/common/ui/dimens.dart | 51 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 lib/common/ui/dimens.dart diff --git a/lib/common/ui/dimens.dart b/lib/common/ui/dimens.dart new file mode 100644 index 000000000..c573ad677 --- /dev/null +++ b/lib/common/ui/dimens.dart @@ -0,0 +1,51 @@ +import '../common.dart'; + +const double borderRadius = 8; +const double activeIconSize = 8; +const double iconSize = 24; +const double badgeSize = 36; +const double messageBarHeight = 59; +const double scrollBarRadius = 50; + +bool isLTR(BuildContext context) => + !forceRTL && Directionality.of(context) == TextDirection.ltr; + +Widget mirrorLTR({required BuildContext context, required Widget child}) => + Transform( + alignment: Alignment.center, + transform: Matrix4.rotationY(isLTR(context) ? 0 : pi), + child: child, + ); + +bool shouldScroll({ + required BuildContext context, + required int numElements, + required double elHeight, +}) { + var height = MediaQuery.of(context).size.height; + var padding = MediaQuery.of(context).padding; + var safeHeight = height - padding.top - padding.bottom; + var topBarHeight = elHeight; + + // TODO: needs to be tested + return safeHeight - topBarHeight < numElements * elHeight; +} + +double calculateStickerHeight(BuildContext context, int messageCount) { + final conversationInnerHeight = MediaQuery.of(context).size.height - + 100.0 - + 100.0; // rough approximation for inner height - top bar height - message bar height + final messageHeight = + 60.0; // rough approximation of how much space a message takes up, including paddings + final minStickerHeight = 353.0; + return max( + minStickerHeight, + conversationInnerHeight - ((messageCount - 1) * messageHeight), + ); +} + +double appBarHeight = 56.0; + +double defaultWarningBarHeight = 30.0; + +BorderRadius defaultBorderRadius = BorderRadius.circular(6.0);