Skip to content

Commit

Permalink
Merge branch 'main' into ai/email-authentification
Browse files Browse the repository at this point in the history
  • Loading branch information
aidaiym authored Aug 8, 2024
2 parents 359b17e + efd8cbf commit 93a7609
Show file tree
Hide file tree
Showing 26 changed files with 192 additions and 166 deletions.
1 change: 1 addition & 0 deletions app/lib/app/data/repository/auth_repositoty_impl.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:developer';

import 'package:meta/meta.dart';
import 'package:mq_either/mq_either.dart';
import 'package:my_quran/app/app.dart';
import 'package:my_quran/core/core.dart';

Expand Down
2 changes: 1 addition & 1 deletion app/lib/app/data/source/auth_remote_data_source.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:mq_either/mq_either.dart';
import 'package:my_quran/app/app.dart';
import 'package:my_quran/core/core.dart';

abstract class AuthRemoteDataSource {
Future<void> loginWithEmail(String email);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import 'package:meta/meta.dart';
import 'package:mq_either/mq_either.dart';
import 'package:my_quran/app/app.dart';

import 'package:my_quran/core/core.dart';

@immutable
final class AuthRemoteDataSourceMock implements AuthRemoteDataSource {
const AuthRemoteDataSourceMock();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:meta/meta.dart';
import 'package:mq_either/mq_either.dart';
import 'package:mq_storage/mq_storage.dart';
import 'package:my_quran/app/app.dart';
import 'package:my_quran/config/config.dart';
Expand Down
2 changes: 1 addition & 1 deletion app/lib/app/domain/repository/auth_repository.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:mq_either/mq_either.dart';
import 'package:my_quran/app/app.dart';
import 'package:my_quran/core/core.dart';

abstract class AuthRepository {
UserEntity? get init;
Expand Down
2 changes: 1 addition & 1 deletion app/lib/app/domain/usecase/apple_sign_in_use_case.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:meta/meta.dart';
import 'package:mq_either/mq_either.dart';
import 'package:my_quran/app/app.dart';
import 'package:my_quran/core/core.dart';

@immutable
final class AppleSignInUseCase {
Expand Down
2 changes: 1 addition & 1 deletion app/lib/app/domain/usecase/google_sign_in_use_case.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:meta/meta.dart';
import 'package:mq_either/mq_either.dart';
import 'package:my_quran/app/app.dart';
import 'package:my_quran/core/core.dart';

@immutable
final class GoogleSignInUseCase {
Expand Down
2 changes: 1 addition & 1 deletion app/lib/app/domain/usecase/patch_gender_user_case.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:meta/meta.dart';
import 'package:mq_either/mq_either.dart';
import 'package:my_quran/app/app.dart';
import 'package:my_quran/core/core.dart';

@immutable
final class PatchGenderUseCase {
Expand Down
2 changes: 1 addition & 1 deletion app/lib/app/domain/usecase/patch_locale_code_use_case.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:meta/meta.dart';
import 'package:mq_either/mq_either.dart';
import 'package:my_quran/app/app.dart';
import 'package:my_quran/core/core.dart';

@immutable
final class PatchLocaleCodeUseCase {
Expand Down
1 change: 1 addition & 0 deletions app/lib/core/client/mq_dio.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';
import 'package:mq_either/mq_either.dart';
import 'package:my_quran/core/core.dart';

part 'mq_dio_base_extension.dart';
Expand Down
1 change: 0 additions & 1 deletion app/lib/core/core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ export 'client/network_client.dart';
export 'client/http_exception.dart';
export 'client/mq_dio.dart';
export 'crashlytics/mq_crashlytics.dart';
export 'either/either.dart';
export 'exceptions/network_exception.dart';
export 'exceptions/server_exception.dart';
export 'exceptions/auth_exception.dart';
Expand Down
101 changes: 0 additions & 101 deletions app/lib/core/either/either.dart

This file was deleted.

7 changes: 7 additions & 0 deletions app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,13 @@ packages:
relative: true
source: path
version: "1.0.0"
mq_either:
dependency: "direct main"
description:
path: "../packages/mq_either"
relative: true
source: path
version: "0.1.0+1"
mq_storage:
dependency: "direct main"
description:
Expand Down
4 changes: 3 additions & 1 deletion app/pubspec_overrides.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# melos_managed_dependency_overrides: mq_ci_keys,mq_storage
# melos_managed_dependency_overrides: mq_ci_keys,mq_storage,mq_either
dependency_overrides:
mq_ci_keys:
path: ../packages/mq_ci_keys
mq_either:
path: ../packages/mq_either
mq_storage:
path: ../packages/mq_storage
1 change: 0 additions & 1 deletion packages/mq_client/README.md

This file was deleted.

14 changes: 0 additions & 14 deletions packages/mq_client/analysis_options.yaml

This file was deleted.

4 changes: 0 additions & 4 deletions packages/mq_client/lib/mq_client.dart

This file was deleted.

7 changes: 0 additions & 7 deletions packages/mq_client/lib/src/mq_client.dart

This file was deleted.

17 changes: 0 additions & 17 deletions packages/mq_client/pubspec.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions packages/mq_client/test/src/mq_client_test.dart

This file was deleted.

48 changes: 48 additions & 0 deletions packages/mq_either/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# MyQuran Dart Either

## Either Class Implementation

This Dart code provides an implementation of the `Either` type, a common functional programming pattern. The `Either` type represents a value that can be one of two types: `Right` or `Left`. This is useful for handling operations that can return two types of results, such as a successful value or an error.

### Either<R, L>

An abstract class for values that can be either `Right` or `Left`.

- `fold<B>(B Function(L l) ifLeft, B Function(R r) ifRight)`: Executes one of the given functions based on the type of value.

### Right<R, L>

Represents a `Right` value.

- `Right(this.value)`: Holds the `Right` value.
- `fold<B>(B Function(L l) ifLeft, B Function(R r) ifRight)`: Executes the `ifRight` function with the `Right` value.

### Left<R, L>

Represents a `Left` value.

- `Left(this.value)`: Holds the Left value.
- `fold<B>(B Function(L l) ifLeft, B Function(R r) ifRight)`: Executes the `ifLeft` function with the `Left` value.

### Usage

Example usage of `Either`, `Right`, and `Left` classes:

```dart
void main() {
final rightValue = Right<int, String>(42);
final leftValue = Left<int, String>('Error');
final rightResult = rightValue.fold(
(error) => 'Left: $error',
(value) => 'Right: $value',
);
print(rightResult); // Output: "Right: 42"
final leftResult = leftValue.fold(
(error) => 'Left: $error',
(value) => 'Right: $value',
);
print(leftResult); // Output: "Left: Error"
}
```
6 changes: 6 additions & 0 deletions packages/mq_either/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
include: package:very_good_analysis/analysis_options.6.0.0.yaml

linter:
rules:
public_member_api_docs: false
lines_longer_than_80_chars: false
4 changes: 4 additions & 0 deletions packages/mq_either/lib/mq_either.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/// MyQuran Dart Either
library;

export 'src/mq_either.dart';
50 changes: 50 additions & 0 deletions packages/mq_either/lib/src/mq_either.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import 'package:meta/meta.dart';

/// An abstract class representing a value that can be either Right or Left.
@immutable
sealed class Either<R, L> {
const Either();

/// Performs operations based on Right and Left values.
B fold<B>(B Function(L l) ifLeft, B Function(R r) ifRight);
}

/// Represents the Right value of an Either.
@immutable
final class Right<R, L> extends Either<R, L> {
const Right(this.value);

/// Holds the Right value.
final R value;

/// Invokes the ifRight function using the Right value.
@override
B fold<B>(B Function(L l) ifLeft, B Function(R r) ifRight) => ifRight(value);

/// Equality and hashCode overrides.
@override
bool operator ==(Object other) => other is Right && other.value == value;

@override
int get hashCode => value.hashCode;
}

/// Represents the Left value of an Either.
@immutable
final class Left<R, L> extends Either<R, L> {
const Left(this.value);

/// Holds the Left value.
final L value;

/// Invokes the ifLeft function using the Left value.
@override
B fold<B>(B Function(L l) ifLeft, B Function(R r) ifRight) => ifLeft(value);

/// Equality and hashCode overrides.
@override
bool operator ==(Object other) => other is Left && other.value == value;

@override
int get hashCode => value.hashCode;
}
Loading

0 comments on commit 93a7609

Please sign in to comment.