Skip to content

Commit

Permalink
Merge pull request #16 from michaelfromyeg/friend
Browse files Browse the repository at this point in the history
Search users, add friend, view profile functionality
  • Loading branch information
oltimaloku authored May 10, 2024
2 parents 612e54e + 64585b2 commit 7fd0995
Show file tree
Hide file tree
Showing 35 changed files with 1,782 additions and 388 deletions.
2 changes: 1 addition & 1 deletion client/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = YES;
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
331C8080294A63A400263BE5 = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
18 changes: 18 additions & 0 deletions client/lib/common/profile_photo.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'package:flutter/material.dart';

class ProfilePhoto extends StatelessWidget {
final double radius;
const ProfilePhoto({super.key, required this.radius});

@override
Widget build(BuildContext context) {
return CircleAvatar(
radius: radius,
backgroundColor: Colors.white,
child: const Icon(
Icons.person,
color: Colors.black,
),
);
}
}
15 changes: 11 additions & 4 deletions client/lib/features/auth/services/auth_service.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import 'dart:convert';
import 'dart:developer';

import 'package:georeal/constants/env_variables.dart';
import 'package:georeal/models/user.dart';
import 'package:http/http.dart' as http;

class AuthService {
static Future<dynamic> login(String email, String password) async {
static Future<User?> login(String email, String password) async {
try {
var uri = Uri.parse('${EnvVariables.uri}/login');
var response = await http.post(
Expand All @@ -19,7 +21,9 @@ class AuthService {
);

if (response.statusCode == 200) {
return json.decode(response.body); // Return the user object (or token
final userJson = json.decode(response.body);
log('User fetched: $userJson');
return User.fromMap(userJson); // Return the user object (or token
} else {
throw Exception(
'Failed to login. Please check your credentials and try again.');
Expand All @@ -29,9 +33,10 @@ class AuthService {
}
}

static Future<void> register(
static Future<User?> register(
String name, String email, String password) async {
try {
log('Registering user...', name: 'AuthService');
var uri = Uri.parse('${EnvVariables.uri}/register');
var response = await http.post(
uri,
Expand All @@ -46,7 +51,9 @@ class AuthService {
);

if (response.statusCode == 200) {
return json.decode(response.body); // Return the user object (or token
final userJson = json.decode(response.body);
log('User fetched: $userJson');
return User.fromMap(userJson);
} else {
throw Exception('Failed to register. Please try again');
}
Expand Down
Loading

0 comments on commit 7fd0995

Please sign in to comment.