Skip to content

Commit

Permalink
Merge pull request #578 from bounswe/feature/MB/469/mobile-user-profi…
Browse files Browse the repository at this point in the history
…le-page

#469 mobile-user-profile-page
  • Loading branch information
haticerk committed Nov 27, 2023
2 parents 13feba4 + be3568c commit b94a2fb
Show file tree
Hide file tree
Showing 17 changed files with 642 additions and 38 deletions.
Binary file added ludos/mobile/assets/images/Epic-Games-Emblem.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ludos/mobile/assets/images/ealogo800.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions ludos/mobile/ios/Flutter/Debug.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
1 change: 1 addition & 0 deletions ludos/mobile/ios/Flutter/Release.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
44 changes: 44 additions & 0 deletions ludos/mobile/ios/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}

def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end

File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
use_frameworks!
use_modular_headers!

flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
target 'RunnerTests' do
inherit! :search_paths
end
end

post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
2 changes: 2 additions & 0 deletions ludos/mobile/lib/edit_game_second.dart
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ class _EditGamePageStateSecond extends State<EditGamePageSecond> {
context,
MaterialPageRoute(
builder: (context) => GamePage(
onRefresh: () {},
id: widget.id,
token: widget.token,
userProvider: widget.userProvider,
Expand All @@ -397,6 +398,7 @@ class _EditGamePageStateSecond extends State<EditGamePageSecond> {
context,
MaterialPageRoute(
builder: (context) => GamePage(
onRefresh: () {},
id: widget.id,
token: widget.token,
userProvider: widget.userProvider,
Expand Down
60 changes: 30 additions & 30 deletions ludos/mobile/lib/game_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,11 @@ import 'login_page.dart';
import 'main.dart';

class GamePage extends StatefulWidget {
final VoidCallback onRefresh;
final UserProvider userProvider;
final String? token;
final String id;
const GamePage(
{required this.id,
required this.token,
Key? key,
required this.userProvider})
: super(key: key);
const GamePage({required this.id, required this.token, Key? key, required this.userProvider, required this.onRefresh}) : super(key: key);
@override
State<GamePage> createState() => _GamePageState();
}
Expand Down Expand Up @@ -455,32 +451,34 @@ class _GamePageState extends State<GamePage> {
),
),
)
.closed
.then((reason) => {});
} else {
bool state = false;
Future<bool> executeAsyncActions() async {
bool state = false;
try {
if (followState) {
http.Response token = await APIService()
.unfollowGame(widget.token, widget.id);
if (token.statusCode == 200) {
state = false;
print("Unfollowed");
.closed
.then((reason) => {});
}else{
bool state = false;
Future<bool> executeAsyncActions() async {
bool state = false;
try {
if (followState) {
http.Response token = await APIService()
.unfollowGame(widget.token, widget.id);
if (token.statusCode == 200) {
state = false;
widget.onRefresh();
print("Unfollowed");
} else {
print("Error: ${token.statusCode}");
}
} else {
print("Error: ${token.statusCode}");
http.Response token = await APIService().followGame(
widget.token, widget.id);
if (token.statusCode == 200) {
state = true;
widget.onRefresh();
print("Followed");
} else {
print("Error: ${token.statusCode}");
}
}
} else {
http.Response token = await APIService()
.followGame(widget.token, widget.id);
if (token.statusCode == 200) {
state = true;
print("Followed");
} else {
print("Error: ${token.statusCode}");
}
}
} catch (error) {
print("Error: $error");
}
Expand Down Expand Up @@ -684,6 +682,7 @@ class _GamePageState extends State<GamePage> {
context,
MaterialPageRoute(
builder: (context) => GamePage(
onRefresh: widget.onRefresh,
token: widget.token,
userProvider: widget.userProvider,
id: widget.id)),
Expand All @@ -697,6 +696,7 @@ class _GamePageState extends State<GamePage> {
context,
MaterialPageRoute(
builder: (context) => GamePage(
onRefresh: widget.onRefresh,
token: widget.token,
userProvider: widget.userProvider,
id: widget.id)),
Expand Down
8 changes: 8 additions & 0 deletions ludos/mobile/lib/helper/APIService.dart
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,14 @@ class APIService {
});
return response;
}
Future<http.Response> userById(String? authToken, String userID) async {
var uri = Uri.parse("$baseURL/user/byId/$userID");
final response = await http.get(uri, headers: {
'content-type': "application/json",
'Authorization': 'Bearer $authToken'
});
return response;
}

Future<Map<String, dynamic>> getGame(String id, String? authToken) async {
var uri = Uri.parse("$baseURL/game/$id");
Expand Down
61 changes: 58 additions & 3 deletions ludos/mobile/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:ludos_mobile_app/change_password.dart';
import 'package:ludos_mobile_app/user_profile_page.dart';
import 'package:ludos_mobile_app/reusable_widgets/forum_thread.dart';
import 'package:ludos_mobile_app/reusable_widgets/home_game_sum.dart';
import 'helper/APIService.dart';
Expand Down Expand Up @@ -113,9 +114,63 @@ class _HomeState extends State<Home> {
const TextStyle(color: MyColors.darkBlue), // Text color
),
accountEmail: null,
currentAccountPicture: const CircleAvatar(
backgroundColor: MyColors.white,
child: Icon(Icons.person),
currentAccountPicture: ElevatedButton(
style: ElevatedButton.styleFrom(
elevation: 15.0,
backgroundColor: MyColors.white,
shape: const CircleBorder(),
padding: const EdgeInsets.all(0.0),
),
child: const CircleAvatar(
backgroundColor: MyColors.white,
child: Icon(Icons.person),
),
onPressed: () {
if(userProvider.isLoggedIn){
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => UserProfilePage(userProvider: userProvider, id: userProvider.username),
));
}
else{
Navigator.pop(context);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: const Row(
children: [
Icon(Icons.error, color: MyColors.blue),
SizedBox(width: 8),
Expanded(
child: Text(
'Please log in to view profile page',
style: TextStyle(
color: MyColors.blue,
fontSize: 16,
),
),
),
],
),
backgroundColor: MyColors.blue2,
duration: const Duration(seconds: 5),
action: SnackBarAction(
label: 'Log In',
textColor: MyColors.blue,
onPressed: () {
ScaffoldMessenger.of(context)
.hideCurrentSnackBar();
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => LoginPage()),
);
},
),
),
)
.closed
.then((reason) => {});
}
},
),
decoration: const BoxDecoration(
color: MyColors.blue, // Header background color
Expand Down
4 changes: 3 additions & 1 deletion ludos/mobile/lib/reusable_widgets/forum_thread.dart
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,9 @@ class _ThreadSummaryState extends State<ThreadSummary> {
builder: (context) => GamePage(
id: gameId,
token: widget.token,
userProvider: widget.userProvider),
userProvider: widget.userProvider,
onRefresh: () {},
),
),
);
},
Expand Down
7 changes: 6 additions & 1 deletion ludos/mobile/lib/reusable_widgets/game_summary.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,12 @@ class _GameSummaryState extends State<GameSummary> {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => GamePage(id: id, token: token, userProvider: userProvider),
builder: (context) => GamePage(
id: id,
token: token,
userProvider: userProvider,
onRefresh: () {},
),
),
);

Expand Down
2 changes: 1 addition & 1 deletion ludos/mobile/lib/reusable_widgets/home_game_sum.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class _HomeGameSumState extends State<HomeGameSum> {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => GamePage(id: id, token: token, userProvider: userProvider),
builder: (context) => GamePage(id: id, token: token, userProvider: userProvider, onRefresh: () {}),
),
);
// Handle button press for the specific game
Expand Down
4 changes: 3 additions & 1 deletion ludos/mobile/lib/thread_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ class _ThreadPageState extends State<ThreadPage>
builder: (context) => GamePage(
id: threadData['game']['id'],
token: widget.token,
userProvider: widget.userProvider),
userProvider: widget.userProvider,
onRefresh: (){},
),
),
);
},
Expand Down

0 comments on commit b94a2fb

Please sign in to comment.