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

Implement Quran Repository Package #279

Merged
merged 2 commits into from
Dec 18, 2024
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
2 changes: 1 addition & 1 deletion app/lib/modules/modules.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export 'hatim/hatim.dart';
export 'login/login.dart';
export 'main/main.dart';
export 'quran/quran.dart';
export 'read/read.dart';
export 'read_theme/read.dart';
export 'settings/settings.dart';
export 'quran_audio/quran_audio.dart';
export 'dev_mode/dev_mode.dart';
18 changes: 18 additions & 0 deletions app/lib/modules/quran/cubit/quran_cubit.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:mq_quran_repository/mq_quran_repository.dart';

class QuranCubit extends Cubit<int> {
QuranCubit({required this.mqQuranRepository}) : super(0);

final MqQuranRepository mqQuranRepository;

void change(int? val) => emit(val ?? 0);

List<JuzEntity> getJuz() {
return mqQuranRepository.getJuzs();
}

List<SurahEntity> getSurah() {
return mqQuranRepository.getSurahs();
}
}
16 changes: 16 additions & 0 deletions app/lib/modules/quran/cubit/quran_read_cubit.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'package:equatable/equatable.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:meta/meta.dart';
import 'package:mq_quran_repository/mq_quran_repository.dart';

part 'quran_read_state.dart';

