From b47be2226939bf716ab56da4e1a368c024f5eb01 Mon Sep 17 00:00:00 2001 From: nrakocevic Date: Sun, 1 Dec 2024 14:02:06 -0800 Subject: [PATCH] Apparently I have to add again once I make changes --- fightme_webapp/lib/dashboard.dart | 39 ++++++++ fightme_webapp/lib/quests_page.dart | 40 ++++++++ fightme_webapp/lib/vs_page.dart | 145 ++++++++++++++++++++++++++++ 3 files changed, 224 insertions(+) diff --git a/fightme_webapp/lib/dashboard.dart b/fightme_webapp/lib/dashboard.dart index e69de29..2676e4f 100644 --- a/fightme_webapp/lib/dashboard.dart +++ b/fightme_webapp/lib/dashboard.dart @@ -0,0 +1,39 @@ +import 'package:flutter/material.dart'; +import 'Models/chatroom.dart'; +import 'Models/user.dart'; +import 'package:fightme_webapp/Models/httpservice.dart'; +import 'pending_requests.dart'; +import 'globals.dart' as globals; + +class DashboardPage extends StatefulWidget { + final User curUser; + + const DashboardPage({super.key, required this.curUser}); + + @override + State createState() => DashboardPageState(); +} + + +class DashboardPageState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: Theme + .of(context) + .colorScheme + .primary, + centerTitle: true, + title: const Text("Home"), + ), + body: Center( + child: Column( + children: [ + + ], + ), + ), + ); + } +} \ No newline at end of file diff --git a/fightme_webapp/lib/quests_page.dart b/fightme_webapp/lib/quests_page.dart index e69de29..3181354 100644 --- a/fightme_webapp/lib/quests_page.dart +++ b/fightme_webapp/lib/quests_page.dart @@ -0,0 +1,40 @@ +import 'package:flutter/material.dart'; +import 'Models/chatroom.dart'; +import 'Models/user.dart'; +import 'package:fightme_webapp/Models/httpservice.dart'; +import 'pending_requests.dart'; +import 'globals.dart' as globals; + +class QuestsPage extends StatefulWidget { + final User curUser; + + const QuestsPage({super.key, required this.curUser}); + + @override + State createState() => QuestsPageState(); +} + + +class QuestsPageState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: Theme + .of(context) + .colorScheme + .primary, + centerTitle: true, + title: const Text("Home"), + // Suggestion for this segment: https://api.flutter.dev/flutter/material/TabBar-class.html + ), + body: Center( + child: Column( + children: [ + + ], + ), + ), + ); + } +} \ No newline at end of file diff --git a/fightme_webapp/lib/vs_page.dart b/fightme_webapp/lib/vs_page.dart index e69de29..90e05ae 100644 --- a/fightme_webapp/lib/vs_page.dart +++ b/fightme_webapp/lib/vs_page.dart @@ -0,0 +1,145 @@ +import 'package:flutter/material.dart'; +import 'Models/fight_game_session.dart'; +import 'Models/user.dart'; +import 'package:fightme_webapp/Models/httpservice.dart'; +import 'Widgets/fightButton.dart'; +import 'Cosmetics/profile_pictures.dart'; +import 'globals.dart' as globals; + +class VsPage extends StatefulWidget { + final User curUser; + + const VsPage({super.key, required this.curUser}); + + @override + State createState() => VsPageState(); +} + + +class VsPageState extends State { + late Future> _list = Future.value([]); + + Future> _buildList() async { + List colors = [Colors.red, Colors.orangeAccent, Colors.amberAccent, Colors.yellowAccent[100]!, Colors.lightGreenAccent[400]!]; + HttpService http = HttpService(); + List list = List.empty(growable: true); + List myFights = List.empty(growable: true); // TODO: Write the fighting game session in the backend then write a function in HttpService. + myFights.removeWhere((element) => element.winnerID != 0); + for (var fight in myFights) { + User user = fight.user2; + list.add( + TextButton( + onPressed: () { + buildFightButton(context, fight); + }, + child: ListTile( + 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: Column( + children: [ + Row( + children: [ + for (int i = 1; i <= 5; i++) + i > 5 - fight.user2hp ? Expanded( + child: Container( + height: 15.0, + decoration: BoxDecoration( + color: colors[fight.user2hp - 1], + border: Border.all( + color: Colors.black, + width: 0.0), + ) + ), + ) : + Expanded( + child: Container( + height: 15.0, + ), + ), + const SizedBox( + width: 5, + ), + const Text("HP"), + ] + ), + Row( + children: [ + const Text("HP"), + const SizedBox( + width: 5, + ), + for (int i = 1; i <= 5; i++) + i <= fight.user1hp ? Expanded( + child: Container( + height: 15.0, + decoration: BoxDecoration( + color: colors[fight.user1hp - 1], + border: Border.all( + color: Colors.black, + width: 0.0), + ) + ), + ) : + Expanded( + child: Container( + height: 15.0, + ), + ), + ] + ), + ], + ), + ) + ) + ); + } + return list; + } + + @override + void initState() { + super.initState(); + _list = _buildList(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: Theme + .of(context) + .colorScheme + .primary, + centerTitle: true, + title: const Text("Home"), + ), + body: Center( + child: Column( + children: [ + FutureBuilder(future: _list, builder: (BuildContext context, AsyncSnapshot> snapshot) { + if (snapshot.hasData) { + if (snapshot.data!.isEmpty) { + return const Text( + "No chat rooms available. Go and make some friends."); + } + else { + return ListView( + scrollDirection: Axis.vertical, + shrinkWrap: true, + children: snapshot.data! + ); + } + } + else { + return const CircularProgressIndicator(); + } + }), + ], + ), + ), + ); + } +} \ No newline at end of file