-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apparently I have to add again once I make changes
- Loading branch information
1 parent
4acfd8c
commit b47be22
Showing
3 changed files
with
224 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<DashboardPage> createState() => DashboardPageState(); | ||
} | ||
|
||
|
||
class DashboardPageState extends State<DashboardPage> { | ||
@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: [ | ||
|
||
], | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<QuestsPage> createState() => QuestsPageState(); | ||
} | ||
|
||
|
||
class QuestsPageState extends State<QuestsPage> { | ||
@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: [ | ||
|
||
], | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<VsPage> createState() => VsPageState(); | ||
} | ||
|
||
|
||
class VsPageState extends State<VsPage> { | ||
late Future<List<Widget>> _list = Future.value([]); | ||
|
||
Future<List<Widget>> _buildList() async { | ||
List<Color> colors = [Colors.red, Colors.orangeAccent, Colors.amberAccent, Colors.yellowAccent[100]!, Colors.lightGreenAccent[400]!]; | ||
HttpService http = HttpService(); | ||
List<Widget> list = List.empty(growable: true); | ||
List<FightGameSession> 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<List<Widget>> 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(); | ||
} | ||
}), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} |