class ReadCubit extends Cubit<ReadState> {
ReadCubit(this.mqQuranRepository) : super(const ReadState());

final MqQuranRepository mqQuranRepository;

Future<QuranPageEntity?> fetchQuranPage(int page) async {
return mqQuranRepository.getPage(page, state.fmt.name);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of 'read_cubit.dart';
part of 'quran_read_cubit.dart';

@immutable
final class ReadState extends Equatable {
Expand Down
8 changes: 0 additions & 8 deletions app/lib/modules/quran/data/data.dart

This file was deleted.

56 changes: 0 additions & 56 deletions app/lib/modules/quran/data/repository/quran_repository_impl.dart

This file was deleted.

10 changes: 0 additions & 10 deletions app/lib/modules/quran/data/source/juz_local_data_source.dart

This file was deleted.

10 changes: 0 additions & 10 deletions app/lib/modules/quran/data/source/surah_local_data_source.dart

This file was deleted.

6 changes: 0 additions & 6 deletions app/lib/modules/quran/domain/domain.dart

This file was deleted.

6 changes: 0 additions & 6 deletions app/lib/modules/quran/domain/repository/quran_repository.dart

This file was deleted.

13 changes: 0 additions & 13 deletions app/lib/modules/quran/domain/usecase/get_juzs.dart

This file was deleted.

13 changes: 0 additions & 13 deletions app/lib/modules/quran/domain/usecase/get_surahs.dart

This file was deleted.

22 changes: 0 additions & 22 deletions app/lib/modules/quran/presentation/cubit/quran_cubit.dart

This file was deleted.

3 changes: 0 additions & 3 deletions app/lib/modules/quran/presentation/presentation.dart

This file was deleted.

9 changes: 6 additions & 3 deletions app/lib/modules/quran/quran.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
export 'presentation/presentation.dart';
export 'domain/domain.dart';
export 'data/data.dart';
export 'cubit/quran_cubit.dart';
export 'cubit/quran_read_cubit.dart';
export 'view/page_view_item.dart';
export 'view/quran_view.dart';
export 'view/quran_read_view.dart';
export 'view/pagination_view.dart';
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:mq_analytics/mq_analytics.dart';
import 'package:mq_ci_keys/mq_ci_keys.dart';
import 'package:mq_quran_repository/mq_quran_repository.dart';

import 'package:my_quran/config/config.dart';
import 'package:my_quran/l10n/l10.dart';
import 'package:my_quran/modules/modules.dart';

class PageViewItem<T> extends StatelessWidget {
const PageViewItem(this.items, {super.key});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
import 'package:mq_analytics/mq_analytics.dart';
import 'package:mq_ci_keys/mq_ci_keys.dart';
import 'package:mq_crashlytics/mq_crashlytics.dart';
import 'package:mq_quran_repository/mq_quran_repository.dart';
import 'package:my_quran/constants/contants.dart';
import 'package:my_quran/modules/modules.dart';
import 'package:my_quran/utils/urils.dart';
import 'package:my_quran/app/app.dart';
import 'package:my_quran/l10n/l10.dart';
import 'package:my_quran/modules/modules.dart';

class PaginationView extends StatefulWidget {
const PaginationView(this.pages, {required this.isHatim, super.key});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
import 'package:mq_analytics/mq_analytics.dart';
import 'package:mq_ci_keys/mq_ci_keys.dart';
import 'package:mq_quran_repository/mq_quran_repository.dart';
import 'package:mq_remote_client/mq_remote_client.dart';
import 'package:mq_storage/mq_storage.dart';
import 'package:my_quran/config/config.dart';
Expand Down Expand Up @@ -30,13 +31,13 @@ class ReadView extends StatelessWidget {
providers: [
BlocProvider(
create: (context) => ReadCubit(
GetReadPageUseCase(
ReadRepositoryImpl(
context.read<AppConfig>().isMockData
? ReadRemoteDataSourceMock()
: ReadRemoteDataSourceImpl(context.read<MqRemoteClient>()),
ReadLocalDataSourceImpl(context.read<PreferencesStorage>()),
),
MqQuranRepositoryImpl(
context.read<AppConfig>().isMockData
? const MqQuranLocalDataSourceMock()
: MqQuranLocalDataSourceImpl(context.read<PreferencesStorage>()),
context.read<AppConfig>().isMockData
? MqQuranRemoteDataSourceMock()
: MqQuranRemoteDataSourceImpl(context.read<MqRemoteClient>()),
),
),
),
Expand All @@ -47,11 +48,10 @@ class ReadView extends StatelessWidget {
),
BlocProvider(
create: (context) => ReadThemeCubit(
getInitialThemeUseCase: GetInitialThemeUseCase(
context.read<ReadThemeRepository>(),
),
saveThemeChangesUseCase: SaveThemeChangesUseCase(
context.read<ReadThemeRepository>(),
readThemeRepository: ReadThemeRepositoryImpl(
LocalThemeDataSourceImpl(
context.read<PreferencesStorage>(),
),
),
),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:mq_ci_keys/mq_ci_keys.dart';
import 'package:mq_quran_repository/mq_quran_repository.dart';
import 'package:mq_remote_client/mq_remote_client.dart';
import 'package:mq_storage/mq_storage.dart';

import 'package:my_quran/components/components.dart';
import 'package:my_quran/l10n/l10.dart';
Expand All @@ -16,20 +19,15 @@ class QuranView extends StatelessWidget {
length: 2,
child: MultiBlocProvider(
providers: [
RepositoryProvider<QuranRepository>(
create: (context) => QuranRepositoryImpl(
JuzLocalDataSource(),
SurahLocalDataSource(),
RepositoryProvider<MqQuranRepository>(
create: (context) => MqQuranRepositoryImpl(
MqQuranLocalDataSourceImpl(context.read<PreferencesStorage>()),
MqQuranRemoteDataSourceImpl(context.read<MqRemoteClient>()),
),
),
BlocProvider(
create: (context) => QuranCubit(
getJuzUseCase: GetJuzUseCase(
context.read<QuranRepository>(),
),
getSurahsUseCase: GetSurahsUseCase(
context.read<QuranRepository>(),
),
mqQuranRepository: context.read<MqQuranRepository>(),
),
),
],
Expand Down
2 changes: 1 addition & 1 deletion app/lib/modules/quran_audio/logic/quran_audio_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:just_audio/just_audio.dart';
import 'package:just_audio_background/just_audio_background.dart';
import 'package:mq_crashlytics/mq_crashlytics.dart';
import 'package:mq_quran_repository/mq_quran_repository.dart';
import 'package:mq_remote_client/mq_remote_client.dart';

import 'package:my_quran/config/config.dart';
import 'package:my_quran/modules/modules.dart';

part 'quran_audio_state.dart';

Expand Down
15 changes: 0 additions & 15 deletions app/lib/modules/read/data/data.dart

This file was deleted.

42 changes: 0 additions & 42 deletions app/lib/modules/read/data/repository/read_repository_impl.dart

This file was deleted.

Loading
Loading