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 package hatim repo #280

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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
3 changes: 0 additions & 3 deletions app/lib/constants/api/api_const.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -29,7 +29,7 @@ class HatimBloc extends Bloc<HatimEvent, HatimState> {
on<ReceidevBaseDataEvent>(_onReceidevBaseDataEvent);
}

final HatimRepository repo;
final MqHatimRepository repo;
final String token;
bool islistened = false;

Expand Down Expand Up @@ -114,11 +114,11 @@ class HatimBloc extends Bloc<HatimEvent, HatimState> {
) {
final src = event.data;
final newState = switch (src.$1) {
HatimResponseType.listOfJuz => state.copyWith(juzsState: HatimJuzsFetched(src.$2 as List<HatimJusEntity>)),
HatimResponseType.listOfJuz => state.copyWith(juzsState: HatimJuzsFetched(src.$2 as List<MqHatimJusEntity>)),
HatimResponseType.listOfPage =>
state.copyWith(juzPagesState: HatimJuzPagesFetched(src.$2 as List<HatimPagesEntity>)),
state.copyWith(juzPagesState: HatimJuzPagesFetched(src.$2 as List<MqHatimPagesEntity>)),
HatimResponseType.userPages =>
state.copyWith(userPagesState: HatimUserPagesFetched(src.$2 as List<HatimPagesEntity>)),
state.copyWith(userPagesState: HatimUserPagesFetched(src.$2 as List<MqHatimPagesEntity>)),
};

emit(newState);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ final class SetDonePagesEvent extends HatimEvent {
final class ReceidevBaseDataEvent extends HatimEvent {
const ReceidevBaseDataEvent(this.data);

final (HatimResponseType, List<HatimBaseEntity>) data;
final (HatimResponseType, List<MqHatimBaseEntity>) data;
}

@immutable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class HatimJuzPagesLoading extends HatimJuzPagesState {
final class HatimJuzPagesFetched extends HatimJuzPagesState {
const HatimJuzPagesFetched(this.data);

final List<HatimPagesEntity> data;
final List<MqHatimPagesEntity> data;
}

@immutable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class HatimJuzsLoading extends HatimJuzsState {
final class HatimJuzsFetched extends HatimJuzsState {
const HatimJuzsFetched(this.data);

final List<HatimJusEntity> data;
final List<MqHatimJusEntity> data;
}

@immutable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class HatimUserPagesLoading extends HatimUserPagesState {
final class HatimUserPagesFetched extends HatimUserPagesState {
const HatimUserPagesFetched(this.data);

final List<HatimPagesEntity> data;
final List<MqHatimPagesEntity> data;
}

@immutable
Expand Down
8 changes: 0 additions & 8 deletions app/lib/modules/hatim/data/data.dart

This file was deleted.

5 changes: 0 additions & 5 deletions app/lib/modules/hatim/domain/domain.dart

This file was deleted.

1 change: 0 additions & 1 deletion app/lib/modules/hatim/domain/entity/hatim_base_entity.dart

This file was deleted.

15 changes: 0 additions & 15 deletions app/lib/modules/hatim/domain/entity/hatim_read_entity.dart

This file was deleted.

11 changes: 8 additions & 3 deletions app/lib/modules/hatim/hatim.dart
Original file line number Diff line number Diff line change
@@ -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';
8 changes: 0 additions & 8 deletions app/lib/modules/hatim/presentation/presentation.dart

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -14,7 +15,7 @@ class HatimJusSelectPagesView extends StatelessWidget {
super.key,
});

final HatimJusEntity hatimJusEntity;
final MqHatimJusEntity hatimJusEntity;

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -268,7 +269,7 @@ class HatimJusSelectPagesView extends StatelessWidget {
class HatimPageGridListBuilder extends StatelessWidget {
const HatimPageGridListBuilder(this.items, {super.key});

final List<HatimPagesEntity> items;
final List<MqHatimPagesEntity> items;

@override
Widget build(BuildContext context) {
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_hatim_repository/mq_hatim_repository.dart';
import 'package:mq_remote_client/mq_remote_client.dart';

import 'package:my_quran/app/app.dart';
Expand All @@ -19,10 +20,10 @@ class HatimView extends StatelessWidget {
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => HatimBloc(
repo: HatimReadRepositoryImpl(
repo: MqHatimReadRepositoryImpl(
dataSource: context.read<AppConfig>().isMockData
? HatimRemoteDataSourceMock()
: HatimRemoteDataSourceImpl(remoteClient: context.read<MqRemoteClient>()),
? MqHatimRemoteDataSourceMock()
: MqHatimRemoteDataSourceImpl(remoteClient: context.read<MqRemoteClient>()),
),
token: context.read<AuthCubit>().state.user!.accessToken,
)..add(const GetInitailDataEvent()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ 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';

class HatimJuzListBuilder extends StatelessWidget {
const HatimJuzListBuilder(this.items, {super.key});

final List<HatimJusEntity> items;
final List<MqHatimJusEntity> items;

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -104,7 +105,7 @@ class HatimJuzListBuilder extends StatelessWidget {
);
}

Future<void> _onTap(HatimJusEntity item, BuildContext context) async {
Future<void> _onTap(MqHatimJusEntity item, BuildContext context) async {
MqAnalytic.track(
AnalyticKey.selectHatimJuz,
params: {'juzId': item.id},
Expand Down Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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({
Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -8,7 +9,7 @@ class JuzAnnotationWidget extends StatelessWidget {
super.key,
});

final HatimJusEntity item;
final MqHatimJusEntity item;

@override
Widget build(BuildContext context) {
Expand Down
7 changes: 7 additions & 0 deletions app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion app/pubspec_overrides.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand Down
1 change: 1 addition & 0 deletions packages/mq_hatim_repository/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Mq Hatim Repository
15 changes: 15 additions & 0 deletions packages/mq_hatim_repository/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -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/**"
4 changes: 4 additions & 0 deletions packages/mq_hatim_repository/lib/mq_hatim_repository.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/// Mq Hatim Repository Package
library mq_hatim_repository;

export 'src/src.dart';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
interface class MqHatimBaseEntity {}
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:meta/meta.dart';

part 'hatim_base_response.g.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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';

Expand All @@ -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,
Expand Down
Loading
Loading