Chat module
This commit is contained in:
@@ -235,8 +235,6 @@
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:cached_video_player_plus/cached_video_player_plus.dart';
|
||||
|
||||
@@ -438,10 +436,13 @@
|
||||
import 'package:caller/app/modules/chat/MessageModule/views/messageChatViews/ChatHomePage.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cached_video_player_plus/cached_video_player_plus.dart';
|
||||
import 'package:flutter_vlc_player/flutter_vlc_player.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../../../constants/colors/colors.dart';
|
||||
import '../services/videoPreloader.dart';
|
||||
import '../widgets/videoWidget.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class VideoFeedScreen extends StatefulWidget {
|
||||
const VideoFeedScreen({Key? key}) : super(key: key);
|
||||
@@ -450,7 +451,8 @@ class VideoFeedScreen extends StatefulWidget {
|
||||
_VideoFeedScreenState createState() => _VideoFeedScreenState();
|
||||
}
|
||||
|
||||
class _VideoFeedScreenState extends State<VideoFeedScreen> {
|
||||
class _VideoFeedScreenState extends State<VideoFeedScreen>
|
||||
with WidgetsBindingObserver {
|
||||
final PageController _pageController = PageController();
|
||||
final VideoPreloader _preloader = VideoPreloader();
|
||||
|
||||
@@ -464,11 +466,14 @@ class _VideoFeedScreenState extends State<VideoFeedScreen> {
|
||||
];
|
||||
|
||||
int currentIndex = 0;
|
||||
|
||||
final Map<int, CachedVideoPlayerPlusController> _controllers = {};
|
||||
final Map<int, VlcPlayerController> _rtmpControllers = {};
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
_initializePreloader();
|
||||
_loadSavedIndex();
|
||||
}
|
||||
@@ -532,6 +537,7 @@ class _VideoFeedScreenState extends State<VideoFeedScreen> {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
WidgetsBinding.instance.removeObserver(this);
|
||||
_controllers.forEach((key, controller) {
|
||||
controller.dispose();
|
||||
});
|
||||
@@ -539,17 +545,51 @@ class _VideoFeedScreenState extends State<VideoFeedScreen> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||
if (state == AppLifecycleState.paused ||
|
||||
state == AppLifecycleState.inactive ||
|
||||
state == AppLifecycleState.detached) {
|
||||
for (var controller in _controllers.values) {
|
||||
if (controller.value.isInitialized) {
|
||||
controller.setVolume(0);
|
||||
controller.pause();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.black,
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.black,
|
||||
title: const Text('Video Feed'),
|
||||
backgroundColor: AppColors.primary,
|
||||
centerTitle: true,
|
||||
leading: null,
|
||||
title: Text(
|
||||
'self_media_title'.tr,
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.switch_account),
|
||||
onPressed: ()=>Navigator.pushReplacement(context, MaterialPageRoute(builder: (_)=>ChatHomeScreen())),
|
||||
IconButton(
|
||||
icon: Icon(Icons.switch_account,),
|
||||
onPressed: () async {
|
||||
for (var controller in _controllers.values) {
|
||||
if (controller.value.isInitialized) {
|
||||
controller.setVolume(0);
|
||||
await controller.pause();
|
||||
}
|
||||
}
|
||||
await Future.delayed(Duration(milliseconds: 100));
|
||||
if (mounted) {
|
||||
await Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => ChatHomeScreen()),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
// IconButton(
|
||||
// icon: const Icon(Icons.info),
|
||||
@@ -610,7 +650,9 @@ class _VideoFeedScreenState extends State<VideoFeedScreen> {
|
||||
children: [
|
||||
Text('Cache Size: $cacheSize'),
|
||||
Text('Cached Videos: $cachedCount'),
|
||||
Text('Max Cache Size: ${(_preloader.maxCacheSize / (1024 * 1024)).toStringAsFixed(0)}MB'),
|
||||
Text(
|
||||
'Max Cache Size: ${(_preloader.maxCacheSize / (1024 * 1024)).toStringAsFixed(0)}MB',
|
||||
),
|
||||
Text('Preload Count: ${_preloader.maxPreloadCount}'),
|
||||
],
|
||||
),
|
||||
@@ -629,7 +671,9 @@ class _VideoFeedScreenState extends State<VideoFeedScreen> {
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('Clear Cache'),
|
||||
content: const Text('Are you sure you want to clear all cached videos?'),
|
||||
content: const Text(
|
||||
'Are you sure you want to clear all cached videos?',
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
|
Reference in New Issue
Block a user