Skip to content

Commit

Permalink
Preparing for main pull. Don't forget pending requests still very muc…
Browse files Browse the repository at this point in the history
…h needs to be fixed
  • Loading branch information
nrakocevic committed Dec 2, 2024
1 parent da71c79 commit bf30d64
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 17 deletions.
28 changes: 19 additions & 9 deletions fightme_webapp/lib/chat_page_web_socket.dart
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,26 @@ class ChatPageState extends State<ChatPage> {
labelText: "Message",
),
onSubmitted: (value) async {
_sendMessage(value); // Send message via WebSocket
print("Are we here?");
randomNumber = Random().nextInt(100);
if (randomNumber < 50) {
print("I received $randomNumber, increase");
// Optionally update score (or any other game-related logic)
await HttpService().updateUserGamerScore(
widget.currentUID, widget.currentUser.gamerScore + 1);
if (value.length > 255) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
duration: Duration(seconds: 3),
content: Text('You exceeded the character limit.'),
)
);
}
else {
_sendMessage(value); // Send message via WebSocket
print("Are we here?");
randomNumber = Random().nextInt(100);
if (randomNumber < 50) {
print("I received $randomNumber, increase");
// Optionally update score (or any other game-related logic)
await HttpService().updateUserGamerScore(
widget.currentUID, widget.currentUser.gamerScore + 1);
}
textEditControl.clear();
}
textEditControl.clear();
},
),
],
Expand Down
10 changes: 8 additions & 2 deletions fightme_webapp/lib/chats_master_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'Models/chatroom.dart';
// import 'chat_page.dart';
import 'chat_page_web_socket.dart';
import 'Cosmetics/profile_pictures.dart';
import 'Models/user.dart';
import 'package:fightme_webapp/Models/httpservice.dart';
import 'pending_requests.dart';
Expand Down Expand Up @@ -59,9 +60,14 @@ class ChatsMasterPageState extends State<ChatsMasterPage> {
)));
},
child: ListTile(
leading: const Icon(Icons.account_circle_sharp),
leading: ClipRRect(
borderRadius: BorderRadius.circular(80.0),
child: Image.asset(profilePictures[user.pfp], fit: BoxFit.cover, width: 60, height: 60),
),
title: user.id != 0 ? Text(user.name) : const Text("Group"),
subtitle: room.messages.isEmpty ? const Text("") : Text(room.messages.last.content),
subtitle: room.messages.isEmpty ? const Text("") : Text(room.messages.last.content, overflow: TextOverflow.fade,
maxLines: 1,
softWrap: false),
)
);
}
Expand Down
18 changes: 14 additions & 4 deletions fightme_webapp/lib/pending_requests.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import 'package:flutter/material.dart';
import 'package:fightme_webapp/Models/httpservice.dart';
import 'profile_page.dart';
import 'Cosmetics/profile_pictures.dart';
import 'package:fightme_webapp/Models/user.dart';
import 'Widgets/fightButton.dart';
import 'package:fightme_webapp/Models/friend_request.dart';
import 'package:fightme_webapp/Models/fight_game_session.dart';
import 'globals.dart' as globals;

class PendingRequestsPage extends StatefulWidget {
Expand All @@ -22,7 +25,7 @@ class PendingRequestsPageState extends State<PendingRequestsPage> {
HttpService http = HttpService();
List<Widget> list = List.empty(growable: true);
List<FriendRequest> myRequests = await http.getAllFriendRequests(globals.uid);
myRequests.removeWhere((element) => element.status != Status.pending);
myRequests.removeWhere((element) => element.status == Status.rejected);
for (var request in myRequests) {
User user = await http.getUserByID(request.fromUserID);
list.add(
Expand All @@ -36,9 +39,12 @@ class PendingRequestsPageState extends State<PendingRequestsPage> {
userViewed: user)));
},
child: ListTile(
leading: const Icon(Icons.account_circle_sharp),
leading: ClipRRect(
borderRadius: BorderRadius.circular(60.0),
child: Image.asset(profilePictures[user.pfp], fit: BoxFit.cover, width: 60, height: 60),
),
title: user.id != 0 ? Text(user.name) : const Text("Group"),
trailing: Row(
trailing: request.status == Status.pending ? Row(
mainAxisSize: MainAxisSize.min,
children: [
FilledButton.tonal(
Expand Down Expand Up @@ -68,7 +74,11 @@ class PendingRequestsPageState extends State<PendingRequestsPage> {
child: const Text("reject"),
)
]
)
) : ElevatedButton(
onPressed: () =>
buildFightButton(context, FightGameSession(curUser, user)),
child: const Text('Fight!')
),
)
)
);
Expand Down
3 changes: 1 addition & 2 deletions fightme_webapp/lib/profile_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class ProfilePageState extends State<ProfilePage> {

@override
Widget build(BuildContext context) {
List<String> friendsList = List<String>.filled(5, widget.userViewed.name);
return Scaffold(
appBar: AppBar(
backgroundColor: Theme
Expand All @@ -76,7 +75,7 @@ class ProfilePageState extends State<ProfilePage> {
Navigator.push(
context,
MaterialPageRoute<GamerscoreShop>(
builder: (context) => GamerscoreShop(curUser: widget.userViewed)),
builder: (context) => GamerscoreShop(curUser: widget.curUser)),
);
},
icon: Row(
Expand Down

0 comments on commit bf30d64

Please sign in to comment.