diff --git a/.idea/libraries/Dart_Packages.xml b/.idea/libraries/Dart_Packages.xml
index 2328905..2795ffb 100644
--- a/.idea/libraries/Dart_Packages.xml
+++ b/.idea/libraries/Dart_Packages.xml
@@ -814,6 +814,13 @@
+
+
+
+
+
+
+
@@ -1013,6 +1020,7 @@
+
diff --git a/Sources/justMUSIC/lib/components/comment_component.dart b/Sources/justMUSIC/lib/components/comment_component.dart
index 859df15..c83463b 100644
--- a/Sources/justMUSIC/lib/components/comment_component.dart
+++ b/Sources/justMUSIC/lib/components/comment_component.dart
@@ -17,11 +17,12 @@ class CommentComponent extends StatelessWidget {
return Container(
width: double.infinity,
- decoration: BoxDecoration(color: bgComment, borderRadius: BorderRadius.circular(20)),
- padding: EdgeInsets.all(20),
- margin: EdgeInsets.only(bottom: 20),
+ decoration: BoxDecoration(color: bgComment.withOpacity(0.6), borderRadius: BorderRadius.circular(15)),
+ padding: EdgeInsets.fromLTRB(20, 10, 20, 10),
+ margin: EdgeInsets.only(bottom: 13),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisAlignment: MainAxisAlignment.start,
children: [
ClipOval(
child: SizedBox.fromSize(
@@ -50,7 +51,7 @@ class CommentComponent extends StatelessWidget {
Padding(
padding: EdgeInsets.only(top: 6, left: 10),
child: Text(
- "il y a ${difference.inHours}h",
+ "il y a ${difference.inHours > 0 ? difference.inHours : difference.inMinutes}${difference.inHours > 0 ? "h" : "m"}",
style: GoogleFonts.plusJakartaSans(
color: Colors.white.withOpacity(0.6), fontWeight: FontWeight.w400, fontSize: 10),
),
@@ -58,13 +59,13 @@ class CommentComponent extends StatelessWidget {
],
),
SizedBox(
- height: 8,
+ height: 4,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Text(
comment.text,
- style: GoogleFonts.plusJakartaSans(color: Colors.white, fontWeight: FontWeight.w400, fontSize: 12),
+ style: GoogleFonts.plusJakartaSans(color: Colors.white, fontWeight: FontWeight.w400, fontSize: 15),
),
),
],
diff --git a/Sources/justMUSIC/lib/main.dart b/Sources/justMUSIC/lib/main.dart
index f04370c..3c6a7ce 100644
--- a/Sources/justMUSIC/lib/main.dart
+++ b/Sources/justMUSIC/lib/main.dart
@@ -10,21 +10,23 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:justmusic/screens/add_friend_screen.dart';
import 'package:justmusic/screens/explanations_screen.dart';
import 'package:justmusic/screens/feed_screen.dart';
+import 'package:justmusic/screens/loading_screen.dart';
import 'package:justmusic/screens/login_screen.dart';
import 'package:justmusic/screens/launching_rocker_screen.dart';
import 'package:justmusic/screens/post_screen.dart';
import 'package:justmusic/screens/profile_screen.dart';
import 'package:justmusic/screens/registration_screen.dart';
import 'package:justmusic/screens/welcome_screen.dart';
-import 'package:justmusic/values/constants.dart';
import 'package:justmusic/view_model/CommentViewModel.dart';
import 'package:justmusic/view_model/MusicViewModel.dart';
import 'package:justmusic/view_model/PostViewModel.dart';
import 'package:justmusic/view_model/UserViewModel.dart';
import 'package:justmusic/model/User.dart' as userJustMusic;
import 'firebase_options.dart';
+import 'package:timezone/data/latest.dart' as tz;
Future main() async {
+ tz.initializeTimeZones();
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
@@ -99,25 +101,21 @@ class _MyAppState extends State {
},
debugShowCheckedModeBanner: false,
theme: ThemeData(
- // This is the theme of your application.
- //
- // Try running your application with "flutter run". You'll see the
- // application has a blue toolbar. Then, without quitting the app, try
- // changing the primarySwatch below to Colors.green and then invoke
- // "hot reload" (press "r" in the console where you ran "flutter run",
- // or simply save your changes to "hot reload" in a Flutter IDE).
- // Notice that the counter didn't reset back to zero; the application
- // is not restarted.
primarySwatch: Colors.blue,
),
- home: FirebaseAuth.instance.currentUser != null
- ? StreamBuilder(
- stream: userCurrent,
- initialData: null,
- builder: (context, snapshot) {
- if (snapshot.hasData) {
- print("hasdata");
-
+ home: StreamBuilder(
+ stream: FirebaseAuth.instance.authStateChanges(),
+ builder: (context, snapshot) {
+ if (snapshot.connectionState == ConnectionState.waiting) {
+ return LoadingScreen();
+ } else if (snapshot.hasData) {
+ return FutureBuilder(
+ future: MyApp.userViewModel.getUser(snapshot.data!.uid),
+ builder: (context, userSnapshot) {
+ if (userSnapshot.connectionState == ConnectionState.waiting) {
+ return LoadingScreen();
+ } else if (userSnapshot.hasData) {
+ MyApp.userViewModel.userCurrent = userSnapshot.data!;
return AnimatedSwitcher(
duration: Duration(milliseconds: 1000),
transitionBuilder: (child, animation) {
@@ -126,18 +124,15 @@ class _MyAppState extends State {
child: FeedScreen(),
);
} else {
- return Scaffold(
- backgroundColor: bgColor,
- body: Center(
- child: Image(
- image: AssetImage("assets/images/logo.png"),
- width: 130,
- ),
- ),
- );
+ return WellcomeScreen();
}
- })
- : WellcomeScreen());
+ },
+ );
+ } else {
+ return WellcomeScreen();
+ }
+ },
+ ));
},
designSize: Size(390, 844),
);
diff --git a/Sources/justMUSIC/lib/screens/detail_post_screen.dart b/Sources/justMUSIC/lib/screens/detail_post_screen.dart
index ef8dfb9..68c96c3 100644
--- a/Sources/justMUSIC/lib/screens/detail_post_screen.dart
+++ b/Sources/justMUSIC/lib/screens/detail_post_screen.dart
@@ -462,6 +462,14 @@ class _DetailPostScreenState extends State {
keyboardAppearance: Brightness.dark,
controller: _textController,
focusNode: myFocusNode,
+ onSubmitted: (value) async {
+ if (value.isNotEmpty) {
+ await MyApp.commentViewModel.addComment(value, widget.post.id);
+ }
+ setState(() {
+ _textController.clear();
+ });
+ },
cursorColor: primaryColor,
keyboardType: TextInputType.emailAddress,
style: GoogleFonts.plusJakartaSans(color: Colors.white),
diff --git a/Sources/justMUSIC/lib/screens/feed_screen.dart b/Sources/justMUSIC/lib/screens/feed_screen.dart
index 0324f71..25bab59 100644
--- a/Sources/justMUSIC/lib/screens/feed_screen.dart
+++ b/Sources/justMUSIC/lib/screens/feed_screen.dart
@@ -16,6 +16,7 @@ import '../components/top_nav_bar_component.dart';
import '../model/Post.dart';
import '../values/constants.dart';
import 'detail_post_screen.dart';
+import 'package:timezone/timezone.dart' as tz;
class FeedScreen extends StatefulWidget {
const FeedScreen({Key? key}) : super(key: key);
@@ -32,7 +33,6 @@ class _FeedScreenState extends State with SingleTickerProviderStateM
late List discoveryFeed;
late List displayFeed;
- final DateTime midnight = DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day + 1);
bool isDismissed = true;
@override
@@ -56,6 +56,15 @@ class _FeedScreenState extends State with SingleTickerProviderStateM
}
Future showCapsuleDot() async {
+ // Get the timezone for France
+ final franceTimeZone = tz.getLocation('Europe/Paris');
+
+ // Get the current date and time in France timezone
+ var now = tz.TZDateTime.now(franceTimeZone);
+
+ // Calculate the midnight time for the next day in France timezone
+ var midnight = tz.TZDateTime(franceTimeZone, now.year, now.month, now.day + 1);
+
bool res = await MyApp.postViewModel.getAvailable();
if (isDismissed) {
if (res) {
@@ -116,7 +125,7 @@ class _FeedScreenState extends State with SingleTickerProviderStateM
messageText: Align(
alignment: Alignment.centerLeft,
child: CountdownTimer(
- endTime: midnight.millisecondsSinceEpoch - 2 * 60 * 60 * 1000,
+ endTime: midnight.millisecondsSinceEpoch,
textStyle: GoogleFonts.plusJakartaSans(color: Colors.grey, fontSize: 15),
),
),
diff --git a/Sources/justMUSIC/lib/screens/loading_screen.dart b/Sources/justMUSIC/lib/screens/loading_screen.dart
new file mode 100644
index 0000000..e9bb106
--- /dev/null
+++ b/Sources/justMUSIC/lib/screens/loading_screen.dart
@@ -0,0 +1,20 @@
+import 'package:flutter/Material.dart';
+
+import '../values/constants.dart';
+
+class LoadingScreen extends StatelessWidget {
+ const LoadingScreen({Key? key}) : super(key: key);
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ backgroundColor: bgColor,
+ body: Center(
+ child: Image(
+ image: AssetImage("assets/images/logo.png"),
+ width: 130,
+ ),
+ ),
+ );
+ }
+}
diff --git a/Sources/justMUSIC/lib/services/CommentService.dart b/Sources/justMUSIC/lib/services/CommentService.dart
index 633ab78..961dae7 100644
--- a/Sources/justMUSIC/lib/services/CommentService.dart
+++ b/Sources/justMUSIC/lib/services/CommentService.dart
@@ -5,21 +5,16 @@ import '../main.dart';
class CommentService {
createComment(String text, String idPost) async {
var id = MyApp.userViewModel.userCurrent.id;
- final comment = {
- "user_id": id,
- "text": text,
- "date": DateTime.now(),
- "post_id": idPost
- };
+ final comment = {"user_id": id, "text": text, "date": DateTime.now(), "post_id": idPost};
await MyApp.db.collection("comments").add(comment);
}
- Future>>> getCommentsByPostId(
- String id) async {
+ Future>>> getCommentsByPostId(String id) async {
var response = await FirebaseFirestore.instance
.collection("comments")
.where("post_id", isEqualTo: id)
+ .orderBy("date", descending: true)
.get();
return response.docs;
diff --git a/Sources/justMUSIC/pubspec.lock b/Sources/justMUSIC/pubspec.lock
index 30973dd..27bf207 100644
--- a/Sources/justMUSIC/pubspec.lock
+++ b/Sources/justMUSIC/pubspec.lock
@@ -917,6 +917,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.2.0"
+ timezone:
+ dependency: "direct main"
+ description:
+ name: timezone
+ sha256: "1cfd8ddc2d1cfd836bc93e67b9be88c3adaeca6f40a00ca999104c30693cdca0"
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.9.2"
top_snackbar_flutter:
dependency: "direct main"
description:
diff --git a/Sources/justMUSIC/pubspec.yaml b/Sources/justMUSIC/pubspec.yaml
index d56b47b..3f7f94a 100644
--- a/Sources/justMUSIC/pubspec.yaml
+++ b/Sources/justMUSIC/pubspec.yaml
@@ -72,6 +72,7 @@ dependencies:
animations: ^2.0.7
flutter_svg: ^2.0.7
flutter_keyboard_visibility: ^5.4.1
+ timezone: ^0.9.2
dev_dependencies:
flutter_test: