From 407bd19f4a37c2636a8384f6e43aa826f8401790 Mon Sep 17 00:00:00 2001 From: "audric.sabatier" Date: Sun, 15 Jan 2023 23:11:37 -0500 Subject: [PATCH] ADD : Get user from Firestore and display in conv page --- .idea/libraries/Dart_Packages.xml | 396 +++++++++--------- .idea/libraries/Dart_SDK.xml | 38 +- .../lib/controller/controller.dart | 1 + .../messaging/message_database_service.dart | 1 + .../lib/views/pages/main/p_conversation.dart | 4 +- .../lib/views/pages/main/w_messages.dart | 53 ++- 6 files changed, 266 insertions(+), 227 deletions(-) diff --git a/.idea/libraries/Dart_Packages.xml b/.idea/libraries/Dart_Packages.xml index 555e605..9d9042e 100644 --- a/.idea/libraries/Dart_Packages.xml +++ b/.idea/libraries/Dart_Packages.xml @@ -5,798 +5,798 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.idea/libraries/Dart_SDK.xml b/.idea/libraries/Dart_SDK.xml index 6ae284f..008f0f6 100644 --- a/.idea/libraries/Dart_SDK.xml +++ b/.idea/libraries/Dart_SDK.xml @@ -1,25 +1,25 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/Sources/dafl_project_flutter/lib/controller/controller.dart b/Sources/dafl_project_flutter/lib/controller/controller.dart index 474aa9e..ac34f06 100644 --- a/Sources/dafl_project_flutter/lib/controller/controller.dart +++ b/Sources/dafl_project_flutter/lib/controller/controller.dart @@ -38,6 +38,7 @@ class Controller { + initUser() async { await setCurrentMusic(); await setDiscoveries(); diff --git a/Sources/dafl_project_flutter/lib/services/messaging/message_database_service.dart b/Sources/dafl_project_flutter/lib/services/messaging/message_database_service.dart index 51f90a0..7b07e3c 100644 --- a/Sources/dafl_project_flutter/lib/services/messaging/message_database_service.dart +++ b/Sources/dafl_project_flutter/lib/services/messaging/message_database_service.dart @@ -54,4 +54,5 @@ class MessageDatabaseService{ .collection(chatId) .snapshots().map(_getAllMessages); } + } \ No newline at end of file diff --git a/Sources/dafl_project_flutter/lib/views/pages/main/p_conversation.dart b/Sources/dafl_project_flutter/lib/views/pages/main/p_conversation.dart index 7f19aa2..67b8949 100644 --- a/Sources/dafl_project_flutter/lib/views/pages/main/p_conversation.dart +++ b/Sources/dafl_project_flutter/lib/views/pages/main/p_conversation.dart @@ -5,7 +5,9 @@ import 'package:dafl_project_flutter/model/message.dart'; import 'dart:developer' as dev; class ConversationPage extends StatefulWidget { - const ConversationPage({Key? key}) : super(key: key); + String sender; + + ConversationPage({Key? key, required String this.sender}) : super(key: key); @override State createState() => _ConversationPageState(); diff --git a/Sources/dafl_project_flutter/lib/views/pages/main/w_messages.dart b/Sources/dafl_project_flutter/lib/views/pages/main/w_messages.dart index 7d1ffba..795ba63 100644 --- a/Sources/dafl_project_flutter/lib/views/pages/main/w_messages.dart +++ b/Sources/dafl_project_flutter/lib/views/pages/main/w_messages.dart @@ -1,3 +1,5 @@ +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:dafl_project_flutter/main.dart'; import 'package:flutter/material.dart'; import 'package:page_transition/page_transition.dart'; @@ -131,7 +133,10 @@ class _MessagesWidgetState extends State { } class MessagesButtonWidget extends StatelessWidget { - const MessagesButtonWidget({super.key}); + final String sender; + + const MessagesButtonWidget({super.key, required this.sender}); + @override Widget build(BuildContext context) { @@ -171,7 +176,7 @@ class MessagesButtonWidget extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - 'Max', + sender, style: TextStyle( fontFamily: 'DMSans', color: Colors.white.withOpacity(1), @@ -207,17 +212,44 @@ class MessagesButtonWidget extends StatelessWidget { } } + + + class ListConfirmedWidget extends StatelessWidget { const ListConfirmedWidget({super.key}); @override Widget build(BuildContext context) { - return ListView(children: const [ - MessagesButtonWidget(), - MessagesButtonWidget(), - MessagesButtonWidget(), - MessagesButtonWidget(), - ]); + + return StreamBuilder>>( + stream: FirebaseFirestore.instance.collection('users').doc('felix').collection('felix').snapshots(), + builder: (_, snapshot) { + if (snapshot.hasError) return Text('Error = ${snapshot.error}'); + + if (snapshot.hasData) { + final docs = snapshot.data!.docs; + + return ListView.builder( + itemCount: docs.length, + itemBuilder: (context, i) { + final data = docs[i].data(); + return GestureDetector( + onTap: () { + Navigator.of(context).push(PageTransition( + duration: const Duration(milliseconds: 200), + reverseDuration: const Duration(milliseconds: 200), + type: PageTransitionType.rightToLeftWithFade, + childCurrent: context.widget, + child: const ConversationPage())); + }, + child: MessagesButtonWidget(sender : data['user']) + ); + }, + ); + } + return Center(child: CircularProgressIndicator()); + }, + ); } } @@ -226,6 +258,7 @@ class ListWaitingWidget extends StatelessWidget { @override Widget build(BuildContext context) { + return ListView( children: [ GestureDetector( @@ -237,9 +270,11 @@ class ListWaitingWidget extends StatelessWidget { childCurrent: context.widget, child: const ConversationPage())); }, - child: const MessagesButtonWidget(), + child: const MessagesButtonWidget(sender : "test6"), ), ], ); } } + +