From 80e868235726653235ac333918020d159ab255d8 Mon Sep 17 00:00:00 2001 From: otsmr Date: Sun, 9 Feb 2025 22:33:59 +0100 Subject: [PATCH] some more bugs --- .../views/chats/chat_item_details_view.dart | 27 ++++++++++++-- lib/src/views/chats/media_viewer_view.dart | 37 ++++++++++--------- 2 files changed, 43 insertions(+), 21 deletions(-) diff --git a/lib/src/views/chats/chat_item_details_view.dart b/lib/src/views/chats/chat_item_details_view.dart index dccd879..0f66ea1 100644 --- a/lib/src/views/chats/chat_item_details_view.dart +++ b/lib/src/views/chats/chat_item_details_view.dart @@ -276,10 +276,29 @@ class _ChatItemDetailsViewState extends State { _sendMessage(); }, decoration: InputDecoration( - hintText: context.lang.chatListDetailInput, - contentPadding: EdgeInsets.symmetric(horizontal: 10) - // border: OutlineInputBorder(), - ), + hintText: context.lang.chatListDetailInput, + contentPadding: + EdgeInsets.symmetric(horizontal: 20, vertical: 10), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular( + 20), // Set the border radius here + borderSide: BorderSide( + color: Theme.of(context).colorScheme.primary, + width: 2.0), // Customize border color and width + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular( + 20.0), // Same radius for focused border + borderSide: BorderSide( + color: Theme.of(context).colorScheme.primary, + width: 2.0), + ), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular( + 20.0), // Same radius for enabled border + borderSide: BorderSide(color: Colors.grey, width: 2.0), + ), + ), ), ), SizedBox(width: 8), diff --git a/lib/src/views/chats/media_viewer_view.dart b/lib/src/views/chats/media_viewer_view.dart index 5e0953e..216875a 100644 --- a/lib/src/views/chats/media_viewer_view.dart +++ b/lib/src/views/chats/media_viewer_view.dart @@ -27,7 +27,9 @@ class _MediaViewerViewState extends State { DateTime? canBeSeenUntil; int maxShowTime = 999999; bool isRealTwonly = false; + double progress = 0; Timer? _timer; + Timer? _timer2; // DateTime opened; @override @@ -78,8 +80,14 @@ class _MediaViewerViewState extends State { if (context.mounted) { Navigator.pop(context); } + return; } - + // image loading does require some time + Future.delayed(Duration(milliseconds: 200), () { + setState(() { + mediaOpened(); + }); + }); setState(() {}); } } @@ -90,6 +98,14 @@ class _MediaViewerViewState extends State { Navigator.pop(context); } }); + _timer2 = Timer.periodic(Duration(milliseconds: 10), (timer) { + if (canBeSeenUntil != null) { + Duration difference = canBeSeenUntil!.difference(DateTime.now()); + // Calculate the progress as a value between 0.0 and 1.0 + progress = (difference.inMilliseconds / (maxShowTime * 1000)); + setState(() {}); + } + }); } mediaOpened() { @@ -102,6 +118,7 @@ class _MediaViewerViewState extends State { ); maxShowTime = content.maxShowTime; startTimer(); + setState(() {}); } } } @@ -110,38 +127,24 @@ class _MediaViewerViewState extends State { void dispose() { super.dispose(); _timer?.cancel(); + _timer2?.cancel(); _noScreenshot.screenshotOn(); } @override Widget build(BuildContext context) { - double progress = 0; - if (canBeSeenUntil != null) { - Duration difference = canBeSeenUntil!.difference(DateTime.now()); - print(difference.inMilliseconds); - // Calculate the progress as a value between 0.0 and 1.0 - progress = (difference.inMilliseconds / (maxShowTime * 1000)); - if (progress <= 0) { - return Scaffold(); - } - } - // progress = 0.8; - return Scaffold( body: SafeArea( child: Stack( fit: StackFit.expand, children: [ - if (_imageByte != null) + if (_imageByte != null && (canBeSeenUntil == null || progress >= 0)) MediaViewSizing( Image.memory( _imageByte!, fit: BoxFit.contain, frameBuilder: ((context, child, frame, wasSynchronouslyLoaded) { - if (frame != null || wasSynchronouslyLoaded) { - mediaOpened(); - } if (wasSynchronouslyLoaded) return child; return AnimatedSwitcher( duration: const Duration(milliseconds: 200),