some more bugs

This commit is contained in:
otsmr 2025-02-09 22:33:59 +01:00
parent 2e20859a69
commit 80e8682357
2 changed files with 43 additions and 21 deletions

View file

@ -276,10 +276,29 @@ class _ChatItemDetailsViewState extends State<ChatItemDetailsView> {
_sendMessage(); _sendMessage();
}, },
decoration: InputDecoration( decoration: InputDecoration(
hintText: context.lang.chatListDetailInput, hintText: context.lang.chatListDetailInput,
contentPadding: EdgeInsets.symmetric(horizontal: 10) contentPadding:
// border: OutlineInputBorder(), 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), SizedBox(width: 8),

View file

@ -27,7 +27,9 @@ class _MediaViewerViewState extends State<MediaViewerView> {
DateTime? canBeSeenUntil; DateTime? canBeSeenUntil;
int maxShowTime = 999999; int maxShowTime = 999999;
bool isRealTwonly = false; bool isRealTwonly = false;
double progress = 0;
Timer? _timer; Timer? _timer;
Timer? _timer2;
// DateTime opened; // DateTime opened;
@override @override
@ -78,8 +80,14 @@ class _MediaViewerViewState extends State<MediaViewerView> {
if (context.mounted) { if (context.mounted) {
Navigator.pop(context); Navigator.pop(context);
} }
return;
} }
// image loading does require some time
Future.delayed(Duration(milliseconds: 200), () {
setState(() {
mediaOpened();
});
});
setState(() {}); setState(() {});
} }
} }
@ -90,6 +98,14 @@ class _MediaViewerViewState extends State<MediaViewerView> {
Navigator.pop(context); 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() { mediaOpened() {
@ -102,6 +118,7 @@ class _MediaViewerViewState extends State<MediaViewerView> {
); );
maxShowTime = content.maxShowTime; maxShowTime = content.maxShowTime;
startTimer(); startTimer();
setState(() {});
} }
} }
} }
@ -110,38 +127,24 @@ class _MediaViewerViewState extends State<MediaViewerView> {
void dispose() { void dispose() {
super.dispose(); super.dispose();
_timer?.cancel(); _timer?.cancel();
_timer2?.cancel();
_noScreenshot.screenshotOn(); _noScreenshot.screenshotOn();
} }
@override @override
Widget build(BuildContext context) { 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( return Scaffold(
body: SafeArea( body: SafeArea(
child: Stack( child: Stack(
fit: StackFit.expand, fit: StackFit.expand,
children: [ children: [
if (_imageByte != null) if (_imageByte != null && (canBeSeenUntil == null || progress >= 0))
MediaViewSizing( MediaViewSizing(
Image.memory( Image.memory(
_imageByte!, _imageByte!,
fit: BoxFit.contain, fit: BoxFit.contain,
frameBuilder: frameBuilder:
((context, child, frame, wasSynchronouslyLoaded) { ((context, child, frame, wasSynchronouslyLoaded) {
if (frame != null || wasSynchronouslyLoaded) {
mediaOpened();
}
if (wasSynchronouslyLoaded) return child; if (wasSynchronouslyLoaded) return child;
return AnimatedSwitcher( return AnimatedSwitcher(
duration: const Duration(milliseconds: 200), duration: const Duration(milliseconds: 200),