Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion mobile_app/lib/core/di/dependency_injection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import '../../features/profile/ui/cubit/profile_cubit.dart';
import '../../features/quiz/data/repositories/quiz_repository.dart';
import '../../features/quiz/data/services/quiz_api_service.dart';
import '../../features/quiz/ui/cubit/quiz_cubit.dart';
import '../../features/ranking/data/repositories/ranking_repository.dart';
import '../../features/ranking/data/services/ranking_api_service.dart';
import '../../features/ranking/ui/cubit/ranking_cubit.dart';
import '../../features/home/ui/cubit/home_cubit.dart';
import '../../features/battle/ui/cubit/battle_cubit.dart';
Expand Down Expand Up @@ -49,7 +51,9 @@ Future<void> setupGetIt() async {
getIt.registerFactory<CategoriesRepository>(() => CategoriesRepository(getIt()));
getIt.registerFactory<CategoriesCubit>(() => CategoriesCubit(getIt()));

getIt.registerFactory<RankingCubit>(() => RankingCubit());
getIt.registerFactory<RankingApiService>(() => RankingApiService(dio));
getIt.registerFactory<RankingRepository>(() => RankingRepository(getIt()));
getIt.registerFactory<RankingCubit>(() => RankingCubit(getIt()));

getIt.registerFactory<ProfileCubit>(() => ProfileCubit());

Expand Down
2 changes: 2 additions & 0 deletions mobile_app/lib/core/networking/api_constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class ApiConstants {
static const String gameSessionStart = "game/session/start";
static const String gameSessionAnswer = "game/session/answer";
static const String gameSessionComplete = "game/session/complete";

static const String leaderboard = "progression/leaderboard";
}

enum ApiErrorType {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import 'package:flutter/material.dart';

import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import '../../../core/helpers/spacing.dart';
import '../../../core/theming/theming.dart';
import 'cubit/onboarding_cubit.dart';
import 'widgets/widgets.dart';

class OnboardingScreen extends StatelessWidget {
Expand Down Expand Up @@ -47,7 +49,17 @@ class OnboardingScreen extends StatelessWidget {
),
bottomNavigationBar: Padding(
padding: EdgeInsets.symmetric(horizontal: 24.w, vertical: 24.h),
child: ChooseYourCountryBottomButton(),
child: ElevatedButton(
onPressed: () => context.read<OnboardingCubit>().navigateToSignUpPage(),
style: ElevatedButton.styleFrom(
minimumSize: Size(double.infinity, 48.h),
backgroundColor: ColorsManager.primaryBlack,
foregroundColor: Colors.white,
padding: EdgeInsets.symmetric(horizontal: 24.w, vertical: 12.h),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16.r)),
),
child: Text('Get Started →', style: InterFontStyle.font16W600White),
),
),
);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export 'choose_your_country_bottom_button.dart';
export 'country_quiz.dart';
export 'do_you_really_now_text.dart';
export 'onboarding_bloc_listener.dart';
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import '../../domain/models/leaderboard_player_model.dart';

class LeaderboardPlayerDto {
final String userId;
final String username;
final String color;
final int level;
final int xp;

const LeaderboardPlayerDto({
required this.userId,
required this.username,
required this.color,
required this.level,
required this.xp,
});

factory LeaderboardPlayerDto.fromJson(Map<String, dynamic> json) => LeaderboardPlayerDto(
userId: json['userId'] as String,
username: json['username'] as String,
color: (json['color'] as String?) ?? '',
level: (json['level'] as int?) ?? 1,
xp: (json['xp'] as int?) ?? 0,
);

LeaderboardPlayerModel toDomain() =>
LeaderboardPlayerModel(userId: userId, username: username, color: color, level: level, xp: xp);
}

class LeaderboardResponseDto {
final List<LeaderboardPlayerDto> topByXP;

const LeaderboardResponseDto({required this.topByXP});

factory LeaderboardResponseDto.fromJson(Map<String, dynamic> json) {
final list = json['topByXP'] as List? ?? [];
return LeaderboardResponseDto(
topByXP: list.map((e) => LeaderboardPlayerDto.fromJson(e as Map<String, dynamic>)).toList(),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import '../../../../core/networking/api_error_handler.dart';
import '../../../../core/networking/api_result.dart';
import '../../domain/models/leaderboard_player_model.dart';
import '../services/ranking_api_service.dart';

class RankingRepository {
final RankingApiService _api;

const RankingRepository(this._api);

Future<ApiResult<List<LeaderboardPlayerModel>>> getLeaderboard() async {
try {
final dto = await _api.getLeaderboard();
return ApiSuccess(dto.topByXP.map((e) => e.toDomain()).toList());
} catch (e) {
return ApiFailure(ApiErrorHandler.handle(e));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import 'package:dio/dio.dart';

import '../../../../core/networking/api_constants.dart';
import '../dtos/leaderboard_response_dto.dart';

class RankingApiService {
final Dio _dio;

const RankingApiService(this._dio);

Future<LeaderboardResponseDto> getLeaderboard() async {
final response = await _dio.get(ApiConstants.leaderboard);
return LeaderboardResponseDto.fromJson(response.data as Map<String, dynamic>);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class LeaderboardPlayerModel {
final String userId;
final String username;
final String color;
final int level;
final int xp;

const LeaderboardPlayerModel({
required this.userId,
required this.username,
required this.color,
required this.level,
required this.xp,
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,18 @@ class RankingEntryModel {
final int rank;
final String username;
final String initial;
final String country;
final String countryCode;
final int level;
final String ptsFormatted;
final String scoreFormatted;
final String deltaFormatted;
final Color deltaColor;
final bool isVerified;
final Color avatarBg;

const RankingEntryModel({
required this.rank,
required this.username,
required this.initial,
required this.country,
required this.countryCode,
required this.level,
required this.ptsFormatted,
required this.scoreFormatted,
required this.deltaFormatted,
required this.deltaColor,
this.isVerified = false,
required this.avatarBg,
});
}
Loading
Loading