fixed web

This commit is contained in:
mohamadmahdi jebeli 2025-07-12 16:04:38 +03:30
parent 5f02802ad1
commit 3827209ade
5 changed files with 40 additions and 52 deletions

View File

@ -496,7 +496,6 @@ class RouteGenerator {
textScaler: const TextScaler.linear(1.0), textScaler: const TextScaler.linear(1.0),
), ),
child: Container( child: Container(
// ignore: deprecated_member_use
color: Theme.of(context).colorScheme.background, color: Theme.of(context).colorScheme.background,
alignment: Alignment.center, alignment: Alignment.center,
child: AspectRatio(aspectRatio: 9 / 16, child: page), child: AspectRatio(aspectRatio: 9 / 16, child: page),

View File

@ -1,3 +1,5 @@
// lib/views/home/main/widgets/swot_item_card.dart
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'package:cached_network_image_platform_interface/cached_network_image_platform_interface.dart'; import 'package:cached_network_image_platform_interface/cached_network_image_platform_interface.dart';
import 'package:didvan/config/theme_data.dart'; import 'package:didvan/config/theme_data.dart';
@ -52,7 +54,7 @@ class _SwotItemCardState extends State<SwotItemCard> {
}, },
child: Container( child: Container(
height: 500 , height: 500 ,
width: 250, width: kIsWeb ? 350 : 250,
margin: const EdgeInsets.only(right: 0), margin: const EdgeInsets.only(right: 0),
padding: const EdgeInsets.all(0), padding: const EdgeInsets.all(0),
decoration: BoxDecoration( decoration: BoxDecoration(
@ -76,7 +78,7 @@ class _SwotItemCardState extends State<SwotItemCard> {
} }
return Container( return Container(
height: 150, height: 150,
width: 300, width: kIsWeb ? 350 : 300,
decoration: BoxDecoration( decoration: BoxDecoration(
color: color:
Theme.of(context).colorScheme.disabledBackground, Theme.of(context).colorScheme.disabledBackground,
@ -90,11 +92,11 @@ class _SwotItemCardState extends State<SwotItemCard> {
httpHeaders: { httpHeaders: {
'Authorization': 'Bearer ${RequestService.token}' 'Authorization': 'Bearer ${RequestService.token}'
}, },
width: 300, width: kIsWeb ? 350 : 300,
height: 150, height: 150,
imageUrl: widget.item.imageUrl, imageUrl: widget.item.imageUrl,
placeholder: (context, _) => const ShimmerPlaceholder( placeholder: (context, _) => ShimmerPlaceholder(
width: 300, width: kIsWeb ? 350 : 300,
height: 150, height: 150,
), ),
), ),

View File

@ -1,4 +1,4 @@
// ignore_for_file: avoid_print // lib/views/story_viewer/story_viewer_page.dart
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'package:didvan/models/story_model.dart'; import 'package:didvan/models/story_model.dart';
@ -86,14 +86,13 @@ class _UserStoryViewerState extends State<UserStoryViewer>
late AnimationController _animationController; late AnimationController _animationController;
VideoPlayerController? _videoController; VideoPlayerController? _videoController;
int _currentStoryIndex = 0; int _currentStoryIndex = 0;
bool _isLongPressing = false;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_animationController = AnimationController(vsync: this); _animationController = AnimationController(vsync: this);
final allStoriesInGroupViewed = final allStoriesInGroupViewed =
widget.userStories.stories.every((story) => story.isViewed.value); widget.userStories.stories.every((story) => story.isViewed.value);
if (allStoriesInGroupViewed) { if (allStoriesInGroupViewed) {
@ -155,6 +154,7 @@ class _UserStoryViewerState extends State<UserStoryViewer>
_videoController!.play(); _videoController!.play();
_animationController.forward(); _animationController.forward();
} else { } else {
// ignore: avoid_print
print( print(
"Video failed to initialize or has zero duration. Skipping."); "Video failed to initialize or has zero duration. Skipping.");
_nextStory(); _nextStory();
@ -162,6 +162,7 @@ class _UserStoryViewerState extends State<UserStoryViewer>
}); });
} }
}).catchError((error) { }).catchError((error) {
// ignore: avoid_print
print("Error loading video: $error. Skipping."); print("Error loading video: $error. Skipping.");
if (mounted) { if (mounted) {
_nextStory(); _nextStory();
@ -202,44 +203,37 @@ class _UserStoryViewerState extends State<UserStoryViewer>
_videoController?.play(); _videoController?.play();
} }
void _handleTap(TapUpDetails details) {
if (_isLongPressing) {
_isLongPressing = false;
_resumeStory();
return;
}
final double screenWidth = MediaQuery.of(context).size.width;
final double dx = details.globalPosition.dx;
if (dx > screenWidth / 2) {
_nextStory();
} else {
_previousStory();
}
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final story = widget.userStories.stories[_currentStoryIndex]; final story = widget.userStories.stories[_currentStoryIndex];
return Scaffold( return Scaffold(
backgroundColor: Colors.black, backgroundColor: Colors.black,
body: GestureDetector( body: Stack(
onTapUp: _handleTap, fit: StackFit.expand,
onLongPressStart: (_) { children: [
_isLongPressing = true; _buildMediaViewer(story),
_pauseStory(); Row(
}, children: [
onLongPressEnd: (_) { Expanded(
_isLongPressing = false; child: GestureDetector(
_resumeStory(); onTap: _previousStory,
}, onLongPress: _pauseStory,
child: Stack( onLongPressUp: _resumeStory,
fit: StackFit.expand, child: Container(color: Colors.transparent),
children: [ ),
_buildMediaViewer(story), ),
_buildStoryHeader(), Expanded(
], child: GestureDetector(
), onTap: _nextStory,
onLongPress: _pauseStory,
onLongPressUp: _resumeStory,
child: Container(color: Colors.transparent),
),
),
],
),
_buildStoryHeader(),
],
), ),
); );
} }
@ -405,13 +399,6 @@ class _UserInfo extends StatelessWidget {
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
), ),
), ),
// DidvanText(
// DateTimeUtils.momentGenerator(user.createdAt),
// style: const TextStyle(
// color: Colors.white70,
// fontSize: 14.0,
// ),
// ),
], ],
), ),
), ),

View File

@ -108,7 +108,7 @@ class _DidvanTextFieldState extends State<DidvanTextField> {
? TextDirection.ltr ? TextDirection.ltr
: TextDirection.rtl, : TextDirection.rtl,
child: Padding( child: Padding(
padding: const EdgeInsets.fromLTRB(8,8,0,8), padding: const EdgeInsets.fromLTRB(8,8,0,15),
child: TextFormField( child: TextFormField(
inputFormatters: <TextInputFormatter>[ inputFormatters: <TextInputFormatter>[
if (!widget.acceptSpace) if (!widget.acceptSpace)

View File

@ -44,7 +44,7 @@ class SkeletonImage extends StatelessWidget {
child: const Icon(Icons.image_not_supported_outlined)); child: const Icon(Icons.image_not_supported_outlined));
}, },
errorListener: (value) {}, errorListener: (value) {},
fit: BoxFit.cover, fit: kIsWeb? BoxFit.fill:BoxFit.cover,
imageRenderMethodForWeb: ImageRenderMethodForWeb.HttpGet, imageRenderMethodForWeb: ImageRenderMethodForWeb.HttpGet,
httpHeaders: {'Authorization': 'Bearer ${RequestService.token}'}, httpHeaders: {'Authorization': 'Bearer ${RequestService.token}'},
width: width, width: width,