Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#469 mobile-user-profile-page #578

Merged
merged 3 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
5 changes: 4 additions & 1 deletion ludos/mobile/lib/game_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ import 'helper/APIService.dart';
import 'login_page.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 @@ -256,6 +257,7 @@ class _GamePageState extends State<GamePage> {
.unfollowGame(widget.token, widget.id);
if (token.statusCode == 200) {
state = false;
widget.onRefresh();
print("Unfollowed");
} else {
print("Error: ${token.statusCode}");
Expand All @@ -265,6 +267,7 @@ class _GamePageState extends State<GamePage> {
widget.token, widget.id);
if (token.statusCode == 200) {
state = true;
widget.onRefresh();
print("Followed");
} else {
print("Error: ${token.statusCode}");
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
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:ludos_mobile_app/change_password.dart';
import 'package:ludos_mobile_app/user_profile_page.dart';
import 'login_page.dart';
import 'games_page.dart';
import 'userProvider.dart';
Expand Down Expand Up @@ -30,9 +31,63 @@ class Home extends StatelessWidget {
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
4 changes: 3 additions & 1 deletion ludos/mobile/lib/thread_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,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