diff --git a/app/lib/constants/api/api_const.dart b/app/lib/constants/api/api_const.dart index 610377e3..f6244e9e 100644 --- a/app/lib/constants/api/api_const.dart +++ b/app/lib/constants/api/api_const.dart @@ -9,15 +9,12 @@ class ApiConst { static const domain = 'https://myquran.life'; - String get socketBase => 'wss://myquran.life/ws'; String get loginEmailSend => '$_getDomain/api/v1/accounts/otp/send/'; String get loginEmailVerify => '$_getDomain/api/v1/accounts/otp/verify/'; String get loginWithGoogle => '$_getDomain/api/v1/accounts/google/'; String get loginWithApple => '$_getDomain/api/v1/accounts/apple/'; String get deleteProfile => '$_getDomain/api/v1/accounts/profile/delete_my_account/'; String putProfile(String userId) => '$_getDomain/api/v1/accounts/profile/$userId/'; - String get joinToHatim => '$_getDomain/api/v1/hatim/join_to_hatim'; - String getSocket(String token) => '$socketBase/?token=$token'; String get _getDomain { if (isDevmode && devDomain != null && devDomain!.isNotEmpty) return devDomain!; diff --git a/app/lib/modules/hatim/presentation/bloc/hatim_bloc.dart b/app/lib/modules/hatim/bloc/hatim_bloc.dart similarity index 94% rename from app/lib/modules/hatim/presentation/bloc/hatim_bloc.dart rename to app/lib/modules/hatim/bloc/hatim_bloc.dart index 3ae4ef85..9e7246e8 100644 --- a/app/lib/modules/hatim/presentation/bloc/hatim_bloc.dart +++ b/app/lib/modules/hatim/bloc/hatim_bloc.dart @@ -5,7 +5,7 @@ import 'package:equatable/equatable.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:meta/meta.dart'; import 'package:mq_crashlytics/mq_crashlytics.dart'; -import 'package:my_quran/modules/hatim/hatim.dart'; +import 'package:mq_hatim_repository/mq_hatim_repository.dart'; part 'hatim_event.dart'; part 'hatim_state.dart'; @@ -29,7 +29,7 @@ class HatimBloc extends Bloc { on(_onReceidevBaseDataEvent); } - final HatimRepository repo; + final MqHatimRepository repo; final String token; bool islistened = false; @@ -114,11 +114,11 @@ class HatimBloc extends Bloc { ) { final src = event.data; final newState = switch (src.$1) { - HatimResponseType.listOfJuz => state.copyWith(juzsState: HatimJuzsFetched(src.$2 as List)), + HatimResponseType.listOfJuz => state.copyWith(juzsState: HatimJuzsFetched(src.$2 as List)), HatimResponseType.listOfPage => - state.copyWith(juzPagesState: HatimJuzPagesFetched(src.$2 as List)), + state.copyWith(juzPagesState: HatimJuzPagesFetched(src.$2 as List)), HatimResponseType.userPages => - state.copyWith(userPagesState: HatimUserPagesFetched(src.$2 as List)), + state.copyWith(userPagesState: HatimUserPagesFetched(src.$2 as List)), }; emit(newState); diff --git a/app/lib/modules/hatim/presentation/bloc/hatim_event.dart b/app/lib/modules/hatim/bloc/hatim_event.dart similarity index 94% rename from app/lib/modules/hatim/presentation/bloc/hatim_event.dart rename to app/lib/modules/hatim/bloc/hatim_event.dart index 981947d6..ab434899 100644 --- a/app/lib/modules/hatim/presentation/bloc/hatim_event.dart +++ b/app/lib/modules/hatim/bloc/hatim_event.dart @@ -49,7 +49,7 @@ final class SetDonePagesEvent extends HatimEvent { final class ReceidevBaseDataEvent extends HatimEvent { const ReceidevBaseDataEvent(this.data); - final (HatimResponseType, List) data; + final (HatimResponseType, List) data; } @immutable diff --git a/app/lib/modules/hatim/presentation/bloc/hatim_state.dart b/app/lib/modules/hatim/bloc/hatim_state.dart similarity index 100% rename from app/lib/modules/hatim/presentation/bloc/hatim_state.dart rename to app/lib/modules/hatim/bloc/hatim_state.dart diff --git a/app/lib/modules/hatim/presentation/bloc/hatim_state_dashboard.dart b/app/lib/modules/hatim/bloc/hatim_state_dashboard.dart similarity index 94% rename from app/lib/modules/hatim/presentation/bloc/hatim_state_dashboard.dart rename to app/lib/modules/hatim/bloc/hatim_state_dashboard.dart index ac633a80..b77d669f 100644 --- a/app/lib/modules/hatim/presentation/bloc/hatim_state_dashboard.dart +++ b/app/lib/modules/hatim/bloc/hatim_state_dashboard.dart @@ -19,7 +19,7 @@ final class HatimDashBoardLoading extends HatimDashBoardState { final class HatimDashBoardFetched extends HatimDashBoardState { const HatimDashBoardFetched(this.data); - final HatimReadEntity data; + final MqHatimReadEntity data; } @immutable diff --git a/app/lib/modules/hatim/presentation/bloc/hatim_state_juz_pages.dart b/app/lib/modules/hatim/bloc/hatim_state_juz_pages.dart similarity index 93% rename from app/lib/modules/hatim/presentation/bloc/hatim_state_juz_pages.dart rename to app/lib/modules/hatim/bloc/hatim_state_juz_pages.dart index b361c889..9a79c612 100644 --- a/app/lib/modules/hatim/presentation/bloc/hatim_state_juz_pages.dart +++ b/app/lib/modules/hatim/bloc/hatim_state_juz_pages.dart @@ -19,7 +19,7 @@ final class HatimJuzPagesLoading extends HatimJuzPagesState { final class HatimJuzPagesFetched extends HatimJuzPagesState { const HatimJuzPagesFetched(this.data); - final List data; + final List data; } @immutable diff --git a/app/lib/modules/hatim/presentation/bloc/hatim_state_juzs.dart b/app/lib/modules/hatim/bloc/hatim_state_juzs.dart similarity index 93% rename from app/lib/modules/hatim/presentation/bloc/hatim_state_juzs.dart rename to app/lib/modules/hatim/bloc/hatim_state_juzs.dart index 49e09ed9..0ecd0025 100644 --- a/app/lib/modules/hatim/presentation/bloc/hatim_state_juzs.dart +++ b/app/lib/modules/hatim/bloc/hatim_state_juzs.dart @@ -19,7 +19,7 @@ final class HatimJuzsLoading extends HatimJuzsState { final class HatimJuzsFetched extends HatimJuzsState { const HatimJuzsFetched(this.data); - final List data; + final List data; } @immutable diff --git a/app/lib/modules/hatim/presentation/bloc/hatim_state_user_pages.dart b/app/lib/modules/hatim/bloc/hatim_state_user_pages.dart similarity index 93% rename from app/lib/modules/hatim/presentation/bloc/hatim_state_user_pages.dart rename to app/lib/modules/hatim/bloc/hatim_state_user_pages.dart index 7a8f28bb..50770a18 100644 --- a/app/lib/modules/hatim/presentation/bloc/hatim_state_user_pages.dart +++ b/app/lib/modules/hatim/bloc/hatim_state_user_pages.dart @@ -19,7 +19,7 @@ final class HatimUserPagesLoading extends HatimUserPagesState { final class HatimUserPagesFetched extends HatimUserPagesState { const HatimUserPagesFetched(this.data); - final List data; + final List data; } @immutable diff --git a/app/lib/modules/hatim/data/data.dart b/app/lib/modules/hatim/data/data.dart deleted file mode 100644 index 57e0cfa3..00000000 --- a/app/lib/modules/hatim/data/data.dart +++ /dev/null @@ -1,8 +0,0 @@ -export 'model/hatim_read_model.dart'; -export 'model/hatim_juz.dart'; -export 'model/hatim_page.dart'; -export 'model/hatim_base_response.dart'; -export 'source/remote/hatim_remote_data_source_impl.dart'; -export 'source/hatim_remote_data_source.dart'; -export 'source/mock/hatim_remote_data_source_mock.dart'; -export 'repository/hatim_read_repository_impl.dart'; diff --git a/app/lib/modules/hatim/domain/domain.dart b/app/lib/modules/hatim/domain/domain.dart deleted file mode 100644 index 3dab10b8..00000000 --- a/app/lib/modules/hatim/domain/domain.dart +++ /dev/null @@ -1,5 +0,0 @@ -export 'entity/hatim_read_entity.dart'; -export 'entity/hatim_juz_entity.dart'; -export 'entity/hatim_page_entity.dart'; -export 'entity/hatim_base_entity.dart'; -export 'repository/hatim_read_repository.dart'; diff --git a/app/lib/modules/hatim/domain/entity/hatim_base_entity.dart b/app/lib/modules/hatim/domain/entity/hatim_base_entity.dart deleted file mode 100644 index 04dba202..00000000 --- a/app/lib/modules/hatim/domain/entity/hatim_base_entity.dart +++ /dev/null @@ -1 +0,0 @@ -interface class HatimBaseEntity {} diff --git a/app/lib/modules/hatim/domain/entity/hatim_read_entity.dart b/app/lib/modules/hatim/domain/entity/hatim_read_entity.dart deleted file mode 100644 index fc047161..00000000 --- a/app/lib/modules/hatim/domain/entity/hatim_read_entity.dart +++ /dev/null @@ -1,15 +0,0 @@ -import 'package:meta/meta.dart'; -import 'package:my_quran/modules/modules.dart'; - -@immutable -final class HatimReadEntity implements HatimBaseEntity { - const HatimReadEntity({ - required this.id, - required this.status, - required this.type, - }); - - final String id; - final String status; - final String type; -} diff --git a/app/lib/modules/hatim/hatim.dart b/app/lib/modules/hatim/hatim.dart index 0192af9d..9590f9d8 100644 --- a/app/lib/modules/hatim/hatim.dart +++ b/app/lib/modules/hatim/hatim.dart @@ -1,3 +1,8 @@ -export 'presentation/presentation.dart'; -export 'domain/domain.dart'; -export 'data/data.dart'; +export 'bloc/hatim_bloc.dart'; +export 'view/hatim_view.dart'; +export 'view/hatim_select_page_view.dart'; +export 'widgets/hatim_juz_list_builder.dart'; +export 'widgets/hatim_page_status_card.dart'; +export 'widgets/hatim_status_widget.dart'; +export 'widgets/juz_annotation_widget.dart'; +export 'widgets/progress_row_widget.dart'; diff --git a/app/lib/modules/hatim/presentation/presentation.dart b/app/lib/modules/hatim/presentation/presentation.dart deleted file mode 100644 index 22914dde..00000000 --- a/app/lib/modules/hatim/presentation/presentation.dart +++ /dev/null @@ -1,8 +0,0 @@ -export 'widgets/hatim_page_status_card.dart'; -export 'widgets/hatim_juz_list_builder.dart'; -export 'widgets/juz_annotation_widget.dart'; -export 'widgets/progress_row_widget.dart'; -export 'widgets/hatim_status_widget.dart'; -export 'view/hatim_select_page_view.dart'; -export 'view/hatim_view.dart'; -export 'bloc/hatim_bloc.dart'; diff --git a/app/lib/modules/hatim/presentation/view/hatim_select_page_view.dart b/app/lib/modules/hatim/view/hatim_select_page_view.dart similarity index 98% rename from app/lib/modules/hatim/presentation/view/hatim_select_page_view.dart rename to app/lib/modules/hatim/view/hatim_select_page_view.dart index 1bbb53a5..2ee19bef 100644 --- a/app/lib/modules/hatim/presentation/view/hatim_select_page_view.dart +++ b/app/lib/modules/hatim/view/hatim_select_page_view.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:mq_analytics/mq_analytics.dart'; import 'package:mq_ci_keys/mq_ci_keys.dart'; +import 'package:mq_hatim_repository/mq_hatim_repository.dart'; import 'package:my_quran/constants/contants.dart'; import 'package:my_quran/l10n/l10.dart'; @@ -14,7 +15,7 @@ class HatimJusSelectPagesView extends StatelessWidget { super.key, }); - final HatimJusEntity hatimJusEntity; + final MqHatimJusEntity hatimJusEntity; @override Widget build(BuildContext context) { @@ -268,7 +269,7 @@ class HatimJusSelectPagesView extends StatelessWidget { class HatimPageGridListBuilder extends StatelessWidget { const HatimPageGridListBuilder(this.items, {super.key}); - final List items; + final List items; @override Widget build(BuildContext context) { diff --git a/app/lib/modules/hatim/presentation/view/hatim_view.dart b/app/lib/modules/hatim/view/hatim_view.dart similarity index 95% rename from app/lib/modules/hatim/presentation/view/hatim_view.dart rename to app/lib/modules/hatim/view/hatim_view.dart index 8770499d..2329209c 100644 --- a/app/lib/modules/hatim/presentation/view/hatim_view.dart +++ b/app/lib/modules/hatim/view/hatim_view.dart @@ -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_hatim_repository/mq_hatim_repository.dart'; import 'package:mq_remote_client/mq_remote_client.dart'; import 'package:my_quran/app/app.dart'; @@ -19,10 +20,10 @@ class HatimView extends StatelessWidget { Widget build(BuildContext context) { return BlocProvider( create: (context) => HatimBloc( - repo: HatimReadRepositoryImpl( + repo: MqHatimReadRepositoryImpl( dataSource: context.read().isMockData - ? HatimRemoteDataSourceMock() - : HatimRemoteDataSourceImpl(remoteClient: context.read()), + ? MqHatimRemoteDataSourceMock() + : MqHatimRemoteDataSourceImpl(remoteClient: context.read()), ), token: context.read().state.user!.accessToken, )..add(const GetInitailDataEvent()), diff --git a/app/lib/modules/hatim/presentation/widgets/hatim_juz_list_builder.dart b/app/lib/modules/hatim/widgets/hatim_juz_list_builder.dart similarity index 97% rename from app/lib/modules/hatim/presentation/widgets/hatim_juz_list_builder.dart rename to app/lib/modules/hatim/widgets/hatim_juz_list_builder.dart index 870244c1..40b3fdcc 100644 --- a/app/lib/modules/hatim/presentation/widgets/hatim_juz_list_builder.dart +++ b/app/lib/modules/hatim/widgets/hatim_juz_list_builder.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:mq_analytics/mq_analytics.dart'; import 'package:mq_ci_keys/mq_ci_keys.dart'; +import 'package:mq_hatim_repository/mq_hatim_repository.dart'; import 'package:my_quran/l10n/l10.dart'; import 'package:my_quran/modules/modules.dart'; import 'package:syncfusion_flutter_gauges/gauges.dart'; @@ -9,7 +10,7 @@ import 'package:syncfusion_flutter_gauges/gauges.dart'; class HatimJuzListBuilder extends StatelessWidget { const HatimJuzListBuilder(this.items, {super.key}); - final List items; + final List items; @override Widget build(BuildContext context) { @@ -104,7 +105,7 @@ class HatimJuzListBuilder extends StatelessWidget { ); } - Future _onTap(HatimJusEntity item, BuildContext context) async { + Future _onTap(MqHatimJusEntity item, BuildContext context) async { MqAnalytic.track( AnalyticKey.selectHatimJuz, params: {'juzId': item.id}, @@ -138,7 +139,7 @@ class HatimJuzItemWidget extends StatelessWidget { final double endAngleTodo; final double endAngleInProgress; final double endAngleDone; - final HatimJusEntity item; + final MqHatimJusEntity item; final void Function() onTap; final int index; diff --git a/app/lib/modules/hatim/presentation/widgets/hatim_page_status_card.dart b/app/lib/modules/hatim/widgets/hatim_page_status_card.dart similarity index 94% rename from app/lib/modules/hatim/presentation/widgets/hatim_page_status_card.dart rename to app/lib/modules/hatim/widgets/hatim_page_status_card.dart index 9a603a6a..3a318710 100644 --- a/app/lib/modules/hatim/presentation/widgets/hatim_page_status_card.dart +++ b/app/lib/modules/hatim/widgets/hatim_page_status_card.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; +import 'package:mq_hatim_repository/mq_hatim_repository.dart'; import 'package:my_quran/components/components.dart'; -import 'package:my_quran/modules/modules.dart'; class HatimPageStatusCard extends StatelessWidget { const HatimPageStatusCard({ diff --git a/app/lib/modules/hatim/presentation/widgets/hatim_status_widget.dart b/app/lib/modules/hatim/widgets/hatim_status_widget.dart similarity index 100% rename from app/lib/modules/hatim/presentation/widgets/hatim_status_widget.dart rename to app/lib/modules/hatim/widgets/hatim_status_widget.dart diff --git a/app/lib/modules/hatim/presentation/widgets/juz_annotation_widget.dart b/app/lib/modules/hatim/widgets/juz_annotation_widget.dart similarity index 91% rename from app/lib/modules/hatim/presentation/widgets/juz_annotation_widget.dart rename to app/lib/modules/hatim/widgets/juz_annotation_widget.dart index 792c6560..99542688 100644 --- a/app/lib/modules/hatim/presentation/widgets/juz_annotation_widget.dart +++ b/app/lib/modules/hatim/widgets/juz_annotation_widget.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:mq_hatim_repository/mq_hatim_repository.dart'; import 'package:my_quran/l10n/l10.dart'; import 'package:my_quran/modules/modules.dart'; @@ -8,7 +9,7 @@ class JuzAnnotationWidget extends StatelessWidget { super.key, }); - final HatimJusEntity item; + final MqHatimJusEntity item; @override Widget build(BuildContext context) { diff --git a/app/lib/modules/hatim/presentation/widgets/progress_row_widget.dart b/app/lib/modules/hatim/widgets/progress_row_widget.dart similarity index 100% rename from app/lib/modules/hatim/presentation/widgets/progress_row_widget.dart rename to app/lib/modules/hatim/widgets/progress_row_widget.dart diff --git a/app/pubspec.lock b/app/pubspec.lock index b0e36431..9fe31622 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -944,6 +944,13 @@ packages: relative: true source: path version: "0.1.0+1" + mq_hatim_repository: + dependency: "direct main" + description: + path: "../packages/mq_hatim_repository" + relative: true + source: path + version: "0.1.0+1" mq_home_repository: dependency: "direct main" description: diff --git a/app/pubspec.yaml b/app/pubspec.yaml index 3f83d19b..04efa7ce 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -81,6 +81,8 @@ dependencies: path: ../packages/mq_home_repository mq_quran_repository: path: ../packages/mq_quran_repository + mq_hatim_repository: + path: ../packages/mq_hatim_repository dev_dependencies: flutter_test: diff --git a/app/pubspec_overrides.yaml b/app/pubspec_overrides.yaml index d820b73b..2206050b 100644 --- a/app/pubspec_overrides.yaml +++ b/app/pubspec_overrides.yaml @@ -1,4 +1,4 @@ -# melos_managed_dependency_overrides: mq_analytics,mq_ci_keys,mq_crashlytics,mq_either,mq_home_repository,mq_quran_repository,mq_remote_config,mq_storage +# melos_managed_dependency_overrides: mq_analytics,mq_ci_keys,mq_crashlytics,mq_either,mq_home_repository,mq_quran_repository,mq_remote_config,mq_storage,mq_hatim_repository dependency_overrides: mq_analytics: path: ../packages/mq_analytics @@ -8,6 +8,8 @@ dependency_overrides: path: ../packages/mq_crashlytics mq_either: path: ../packages/mq_either + mq_hatim_repository: + path: ../packages/mq_hatim_repository mq_home_repository: path: ../packages/mq_home_repository mq_quran_repository: diff --git a/packages/mq_hatim_repository/README.md b/packages/mq_hatim_repository/README.md new file mode 100644 index 00000000..c0f83760 --- /dev/null +++ b/packages/mq_hatim_repository/README.md @@ -0,0 +1 @@ +# Mq Hatim Repository diff --git a/packages/mq_hatim_repository/analysis_options.yaml b/packages/mq_hatim_repository/analysis_options.yaml new file mode 100644 index 00000000..7ad0bbf5 --- /dev/null +++ b/packages/mq_hatim_repository/analysis_options.yaml @@ -0,0 +1,15 @@ +include: package:very_good_analysis/analysis_options.6.0.0.yaml + +linter: + rules: + public_member_api_docs: false + lines_longer_than_80_chars: false + sort_pub_dependencies: false + +analyzer: + errors: + one_member_abstracts: ignore + exclude: + - "**/*.g.dart" + - "**/*.freezed.dart" + - "bin/cache/**" \ No newline at end of file diff --git a/packages/mq_hatim_repository/lib/mq_hatim_repository.dart b/packages/mq_hatim_repository/lib/mq_hatim_repository.dart new file mode 100644 index 00000000..8393a2c2 --- /dev/null +++ b/packages/mq_hatim_repository/lib/mq_hatim_repository.dart @@ -0,0 +1,4 @@ +/// Mq hatim repository package +library mq_hatim_repository; + +export 'src/src.dart'; diff --git a/packages/mq_hatim_repository/lib/src/entity/mq_hatim_base_entity.dart b/packages/mq_hatim_repository/lib/src/entity/mq_hatim_base_entity.dart new file mode 100644 index 00000000..d88e4587 --- /dev/null +++ b/packages/mq_hatim_repository/lib/src/entity/mq_hatim_base_entity.dart @@ -0,0 +1 @@ +interface class MqHatimBaseEntity {} diff --git a/app/lib/modules/hatim/domain/entity/hatim_juz_entity.dart b/packages/mq_hatim_repository/lib/src/entity/mq_hatim_juz_entity.dart similarity index 73% rename from app/lib/modules/hatim/domain/entity/hatim_juz_entity.dart rename to packages/mq_hatim_repository/lib/src/entity/mq_hatim_juz_entity.dart index 8f050622..87664dc0 100644 --- a/app/lib/modules/hatim/domain/entity/hatim_juz_entity.dart +++ b/packages/mq_hatim_repository/lib/src/entity/mq_hatim_juz_entity.dart @@ -1,9 +1,9 @@ -import 'package:meta/meta.dart'; -import 'package:my_quran/modules/modules.dart'; +import 'package:flutter/foundation.dart'; +import 'package:mq_hatim_repository/mq_hatim_repository.dart'; @immutable -final class HatimJusEntity implements HatimBaseEntity { - const HatimJusEntity({ +final class MqHatimJusEntity implements MqHatimBaseEntity { + const MqHatimJusEntity({ required this.id, required this.status, required this.number, diff --git a/app/lib/modules/hatim/domain/entity/hatim_page_entity.dart b/packages/mq_hatim_repository/lib/src/entity/mq_hatim_page_entity.dart similarity index 51% rename from app/lib/modules/hatim/domain/entity/hatim_page_entity.dart rename to packages/mq_hatim_repository/lib/src/entity/mq_hatim_page_entity.dart index e4045b59..75f48cc1 100644 --- a/app/lib/modules/hatim/domain/entity/hatim_page_entity.dart +++ b/packages/mq_hatim_repository/lib/src/entity/mq_hatim_page_entity.dart @@ -1,9 +1,9 @@ -import 'package:meta/meta.dart'; -import 'package:my_quran/modules/modules.dart'; +import 'package:flutter/foundation.dart'; +import 'package:mq_hatim_repository/mq_hatim_repository.dart'; @immutable -final class HatimPagesEntity implements HatimBaseEntity { - const HatimPagesEntity({ +final class MqHatimPagesEntity implements MqHatimBaseEntity { + const MqHatimPagesEntity({ required this.id, required this.status, required this.number, diff --git a/packages/mq_hatim_repository/lib/src/entity/mq_hatim_read_entity.dart b/packages/mq_hatim_repository/lib/src/entity/mq_hatim_read_entity.dart new file mode 100644 index 00000000..00d76ab4 --- /dev/null +++ b/packages/mq_hatim_repository/lib/src/entity/mq_hatim_read_entity.dart @@ -0,0 +1,15 @@ +import 'package:flutter/foundation.dart'; +import 'package:mq_hatim_repository/mq_hatim_repository.dart'; + +@immutable +final class MqHatimReadEntity implements MqHatimBaseEntity { + const MqHatimReadEntity({ + required this.id, + required this.status, + required this.type, + }); + + final String id; + final String status; + final String type; +} diff --git a/app/lib/modules/hatim/data/model/hatim_base_response.dart b/packages/mq_hatim_repository/lib/src/model/mq_hatim_base_response.dart similarity index 88% rename from app/lib/modules/hatim/data/model/hatim_base_response.dart rename to packages/mq_hatim_repository/lib/src/model/mq_hatim_base_response.dart index 50277be1..e42e60ec 100644 --- a/app/lib/modules/hatim/data/model/hatim_base_response.dart +++ b/packages/mq_hatim_repository/lib/src/model/mq_hatim_base_response.dart @@ -1,7 +1,7 @@ +import 'package:flutter/material.dart'; import 'package:json_annotation/json_annotation.dart'; -import 'package:meta/meta.dart'; -part 'hatim_base_response.g.dart'; +part 'mq_hatim_base_response.g.dart'; @JsonSerializable() @immutable diff --git a/app/lib/modules/hatim/data/model/hatim_base_response.g.dart b/packages/mq_hatim_repository/lib/src/model/mq_hatim_base_response.g.dart similarity index 95% rename from app/lib/modules/hatim/data/model/hatim_base_response.g.dart rename to packages/mq_hatim_repository/lib/src/model/mq_hatim_base_response.g.dart index 96139dbf..e311bf51 100644 --- a/app/lib/modules/hatim/data/model/hatim_base_response.g.dart +++ b/packages/mq_hatim_repository/lib/src/model/mq_hatim_base_response.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'hatim_base_response.dart'; +part of 'mq_hatim_base_response.dart'; // ************************************************************************** // JsonSerializableGenerator diff --git a/app/lib/modules/hatim/data/model/hatim_juz.dart b/packages/mq_hatim_repository/lib/src/model/mq_hatim_juz.dart similarity index 81% rename from app/lib/modules/hatim/data/model/hatim_juz.dart rename to packages/mq_hatim_repository/lib/src/model/mq_hatim_juz.dart index c2e850f8..1178af08 100644 --- a/app/lib/modules/hatim/data/model/hatim_juz.dart +++ b/packages/mq_hatim_repository/lib/src/model/mq_hatim_juz.dart @@ -1,7 +1,7 @@ import 'package:json_annotation/json_annotation.dart'; -import 'package:my_quran/modules/modules.dart'; +import 'package:mq_hatim_repository/mq_hatim_repository.dart'; -part 'hatim_juz.g.dart'; +part 'mq_hatim_juz.g.dart'; @JsonSerializable() class HatimJus { @@ -24,8 +24,8 @@ class HatimJus { final int inProgress; final int done; - HatimJusEntity get entity { - return HatimJusEntity( + MqHatimJusEntity get entity { + return MqHatimJusEntity( id: id, status: status, number: number, diff --git a/app/lib/modules/hatim/data/model/hatim_juz.g.dart b/packages/mq_hatim_repository/lib/src/model/mq_hatim_juz.g.dart similarity index 96% rename from app/lib/modules/hatim/data/model/hatim_juz.g.dart rename to packages/mq_hatim_repository/lib/src/model/mq_hatim_juz.g.dart index 8ae6b278..01874777 100644 --- a/app/lib/modules/hatim/data/model/hatim_juz.g.dart +++ b/packages/mq_hatim_repository/lib/src/model/mq_hatim_juz.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'hatim_juz.dart'; +part of 'mq_hatim_juz.dart'; // ************************************************************************** // JsonSerializableGenerator diff --git a/app/lib/modules/hatim/data/model/hatim_page.dart b/packages/mq_hatim_repository/lib/src/model/mq_hatim_page.dart similarity index 91% rename from app/lib/modules/hatim/data/model/hatim_page.dart rename to packages/mq_hatim_repository/lib/src/model/mq_hatim_page.dart index 622947a6..ac0f0178 100644 --- a/app/lib/modules/hatim/data/model/hatim_page.dart +++ b/packages/mq_hatim_repository/lib/src/model/mq_hatim_page.dart @@ -1,9 +1,9 @@ import 'dart:ui'; import 'package:json_annotation/json_annotation.dart'; -import 'package:my_quran/modules/modules.dart'; +import 'package:mq_hatim_repository/mq_hatim_repository.dart'; -part 'hatim_page.g.dart'; +part 'mq_hatim_page.g.dart'; @JsonSerializable() class HatimPages { @@ -22,8 +22,8 @@ class HatimPages { final HatimPageStatus status; final bool mine; - HatimPagesEntity get entity { - return HatimPagesEntity( + MqHatimPagesEntity get entity { + return MqHatimPagesEntity( id: id, status: status, number: number, diff --git a/app/lib/modules/hatim/data/model/hatim_page.g.dart b/packages/mq_hatim_repository/lib/src/model/mq_hatim_page.g.dart similarity index 96% rename from app/lib/modules/hatim/data/model/hatim_page.g.dart rename to packages/mq_hatim_repository/lib/src/model/mq_hatim_page.g.dart index 91213a87..dea4014a 100644 --- a/app/lib/modules/hatim/data/model/hatim_page.g.dart +++ b/packages/mq_hatim_repository/lib/src/model/mq_hatim_page.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'hatim_page.dart'; +part of 'mq_hatim_page.dart'; // ************************************************************************** // JsonSerializableGenerator diff --git a/app/lib/modules/hatim/data/model/hatim_read_model.dart b/packages/mq_hatim_repository/lib/src/model/mq_hatim_read_model.dart similarity index 75% rename from app/lib/modules/hatim/data/model/hatim_read_model.dart rename to packages/mq_hatim_repository/lib/src/model/mq_hatim_read_model.dart index 3a65ae11..0082a356 100644 --- a/app/lib/modules/hatim/data/model/hatim_read_model.dart +++ b/packages/mq_hatim_repository/lib/src/model/mq_hatim_read_model.dart @@ -1,7 +1,7 @@ import 'package:json_annotation/json_annotation.dart'; -import 'package:my_quran/modules/hatim/hatim.dart'; +import 'package:mq_hatim_repository/mq_hatim_repository.dart'; -part 'hatim_read_model.g.dart'; +part 'mq_hatim_read_model.g.dart'; @JsonSerializable() class HatimReadModel { @@ -18,8 +18,8 @@ class HatimReadModel { final String status; final String type; - HatimReadEntity get toEntity { - return HatimReadEntity( + MqHatimReadEntity get toEntity { + return MqHatimReadEntity( id: id, status: status, type: type, diff --git a/app/lib/modules/hatim/data/model/hatim_read_model.g.dart b/packages/mq_hatim_repository/lib/src/model/mq_hatim_read_model.g.dart similarity index 94% rename from app/lib/modules/hatim/data/model/hatim_read_model.g.dart rename to packages/mq_hatim_repository/lib/src/model/mq_hatim_read_model.g.dart index 4a956233..2720a7ea 100644 --- a/app/lib/modules/hatim/data/model/hatim_read_model.g.dart +++ b/packages/mq_hatim_repository/lib/src/model/mq_hatim_read_model.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'hatim_read_model.dart'; +part of 'mq_hatim_read_model.dart'; // ************************************************************************** // JsonSerializableGenerator diff --git a/app/lib/modules/hatim/domain/repository/hatim_read_repository.dart b/packages/mq_hatim_repository/lib/src/repository/mq_hatim_read_repository.dart similarity index 63% rename from app/lib/modules/hatim/domain/repository/hatim_read_repository.dart rename to packages/mq_hatim_repository/lib/src/repository/mq_hatim_read_repository.dart index 9d7796e8..896772fb 100644 --- a/app/lib/modules/hatim/domain/repository/hatim_read_repository.dart +++ b/packages/mq_hatim_repository/lib/src/repository/mq_hatim_read_repository.dart @@ -1,7 +1,7 @@ -import 'package:my_quran/modules/modules.dart'; +import 'package:mq_hatim_repository/mq_hatim_repository.dart'; -abstract class HatimRepository { - Future getHatim(); +abstract class MqHatimRepository { + Future getHatim(); void connectToSocket(String token); @@ -19,7 +19,7 @@ abstract class HatimRepository { void sinkDonePages(List pageIds); - Stream<(HatimResponseType, List)> get stream; + Stream<(HatimResponseType, List)> get stream; Future close(); } diff --git a/app/lib/modules/hatim/data/repository/hatim_read_repository_impl.dart b/packages/mq_hatim_repository/lib/src/repository/mq_hatim_read_repository_impl.dart similarity index 77% rename from app/lib/modules/hatim/data/repository/hatim_read_repository_impl.dart rename to packages/mq_hatim_repository/lib/src/repository/mq_hatim_read_repository_impl.dart index 690c2663..395569f4 100644 --- a/app/lib/modules/hatim/data/repository/hatim_read_repository_impl.dart +++ b/packages/mq_hatim_repository/lib/src/repository/mq_hatim_read_repository_impl.dart @@ -2,16 +2,16 @@ import 'dart:async'; import 'dart:convert'; import 'package:flutter/foundation.dart'; -import 'package:my_quran/modules/modules.dart'; +import 'package:mq_hatim_repository/mq_hatim_repository.dart'; @immutable -final class HatimReadRepositoryImpl implements HatimRepository { - const HatimReadRepositoryImpl({required this.dataSource}); +final class MqHatimReadRepositoryImpl implements MqHatimRepository { + const MqHatimReadRepositoryImpl({required this.dataSource}); - final HatimRemoteDataSource dataSource; + final MqHatimRemoteDataSource dataSource; @override - Future getHatim() async { + Future getHatim() async { final res = await dataSource.getHatim(); return res.toEntity; } @@ -22,7 +22,7 @@ final class HatimReadRepositoryImpl implements HatimRepository { } @override - Stream<(HatimResponseType, List)> get stream { + Stream<(HatimResponseType, List)> get stream { return dataSource.stream.map((data) { final src = HatimBaseResponse.fromJson( jsonDecode(data as String) as Map, @@ -36,17 +36,17 @@ final class HatimReadRepositoryImpl implements HatimRepository { }); } - (HatimResponseType, List) _receidevJuzs(List src) { + (HatimResponseType, List) _receidevJuzs(List src) { final data = src.map((e) => HatimJus.fromJson(e as Map)).toList(); return (HatimResponseType.listOfJuz, data.map((e) => e.entity).toList()); } - (HatimResponseType, List) _receidevJuzPage(List src) { + (HatimResponseType, List) _receidevJuzPage(List src) { final data = src.map((e) => HatimPages.fromJson(e as Map)).toList(); return (HatimResponseType.listOfPage, data.map((e) => e.entity).toList()); } - (HatimResponseType, List) _receidevUserPages(List src) { + (HatimResponseType, List) _receidevUserPages(List src) { final data = src.map((e) => HatimPages.fromJson(e as Map)).toList(); return (HatimResponseType.userPages, data.map((e) => e.entity).toList()); } diff --git a/app/lib/modules/hatim/data/source/mock/hatim_remote_data_source_mock.dart b/packages/mq_hatim_repository/lib/src/source/mock/mq_hatim_remote_data_source_mock.dart similarity index 92% rename from app/lib/modules/hatim/data/source/mock/hatim_remote_data_source_mock.dart rename to packages/mq_hatim_repository/lib/src/source/mock/mq_hatim_remote_data_source_mock.dart index afb3f903..5bd00f14 100644 --- a/app/lib/modules/hatim/data/source/mock/hatim_remote_data_source_mock.dart +++ b/packages/mq_hatim_repository/lib/src/source/mock/mq_hatim_remote_data_source_mock.dart @@ -1,9 +1,9 @@ import 'dart:async'; import 'dart:convert'; -import 'package:my_quran/modules/modules.dart'; +import 'package:mq_hatim_repository/mq_hatim_repository.dart'; -class HatimRemoteDataSourceMock implements HatimRemoteDataSource { +class MqHatimRemoteDataSourceMock implements MqHatimRemoteDataSource { final StreamController _controller = StreamController(); @override diff --git a/app/lib/modules/hatim/data/source/hatim_remote_data_source.dart b/packages/mq_hatim_repository/lib/src/source/mq_hatim_remote_data_source.dart similarity index 79% rename from app/lib/modules/hatim/data/source/hatim_remote_data_source.dart rename to packages/mq_hatim_repository/lib/src/source/mq_hatim_remote_data_source.dart index 108ae8f2..d369b007 100644 --- a/app/lib/modules/hatim/data/source/hatim_remote_data_source.dart +++ b/packages/mq_hatim_repository/lib/src/source/mq_hatim_remote_data_source.dart @@ -1,6 +1,6 @@ -import 'package:my_quran/modules/modules.dart'; +import 'package:mq_hatim_repository/mq_hatim_repository.dart'; -abstract class HatimRemoteDataSource { +abstract class MqHatimRemoteDataSource { Future getHatim(); void connectToSocket(String token); void sinkHatimJuzs(String hatimId); diff --git a/app/lib/modules/hatim/data/source/remote/hatim_remote_data_source_impl.dart b/packages/mq_hatim_repository/lib/src/source/remote/mq_hatim_remote_data_source_impl.dart similarity index 89% rename from app/lib/modules/hatim/data/source/remote/hatim_remote_data_source_impl.dart rename to packages/mq_hatim_repository/lib/src/source/remote/mq_hatim_remote_data_source_impl.dart index 70c455c5..b6fd21b9 100644 --- a/app/lib/modules/hatim/data/source/remote/hatim_remote_data_source_impl.dart +++ b/packages/mq_hatim_repository/lib/src/source/remote/mq_hatim_remote_data_source_impl.dart @@ -2,13 +2,13 @@ import 'dart:async'; import 'dart:convert'; import 'package:mq_crashlytics/mq_crashlytics.dart'; +import 'package:mq_hatim_repository/mq_hatim_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'; + import 'package:web_socket_channel/web_socket_channel.dart'; -class HatimRemoteDataSourceImpl implements HatimRemoteDataSource { - HatimRemoteDataSourceImpl({ +class MqHatimRemoteDataSourceImpl implements MqHatimRemoteDataSource { + MqHatimRemoteDataSourceImpl({ required this.remoteClient, }); @@ -21,7 +21,7 @@ class HatimRemoteDataSourceImpl implements HatimRemoteDataSource { Future getHatim() async { try { final res = await remoteClient.postType( - apiConst.joinToHatim, + '/api/v1/hatim/join_to_hatim', fromJson: HatimReadModel.fromJson, ); @@ -36,7 +36,7 @@ class HatimRemoteDataSourceImpl implements HatimRemoteDataSource { void connectToSocket(String token) { if (!isInitilized) { channel = WebSocketChannel.connect( - Uri.parse(apiConst.getSocket(token)), + Uri.parse('wss://myquran.life/ws/?token=$token'), ); isInitilized = true; } diff --git a/packages/mq_hatim_repository/lib/src/src.dart b/packages/mq_hatim_repository/lib/src/src.dart new file mode 100644 index 00000000..d529592b --- /dev/null +++ b/packages/mq_hatim_repository/lib/src/src.dart @@ -0,0 +1,17 @@ +// entities +export 'entity/mq_hatim_base_entity.dart'; +export 'entity/mq_hatim_juz_entity.dart'; +export 'entity/mq_hatim_page_entity.dart'; +export 'entity/mq_hatim_read_entity.dart'; +// models +export 'model/mq_hatim_base_response.dart'; +export 'model/mq_hatim_juz.dart'; +export 'model/mq_hatim_page.dart'; +export 'model/mq_hatim_read_model.dart'; +// repositories +export 'repository/mq_hatim_read_repository.dart'; +export 'repository/mq_hatim_read_repository_impl.dart'; +// sources +export 'source/mock/mq_hatim_remote_data_source_mock.dart'; +export 'source/mq_hatim_remote_data_source.dart'; +export 'source/remote/mq_hatim_remote_data_source_impl.dart'; diff --git a/packages/mq_hatim_repository/pubspec.yaml b/packages/mq_hatim_repository/pubspec.yaml new file mode 100644 index 00000000..ffb1be9c --- /dev/null +++ b/packages/mq_hatim_repository/pubspec.yaml @@ -0,0 +1,28 @@ +name: mq_hatim_repository +description: Mq hatim repository package +version: 0.1.0+1 +publish_to: none + +environment: + sdk: ^3.5.0 + flutter: ^3.24.0 + +dependencies: + flutter: + sdk: flutter + json_annotation: ^4.9.0 + web_socket_channel: ^3.0.1 + + # Packages + mq_crashlytics: + path: ../mq_crashlytics + mq_remote_client: + path: ../mq_remote_client + +dev_dependencies: + flutter_test: + sdk: flutter + build_runner: ^2.4.13 + mocktail: ^1.0.4 + very_good_analysis: ^6.0.0 + json_serializable: ^6.9.0 \ No newline at end of file diff --git a/packages/mq_hatim_repository/pubspec_overrides.yaml b/packages/mq_hatim_repository/pubspec_overrides.yaml new file mode 100644 index 00000000..ef9a3c1e --- /dev/null +++ b/packages/mq_hatim_repository/pubspec_overrides.yaml @@ -0,0 +1,8 @@ +# melos_managed_dependency_overrides: mq_crashlytics,mq_either,mq_remote_client +dependency_overrides: + mq_crashlytics: + path: ../mq_crashlytics + mq_either: + path: ../mq_either + mq_remote_client: + path: ../mq_remote_client diff --git a/packages/mq_hatim_repository/test/mq_hatim_repository_test.dart b/packages/mq_hatim_repository/test/mq_hatim_repository_test.dart new file mode 100644 index 00000000..40713c67 --- /dev/null +++ b/packages/mq_hatim_repository/test/mq_hatim_repository_test.dart @@ -0,0 +1,11 @@ +// ignore_for_file: prefer_const_constructors + +import 'package:flutter_test/flutter_test.dart'; + +void main() { + group('MqHatimRepository', () { + test('can be instantiated', () { + expect(1 + 1, 2); + }); + }); +} diff --git a/packages/mq_home_repository/analysis_options.yaml b/packages/mq_home_repository/analysis_options.yaml index 5ea2ad9f..7ad0bbf5 100644 --- a/packages/mq_home_repository/analysis_options.yaml +++ b/packages/mq_home_repository/analysis_options.yaml @@ -1,6 +1,3 @@ -analyzer: - errors: - one_member_abstracts: ignore include: package:very_good_analysis/analysis_options.6.0.0.yaml linter: @@ -8,3 +5,11 @@ linter: public_member_api_docs: false lines_longer_than_80_chars: false sort_pub_dependencies: false + +analyzer: + errors: + one_member_abstracts: ignore + exclude: + - "**/*.g.dart" + - "**/*.freezed.dart" + - "bin/cache/**" \ No newline at end of file diff --git a/packages/mq_home_repository/lib/src/model/mq_home_model_response.dart b/packages/mq_home_repository/lib/src/model/mq_home_model_response.dart index c80f8395..c69c4eb4 100644 --- a/packages/mq_home_repository/lib/src/model/mq_home_model_response.dart +++ b/packages/mq_home_repository/lib/src/model/mq_home_model_response.dart @@ -12,8 +12,8 @@ final class MqHomeModelResponse { required this.donePages, }); - factory MqHomeModelResponse.fromJson(Map json) => _$HomeModelResponseFromJson(json); - Map toJson() => _$HomeModelResponseToJson(this); + factory MqHomeModelResponse.fromJson(Map json) => _$MqHomeModelResponseFromJson(json); + Map toJson() => _$MqHomeModelResponseToJson(this); final int allDoneHatims; final int allDonePages; diff --git a/packages/mq_home_repository/lib/src/model/mq_home_model_response.g.dart b/packages/mq_home_repository/lib/src/model/mq_home_model_response.g.dart index 84179d0e..3264544d 100644 --- a/packages/mq_home_repository/lib/src/model/mq_home_model_response.g.dart +++ b/packages/mq_home_repository/lib/src/model/mq_home_model_response.g.dart @@ -6,13 +6,13 @@ part of 'mq_home_model_response.dart'; // JsonSerializableGenerator // ************************************************************************** -MqHomeModelResponse _$HomeModelResponseFromJson(Map json) => MqHomeModelResponse( +MqHomeModelResponse _$MqHomeModelResponseFromJson(Map json) => MqHomeModelResponse( allDoneHatims: (json['allDoneHatims'] as num).toInt(), allDonePages: (json['allDonePages'] as num).toInt(), donePages: (json['donePages'] as num).toInt(), ); -Map _$HomeModelResponseToJson(MqHomeModelResponse instance) => { +Map _$MqHomeModelResponseToJson(MqHomeModelResponse instance) => { 'allDoneHatims': instance.allDoneHatims, 'allDonePages': instance.allDonePages, 'donePages': instance.donePages, diff --git a/packages/mq_home_repository/pubspec.yaml b/packages/mq_home_repository/pubspec.yaml index b5faa2c1..f7d0c3ca 100644 --- a/packages/mq_home_repository/pubspec.yaml +++ b/packages/mq_home_repository/pubspec.yaml @@ -28,3 +28,5 @@ dev_dependencies: sdk: flutter mocktail: ^1.0.4 very_good_analysis: ^6.0.0 + build_runner: ^2.4.13 + json_serializable: ^6.9.0 diff --git a/packages/mq_quran_repository/analysis_options.yaml b/packages/mq_quran_repository/analysis_options.yaml index 5ea2ad9f..7ad0bbf5 100644 --- a/packages/mq_quran_repository/analysis_options.yaml +++ b/packages/mq_quran_repository/analysis_options.yaml @@ -1,6 +1,3 @@ -analyzer: - errors: - one_member_abstracts: ignore include: package:very_good_analysis/analysis_options.6.0.0.yaml linter: @@ -8,3 +5,11 @@ linter: public_member_api_docs: false lines_longer_than_80_chars: false sort_pub_dependencies: false + +analyzer: + errors: + one_member_abstracts: ignore + exclude: + - "**/*.g.dart" + - "**/*.freezed.dart" + - "bin/cache/**" \ No newline at end of file diff --git a/packages/mq_quran_repository/pubspec.yaml b/packages/mq_quran_repository/pubspec.yaml index 154c571b..b098e865 100644 --- a/packages/mq_quran_repository/pubspec.yaml +++ b/packages/mq_quran_repository/pubspec.yaml @@ -23,3 +23,5 @@ dev_dependencies: sdk: flutter mocktail: ^1.0.4 very_good_analysis: ^6.0.0 + build_runner: ^2.4.13 + json_serializable: ^6.9.0