Messaging
Implemented Chat Screens, Profile Pages, Search Pages WIP: User profile, new chat button Intended: Groups, Calls, Voice Messages Properly deleting chats, offline storage of messages
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
||||
import 'package:messaging_app/components/messaging_provider.dart';
|
||||
@@ -9,37 +11,56 @@ import 'package:provider/provider.dart';
|
||||
import 'package:timeago/timeago.dart' as timeago;
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class RecentConverstationsPage extends StatelessWidget {
|
||||
class RecentConverstationsPage extends StatefulWidget {
|
||||
//
|
||||
final double _deviceHeight;
|
||||
final double _deviceWidth;
|
||||
|
||||
const RecentConverstationsPage(this._deviceHeight, this._deviceWidth,
|
||||
{super.key});
|
||||
|
||||
@override
|
||||
State<RecentConverstationsPage> createState() =>
|
||||
_RecentConverstationsPageState();
|
||||
}
|
||||
|
||||
class _RecentConverstationsPageState extends State<RecentConverstationsPage> {
|
||||
late MessagingProviders _auth;
|
||||
|
||||
RecentConverstationsPage(this._deviceHeight, this._deviceWidth);
|
||||
final myController = StreamController<List<Conversations>>.broadcast();
|
||||
Stream<List<Conversations>> get messageStream => myController.stream;
|
||||
|
||||
void messager() {
|
||||
MessagingProviders.instance.getUserConversation(_auth.user!.$id);
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
myController.close();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: _deviceHeight,
|
||||
width: _deviceWidth,
|
||||
return SizedBox(
|
||||
height: widget._deviceHeight,
|
||||
width: widget._deviceWidth,
|
||||
child: ChangeNotifierProvider<MessagingProviders>.value(
|
||||
value: MessagingProviders.instance,
|
||||
child: _conversationView(),
|
||||
child: _conversationView(context),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _conversationView() {
|
||||
return Builder(builder: (_context) {
|
||||
Widget _conversationView(BuildContext _context) {
|
||||
return Builder(builder: (BuildContext _context) {
|
||||
SnackBarService.instance.buildContext = _context;
|
||||
_auth = Provider.of<MessagingProviders>(_context);
|
||||
return SizedBox(
|
||||
height: _deviceHeight,
|
||||
width: _deviceWidth,
|
||||
height: widget._deviceHeight,
|
||||
width: widget._deviceWidth,
|
||||
child: StreamBuilder<List<Conversations>>(
|
||||
stream: MessagingProviders.instance
|
||||
.getUserConversation(_auth.user!.$id),
|
||||
builder: (_, _snapshot) {
|
||||
builder: (_context, _snapshot) {
|
||||
if (_snapshot.hasData) {
|
||||
return ListView.builder(
|
||||
itemCount: _snapshot.data!.length,
|
||||
@@ -53,7 +74,7 @@ class RecentConverstationsPage extends StatelessWidget {
|
||||
MaterialPageRoute(
|
||||
builder: (BuildContext _context) {
|
||||
return ConversationsPage(
|
||||
conversationId: _chatId,
|
||||
chatId: _chatId,
|
||||
chatName: _details.name,
|
||||
chatImage: _details.image,
|
||||
);
|
||||
@@ -62,7 +83,11 @@ class RecentConverstationsPage extends StatelessWidget {
|
||||
);
|
||||
},
|
||||
title: Text(_details.name),
|
||||
subtitle: Text(_details.lastMessage!),
|
||||
subtitle: Text(
|
||||
_details.type == 'text'
|
||||
? _details.lastMessage!
|
||||
: 'attachment: image',
|
||||
),
|
||||
leading: Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
@@ -78,8 +103,7 @@ class RecentConverstationsPage extends StatelessWidget {
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
if (_snapshot.hasError) {
|
||||
} else if (_snapshot.hasError) {
|
||||
return Align(
|
||||
child: Text(
|
||||
"no active conversation",
|
||||
|
||||
Reference in New Issue
Block a user