common
This commit is contained in:
parent
00ed567f84
commit
baa660eacd
111 changed files with 10202 additions and 3 deletions
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 76d5f8efdb7e71bcb375f3e4c80eca666ecb9aa3
|
||||
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 22e65dcc3650f220eeacbd94c866f0e37b0a94a0
|
||||
3
mnemo_cards_common/CHANGELOG.md
Normal file
3
mnemo_cards_common/CHANGELOG.md
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
## 0.0.1
|
||||
|
||||
* TODO: Describe initial release.
|
||||
1
mnemo_cards_common/LICENSE
Normal file
1
mnemo_cards_common/LICENSE
Normal file
|
|
@ -0,0 +1 @@
|
|||
TODO: Add your license here.
|
||||
39
mnemo_cards_common/README.md
Normal file
39
mnemo_cards_common/README.md
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<!--
|
||||
This README describes the package. If you publish this package to pub.dev,
|
||||
this README's contents appear on the landing page for your package.
|
||||
|
||||
For information about how to write a good package README, see the guide for
|
||||
[writing package pages](https://dart.dev/guides/libraries/writing-package-pages).
|
||||
|
||||
For general information about developing packages, see the Dart guide for
|
||||
[creating packages](https://dart.dev/guides/libraries/create-library-packages)
|
||||
and the Flutter guide for
|
||||
[developing packages and plugins](https://flutter.dev/developing-packages).
|
||||
-->
|
||||
|
||||
TODO: Put a short description of the package here that helps potential users
|
||||
know whether this package might be useful for them.
|
||||
|
||||
## Features
|
||||
|
||||
TODO: List what your package can do. Maybe include images, gifs, or videos.
|
||||
|
||||
## Getting started
|
||||
|
||||
TODO: List prerequisites and provide or point to information on how to
|
||||
start using the package.
|
||||
|
||||
## Usage
|
||||
|
||||
TODO: Include short and useful examples for package users. Add longer examples
|
||||
to `/example` folder.
|
||||
|
||||
```dart
|
||||
const like = 'sample';
|
||||
```
|
||||
|
||||
## Additional information
|
||||
|
||||
TODO: Tell users more about the package: where to find more information, how to
|
||||
contribute to the package, how to file issues, what response they can expect
|
||||
from the package authors, and more.
|
||||
4
mnemo_cards_common/analysis_options.yaml
Normal file
4
mnemo_cards_common/analysis_options.yaml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
include: package:flutter_lints/flutter.yaml
|
||||
|
||||
# Additional information about this file can be found at
|
||||
# https://dart.dev/guides/language/analysis-options
|
||||
2
mnemo_cards_common/codegen.sh
Normal file
2
mnemo_cards_common/codegen.sh
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#!/bin/bash
|
||||
dart run build_runner build --delete-conflicting-outputs
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
{
|
||||
"pack": "3",
|
||||
"data": [
|
||||
{
|
||||
"es": "zumo de mora",
|
||||
"ru": "сок из ежевики"
|
||||
},
|
||||
{
|
||||
"es": "zumo de col",
|
||||
"ru": "сок из капусты"
|
||||
},
|
||||
{
|
||||
"es": "zumo de zanahoria",
|
||||
"ru": "морковный сок"
|
||||
},
|
||||
{
|
||||
"es": "zumo de sandía",
|
||||
"ru": "арбузный сок"
|
||||
},
|
||||
{
|
||||
"es": "zumo de fresa",
|
||||
"ru": "клубничный сок"
|
||||
},
|
||||
{
|
||||
"es": "zumo de piña",
|
||||
"ru": "ананасовый сок"
|
||||
},
|
||||
{
|
||||
"es": "zumo de calabaza",
|
||||
"ru": "тыквенный сок"
|
||||
},
|
||||
{
|
||||
"es": "pastel de queso",
|
||||
"ru": "чизкейк"
|
||||
},
|
||||
{
|
||||
"es": "pastel de zanahoria",
|
||||
"ru": "морковный торт"
|
||||
},
|
||||
{
|
||||
"es": "pastel de fresa",
|
||||
"ru": "клубничный торт"
|
||||
},
|
||||
{
|
||||
"es": "pastel de piña",
|
||||
"ru": "ананасовый торт"
|
||||
},
|
||||
{
|
||||
"es": "pastel de calabaza",
|
||||
"ru": "тыквенный торт"
|
||||
},
|
||||
{
|
||||
"es": "pastel de plátano",
|
||||
"ru": "банановый торт"
|
||||
},
|
||||
{
|
||||
"es": "pastel de higo",
|
||||
"ru": "торт с инжиром"
|
||||
}
|
||||
]
|
||||
}
|
||||
57
mnemo_cards_common/lib/mnemo_cards_common.dart
Normal file
57
mnemo_cards_common/lib/mnemo_cards_common.dart
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
library mnemo_cards_common;
|
||||
|
||||
export 'src/dtos/packs/card_pack_action.dart';
|
||||
export 'src/dtos/packs/card_pack_dto.dart';
|
||||
export 'src/dtos/packs/edit_card_pack_dto.dart';
|
||||
export 'src/dtos/packs/card_pack_buy_dto.dart';
|
||||
export 'src/dtos/packs/card_pack_loading_dto.dart';
|
||||
export 'src/dtos/packs/card_pack_preview_dto.dart';
|
||||
export 'src/dtos/packs/pack_tip.dart';
|
||||
export 'src/dtos/packs/get_card_pack_response.dart';
|
||||
export 'src/dtos/game_card_dto.dart';
|
||||
|
||||
export 'src/dtos/payment/export.dart';
|
||||
|
||||
export 'src/dtos/promo_codes/promo_codes_campaign_dto.dart';
|
||||
export 'src/dtos/discounts/discount_campaign_dto.dart';
|
||||
export 'src/dtos/discounts/discount_dto.dart';
|
||||
|
||||
export 'src/dtos/user/user_dto.dart';
|
||||
export 'src/dtos/user/data/user_data_dto.dart';
|
||||
export 'src/dtos/user/data/word_statistics_dto.dart';
|
||||
export 'src/dtos/user/data/all_words_statistics_dto.dart';
|
||||
export 'src/dtos/game_tests/test_statistics_dto.dart';
|
||||
export 'src/dtos/user/data/all_tests_statistics_dto.dart';
|
||||
export 'src/dtos/user/promo_code_dto.dart';
|
||||
export 'src/dtos/user/settings/user_settings_dto.dart';
|
||||
export 'src/dtos/user/enums.dart';
|
||||
|
||||
// NEW: Extended statistics DTOs
|
||||
export 'src/dtos/user/data/pack_progress_dto.dart';
|
||||
export 'src/dtos/user/achievement_dto.dart';
|
||||
export 'src/dtos/user/data/detailed_word_statistics_dto.dart';
|
||||
export 'src/dtos/user/study_session_dto.dart';
|
||||
|
||||
export 'src/dtos/games/game_dto.dart';
|
||||
|
||||
export 'src/dtos/game_tests/test_bodies/input_buttons_test_question_body.dart';
|
||||
export 'src/dtos/game_tests/test_bodies/simple_test_question.dart';
|
||||
export 'src/dtos/game_tests/test_bodies/abstract_test_question.dart';
|
||||
|
||||
export 'src/dtos/subscription/subscription_plan_admin_dto.dart';
|
||||
export 'src/dtos/subscription/subscription_plan_dto.dart';
|
||||
export 'src/dtos/subscription/subscription_features.dart';
|
||||
export 'src/dtos/subscription/subscription_plan_ui_dto.dart';
|
||||
|
||||
export 'src/dtos/game_tests/test.dart';
|
||||
export 'src/dtos/game_tests/test_button.dart';
|
||||
export 'src/dtos/game_tests/test_question_type.dart';
|
||||
|
||||
export 'src/dtos/items/items.dart';
|
||||
|
||||
export 'src/utils/utils.dart';
|
||||
export 'src/utils/iterable_helper.dart';
|
||||
export 'src/utils/token_generator.dart';
|
||||
export 'src/app_headers.dart';
|
||||
|
||||
export 'src/deeplinks/export.dart';
|
||||
5
mnemo_cards_common/lib/src/app_headers.dart
Normal file
5
mnemo_cards_common/lib/src/app_headers.dart
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class AppHeaders {
|
||||
static const String userToken = 'user_token';
|
||||
static const String requestToken = 'request_token';
|
||||
static const String appVersion = 'app_version';
|
||||
}
|
||||
16
mnemo_cards_common/lib/src/deeplinks/deeplink.dart
Normal file
16
mnemo_cards_common/lib/src/deeplinks/deeplink.dart
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import 'package:mnemo_cards_common/mnemo_cards_common.dart';
|
||||
|
||||
abstract mixin class MnemoCardsDeeplink {
|
||||
String get host;
|
||||
|
||||
String get path;
|
||||
|
||||
Map<String, dynamic>? get queryParameters;
|
||||
|
||||
Uri get uri => Uri(
|
||||
scheme: 'mnemocards',
|
||||
host: host,
|
||||
path: path.notEmptyOrNull,
|
||||
queryParameters: queryParameters,
|
||||
);
|
||||
}
|
||||
5
mnemo_cards_common/lib/src/deeplinks/export.dart
Normal file
5
mnemo_cards_common/lib/src/deeplinks/export.dart
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
export 'purchase_check.dart';
|
||||
export 'purchase_init.dart';
|
||||
export 'subscription_open.dart';
|
||||
export 'product_for_ad.dart';
|
||||
export 'deeplink.dart';
|
||||
31
mnemo_cards_common/lib/src/deeplinks/product_for_ad.dart
Normal file
31
mnemo_cards_common/lib/src/deeplinks/product_for_ad.dart
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:mnemo_cards_common/src/deeplinks/deeplink.dart';
|
||||
|
||||
import '../dtos/payment/export.dart';
|
||||
|
||||
class ProductForAdDeeplink with MnemoCardsDeeplink {
|
||||
final MnemoCardsProductDto product;
|
||||
final String key;
|
||||
|
||||
static const deeplinkPath = 'open';
|
||||
|
||||
ProductForAdDeeplink(this.product, this.key);
|
||||
|
||||
@override
|
||||
String get host => 'ad';
|
||||
|
||||
@override
|
||||
String get path => deeplinkPath;
|
||||
|
||||
@override
|
||||
Map<String, dynamic>? get queryParameters => {
|
||||
'key': key,
|
||||
'id': product.id,
|
||||
'type': product.toJson()['type'],
|
||||
};
|
||||
|
||||
factory ProductForAdDeeplink.parse(Uri uri) => ProductForAdDeeplink(
|
||||
MnemoCardsProductDto.fromJson(uri.queryParameters),
|
||||
uri.queryParameters['key'] as String,
|
||||
);
|
||||
}
|
||||
45
mnemo_cards_common/lib/src/deeplinks/purchase_check.dart
Normal file
45
mnemo_cards_common/lib/src/deeplinks/purchase_check.dart
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:mnemo_cards_common/src/deeplinks/deeplink.dart';
|
||||
|
||||
import '../dtos/payment/export.dart';
|
||||
|
||||
part 'purchase_check.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class PurchaseCheckDeeplink with MnemoCardsDeeplink {
|
||||
final String id;
|
||||
|
||||
@JsonKey(
|
||||
fromJson: MnemoCardsProductType.fromName,
|
||||
toJson: MnemoCardsProductType.toName,
|
||||
)
|
||||
final MnemoCardsProductType productType;
|
||||
|
||||
// For yookassa - same as payment model id
|
||||
final String token;
|
||||
|
||||
@JsonKey(unknownEnumValue: PaymentSystem.unknown)
|
||||
final PaymentSystem paymentSystem;
|
||||
|
||||
static const deeplinkPath = 'check';
|
||||
|
||||
PurchaseCheckDeeplink({
|
||||
required this.id,
|
||||
required this.productType,
|
||||
required this.token,
|
||||
required this.paymentSystem,
|
||||
});
|
||||
|
||||
@override
|
||||
String get host => 'purchase';
|
||||
|
||||
@override
|
||||
String get path => deeplinkPath;
|
||||
|
||||
@override
|
||||
Map<String, dynamic>? get queryParameters =>
|
||||
_$PurchaseCheckDeeplinkToJson(this);
|
||||
|
||||
factory PurchaseCheckDeeplink.parse(Uri uri) =>
|
||||
_$PurchaseCheckDeeplinkFromJson(uri.queryParameters);
|
||||
}
|
||||
37
mnemo_cards_common/lib/src/deeplinks/purchase_check.g.dart
Normal file
37
mnemo_cards_common/lib/src/deeplinks/purchase_check.g.dart
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'purchase_check.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
PurchaseCheckDeeplink _$PurchaseCheckDeeplinkFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
PurchaseCheckDeeplink(
|
||||
id: json['id'] as String,
|
||||
productType:
|
||||
MnemoCardsProductType.fromName(json['productType'] as String),
|
||||
token: json['token'] as String,
|
||||
paymentSystem: $enumDecode(_$PaymentSystemEnumMap, json['paymentSystem'],
|
||||
unknownValue: PaymentSystem.unknown),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$PurchaseCheckDeeplinkToJson(
|
||||
PurchaseCheckDeeplink instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'productType': MnemoCardsProductType.toName(instance.productType),
|
||||
'token': instance.token,
|
||||
'paymentSystem': _$PaymentSystemEnumMap[instance.paymentSystem]!,
|
||||
};
|
||||
|
||||
const _$PaymentSystemEnumMap = {
|
||||
PaymentSystem.google: 'google',
|
||||
PaymentSystem.apple: 'apple',
|
||||
PaymentSystem.rustore: 'rustore',
|
||||
PaymentSystem.yookassa: 'yookassa',
|
||||
PaymentSystem.promoCode: 'promoCode',
|
||||
PaymentSystem.adView: 'adView',
|
||||
PaymentSystem.unknown: 'unknown',
|
||||
};
|
||||
45
mnemo_cards_common/lib/src/deeplinks/purchase_init.dart
Normal file
45
mnemo_cards_common/lib/src/deeplinks/purchase_init.dart
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:mnemo_cards_common/src/deeplinks/deeplink.dart';
|
||||
|
||||
import '../dtos/payment/export.dart';
|
||||
|
||||
part 'purchase_init.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class PurchaseInitDeeplink with MnemoCardsDeeplink {
|
||||
final String id;
|
||||
|
||||
@JsonKey(
|
||||
fromJson: MnemoCardsProductType.fromName,
|
||||
toJson: MnemoCardsProductType.toName,
|
||||
)
|
||||
final MnemoCardsProductType productType;
|
||||
final String paymentId;
|
||||
|
||||
@JsonKey(unknownEnumValue: PaymentSystem.unknown)
|
||||
final PaymentSystem paymentSystem;
|
||||
final String? source;
|
||||
|
||||
static const deeplinkPath = 'init';
|
||||
|
||||
PurchaseInitDeeplink({
|
||||
required this.id,
|
||||
required this.productType,
|
||||
required this.paymentId,
|
||||
required this.paymentSystem,
|
||||
this.source,
|
||||
});
|
||||
|
||||
@override
|
||||
String get host => 'purchase';
|
||||
|
||||
@override
|
||||
String get path => deeplinkPath;
|
||||
|
||||
@override
|
||||
Map<String, dynamic>? get queryParameters =>
|
||||
_$PurchaseInitDeeplinkToJson(this);
|
||||
|
||||
factory PurchaseInitDeeplink.parse(Uri uri) =>
|
||||
_$PurchaseInitDeeplinkFromJson(uri.queryParameters);
|
||||
}
|
||||
39
mnemo_cards_common/lib/src/deeplinks/purchase_init.g.dart
Normal file
39
mnemo_cards_common/lib/src/deeplinks/purchase_init.g.dart
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'purchase_init.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
PurchaseInitDeeplink _$PurchaseInitDeeplinkFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
PurchaseInitDeeplink(
|
||||
id: json['id'] as String,
|
||||
productType:
|
||||
MnemoCardsProductType.fromName(json['productType'] as String),
|
||||
paymentId: json['paymentId'] as String,
|
||||
paymentSystem: $enumDecode(_$PaymentSystemEnumMap, json['paymentSystem'],
|
||||
unknownValue: PaymentSystem.unknown),
|
||||
source: json['source'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$PurchaseInitDeeplinkToJson(
|
||||
PurchaseInitDeeplink instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'productType': MnemoCardsProductType.toName(instance.productType),
|
||||
'paymentId': instance.paymentId,
|
||||
'paymentSystem': _$PaymentSystemEnumMap[instance.paymentSystem]!,
|
||||
'source': instance.source,
|
||||
};
|
||||
|
||||
const _$PaymentSystemEnumMap = {
|
||||
PaymentSystem.google: 'google',
|
||||
PaymentSystem.apple: 'apple',
|
||||
PaymentSystem.rustore: 'rustore',
|
||||
PaymentSystem.yookassa: 'yookassa',
|
||||
PaymentSystem.promoCode: 'promoCode',
|
||||
PaymentSystem.adView: 'adView',
|
||||
PaymentSystem.unknown: 'unknown',
|
||||
};
|
||||
26
mnemo_cards_common/lib/src/deeplinks/subscription_open.dart
Normal file
26
mnemo_cards_common/lib/src/deeplinks/subscription_open.dart
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:mnemo_cards_common/src/deeplinks/deeplink.dart';
|
||||
|
||||
|
||||
part 'subscription_open.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class SubscriptionOpenDeeplink with MnemoCardsDeeplink {
|
||||
|
||||
static const deeplinkPath = 'open';
|
||||
|
||||
SubscriptionOpenDeeplink();
|
||||
|
||||
@override
|
||||
String get host => 'subscription';
|
||||
|
||||
@override
|
||||
String get path => deeplinkPath;
|
||||
|
||||
@override
|
||||
Map<String, dynamic>? get queryParameters =>
|
||||
_$SubscriptionOpenDeeplinkToJson(this);
|
||||
|
||||
factory SubscriptionOpenDeeplink.parse(Uri uri) =>
|
||||
_$SubscriptionOpenDeeplinkFromJson(uri.queryParameters);
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'subscription_open.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
SubscriptionOpenDeeplink _$SubscriptionOpenDeeplinkFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
SubscriptionOpenDeeplink();
|
||||
|
||||
Map<String, dynamic> _$SubscriptionOpenDeeplinkToJson(
|
||||
SubscriptionOpenDeeplink instance) =>
|
||||
<String, dynamic>{};
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'package:mnemo_cards_common/src/dtos/discounts/discount_dto.dart';
|
||||
|
||||
|
||||
part 'discount_campaign_dto.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
@CopyWith()
|
||||
class DiscountCampaignDto {
|
||||
final int? id;
|
||||
final DateTime start;
|
||||
final DateTime finish;
|
||||
final DiscountCampaignStatus status;
|
||||
final String? name;
|
||||
final List<String> tags;
|
||||
final List<DiscountDto> discounts;
|
||||
|
||||
const DiscountCampaignDto({
|
||||
required this.start,
|
||||
required this.finish,
|
||||
required this.status,
|
||||
required this.tags,
|
||||
required this.discounts,
|
||||
this.name,
|
||||
this.id,
|
||||
});
|
||||
|
||||
factory DiscountCampaignDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$DiscountCampaignDtoFromJson(json);
|
||||
|
||||
Map<String, Object?> toJson() => _$DiscountCampaignDtoToJson(this);
|
||||
}
|
||||
|
||||
enum DiscountCampaignStatus {
|
||||
created,
|
||||
active,
|
||||
expired,
|
||||
disabled,
|
||||
}
|
||||
|
|
@ -0,0 +1,161 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'discount_campaign_dto.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$DiscountCampaignDtoCWProxy {
|
||||
DiscountCampaignDto start(DateTime start);
|
||||
|
||||
DiscountCampaignDto finish(DateTime finish);
|
||||
|
||||
DiscountCampaignDto status(DiscountCampaignStatus status);
|
||||
|
||||
DiscountCampaignDto tags(List<String> tags);
|
||||
|
||||
DiscountCampaignDto discounts(List<DiscountDto> discounts);
|
||||
|
||||
DiscountCampaignDto name(String? name);
|
||||
|
||||
DiscountCampaignDto id(int? id);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `DiscountCampaignDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// DiscountCampaignDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
DiscountCampaignDto call({
|
||||
DateTime? start,
|
||||
DateTime? finish,
|
||||
DiscountCampaignStatus? status,
|
||||
List<String>? tags,
|
||||
List<DiscountDto>? discounts,
|
||||
String? name,
|
||||
int? id,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfDiscountCampaignDto.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfDiscountCampaignDto.copyWith.fieldName(...)`
|
||||
class _$DiscountCampaignDtoCWProxyImpl implements _$DiscountCampaignDtoCWProxy {
|
||||
const _$DiscountCampaignDtoCWProxyImpl(this._value);
|
||||
|
||||
final DiscountCampaignDto _value;
|
||||
|
||||
@override
|
||||
DiscountCampaignDto start(DateTime start) => this(start: start);
|
||||
|
||||
@override
|
||||
DiscountCampaignDto finish(DateTime finish) => this(finish: finish);
|
||||
|
||||
@override
|
||||
DiscountCampaignDto status(DiscountCampaignStatus status) =>
|
||||
this(status: status);
|
||||
|
||||
@override
|
||||
DiscountCampaignDto tags(List<String> tags) => this(tags: tags);
|
||||
|
||||
@override
|
||||
DiscountCampaignDto discounts(List<DiscountDto> discounts) =>
|
||||
this(discounts: discounts);
|
||||
|
||||
@override
|
||||
DiscountCampaignDto name(String? name) => this(name: name);
|
||||
|
||||
@override
|
||||
DiscountCampaignDto id(int? id) => this(id: id);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `DiscountCampaignDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// DiscountCampaignDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
DiscountCampaignDto call({
|
||||
Object? start = const $CopyWithPlaceholder(),
|
||||
Object? finish = const $CopyWithPlaceholder(),
|
||||
Object? status = const $CopyWithPlaceholder(),
|
||||
Object? tags = const $CopyWithPlaceholder(),
|
||||
Object? discounts = const $CopyWithPlaceholder(),
|
||||
Object? name = const $CopyWithPlaceholder(),
|
||||
Object? id = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return DiscountCampaignDto(
|
||||
start: start == const $CopyWithPlaceholder() || start == null
|
||||
? _value.start
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: start as DateTime,
|
||||
finish: finish == const $CopyWithPlaceholder() || finish == null
|
||||
? _value.finish
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: finish as DateTime,
|
||||
status: status == const $CopyWithPlaceholder() || status == null
|
||||
? _value.status
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: status as DiscountCampaignStatus,
|
||||
tags: tags == const $CopyWithPlaceholder() || tags == null
|
||||
? _value.tags
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: tags as List<String>,
|
||||
discounts: discounts == const $CopyWithPlaceholder() || discounts == null
|
||||
? _value.discounts
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: discounts as List<DiscountDto>,
|
||||
name: name == const $CopyWithPlaceholder()
|
||||
? _value.name
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: name as String?,
|
||||
id: id == const $CopyWithPlaceholder()
|
||||
? _value.id
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: id as int?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $DiscountCampaignDtoCopyWith on DiscountCampaignDto {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfDiscountCampaignDto.copyWith(...)` or like so:`instanceOfDiscountCampaignDto.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$DiscountCampaignDtoCWProxy get copyWith =>
|
||||
_$DiscountCampaignDtoCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
DiscountCampaignDto _$DiscountCampaignDtoFromJson(Map<String, dynamic> json) =>
|
||||
DiscountCampaignDto(
|
||||
start: DateTime.parse(json['start'] as String),
|
||||
finish: DateTime.parse(json['finish'] as String),
|
||||
status: $enumDecode(_$DiscountCampaignStatusEnumMap, json['status']),
|
||||
tags: (json['tags'] as List<dynamic>).map((e) => e as String).toList(),
|
||||
discounts: (json['discounts'] as List<dynamic>)
|
||||
.map((e) => DiscountDto.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
name: json['name'] as String?,
|
||||
id: json['id'] as int?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$DiscountCampaignDtoToJson(
|
||||
DiscountCampaignDto instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'start': instance.start.toIso8601String(),
|
||||
'finish': instance.finish.toIso8601String(),
|
||||
'status': _$DiscountCampaignStatusEnumMap[instance.status]!,
|
||||
'name': instance.name,
|
||||
'tags': instance.tags,
|
||||
'discounts': instance.discounts,
|
||||
};
|
||||
|
||||
const _$DiscountCampaignStatusEnumMap = {
|
||||
DiscountCampaignStatus.created: 'created',
|
||||
DiscountCampaignStatus.active: 'active',
|
||||
DiscountCampaignStatus.expired: 'expired',
|
||||
DiscountCampaignStatus.disabled: 'disabled',
|
||||
};
|
||||
28
mnemo_cards_common/lib/src/dtos/discounts/discount_dto.dart
Normal file
28
mnemo_cards_common/lib/src/dtos/discounts/discount_dto.dart
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
|
||||
import '../payment/export.dart';
|
||||
|
||||
part 'discount_dto.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
@CopyWith()
|
||||
class DiscountDto implements MnemoCardsProductDto {
|
||||
String? id;
|
||||
final double discountPercent; // 0 - 100
|
||||
final List<MnemoCardsProductDto> products;
|
||||
|
||||
DiscountDto({
|
||||
required this.discountPercent,
|
||||
required this.products,
|
||||
this.id,
|
||||
});
|
||||
|
||||
factory DiscountDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$DiscountDtoFromJson(json);
|
||||
|
||||
Map<String, Object?> toJson() => _$DiscountDtoToJson(this);
|
||||
|
||||
@override
|
||||
MnemoCardsProductType get type => MnemoCardsProductType.discount;
|
||||
}
|
||||
100
mnemo_cards_common/lib/src/dtos/discounts/discount_dto.g.dart
Normal file
100
mnemo_cards_common/lib/src/dtos/discounts/discount_dto.g.dart
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'discount_dto.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$DiscountDtoCWProxy {
|
||||
DiscountDto discountPercent(double discountPercent);
|
||||
|
||||
DiscountDto products(List<MnemoCardsProductDto> products);
|
||||
|
||||
DiscountDto id(String? id);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `DiscountDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// DiscountDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
DiscountDto call({
|
||||
double? discountPercent,
|
||||
List<MnemoCardsProductDto>? products,
|
||||
String? id,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfDiscountDto.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfDiscountDto.copyWith.fieldName(...)`
|
||||
class _$DiscountDtoCWProxyImpl implements _$DiscountDtoCWProxy {
|
||||
const _$DiscountDtoCWProxyImpl(this._value);
|
||||
|
||||
final DiscountDto _value;
|
||||
|
||||
@override
|
||||
DiscountDto discountPercent(double discountPercent) =>
|
||||
this(discountPercent: discountPercent);
|
||||
|
||||
@override
|
||||
DiscountDto products(List<MnemoCardsProductDto> products) =>
|
||||
this(products: products);
|
||||
|
||||
@override
|
||||
DiscountDto id(String? id) => this(id: id);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `DiscountDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// DiscountDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
DiscountDto call({
|
||||
Object? discountPercent = const $CopyWithPlaceholder(),
|
||||
Object? products = const $CopyWithPlaceholder(),
|
||||
Object? id = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return DiscountDto(
|
||||
discountPercent: discountPercent == const $CopyWithPlaceholder() ||
|
||||
discountPercent == null
|
||||
? _value.discountPercent
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: discountPercent as double,
|
||||
products: products == const $CopyWithPlaceholder() || products == null
|
||||
? _value.products
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: products as List<MnemoCardsProductDto>,
|
||||
id: id == const $CopyWithPlaceholder()
|
||||
? _value.id
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: id as String?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $DiscountDtoCopyWith on DiscountDto {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfDiscountDto.copyWith(...)` or like so:`instanceOfDiscountDto.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$DiscountDtoCWProxy get copyWith => _$DiscountDtoCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
DiscountDto _$DiscountDtoFromJson(Map<String, dynamic> json) => DiscountDto(
|
||||
discountPercent: (json['discountPercent'] as num).toDouble(),
|
||||
products: (json['products'] as List<dynamic>)
|
||||
.map((e) => MnemoCardsProductDto.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
id: json['id'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$DiscountDtoToJson(DiscountDto instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'discountPercent': instance.discountPercent,
|
||||
'products': instance.products,
|
||||
};
|
||||
35
mnemo_cards_common/lib/src/dtos/game_card_dto.dart
Normal file
35
mnemo_cards_common/lib/src/dtos/game_card_dto.dart
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
|
||||
part 'game_card_dto.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
@CopyWith()
|
||||
class GameCardDto {
|
||||
final int id;
|
||||
final String? image;
|
||||
final String? mnemo;
|
||||
final String? original;
|
||||
final String? translation;
|
||||
final String? transcription;
|
||||
final String? imageBack;
|
||||
final String? transcriptionMnemo;
|
||||
final String? back;
|
||||
|
||||
const GameCardDto({
|
||||
required this.id,
|
||||
required this.mnemo,
|
||||
required this.original,
|
||||
required this.translation,
|
||||
required this.transcription,
|
||||
this.transcriptionMnemo,
|
||||
this.image,
|
||||
this.imageBack,
|
||||
this.back,
|
||||
});
|
||||
|
||||
factory GameCardDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$GameCardDtoFromJson(json);
|
||||
|
||||
Map<String, Object?> toJson() => _$GameCardDtoToJson(this);
|
||||
}
|
||||
176
mnemo_cards_common/lib/src/dtos/game_card_dto.g.dart
Normal file
176
mnemo_cards_common/lib/src/dtos/game_card_dto.g.dart
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'game_card_dto.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$GameCardDtoCWProxy {
|
||||
GameCardDto id(int id);
|
||||
|
||||
GameCardDto mnemo(String? mnemo);
|
||||
|
||||
GameCardDto original(String? original);
|
||||
|
||||
GameCardDto translation(String? translation);
|
||||
|
||||
GameCardDto transcription(String? transcription);
|
||||
|
||||
GameCardDto transcriptionMnemo(String? transcriptionMnemo);
|
||||
|
||||
GameCardDto image(String? image);
|
||||
|
||||
GameCardDto imageBack(String? imageBack);
|
||||
|
||||
GameCardDto back(String? back);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `GameCardDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// GameCardDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
GameCardDto call({
|
||||
int? id,
|
||||
String? mnemo,
|
||||
String? original,
|
||||
String? translation,
|
||||
String? transcription,
|
||||
String? transcriptionMnemo,
|
||||
String? image,
|
||||
String? imageBack,
|
||||
String? back,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfGameCardDto.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfGameCardDto.copyWith.fieldName(...)`
|
||||
class _$GameCardDtoCWProxyImpl implements _$GameCardDtoCWProxy {
|
||||
const _$GameCardDtoCWProxyImpl(this._value);
|
||||
|
||||
final GameCardDto _value;
|
||||
|
||||
@override
|
||||
GameCardDto id(int id) => this(id: id);
|
||||
|
||||
@override
|
||||
GameCardDto mnemo(String? mnemo) => this(mnemo: mnemo);
|
||||
|
||||
@override
|
||||
GameCardDto original(String? original) => this(original: original);
|
||||
|
||||
@override
|
||||
GameCardDto translation(String? translation) =>
|
||||
this(translation: translation);
|
||||
|
||||
@override
|
||||
GameCardDto transcription(String? transcription) =>
|
||||
this(transcription: transcription);
|
||||
|
||||
@override
|
||||
GameCardDto transcriptionMnemo(String? transcriptionMnemo) =>
|
||||
this(transcriptionMnemo: transcriptionMnemo);
|
||||
|
||||
@override
|
||||
GameCardDto image(String? image) => this(image: image);
|
||||
|
||||
@override
|
||||
GameCardDto imageBack(String? imageBack) => this(imageBack: imageBack);
|
||||
|
||||
@override
|
||||
GameCardDto back(String? back) => this(back: back);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `GameCardDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// GameCardDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
GameCardDto call({
|
||||
Object? id = const $CopyWithPlaceholder(),
|
||||
Object? mnemo = const $CopyWithPlaceholder(),
|
||||
Object? original = const $CopyWithPlaceholder(),
|
||||
Object? translation = const $CopyWithPlaceholder(),
|
||||
Object? transcription = const $CopyWithPlaceholder(),
|
||||
Object? transcriptionMnemo = const $CopyWithPlaceholder(),
|
||||
Object? image = const $CopyWithPlaceholder(),
|
||||
Object? imageBack = const $CopyWithPlaceholder(),
|
||||
Object? back = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return GameCardDto(
|
||||
id: id == const $CopyWithPlaceholder() || id == null
|
||||
? _value.id
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: id as int,
|
||||
mnemo: mnemo == const $CopyWithPlaceholder()
|
||||
? _value.mnemo
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: mnemo as String?,
|
||||
original: original == const $CopyWithPlaceholder()
|
||||
? _value.original
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: original as String?,
|
||||
translation: translation == const $CopyWithPlaceholder()
|
||||
? _value.translation
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: translation as String?,
|
||||
transcription: transcription == const $CopyWithPlaceholder()
|
||||
? _value.transcription
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: transcription as String?,
|
||||
transcriptionMnemo: transcriptionMnemo == const $CopyWithPlaceholder()
|
||||
? _value.transcriptionMnemo
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: transcriptionMnemo as String?,
|
||||
image: image == const $CopyWithPlaceholder()
|
||||
? _value.image
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: image as String?,
|
||||
imageBack: imageBack == const $CopyWithPlaceholder()
|
||||
? _value.imageBack
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: imageBack as String?,
|
||||
back: back == const $CopyWithPlaceholder()
|
||||
? _value.back
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: back as String?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $GameCardDtoCopyWith on GameCardDto {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfGameCardDto.copyWith(...)` or like so:`instanceOfGameCardDto.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$GameCardDtoCWProxy get copyWith => _$GameCardDtoCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
GameCardDto _$GameCardDtoFromJson(Map<String, dynamic> json) => GameCardDto(
|
||||
id: json['id'] as int,
|
||||
mnemo: json['mnemo'] as String?,
|
||||
original: json['original'] as String?,
|
||||
translation: json['translation'] as String?,
|
||||
transcription: json['transcription'] as String?,
|
||||
transcriptionMnemo: json['transcriptionMnemo'] as String?,
|
||||
image: json['image'] as String?,
|
||||
imageBack: json['imageBack'] as String?,
|
||||
back: json['back'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GameCardDtoToJson(GameCardDto instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'image': instance.image,
|
||||
'mnemo': instance.mnemo,
|
||||
'original': instance.original,
|
||||
'translation': instance.translation,
|
||||
'transcription': instance.transcription,
|
||||
'imageBack': instance.imageBack,
|
||||
'transcriptionMnemo': instance.transcriptionMnemo,
|
||||
'back': instance.back,
|
||||
};
|
||||
50
mnemo_cards_common/lib/src/dtos/game_tests/test.dart
Normal file
50
mnemo_cards_common/lib/src/dtos/game_tests/test.dart
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:mnemo_cards_common/mnemo_cards_common.dart';
|
||||
|
||||
part 'test.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
@CopyWith()
|
||||
class TestDto {
|
||||
final List<AbstractTestQuestion> questions;
|
||||
final String name;
|
||||
final String? color;
|
||||
final String? cover;
|
||||
final String? version;
|
||||
final String? time;
|
||||
final String? timeSubtitle;
|
||||
final TestStatisticsDto? statistics;
|
||||
|
||||
String? id;
|
||||
|
||||
TestDto({
|
||||
this.id,
|
||||
required this.questions,
|
||||
required this.name,
|
||||
this.time,
|
||||
this.timeSubtitle,
|
||||
this.color,
|
||||
this.cover,
|
||||
this.statistics,
|
||||
this.version,
|
||||
});
|
||||
|
||||
factory TestDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$TestDtoFromJson(json);
|
||||
|
||||
Map<String, Object?> toJson() => _$TestDtoToJson(this);
|
||||
|
||||
@override
|
||||
int get hashCode => version.hashCode ^ statistics.hashCode ^ id.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
|
||||
return other is TestDto &&
|
||||
other.statistics == statistics &&
|
||||
other.version == version &&
|
||||
other.id == id;
|
||||
}
|
||||
}
|
||||
180
mnemo_cards_common/lib/src/dtos/game_tests/test.g.dart
Normal file
180
mnemo_cards_common/lib/src/dtos/game_tests/test.g.dart
Normal file
|
|
@ -0,0 +1,180 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'test.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$TestDtoCWProxy {
|
||||
TestDto id(String? id);
|
||||
|
||||
TestDto questions(List<AbstractTestQuestion> questions);
|
||||
|
||||
TestDto name(String name);
|
||||
|
||||
TestDto time(String? time);
|
||||
|
||||
TestDto timeSubtitle(String? timeSubtitle);
|
||||
|
||||
TestDto color(String? color);
|
||||
|
||||
TestDto cover(String? cover);
|
||||
|
||||
TestDto statistics(TestStatisticsDto? statistics);
|
||||
|
||||
TestDto version(String? version);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `TestDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// TestDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
TestDto call({
|
||||
String? id,
|
||||
List<AbstractTestQuestion>? questions,
|
||||
String? name,
|
||||
String? time,
|
||||
String? timeSubtitle,
|
||||
String? color,
|
||||
String? cover,
|
||||
TestStatisticsDto? statistics,
|
||||
String? version,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfTestDto.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfTestDto.copyWith.fieldName(...)`
|
||||
class _$TestDtoCWProxyImpl implements _$TestDtoCWProxy {
|
||||
const _$TestDtoCWProxyImpl(this._value);
|
||||
|
||||
final TestDto _value;
|
||||
|
||||
@override
|
||||
TestDto id(String? id) => this(id: id);
|
||||
|
||||
@override
|
||||
TestDto questions(List<AbstractTestQuestion> questions) =>
|
||||
this(questions: questions);
|
||||
|
||||
@override
|
||||
TestDto name(String name) => this(name: name);
|
||||
|
||||
@override
|
||||
TestDto time(String? time) => this(time: time);
|
||||
|
||||
@override
|
||||
TestDto timeSubtitle(String? timeSubtitle) =>
|
||||
this(timeSubtitle: timeSubtitle);
|
||||
|
||||
@override
|
||||
TestDto color(String? color) => this(color: color);
|
||||
|
||||
@override
|
||||
TestDto cover(String? cover) => this(cover: cover);
|
||||
|
||||
@override
|
||||
TestDto statistics(TestStatisticsDto? statistics) =>
|
||||
this(statistics: statistics);
|
||||
|
||||
@override
|
||||
TestDto version(String? version) => this(version: version);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `TestDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// TestDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
TestDto call({
|
||||
Object? id = const $CopyWithPlaceholder(),
|
||||
Object? questions = const $CopyWithPlaceholder(),
|
||||
Object? name = const $CopyWithPlaceholder(),
|
||||
Object? time = const $CopyWithPlaceholder(),
|
||||
Object? timeSubtitle = const $CopyWithPlaceholder(),
|
||||
Object? color = const $CopyWithPlaceholder(),
|
||||
Object? cover = const $CopyWithPlaceholder(),
|
||||
Object? statistics = const $CopyWithPlaceholder(),
|
||||
Object? version = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return TestDto(
|
||||
id: id == const $CopyWithPlaceholder()
|
||||
? _value.id
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: id as String?,
|
||||
questions: questions == const $CopyWithPlaceholder() || questions == null
|
||||
? _value.questions
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: questions as List<AbstractTestQuestion>,
|
||||
name: name == const $CopyWithPlaceholder() || name == null
|
||||
? _value.name
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: name as String,
|
||||
time: time == const $CopyWithPlaceholder()
|
||||
? _value.time
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: time as String?,
|
||||
timeSubtitle: timeSubtitle == const $CopyWithPlaceholder()
|
||||
? _value.timeSubtitle
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: timeSubtitle as String?,
|
||||
color: color == const $CopyWithPlaceholder()
|
||||
? _value.color
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: color as String?,
|
||||
cover: cover == const $CopyWithPlaceholder()
|
||||
? _value.cover
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: cover as String?,
|
||||
statistics: statistics == const $CopyWithPlaceholder()
|
||||
? _value.statistics
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: statistics as TestStatisticsDto?,
|
||||
version: version == const $CopyWithPlaceholder()
|
||||
? _value.version
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: version as String?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $TestDtoCopyWith on TestDto {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfTestDto.copyWith(...)` or like so:`instanceOfTestDto.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$TestDtoCWProxy get copyWith => _$TestDtoCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
TestDto _$TestDtoFromJson(Map<String, dynamic> json) => TestDto(
|
||||
id: json['id'] as String?,
|
||||
questions: (json['questions'] as List<dynamic>)
|
||||
.map((e) => AbstractTestQuestion.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
name: json['name'] as String,
|
||||
time: json['time'] as String?,
|
||||
timeSubtitle: json['timeSubtitle'] as String?,
|
||||
color: json['color'] as String?,
|
||||
cover: json['cover'] as String?,
|
||||
statistics: json['statistics'] == null
|
||||
? null
|
||||
: TestStatisticsDto.fromJson(
|
||||
json['statistics'] as Map<String, dynamic>),
|
||||
version: json['version'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$TestDtoToJson(TestDto instance) => <String, dynamic>{
|
||||
'questions': instance.questions,
|
||||
'name': instance.name,
|
||||
'color': instance.color,
|
||||
'cover': instance.cover,
|
||||
'version': instance.version,
|
||||
'time': instance.time,
|
||||
'timeSubtitle': instance.timeSubtitle,
|
||||
'statistics': instance.statistics,
|
||||
'id': instance.id,
|
||||
};
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
|
||||
import '../test_question_type.dart';
|
||||
import 'input_buttons_test_question_body.dart';
|
||||
import 'simple_test_question.dart';
|
||||
|
||||
abstract class AbstractTestQuestion {
|
||||
int? id;
|
||||
final TestQuestionType questionType;
|
||||
final String word;
|
||||
final String? body;
|
||||
|
||||
AbstractTestQuestion({
|
||||
required this.questionType,
|
||||
required this.word,
|
||||
this.body,
|
||||
this.id,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
factory AbstractTestQuestion.fromJson(Map<String, dynamic> json) {
|
||||
final questionType = TestQuestionType.values
|
||||
.where((element) => element.name == json['questionType'])
|
||||
.firstOrNull;
|
||||
switch (questionType) {
|
||||
case null:
|
||||
throw Exception('Undefined type');
|
||||
case TestQuestionType.simple:
|
||||
return SimpleTestQuestionBody.fromJson(json);
|
||||
case TestQuestionType.input_buttons:
|
||||
return InputButtonsTestQuestionBody.fromJson(json);
|
||||
case TestQuestionType.matrix:
|
||||
throw UnimplementedError('Not implemented yet');
|
||||
case TestQuestionType.match:
|
||||
throw UnimplementedError('Not implemented yet');
|
||||
case TestQuestionType.undefined:
|
||||
throw UnimplementedError('Undefined type');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
import '../test_button.dart';
|
||||
import '../test_question_type.dart';
|
||||
import 'abstract_test_question.dart';
|
||||
|
||||
part 'input_buttons_test_question_body.g.dart';
|
||||
|
||||
@JsonSerializable(explicitToJson: true, includeIfNull: false)
|
||||
@CopyWith()
|
||||
class InputButtonsTestQuestionBody extends AbstractTestQuestion {
|
||||
final String? image;
|
||||
final String? text;
|
||||
final String? audio;
|
||||
final List<TestButtonDto> buttons;
|
||||
final String answer;
|
||||
final String template;
|
||||
|
||||
InputButtonsTestQuestionBody({
|
||||
super.id,
|
||||
required this.answer,
|
||||
required this.buttons,
|
||||
required this.template,
|
||||
required super.word,
|
||||
this.image,
|
||||
this.text,
|
||||
this.audio,
|
||||
super.questionType = TestQuestionType.input_buttons,
|
||||
});
|
||||
|
||||
factory InputButtonsTestQuestionBody.fromJson(Map<String, dynamic> json) =>
|
||||
_$InputButtonsTestQuestionBodyFromJson(json);
|
||||
|
||||
Map<String, Object?> toJson() => _$InputButtonsTestQuestionBodyToJson(this);
|
||||
|
||||
// @override
|
||||
// TestQuestionBody toTestQuestionBody() => TestQuestionBody(
|
||||
// id: this.id,
|
||||
// questionType: this.questionType,
|
||||
// body: jsonEncode(toJson()),
|
||||
// );
|
||||
}
|
||||
|
||||
extension InputButtonsStringExt on String {
|
||||
String get asTemplate => this.replaceAll(RegExp('[^ ]'), '_');
|
||||
}
|
||||
|
|
@ -0,0 +1,203 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'input_buttons_test_question_body.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$InputButtonsTestQuestionBodyCWProxy {
|
||||
InputButtonsTestQuestionBody id(int? id);
|
||||
|
||||
InputButtonsTestQuestionBody answer(String answer);
|
||||
|
||||
InputButtonsTestQuestionBody buttons(List<TestButtonDto> buttons);
|
||||
|
||||
InputButtonsTestQuestionBody template(String template);
|
||||
|
||||
InputButtonsTestQuestionBody word(String word);
|
||||
|
||||
InputButtonsTestQuestionBody image(String? image);
|
||||
|
||||
InputButtonsTestQuestionBody text(String? text);
|
||||
|
||||
InputButtonsTestQuestionBody audio(String? audio);
|
||||
|
||||
InputButtonsTestQuestionBody questionType(TestQuestionType questionType);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `InputButtonsTestQuestionBody(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// InputButtonsTestQuestionBody(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
InputButtonsTestQuestionBody call({
|
||||
int? id,
|
||||
String? answer,
|
||||
List<TestButtonDto>? buttons,
|
||||
String? template,
|
||||
String? word,
|
||||
String? image,
|
||||
String? text,
|
||||
String? audio,
|
||||
TestQuestionType? questionType,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfInputButtonsTestQuestionBody.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfInputButtonsTestQuestionBody.copyWith.fieldName(...)`
|
||||
class _$InputButtonsTestQuestionBodyCWProxyImpl
|
||||
implements _$InputButtonsTestQuestionBodyCWProxy {
|
||||
const _$InputButtonsTestQuestionBodyCWProxyImpl(this._value);
|
||||
|
||||
final InputButtonsTestQuestionBody _value;
|
||||
|
||||
@override
|
||||
InputButtonsTestQuestionBody id(int? id) => this(id: id);
|
||||
|
||||
@override
|
||||
InputButtonsTestQuestionBody answer(String answer) => this(answer: answer);
|
||||
|
||||
@override
|
||||
InputButtonsTestQuestionBody buttons(List<TestButtonDto> buttons) =>
|
||||
this(buttons: buttons);
|
||||
|
||||
@override
|
||||
InputButtonsTestQuestionBody template(String template) =>
|
||||
this(template: template);
|
||||
|
||||
@override
|
||||
InputButtonsTestQuestionBody word(String word) => this(word: word);
|
||||
|
||||
@override
|
||||
InputButtonsTestQuestionBody image(String? image) => this(image: image);
|
||||
|
||||
@override
|
||||
InputButtonsTestQuestionBody text(String? text) => this(text: text);
|
||||
|
||||
@override
|
||||
InputButtonsTestQuestionBody audio(String? audio) => this(audio: audio);
|
||||
|
||||
@override
|
||||
InputButtonsTestQuestionBody questionType(TestQuestionType questionType) =>
|
||||
this(questionType: questionType);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `InputButtonsTestQuestionBody(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// InputButtonsTestQuestionBody(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
InputButtonsTestQuestionBody call({
|
||||
Object? id = const $CopyWithPlaceholder(),
|
||||
Object? answer = const $CopyWithPlaceholder(),
|
||||
Object? buttons = const $CopyWithPlaceholder(),
|
||||
Object? template = const $CopyWithPlaceholder(),
|
||||
Object? word = const $CopyWithPlaceholder(),
|
||||
Object? image = const $CopyWithPlaceholder(),
|
||||
Object? text = const $CopyWithPlaceholder(),
|
||||
Object? audio = const $CopyWithPlaceholder(),
|
||||
Object? questionType = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return InputButtonsTestQuestionBody(
|
||||
id: id == const $CopyWithPlaceholder()
|
||||
? _value.id
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: id as int?,
|
||||
answer: answer == const $CopyWithPlaceholder() || answer == null
|
||||
? _value.answer
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: answer as String,
|
||||
buttons: buttons == const $CopyWithPlaceholder() || buttons == null
|
||||
? _value.buttons
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: buttons as List<TestButtonDto>,
|
||||
template: template == const $CopyWithPlaceholder() || template == null
|
||||
? _value.template
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: template as String,
|
||||
word: word == const $CopyWithPlaceholder() || word == null
|
||||
? _value.word
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: word as String,
|
||||
image: image == const $CopyWithPlaceholder()
|
||||
? _value.image
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: image as String?,
|
||||
text: text == const $CopyWithPlaceholder()
|
||||
? _value.text
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: text as String?,
|
||||
audio: audio == const $CopyWithPlaceholder()
|
||||
? _value.audio
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: audio as String?,
|
||||
questionType:
|
||||
questionType == const $CopyWithPlaceholder() || questionType == null
|
||||
? _value.questionType
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: questionType as TestQuestionType,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $InputButtonsTestQuestionBodyCopyWith
|
||||
on InputButtonsTestQuestionBody {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfInputButtonsTestQuestionBody.copyWith(...)` or like so:`instanceOfInputButtonsTestQuestionBody.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$InputButtonsTestQuestionBodyCWProxy get copyWith =>
|
||||
_$InputButtonsTestQuestionBodyCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
InputButtonsTestQuestionBody _$InputButtonsTestQuestionBodyFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
InputButtonsTestQuestionBody(
|
||||
id: json['id'] as int?,
|
||||
answer: json['answer'] as String,
|
||||
buttons: (json['buttons'] as List<dynamic>)
|
||||
.map((e) => TestButtonDto.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
template: json['template'] as String,
|
||||
word: json['word'] as String,
|
||||
image: json['image'] as String?,
|
||||
text: json['text'] as String?,
|
||||
audio: json['audio'] as String?,
|
||||
questionType: $enumDecodeNullable(
|
||||
_$TestQuestionTypeEnumMap, json['questionType']) ??
|
||||
TestQuestionType.input_buttons,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$InputButtonsTestQuestionBodyToJson(
|
||||
InputButtonsTestQuestionBody instance) {
|
||||
final val = <String, dynamic>{};
|
||||
|
||||
void writeNotNull(String key, dynamic value) {
|
||||
if (value != null) {
|
||||
val[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
writeNotNull('id', instance.id);
|
||||
val['questionType'] = _$TestQuestionTypeEnumMap[instance.questionType]!;
|
||||
val['word'] = instance.word;
|
||||
writeNotNull('image', instance.image);
|
||||
writeNotNull('text', instance.text);
|
||||
writeNotNull('audio', instance.audio);
|
||||
val['buttons'] = instance.buttons.map((e) => e.toJson()).toList();
|
||||
val['answer'] = instance.answer;
|
||||
val['template'] = instance.template;
|
||||
return val;
|
||||
}
|
||||
|
||||
const _$TestQuestionTypeEnumMap = {
|
||||
TestQuestionType.simple: 'simple',
|
||||
TestQuestionType.input_buttons: 'input_buttons',
|
||||
TestQuestionType.matrix: 'matrix',
|
||||
TestQuestionType.match: 'match',
|
||||
TestQuestionType.undefined: 'undefined',
|
||||
};
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:mnemo_cards_common/mnemo_cards_common.dart';
|
||||
|
||||
|
||||
part 'simple_test_question.g.dart';
|
||||
|
||||
@JsonSerializable(explicitToJson: true, includeIfNull: false)
|
||||
@CopyWith()
|
||||
class SimpleTestQuestionBody extends AbstractTestQuestion {
|
||||
final String? image;
|
||||
final String? text;
|
||||
final String? audio;
|
||||
final List<TestButtonDto> buttons;
|
||||
final String answer;
|
||||
|
||||
SimpleTestQuestionBody({
|
||||
super.id,
|
||||
required this.answer,
|
||||
required this.buttons,
|
||||
required super.word,
|
||||
this.image,
|
||||
this.text,
|
||||
this.audio,
|
||||
super.questionType = TestQuestionType.simple,
|
||||
});
|
||||
|
||||
factory SimpleTestQuestionBody.fromJson(Map<String, dynamic> json) =>
|
||||
_$SimpleTestQuestionBodyFromJson(json);
|
||||
|
||||
@override
|
||||
Map<String, Object?> toJson() => _$SimpleTestQuestionBodyToJson(this);
|
||||
}
|
||||
|
|
@ -0,0 +1,188 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'simple_test_question.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$SimpleTestQuestionBodyCWProxy {
|
||||
SimpleTestQuestionBody id(int? id);
|
||||
|
||||
SimpleTestQuestionBody answer(String answer);
|
||||
|
||||
SimpleTestQuestionBody buttons(List<TestButtonDto> buttons);
|
||||
|
||||
SimpleTestQuestionBody word(String word);
|
||||
|
||||
SimpleTestQuestionBody image(String? image);
|
||||
|
||||
SimpleTestQuestionBody text(String? text);
|
||||
|
||||
SimpleTestQuestionBody audio(String? audio);
|
||||
|
||||
SimpleTestQuestionBody questionType(TestQuestionType questionType);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `SimpleTestQuestionBody(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// SimpleTestQuestionBody(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
SimpleTestQuestionBody call({
|
||||
int? id,
|
||||
String? answer,
|
||||
List<TestButtonDto>? buttons,
|
||||
String? word,
|
||||
String? image,
|
||||
String? text,
|
||||
String? audio,
|
||||
TestQuestionType? questionType,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfSimpleTestQuestionBody.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfSimpleTestQuestionBody.copyWith.fieldName(...)`
|
||||
class _$SimpleTestQuestionBodyCWProxyImpl
|
||||
implements _$SimpleTestQuestionBodyCWProxy {
|
||||
const _$SimpleTestQuestionBodyCWProxyImpl(this._value);
|
||||
|
||||
final SimpleTestQuestionBody _value;
|
||||
|
||||
@override
|
||||
SimpleTestQuestionBody id(int? id) => this(id: id);
|
||||
|
||||
@override
|
||||
SimpleTestQuestionBody answer(String answer) => this(answer: answer);
|
||||
|
||||
@override
|
||||
SimpleTestQuestionBody buttons(List<TestButtonDto> buttons) =>
|
||||
this(buttons: buttons);
|
||||
|
||||
@override
|
||||
SimpleTestQuestionBody word(String word) => this(word: word);
|
||||
|
||||
@override
|
||||
SimpleTestQuestionBody image(String? image) => this(image: image);
|
||||
|
||||
@override
|
||||
SimpleTestQuestionBody text(String? text) => this(text: text);
|
||||
|
||||
@override
|
||||
SimpleTestQuestionBody audio(String? audio) => this(audio: audio);
|
||||
|
||||
@override
|
||||
SimpleTestQuestionBody questionType(TestQuestionType questionType) =>
|
||||
this(questionType: questionType);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `SimpleTestQuestionBody(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// SimpleTestQuestionBody(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
SimpleTestQuestionBody call({
|
||||
Object? id = const $CopyWithPlaceholder(),
|
||||
Object? answer = const $CopyWithPlaceholder(),
|
||||
Object? buttons = const $CopyWithPlaceholder(),
|
||||
Object? word = const $CopyWithPlaceholder(),
|
||||
Object? image = const $CopyWithPlaceholder(),
|
||||
Object? text = const $CopyWithPlaceholder(),
|
||||
Object? audio = const $CopyWithPlaceholder(),
|
||||
Object? questionType = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return SimpleTestQuestionBody(
|
||||
id: id == const $CopyWithPlaceholder()
|
||||
? _value.id
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: id as int?,
|
||||
answer: answer == const $CopyWithPlaceholder() || answer == null
|
||||
? _value.answer
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: answer as String,
|
||||
buttons: buttons == const $CopyWithPlaceholder() || buttons == null
|
||||
? _value.buttons
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: buttons as List<TestButtonDto>,
|
||||
word: word == const $CopyWithPlaceholder() || word == null
|
||||
? _value.word
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: word as String,
|
||||
image: image == const $CopyWithPlaceholder()
|
||||
? _value.image
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: image as String?,
|
||||
text: text == const $CopyWithPlaceholder()
|
||||
? _value.text
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: text as String?,
|
||||
audio: audio == const $CopyWithPlaceholder()
|
||||
? _value.audio
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: audio as String?,
|
||||
questionType:
|
||||
questionType == const $CopyWithPlaceholder() || questionType == null
|
||||
? _value.questionType
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: questionType as TestQuestionType,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $SimpleTestQuestionBodyCopyWith on SimpleTestQuestionBody {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfSimpleTestQuestionBody.copyWith(...)` or like so:`instanceOfSimpleTestQuestionBody.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$SimpleTestQuestionBodyCWProxy get copyWith =>
|
||||
_$SimpleTestQuestionBodyCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
SimpleTestQuestionBody _$SimpleTestQuestionBodyFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
SimpleTestQuestionBody(
|
||||
id: json['id'] as int?,
|
||||
answer: json['answer'] as String,
|
||||
buttons: (json['buttons'] as List<dynamic>)
|
||||
.map((e) => TestButtonDto.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
word: json['word'] as String,
|
||||
image: json['image'] as String?,
|
||||
text: json['text'] as String?,
|
||||
audio: json['audio'] as String?,
|
||||
questionType: $enumDecodeNullable(
|
||||
_$TestQuestionTypeEnumMap, json['questionType']) ??
|
||||
TestQuestionType.simple,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$SimpleTestQuestionBodyToJson(
|
||||
SimpleTestQuestionBody instance) {
|
||||
final val = <String, dynamic>{};
|
||||
|
||||
void writeNotNull(String key, dynamic value) {
|
||||
if (value != null) {
|
||||
val[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
writeNotNull('id', instance.id);
|
||||
val['questionType'] = _$TestQuestionTypeEnumMap[instance.questionType]!;
|
||||
val['word'] = instance.word;
|
||||
writeNotNull('image', instance.image);
|
||||
writeNotNull('text', instance.text);
|
||||
writeNotNull('audio', instance.audio);
|
||||
val['buttons'] = instance.buttons.map((e) => e.toJson()).toList();
|
||||
val['answer'] = instance.answer;
|
||||
return val;
|
||||
}
|
||||
|
||||
const _$TestQuestionTypeEnumMap = {
|
||||
TestQuestionType.simple: 'simple',
|
||||
TestQuestionType.input_buttons: 'input_buttons',
|
||||
TestQuestionType.matrix: 'matrix',
|
||||
TestQuestionType.match: 'match',
|
||||
TestQuestionType.undefined: 'undefined',
|
||||
};
|
||||
28
mnemo_cards_common/lib/src/dtos/game_tests/test_button.dart
Normal file
28
mnemo_cards_common/lib/src/dtos/game_tests/test_button.dart
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
|
||||
part 'test_button.g.dart';
|
||||
|
||||
@CopyWith()
|
||||
@JsonSerializable(explicitToJson: true, includeIfNull: false)
|
||||
class TestButtonDto {
|
||||
final String id;
|
||||
final String? image;
|
||||
final String? text;
|
||||
|
||||
TestButtonDto(this.id, this.image, this.text);
|
||||
|
||||
TestButtonDto.text(this.id, this.text) : image = null;
|
||||
|
||||
TestButtonDto.image(this.id, this.image) : text = null;
|
||||
|
||||
bool get isImageButton => image != null;
|
||||
|
||||
bool get isTextButton => !isImageButton;
|
||||
|
||||
factory TestButtonDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$TestButtonDtoFromJson(json);
|
||||
|
||||
@override
|
||||
Map<String, Object?> toJson() => _$TestButtonDtoToJson(this);
|
||||
}
|
||||
105
mnemo_cards_common/lib/src/dtos/game_tests/test_button.g.dart
Normal file
105
mnemo_cards_common/lib/src/dtos/game_tests/test_button.g.dart
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'test_button.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$TestButtonDtoCWProxy {
|
||||
TestButtonDto id(String id);
|
||||
|
||||
TestButtonDto image(String? image);
|
||||
|
||||
TestButtonDto text(String? text);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `TestButtonDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// TestButtonDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
TestButtonDto call({
|
||||
String? id,
|
||||
String? image,
|
||||
String? text,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfTestButtonDto.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfTestButtonDto.copyWith.fieldName(...)`
|
||||
class _$TestButtonDtoCWProxyImpl implements _$TestButtonDtoCWProxy {
|
||||
const _$TestButtonDtoCWProxyImpl(this._value);
|
||||
|
||||
final TestButtonDto _value;
|
||||
|
||||
@override
|
||||
TestButtonDto id(String id) => this(id: id);
|
||||
|
||||
@override
|
||||
TestButtonDto image(String? image) => this(image: image);
|
||||
|
||||
@override
|
||||
TestButtonDto text(String? text) => this(text: text);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `TestButtonDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// TestButtonDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
TestButtonDto call({
|
||||
Object? id = const $CopyWithPlaceholder(),
|
||||
Object? image = const $CopyWithPlaceholder(),
|
||||
Object? text = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return TestButtonDto(
|
||||
id == const $CopyWithPlaceholder() || id == null
|
||||
? _value.id
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: id as String,
|
||||
image == const $CopyWithPlaceholder()
|
||||
? _value.image
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: image as String?,
|
||||
text == const $CopyWithPlaceholder()
|
||||
? _value.text
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: text as String?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $TestButtonDtoCopyWith on TestButtonDto {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfTestButtonDto.copyWith(...)` or like so:`instanceOfTestButtonDto.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$TestButtonDtoCWProxy get copyWith => _$TestButtonDtoCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
TestButtonDto _$TestButtonDtoFromJson(Map<String, dynamic> json) =>
|
||||
TestButtonDto(
|
||||
json['id'] as String,
|
||||
json['image'] as String?,
|
||||
json['text'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$TestButtonDtoToJson(TestButtonDto instance) {
|
||||
final val = <String, dynamic>{
|
||||
'id': instance.id,
|
||||
};
|
||||
|
||||
void writeNotNull(String key, dynamic value) {
|
||||
if (value != null) {
|
||||
val[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
writeNotNull('image', instance.image);
|
||||
writeNotNull('text', instance.text);
|
||||
return val;
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
enum TestQuestionType {
|
||||
simple,
|
||||
input_buttons,
|
||||
matrix,
|
||||
match,
|
||||
undefined,
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'package:mnemo_cards_common/mnemo_cards_common.dart';
|
||||
|
||||
part 'test_statistics_dto.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
@CopyWith()
|
||||
class TestStatisticsDto {
|
||||
final int testId;
|
||||
final AllWordsStatisticsDto words;
|
||||
final String? sessionToken;
|
||||
final int attempts;
|
||||
|
||||
TestStatisticsDto({
|
||||
required this.testId,
|
||||
required this.words,
|
||||
this.attempts = 0,
|
||||
this.sessionToken,
|
||||
});
|
||||
|
||||
factory TestStatisticsDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$TestStatisticsDtoFromJson(json);
|
||||
|
||||
Map<String, Object?> toJson() => _$TestStatisticsDtoToJson(this);
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
testId.hashCode ^ words.hashCode ^ sessionToken.hashCode ^ attempts;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
|
||||
return other is TestStatisticsDto &&
|
||||
other.testId == testId &&
|
||||
other.words == words &&
|
||||
other.sessionToken == sessionToken &&
|
||||
other.attempts == attempts;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'test_statistics_dto.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$TestStatisticsDtoCWProxy {
|
||||
TestStatisticsDto testId(int testId);
|
||||
|
||||
TestStatisticsDto words(AllWordsStatisticsDto words);
|
||||
|
||||
TestStatisticsDto attempts(int attempts);
|
||||
|
||||
TestStatisticsDto sessionToken(String? sessionToken);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `TestStatisticsDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// TestStatisticsDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
TestStatisticsDto call({
|
||||
int? testId,
|
||||
AllWordsStatisticsDto? words,
|
||||
int? attempts,
|
||||
String? sessionToken,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfTestStatisticsDto.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfTestStatisticsDto.copyWith.fieldName(...)`
|
||||
class _$TestStatisticsDtoCWProxyImpl implements _$TestStatisticsDtoCWProxy {
|
||||
const _$TestStatisticsDtoCWProxyImpl(this._value);
|
||||
|
||||
final TestStatisticsDto _value;
|
||||
|
||||
@override
|
||||
TestStatisticsDto testId(int testId) => this(testId: testId);
|
||||
|
||||
@override
|
||||
TestStatisticsDto words(AllWordsStatisticsDto words) => this(words: words);
|
||||
|
||||
@override
|
||||
TestStatisticsDto attempts(int attempts) => this(attempts: attempts);
|
||||
|
||||
@override
|
||||
TestStatisticsDto sessionToken(String? sessionToken) =>
|
||||
this(sessionToken: sessionToken);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `TestStatisticsDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// TestStatisticsDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
TestStatisticsDto call({
|
||||
Object? testId = const $CopyWithPlaceholder(),
|
||||
Object? words = const $CopyWithPlaceholder(),
|
||||
Object? attempts = const $CopyWithPlaceholder(),
|
||||
Object? sessionToken = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return TestStatisticsDto(
|
||||
testId: testId == const $CopyWithPlaceholder() || testId == null
|
||||
? _value.testId
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: testId as int,
|
||||
words: words == const $CopyWithPlaceholder() || words == null
|
||||
? _value.words
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: words as AllWordsStatisticsDto,
|
||||
attempts: attempts == const $CopyWithPlaceholder() || attempts == null
|
||||
? _value.attempts
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: attempts as int,
|
||||
sessionToken: sessionToken == const $CopyWithPlaceholder()
|
||||
? _value.sessionToken
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: sessionToken as String?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $TestStatisticsDtoCopyWith on TestStatisticsDto {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfTestStatisticsDto.copyWith(...)` or like so:`instanceOfTestStatisticsDto.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$TestStatisticsDtoCWProxy get copyWith =>
|
||||
_$TestStatisticsDtoCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
TestStatisticsDto _$TestStatisticsDtoFromJson(Map<String, dynamic> json) =>
|
||||
TestStatisticsDto(
|
||||
testId: json['testId'] as int,
|
||||
words:
|
||||
AllWordsStatisticsDto.fromJson(json['words'] as Map<String, dynamic>),
|
||||
attempts: json['attempts'] as int? ?? 0,
|
||||
sessionToken: json['sessionToken'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$TestStatisticsDtoToJson(TestStatisticsDto instance) =>
|
||||
<String, dynamic>{
|
||||
'testId': instance.testId,
|
||||
'words': instance.words,
|
||||
'sessionToken': instance.sessionToken,
|
||||
'attempts': instance.attempts,
|
||||
};
|
||||
53
mnemo_cards_common/lib/src/dtos/games/game_dto.dart
Normal file
53
mnemo_cards_common/lib/src/dtos/games/game_dto.dart
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
|
||||
import '../payment/export.dart';
|
||||
|
||||
part 'game_dto.g.dart';
|
||||
|
||||
@JsonSerializable(explicitToJson: true, includeIfNull: false)
|
||||
@CopyWith()
|
||||
class GameDto implements MnemoCardsProductDto {
|
||||
final String id;
|
||||
final String title;
|
||||
final String subtitle;
|
||||
final String? color;
|
||||
final String? version;
|
||||
final String? imageBase64;
|
||||
|
||||
const GameDto({
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.subtitle,
|
||||
required this.color,
|
||||
required this.version,
|
||||
required this.imageBase64,
|
||||
});
|
||||
|
||||
factory GameDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$GameDtoFromJson(json);
|
||||
|
||||
Map<String, Object?> toJson() => _$GameDtoToJson(this);
|
||||
|
||||
@override
|
||||
MnemoCardsProductType get type => MnemoCardsProductType.pack;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is GameDto &&
|
||||
runtimeType == other.runtimeType &&
|
||||
id == other.id &&
|
||||
title == other.title &&
|
||||
subtitle == other.subtitle &&
|
||||
color == other.color &&
|
||||
version == other.version;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
id.hashCode ^
|
||||
title.hashCode ^
|
||||
subtitle.hashCode ^
|
||||
color.hashCode ^
|
||||
version.hashCode;
|
||||
}
|
||||
143
mnemo_cards_common/lib/src/dtos/games/game_dto.g.dart
Normal file
143
mnemo_cards_common/lib/src/dtos/games/game_dto.g.dart
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'game_dto.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$GameDtoCWProxy {
|
||||
GameDto id(String id);
|
||||
|
||||
GameDto title(String title);
|
||||
|
||||
GameDto subtitle(String subtitle);
|
||||
|
||||
GameDto color(String? color);
|
||||
|
||||
GameDto version(String? version);
|
||||
|
||||
GameDto imageBase64(String? imageBase64);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `GameDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// GameDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
GameDto call({
|
||||
String? id,
|
||||
String? title,
|
||||
String? subtitle,
|
||||
String? color,
|
||||
String? version,
|
||||
String? imageBase64,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfGameDto.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfGameDto.copyWith.fieldName(...)`
|
||||
class _$GameDtoCWProxyImpl implements _$GameDtoCWProxy {
|
||||
const _$GameDtoCWProxyImpl(this._value);
|
||||
|
||||
final GameDto _value;
|
||||
|
||||
@override
|
||||
GameDto id(String id) => this(id: id);
|
||||
|
||||
@override
|
||||
GameDto title(String title) => this(title: title);
|
||||
|
||||
@override
|
||||
GameDto subtitle(String subtitle) => this(subtitle: subtitle);
|
||||
|
||||
@override
|
||||
GameDto color(String? color) => this(color: color);
|
||||
|
||||
@override
|
||||
GameDto version(String? version) => this(version: version);
|
||||
|
||||
@override
|
||||
GameDto imageBase64(String? imageBase64) => this(imageBase64: imageBase64);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `GameDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// GameDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
GameDto call({
|
||||
Object? id = const $CopyWithPlaceholder(),
|
||||
Object? title = const $CopyWithPlaceholder(),
|
||||
Object? subtitle = const $CopyWithPlaceholder(),
|
||||
Object? color = const $CopyWithPlaceholder(),
|
||||
Object? version = const $CopyWithPlaceholder(),
|
||||
Object? imageBase64 = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return GameDto(
|
||||
id: id == const $CopyWithPlaceholder() || id == null
|
||||
? _value.id
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: id as String,
|
||||
title: title == const $CopyWithPlaceholder() || title == null
|
||||
? _value.title
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: title as String,
|
||||
subtitle: subtitle == const $CopyWithPlaceholder() || subtitle == null
|
||||
? _value.subtitle
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: subtitle as String,
|
||||
color: color == const $CopyWithPlaceholder()
|
||||
? _value.color
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: color as String?,
|
||||
version: version == const $CopyWithPlaceholder()
|
||||
? _value.version
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: version as String?,
|
||||
imageBase64: imageBase64 == const $CopyWithPlaceholder()
|
||||
? _value.imageBase64
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: imageBase64 as String?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $GameDtoCopyWith on GameDto {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfGameDto.copyWith(...)` or like so:`instanceOfGameDto.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$GameDtoCWProxy get copyWith => _$GameDtoCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
GameDto _$GameDtoFromJson(Map<String, dynamic> json) => GameDto(
|
||||
id: json['id'] as String,
|
||||
title: json['title'] as String,
|
||||
subtitle: json['subtitle'] as String,
|
||||
color: json['color'] as String?,
|
||||
version: json['version'] as String?,
|
||||
imageBase64: json['imageBase64'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GameDtoToJson(GameDto instance) {
|
||||
final val = <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'title': instance.title,
|
||||
'subtitle': instance.subtitle,
|
||||
};
|
||||
|
||||
void writeNotNull(String key, dynamic value) {
|
||||
if (value != null) {
|
||||
val[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
writeNotNull('color', instance.color);
|
||||
writeNotNull('version', instance.version);
|
||||
writeNotNull('imageBase64', instance.imageBase64);
|
||||
return val;
|
||||
}
|
||||
32
mnemo_cards_common/lib/src/dtos/items/button_item.dart
Normal file
32
mnemo_cards_common/lib/src/dtos/items/button_item.dart
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'package:mnemo_cards_common/src/dtos/items/item.dart';
|
||||
|
||||
|
||||
part 'button_item.g.dart';
|
||||
|
||||
@JsonSerializable(includeIfNull: false)
|
||||
@CopyWith()
|
||||
class ButtonItem extends Item {
|
||||
final String? id;
|
||||
final List<Item>? children;
|
||||
final String? text;
|
||||
final String? color;
|
||||
final double height;
|
||||
|
||||
const ButtonItem({
|
||||
this.id,
|
||||
this.children,
|
||||
this.text,
|
||||
this.height = 90,
|
||||
this.color,
|
||||
super.deeplink,
|
||||
super.type = ItemType.button,
|
||||
});
|
||||
|
||||
factory ButtonItem.fromJson(Map<String, dynamic> json) =>
|
||||
_$ButtonItemFromJson(json);
|
||||
|
||||
@override
|
||||
Map<String, Object?> toJson() => _$ButtonItemToJson(this);
|
||||
}
|
||||
167
mnemo_cards_common/lib/src/dtos/items/button_item.g.dart
Normal file
167
mnemo_cards_common/lib/src/dtos/items/button_item.g.dart
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'button_item.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$ButtonItemCWProxy {
|
||||
ButtonItem id(String? id);
|
||||
|
||||
ButtonItem children(List<Item>? children);
|
||||
|
||||
ButtonItem text(String? text);
|
||||
|
||||
ButtonItem height(double height);
|
||||
|
||||
ButtonItem color(String? color);
|
||||
|
||||
ButtonItem deeplink(String? deeplink);
|
||||
|
||||
ButtonItem type(ItemType type);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `ButtonItem(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// ButtonItem(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
ButtonItem call({
|
||||
String? id,
|
||||
List<Item>? children,
|
||||
String? text,
|
||||
double? height,
|
||||
String? color,
|
||||
String? deeplink,
|
||||
ItemType? type,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfButtonItem.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfButtonItem.copyWith.fieldName(...)`
|
||||
class _$ButtonItemCWProxyImpl implements _$ButtonItemCWProxy {
|
||||
const _$ButtonItemCWProxyImpl(this._value);
|
||||
|
||||
final ButtonItem _value;
|
||||
|
||||
@override
|
||||
ButtonItem id(String? id) => this(id: id);
|
||||
|
||||
@override
|
||||
ButtonItem children(List<Item>? children) => this(children: children);
|
||||
|
||||
@override
|
||||
ButtonItem text(String? text) => this(text: text);
|
||||
|
||||
@override
|
||||
ButtonItem height(double height) => this(height: height);
|
||||
|
||||
@override
|
||||
ButtonItem color(String? color) => this(color: color);
|
||||
|
||||
@override
|
||||
ButtonItem deeplink(String? deeplink) => this(deeplink: deeplink);
|
||||
|
||||
@override
|
||||
ButtonItem type(ItemType type) => this(type: type);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `ButtonItem(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// ButtonItem(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
ButtonItem call({
|
||||
Object? id = const $CopyWithPlaceholder(),
|
||||
Object? children = const $CopyWithPlaceholder(),
|
||||
Object? text = const $CopyWithPlaceholder(),
|
||||
Object? height = const $CopyWithPlaceholder(),
|
||||
Object? color = const $CopyWithPlaceholder(),
|
||||
Object? deeplink = const $CopyWithPlaceholder(),
|
||||
Object? type = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return ButtonItem(
|
||||
id: id == const $CopyWithPlaceholder()
|
||||
? _value.id
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: id as String?,
|
||||
children: children == const $CopyWithPlaceholder()
|
||||
? _value.children
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: children as List<Item>?,
|
||||
text: text == const $CopyWithPlaceholder()
|
||||
? _value.text
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: text as String?,
|
||||
height: height == const $CopyWithPlaceholder() || height == null
|
||||
? _value.height
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: height as double,
|
||||
color: color == const $CopyWithPlaceholder()
|
||||
? _value.color
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: color as String?,
|
||||
deeplink: deeplink == const $CopyWithPlaceholder()
|
||||
? _value.deeplink
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: deeplink as String?,
|
||||
type: type == const $CopyWithPlaceholder() || type == null
|
||||
? _value.type
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: type as ItemType,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $ButtonItemCopyWith on ButtonItem {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfButtonItem.copyWith(...)` or like so:`instanceOfButtonItem.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$ButtonItemCWProxy get copyWith => _$ButtonItemCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
ButtonItem _$ButtonItemFromJson(Map<String, dynamic> json) => ButtonItem(
|
||||
id: json['id'] as String?,
|
||||
children: (json['children'] as List<dynamic>?)
|
||||
?.map((e) => Item.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
text: json['text'] as String?,
|
||||
height: (json['height'] as num?)?.toDouble() ?? 90,
|
||||
color: json['color'] as String?,
|
||||
deeplink: json['deeplink'] as String?,
|
||||
type: $enumDecodeNullable(_$ItemTypeEnumMap, json['type'],
|
||||
unknownValue: ItemType.unknown) ??
|
||||
ItemType.button,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$ButtonItemToJson(ButtonItem instance) {
|
||||
final val = <String, dynamic>{
|
||||
'type': _$ItemTypeEnumMap[instance.type]!,
|
||||
};
|
||||
|
||||
void writeNotNull(String key, dynamic value) {
|
||||
if (value != null) {
|
||||
val[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
writeNotNull('deeplink', instance.deeplink);
|
||||
writeNotNull('id', instance.id);
|
||||
writeNotNull('children', instance.children);
|
||||
writeNotNull('text', instance.text);
|
||||
writeNotNull('color', instance.color);
|
||||
val['height'] = instance.height;
|
||||
return val;
|
||||
}
|
||||
|
||||
const _$ItemTypeEnumMap = {
|
||||
ItemType.text: 'text',
|
||||
ItemType.spacer: 'spacer',
|
||||
ItemType.button: 'button',
|
||||
ItemType.unknown: 'unknown',
|
||||
};
|
||||
45
mnemo_cards_common/lib/src/dtos/items/item.dart
Normal file
45
mnemo_cards_common/lib/src/dtos/items/item.dart
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
|
||||
import 'items.dart';
|
||||
|
||||
part 'item.g.dart';
|
||||
|
||||
@JsonSerializable(includeIfNull: false)
|
||||
@CopyWith()
|
||||
class Item {
|
||||
final String? id;
|
||||
@JsonKey(unknownEnumValue: ItemType.unknown)
|
||||
final ItemType type;
|
||||
final String? deeplink;
|
||||
|
||||
const Item({
|
||||
this.id,
|
||||
required this.type,
|
||||
this.deeplink,
|
||||
});
|
||||
|
||||
factory Item.fromJson(Map<String, dynamic> json) {
|
||||
final item = _$ItemFromJson(json);
|
||||
switch (item.type) {
|
||||
case ItemType.text:
|
||||
return TextItem.fromJson(json);
|
||||
case ItemType.spacer:
|
||||
return SpacerItem.fromJson(json);
|
||||
case ItemType.button:
|
||||
return ButtonItem.fromJson(json);
|
||||
case ItemType.unknown:
|
||||
default:
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object?> toJson() => _$ItemToJson(this);
|
||||
}
|
||||
|
||||
enum ItemType {
|
||||
text,
|
||||
spacer,
|
||||
button,
|
||||
unknown,
|
||||
}
|
||||
111
mnemo_cards_common/lib/src/dtos/items/item.g.dart
Normal file
111
mnemo_cards_common/lib/src/dtos/items/item.g.dart
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'item.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$ItemCWProxy {
|
||||
Item id(String? id);
|
||||
|
||||
Item type(ItemType type);
|
||||
|
||||
Item deeplink(String? deeplink);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `Item(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// Item(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
Item call({
|
||||
String? id,
|
||||
ItemType? type,
|
||||
String? deeplink,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfItem.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfItem.copyWith.fieldName(...)`
|
||||
class _$ItemCWProxyImpl implements _$ItemCWProxy {
|
||||
const _$ItemCWProxyImpl(this._value);
|
||||
|
||||
final Item _value;
|
||||
|
||||
@override
|
||||
Item id(String? id) => this(id: id);
|
||||
|
||||
@override
|
||||
Item type(ItemType type) => this(type: type);
|
||||
|
||||
@override
|
||||
Item deeplink(String? deeplink) => this(deeplink: deeplink);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `Item(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// Item(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
Item call({
|
||||
Object? id = const $CopyWithPlaceholder(),
|
||||
Object? type = const $CopyWithPlaceholder(),
|
||||
Object? deeplink = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return Item(
|
||||
id: id == const $CopyWithPlaceholder()
|
||||
? _value.id
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: id as String?,
|
||||
type: type == const $CopyWithPlaceholder() || type == null
|
||||
? _value.type
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: type as ItemType,
|
||||
deeplink: deeplink == const $CopyWithPlaceholder()
|
||||
? _value.deeplink
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: deeplink as String?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $ItemCopyWith on Item {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfItem.copyWith(...)` or like so:`instanceOfItem.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$ItemCWProxy get copyWith => _$ItemCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
Item _$ItemFromJson(Map<String, dynamic> json) => Item(
|
||||
id: json['id'] as String?,
|
||||
type: $enumDecode(_$ItemTypeEnumMap, json['type'],
|
||||
unknownValue: ItemType.unknown),
|
||||
deeplink: json['deeplink'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$ItemToJson(Item instance) {
|
||||
final val = <String, dynamic>{};
|
||||
|
||||
void writeNotNull(String key, dynamic value) {
|
||||
if (value != null) {
|
||||
val[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
writeNotNull('id', instance.id);
|
||||
val['type'] = _$ItemTypeEnumMap[instance.type]!;
|
||||
writeNotNull('deeplink', instance.deeplink);
|
||||
return val;
|
||||
}
|
||||
|
||||
const _$ItemTypeEnumMap = {
|
||||
ItemType.text: 'text',
|
||||
ItemType.spacer: 'spacer',
|
||||
ItemType.button: 'button',
|
||||
ItemType.unknown: 'unknown',
|
||||
};
|
||||
4
mnemo_cards_common/lib/src/dtos/items/items.dart
Normal file
4
mnemo_cards_common/lib/src/dtos/items/items.dart
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
export 'item.dart';
|
||||
export 'text_item.dart';
|
||||
export 'spacer_item.dart';
|
||||
export 'button_item.dart';
|
||||
27
mnemo_cards_common/lib/src/dtos/items/spacer_item.dart
Normal file
27
mnemo_cards_common/lib/src/dtos/items/spacer_item.dart
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'package:mnemo_cards_common/src/dtos/items/item.dart';
|
||||
|
||||
|
||||
part 'spacer_item.g.dart';
|
||||
|
||||
@JsonSerializable(includeIfNull: false)
|
||||
@CopyWith()
|
||||
class SpacerItem extends Item {
|
||||
final String? id;
|
||||
final int flex;
|
||||
final double height;
|
||||
|
||||
const SpacerItem({
|
||||
this.id,
|
||||
this.flex = 1,
|
||||
this.height = 0,
|
||||
super.type = ItemType.spacer,
|
||||
});
|
||||
|
||||
factory SpacerItem.fromJson(Map<String, dynamic> json) =>
|
||||
_$SpacerItemFromJson(json);
|
||||
|
||||
@override
|
||||
Map<String, Object?> toJson() => _$SpacerItemToJson(this);
|
||||
}
|
||||
126
mnemo_cards_common/lib/src/dtos/items/spacer_item.g.dart
Normal file
126
mnemo_cards_common/lib/src/dtos/items/spacer_item.g.dart
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'spacer_item.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$SpacerItemCWProxy {
|
||||
SpacerItem id(String? id);
|
||||
|
||||
SpacerItem flex(int flex);
|
||||
|
||||
SpacerItem height(double height);
|
||||
|
||||
SpacerItem type(ItemType type);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `SpacerItem(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// SpacerItem(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
SpacerItem call({
|
||||
String? id,
|
||||
int? flex,
|
||||
double? height,
|
||||
ItemType? type,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfSpacerItem.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfSpacerItem.copyWith.fieldName(...)`
|
||||
class _$SpacerItemCWProxyImpl implements _$SpacerItemCWProxy {
|
||||
const _$SpacerItemCWProxyImpl(this._value);
|
||||
|
||||
final SpacerItem _value;
|
||||
|
||||
@override
|
||||
SpacerItem id(String? id) => this(id: id);
|
||||
|
||||
@override
|
||||
SpacerItem flex(int flex) => this(flex: flex);
|
||||
|
||||
@override
|
||||
SpacerItem height(double height) => this(height: height);
|
||||
|
||||
@override
|
||||
SpacerItem type(ItemType type) => this(type: type);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `SpacerItem(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// SpacerItem(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
SpacerItem call({
|
||||
Object? id = const $CopyWithPlaceholder(),
|
||||
Object? flex = const $CopyWithPlaceholder(),
|
||||
Object? height = const $CopyWithPlaceholder(),
|
||||
Object? type = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return SpacerItem(
|
||||
id: id == const $CopyWithPlaceholder()
|
||||
? _value.id
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: id as String?,
|
||||
flex: flex == const $CopyWithPlaceholder() || flex == null
|
||||
? _value.flex
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: flex as int,
|
||||
height: height == const $CopyWithPlaceholder() || height == null
|
||||
? _value.height
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: height as double,
|
||||
type: type == const $CopyWithPlaceholder() || type == null
|
||||
? _value.type
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: type as ItemType,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $SpacerItemCopyWith on SpacerItem {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfSpacerItem.copyWith(...)` or like so:`instanceOfSpacerItem.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$SpacerItemCWProxy get copyWith => _$SpacerItemCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
SpacerItem _$SpacerItemFromJson(Map<String, dynamic> json) => SpacerItem(
|
||||
id: json['id'] as String?,
|
||||
flex: json['flex'] as int? ?? 1,
|
||||
height: (json['height'] as num?)?.toDouble() ?? 0,
|
||||
type: $enumDecodeNullable(_$ItemTypeEnumMap, json['type'],
|
||||
unknownValue: ItemType.unknown) ??
|
||||
ItemType.spacer,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$SpacerItemToJson(SpacerItem instance) {
|
||||
final val = <String, dynamic>{
|
||||
'type': _$ItemTypeEnumMap[instance.type]!,
|
||||
};
|
||||
|
||||
void writeNotNull(String key, dynamic value) {
|
||||
if (value != null) {
|
||||
val[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
writeNotNull('id', instance.id);
|
||||
val['flex'] = instance.flex;
|
||||
val['height'] = instance.height;
|
||||
return val;
|
||||
}
|
||||
|
||||
const _$ItemTypeEnumMap = {
|
||||
ItemType.text: 'text',
|
||||
ItemType.spacer: 'spacer',
|
||||
ItemType.button: 'button',
|
||||
ItemType.unknown: 'unknown',
|
||||
};
|
||||
33
mnemo_cards_common/lib/src/dtos/items/text_item.dart
Normal file
33
mnemo_cards_common/lib/src/dtos/items/text_item.dart
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'package:mnemo_cards_common/src/dtos/items/item.dart';
|
||||
|
||||
|
||||
part 'text_item.g.dart';
|
||||
|
||||
@JsonSerializable(includeIfNull: false)
|
||||
@CopyWith()
|
||||
class TextItem extends Item {
|
||||
final String? id;
|
||||
final String? title;
|
||||
final String? subtitle;
|
||||
final String? color;
|
||||
@JsonKey(defaultValue: false)
|
||||
final bool hasBorder;
|
||||
|
||||
const TextItem({
|
||||
this.id,
|
||||
this.title,
|
||||
this.subtitle,
|
||||
this.color,
|
||||
this.hasBorder = false,
|
||||
super.deeplink,
|
||||
super.type = ItemType.text,
|
||||
});
|
||||
|
||||
factory TextItem.fromJson(Map<String, dynamic> json) =>
|
||||
_$TextItemFromJson(json);
|
||||
|
||||
@override
|
||||
Map<String, Object?> toJson() => _$TextItemToJson(this);
|
||||
}
|
||||
165
mnemo_cards_common/lib/src/dtos/items/text_item.g.dart
Normal file
165
mnemo_cards_common/lib/src/dtos/items/text_item.g.dart
Normal file
|
|
@ -0,0 +1,165 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'text_item.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$TextItemCWProxy {
|
||||
TextItem id(String? id);
|
||||
|
||||
TextItem title(String? title);
|
||||
|
||||
TextItem subtitle(String? subtitle);
|
||||
|
||||
TextItem color(String? color);
|
||||
|
||||
TextItem hasBorder(bool hasBorder);
|
||||
|
||||
TextItem deeplink(String? deeplink);
|
||||
|
||||
TextItem type(ItemType type);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `TextItem(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// TextItem(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
TextItem call({
|
||||
String? id,
|
||||
String? title,
|
||||
String? subtitle,
|
||||
String? color,
|
||||
bool? hasBorder,
|
||||
String? deeplink,
|
||||
ItemType? type,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfTextItem.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfTextItem.copyWith.fieldName(...)`
|
||||
class _$TextItemCWProxyImpl implements _$TextItemCWProxy {
|
||||
const _$TextItemCWProxyImpl(this._value);
|
||||
|
||||
final TextItem _value;
|
||||
|
||||
@override
|
||||
TextItem id(String? id) => this(id: id);
|
||||
|
||||
@override
|
||||
TextItem title(String? title) => this(title: title);
|
||||
|
||||
@override
|
||||
TextItem subtitle(String? subtitle) => this(subtitle: subtitle);
|
||||
|
||||
@override
|
||||
TextItem color(String? color) => this(color: color);
|
||||
|
||||
@override
|
||||
TextItem hasBorder(bool hasBorder) => this(hasBorder: hasBorder);
|
||||
|
||||
@override
|
||||
TextItem deeplink(String? deeplink) => this(deeplink: deeplink);
|
||||
|
||||
@override
|
||||
TextItem type(ItemType type) => this(type: type);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `TextItem(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// TextItem(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
TextItem call({
|
||||
Object? id = const $CopyWithPlaceholder(),
|
||||
Object? title = const $CopyWithPlaceholder(),
|
||||
Object? subtitle = const $CopyWithPlaceholder(),
|
||||
Object? color = const $CopyWithPlaceholder(),
|
||||
Object? hasBorder = const $CopyWithPlaceholder(),
|
||||
Object? deeplink = const $CopyWithPlaceholder(),
|
||||
Object? type = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return TextItem(
|
||||
id: id == const $CopyWithPlaceholder()
|
||||
? _value.id
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: id as String?,
|
||||
title: title == const $CopyWithPlaceholder()
|
||||
? _value.title
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: title as String?,
|
||||
subtitle: subtitle == const $CopyWithPlaceholder()
|
||||
? _value.subtitle
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: subtitle as String?,
|
||||
color: color == const $CopyWithPlaceholder()
|
||||
? _value.color
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: color as String?,
|
||||
hasBorder: hasBorder == const $CopyWithPlaceholder() || hasBorder == null
|
||||
? _value.hasBorder
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: hasBorder as bool,
|
||||
deeplink: deeplink == const $CopyWithPlaceholder()
|
||||
? _value.deeplink
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: deeplink as String?,
|
||||
type: type == const $CopyWithPlaceholder() || type == null
|
||||
? _value.type
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: type as ItemType,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $TextItemCopyWith on TextItem {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfTextItem.copyWith(...)` or like so:`instanceOfTextItem.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$TextItemCWProxy get copyWith => _$TextItemCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
TextItem _$TextItemFromJson(Map<String, dynamic> json) => TextItem(
|
||||
id: json['id'] as String?,
|
||||
title: json['title'] as String?,
|
||||
subtitle: json['subtitle'] as String?,
|
||||
color: json['color'] as String?,
|
||||
hasBorder: json['hasBorder'] as bool? ?? false,
|
||||
deeplink: json['deeplink'] as String?,
|
||||
type: $enumDecodeNullable(_$ItemTypeEnumMap, json['type'],
|
||||
unknownValue: ItemType.unknown) ??
|
||||
ItemType.text,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$TextItemToJson(TextItem instance) {
|
||||
final val = <String, dynamic>{
|
||||
'type': _$ItemTypeEnumMap[instance.type]!,
|
||||
};
|
||||
|
||||
void writeNotNull(String key, dynamic value) {
|
||||
if (value != null) {
|
||||
val[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
writeNotNull('deeplink', instance.deeplink);
|
||||
writeNotNull('id', instance.id);
|
||||
writeNotNull('title', instance.title);
|
||||
writeNotNull('subtitle', instance.subtitle);
|
||||
writeNotNull('color', instance.color);
|
||||
val['hasBorder'] = instance.hasBorder;
|
||||
return val;
|
||||
}
|
||||
|
||||
const _$ItemTypeEnumMap = {
|
||||
ItemType.text: 'text',
|
||||
ItemType.spacer: 'spacer',
|
||||
ItemType.button: 'button',
|
||||
ItemType.unknown: 'unknown',
|
||||
};
|
||||
31
mnemo_cards_common/lib/src/dtos/packs/card_pack_action.dart
Normal file
31
mnemo_cards_common/lib/src/dtos/packs/card_pack_action.dart
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
|
||||
part 'card_pack_action.g.dart';
|
||||
|
||||
/// Actions for cached packs
|
||||
/// Update action
|
||||
@JsonSerializable()
|
||||
@CopyWith()
|
||||
class CardPackAction {
|
||||
final String id;
|
||||
|
||||
@JsonKey(unknownEnumValue: PackAction.unknown)
|
||||
final PackAction action;
|
||||
|
||||
const CardPackAction({
|
||||
required this.id,
|
||||
required this.action,
|
||||
});
|
||||
|
||||
factory CardPackAction.fromJson(Map<String, dynamic> json) =>
|
||||
_$CardPackActionFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$CardPackActionToJson(this);
|
||||
}
|
||||
|
||||
enum PackAction {
|
||||
delete,
|
||||
update,
|
||||
unknown,
|
||||
}
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'card_pack_action.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$CardPackActionCWProxy {
|
||||
CardPackAction id(String id);
|
||||
|
||||
CardPackAction action(PackAction action);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `CardPackAction(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// CardPackAction(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
CardPackAction call({
|
||||
String? id,
|
||||
PackAction? action,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfCardPackAction.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfCardPackAction.copyWith.fieldName(...)`
|
||||
class _$CardPackActionCWProxyImpl implements _$CardPackActionCWProxy {
|
||||
const _$CardPackActionCWProxyImpl(this._value);
|
||||
|
||||
final CardPackAction _value;
|
||||
|
||||
@override
|
||||
CardPackAction id(String id) => this(id: id);
|
||||
|
||||
@override
|
||||
CardPackAction action(PackAction action) => this(action: action);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `CardPackAction(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// CardPackAction(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
CardPackAction call({
|
||||
Object? id = const $CopyWithPlaceholder(),
|
||||
Object? action = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return CardPackAction(
|
||||
id: id == const $CopyWithPlaceholder() || id == null
|
||||
? _value.id
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: id as String,
|
||||
action: action == const $CopyWithPlaceholder() || action == null
|
||||
? _value.action
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: action as PackAction,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $CardPackActionCopyWith on CardPackAction {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfCardPackAction.copyWith(...)` or like so:`instanceOfCardPackAction.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$CardPackActionCWProxy get copyWith => _$CardPackActionCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
CardPackAction _$CardPackActionFromJson(Map<String, dynamic> json) =>
|
||||
CardPackAction(
|
||||
id: json['id'] as String,
|
||||
action: $enumDecode(_$PackActionEnumMap, json['action'],
|
||||
unknownValue: PackAction.unknown),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$CardPackActionToJson(CardPackAction instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'action': _$PackActionEnumMap[instance.action]!,
|
||||
};
|
||||
|
||||
const _$PackActionEnumMap = {
|
||||
PackAction.delete: 'delete',
|
||||
PackAction.update: 'update',
|
||||
PackAction.unknown: 'unknown',
|
||||
};
|
||||
44
mnemo_cards_common/lib/src/dtos/packs/card_pack_buy_dto.dart
Normal file
44
mnemo_cards_common/lib/src/dtos/packs/card_pack_buy_dto.dart
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
|
||||
import '../game_card_dto.dart';
|
||||
import '../items/item.dart';
|
||||
import 'get_card_pack_response.dart';
|
||||
|
||||
part 'card_pack_buy_dto.g.dart';
|
||||
|
||||
/// Info for not available packs
|
||||
@JsonSerializable(explicitToJson: true, includeIfNull: false)
|
||||
@CopyWith()
|
||||
class CardPackBuyDto extends GetCardPackResponse {
|
||||
final String id;
|
||||
final String title;
|
||||
final String subtitle;
|
||||
final String? color;
|
||||
final String? version;
|
||||
final List<GameCardDto> cards;
|
||||
final List<Item>? items;
|
||||
final String? googlePlayId;
|
||||
final String? rustoreId;
|
||||
final String? appStoreId;
|
||||
final String? price;
|
||||
|
||||
const CardPackBuyDto({
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.subtitle,
|
||||
required this.cards,
|
||||
this.items,
|
||||
this.color,
|
||||
this.version,
|
||||
this.price,
|
||||
this.googlePlayId,
|
||||
this.rustoreId,
|
||||
this.appStoreId,
|
||||
}) : super(responseType: GetCardPackResponseType.buy);
|
||||
|
||||
factory CardPackBuyDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$CardPackBuyDtoFromJson(json);
|
||||
|
||||
Map<String, Object?> toJson() => _$CardPackBuyDtoToJson(this);
|
||||
}
|
||||
214
mnemo_cards_common/lib/src/dtos/packs/card_pack_buy_dto.g.dart
Normal file
214
mnemo_cards_common/lib/src/dtos/packs/card_pack_buy_dto.g.dart
Normal file
|
|
@ -0,0 +1,214 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'card_pack_buy_dto.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$CardPackBuyDtoCWProxy {
|
||||
CardPackBuyDto id(String id);
|
||||
|
||||
CardPackBuyDto title(String title);
|
||||
|
||||
CardPackBuyDto subtitle(String subtitle);
|
||||
|
||||
CardPackBuyDto cards(List<GameCardDto> cards);
|
||||
|
||||
CardPackBuyDto items(List<Item>? items);
|
||||
|
||||
CardPackBuyDto color(String? color);
|
||||
|
||||
CardPackBuyDto version(String? version);
|
||||
|
||||
CardPackBuyDto price(String? price);
|
||||
|
||||
CardPackBuyDto googlePlayId(String? googlePlayId);
|
||||
|
||||
CardPackBuyDto rustoreId(String? rustoreId);
|
||||
|
||||
CardPackBuyDto appStoreId(String? appStoreId);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `CardPackBuyDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// CardPackBuyDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
CardPackBuyDto call({
|
||||
String? id,
|
||||
String? title,
|
||||
String? subtitle,
|
||||
List<GameCardDto>? cards,
|
||||
List<Item>? items,
|
||||
String? color,
|
||||
String? version,
|
||||
String? price,
|
||||
String? googlePlayId,
|
||||
String? rustoreId,
|
||||
String? appStoreId,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfCardPackBuyDto.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfCardPackBuyDto.copyWith.fieldName(...)`
|
||||
class _$CardPackBuyDtoCWProxyImpl implements _$CardPackBuyDtoCWProxy {
|
||||
const _$CardPackBuyDtoCWProxyImpl(this._value);
|
||||
|
||||
final CardPackBuyDto _value;
|
||||
|
||||
@override
|
||||
CardPackBuyDto id(String id) => this(id: id);
|
||||
|
||||
@override
|
||||
CardPackBuyDto title(String title) => this(title: title);
|
||||
|
||||
@override
|
||||
CardPackBuyDto subtitle(String subtitle) => this(subtitle: subtitle);
|
||||
|
||||
@override
|
||||
CardPackBuyDto cards(List<GameCardDto> cards) => this(cards: cards);
|
||||
|
||||
@override
|
||||
CardPackBuyDto items(List<Item>? items) => this(items: items);
|
||||
|
||||
@override
|
||||
CardPackBuyDto color(String? color) => this(color: color);
|
||||
|
||||
@override
|
||||
CardPackBuyDto version(String? version) => this(version: version);
|
||||
|
||||
@override
|
||||
CardPackBuyDto price(String? price) => this(price: price);
|
||||
|
||||
@override
|
||||
CardPackBuyDto googlePlayId(String? googlePlayId) =>
|
||||
this(googlePlayId: googlePlayId);
|
||||
|
||||
@override
|
||||
CardPackBuyDto rustoreId(String? rustoreId) => this(rustoreId: rustoreId);
|
||||
|
||||
@override
|
||||
CardPackBuyDto appStoreId(String? appStoreId) => this(appStoreId: appStoreId);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `CardPackBuyDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// CardPackBuyDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
CardPackBuyDto call({
|
||||
Object? id = const $CopyWithPlaceholder(),
|
||||
Object? title = const $CopyWithPlaceholder(),
|
||||
Object? subtitle = const $CopyWithPlaceholder(),
|
||||
Object? cards = const $CopyWithPlaceholder(),
|
||||
Object? items = const $CopyWithPlaceholder(),
|
||||
Object? color = const $CopyWithPlaceholder(),
|
||||
Object? version = const $CopyWithPlaceholder(),
|
||||
Object? price = const $CopyWithPlaceholder(),
|
||||
Object? googlePlayId = const $CopyWithPlaceholder(),
|
||||
Object? rustoreId = const $CopyWithPlaceholder(),
|
||||
Object? appStoreId = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return CardPackBuyDto(
|
||||
id: id == const $CopyWithPlaceholder() || id == null
|
||||
? _value.id
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: id as String,
|
||||
title: title == const $CopyWithPlaceholder() || title == null
|
||||
? _value.title
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: title as String,
|
||||
subtitle: subtitle == const $CopyWithPlaceholder() || subtitle == null
|
||||
? _value.subtitle
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: subtitle as String,
|
||||
cards: cards == const $CopyWithPlaceholder() || cards == null
|
||||
? _value.cards
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: cards as List<GameCardDto>,
|
||||
items: items == const $CopyWithPlaceholder()
|
||||
? _value.items
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: items as List<Item>?,
|
||||
color: color == const $CopyWithPlaceholder()
|
||||
? _value.color
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: color as String?,
|
||||
version: version == const $CopyWithPlaceholder()
|
||||
? _value.version
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: version as String?,
|
||||
price: price == const $CopyWithPlaceholder()
|
||||
? _value.price
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: price as String?,
|
||||
googlePlayId: googlePlayId == const $CopyWithPlaceholder()
|
||||
? _value.googlePlayId
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: googlePlayId as String?,
|
||||
rustoreId: rustoreId == const $CopyWithPlaceholder()
|
||||
? _value.rustoreId
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: rustoreId as String?,
|
||||
appStoreId: appStoreId == const $CopyWithPlaceholder()
|
||||
? _value.appStoreId
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: appStoreId as String?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $CardPackBuyDtoCopyWith on CardPackBuyDto {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfCardPackBuyDto.copyWith(...)` or like so:`instanceOfCardPackBuyDto.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$CardPackBuyDtoCWProxy get copyWith => _$CardPackBuyDtoCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
CardPackBuyDto _$CardPackBuyDtoFromJson(Map<String, dynamic> json) =>
|
||||
CardPackBuyDto(
|
||||
id: json['id'] as String,
|
||||
title: json['title'] as String,
|
||||
subtitle: json['subtitle'] as String,
|
||||
cards: (json['cards'] as List<dynamic>)
|
||||
.map((e) => GameCardDto.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
items: (json['items'] as List<dynamic>?)
|
||||
?.map((e) => Item.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
color: json['color'] as String?,
|
||||
version: json['version'] as String?,
|
||||
price: json['price'] as String?,
|
||||
googlePlayId: json['googlePlayId'] as String?,
|
||||
rustoreId: json['rustoreId'] as String?,
|
||||
appStoreId: json['appStoreId'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$CardPackBuyDtoToJson(CardPackBuyDto instance) {
|
||||
final val = <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'title': instance.title,
|
||||
'subtitle': instance.subtitle,
|
||||
};
|
||||
|
||||
void writeNotNull(String key, dynamic value) {
|
||||
if (value != null) {
|
||||
val[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
writeNotNull('color', instance.color);
|
||||
writeNotNull('version', instance.version);
|
||||
val['cards'] = instance.cards.map((e) => e.toJson()).toList();
|
||||
writeNotNull('items', instance.items?.map((e) => e.toJson()).toList());
|
||||
writeNotNull('googlePlayId', instance.googlePlayId);
|
||||
writeNotNull('rustoreId', instance.rustoreId);
|
||||
writeNotNull('appStoreId', instance.appStoreId);
|
||||
writeNotNull('price', instance.price);
|
||||
return val;
|
||||
}
|
||||
59
mnemo_cards_common/lib/src/dtos/packs/card_pack_dto.dart
Normal file
59
mnemo_cards_common/lib/src/dtos/packs/card_pack_dto.dart
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'package:mnemo_cards_common/src/dtos/packs/get_card_pack_response.dart';
|
||||
|
||||
import '../game_card_dto.dart';
|
||||
import '../payment/export.dart';
|
||||
|
||||
part 'card_pack_dto.g.dart';
|
||||
|
||||
/// Complete info about the pack (except tests)
|
||||
/// Used for available packs
|
||||
@JsonSerializable(explicitToJson: true, includeIfNull: false)
|
||||
@CopyWith()
|
||||
class CardPackDto extends GetCardPackResponse implements MnemoCardsProductDto {
|
||||
final String id;
|
||||
final String title;
|
||||
final String subtitle;
|
||||
final String? color;
|
||||
final String? version;
|
||||
final List<GameCardDto> cards;
|
||||
|
||||
const CardPackDto({
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.subtitle,
|
||||
required this.cards,
|
||||
required this.color,
|
||||
required this.version,
|
||||
}) : super(responseType: GetCardPackResponseType.dto);
|
||||
|
||||
factory CardPackDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$CardPackDtoFromJson(json);
|
||||
|
||||
Map<String, Object?> toJson() => _$CardPackDtoToJson(this);
|
||||
|
||||
@override
|
||||
MnemoCardsProductType get type => MnemoCardsProductType.pack;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is CardPackDto &&
|
||||
runtimeType == other.runtimeType &&
|
||||
id == other.id &&
|
||||
title == other.title &&
|
||||
subtitle == other.subtitle &&
|
||||
color == other.color &&
|
||||
version == other.version &&
|
||||
cards.length == other.cards.length;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
id.hashCode ^
|
||||
title.hashCode ^
|
||||
subtitle.hashCode ^
|
||||
color.hashCode ^
|
||||
version.hashCode ^
|
||||
cards.length.hashCode;
|
||||
}
|
||||
145
mnemo_cards_common/lib/src/dtos/packs/card_pack_dto.g.dart
Normal file
145
mnemo_cards_common/lib/src/dtos/packs/card_pack_dto.g.dart
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'card_pack_dto.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$CardPackDtoCWProxy {
|
||||
CardPackDto id(String id);
|
||||
|
||||
CardPackDto title(String title);
|
||||
|
||||
CardPackDto subtitle(String subtitle);
|
||||
|
||||
CardPackDto cards(List<GameCardDto> cards);
|
||||
|
||||
CardPackDto color(String? color);
|
||||
|
||||
CardPackDto version(String? version);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `CardPackDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// CardPackDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
CardPackDto call({
|
||||
String? id,
|
||||
String? title,
|
||||
String? subtitle,
|
||||
List<GameCardDto>? cards,
|
||||
String? color,
|
||||
String? version,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfCardPackDto.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfCardPackDto.copyWith.fieldName(...)`
|
||||
class _$CardPackDtoCWProxyImpl implements _$CardPackDtoCWProxy {
|
||||
const _$CardPackDtoCWProxyImpl(this._value);
|
||||
|
||||
final CardPackDto _value;
|
||||
|
||||
@override
|
||||
CardPackDto id(String id) => this(id: id);
|
||||
|
||||
@override
|
||||
CardPackDto title(String title) => this(title: title);
|
||||
|
||||
@override
|
||||
CardPackDto subtitle(String subtitle) => this(subtitle: subtitle);
|
||||
|
||||
@override
|
||||
CardPackDto cards(List<GameCardDto> cards) => this(cards: cards);
|
||||
|
||||
@override
|
||||
CardPackDto color(String? color) => this(color: color);
|
||||
|
||||
@override
|
||||
CardPackDto version(String? version) => this(version: version);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `CardPackDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// CardPackDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
CardPackDto call({
|
||||
Object? id = const $CopyWithPlaceholder(),
|
||||
Object? title = const $CopyWithPlaceholder(),
|
||||
Object? subtitle = const $CopyWithPlaceholder(),
|
||||
Object? cards = const $CopyWithPlaceholder(),
|
||||
Object? color = const $CopyWithPlaceholder(),
|
||||
Object? version = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return CardPackDto(
|
||||
id: id == const $CopyWithPlaceholder() || id == null
|
||||
? _value.id
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: id as String,
|
||||
title: title == const $CopyWithPlaceholder() || title == null
|
||||
? _value.title
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: title as String,
|
||||
subtitle: subtitle == const $CopyWithPlaceholder() || subtitle == null
|
||||
? _value.subtitle
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: subtitle as String,
|
||||
cards: cards == const $CopyWithPlaceholder() || cards == null
|
||||
? _value.cards
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: cards as List<GameCardDto>,
|
||||
color: color == const $CopyWithPlaceholder()
|
||||
? _value.color
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: color as String?,
|
||||
version: version == const $CopyWithPlaceholder()
|
||||
? _value.version
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: version as String?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $CardPackDtoCopyWith on CardPackDto {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfCardPackDto.copyWith(...)` or like so:`instanceOfCardPackDto.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$CardPackDtoCWProxy get copyWith => _$CardPackDtoCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
CardPackDto _$CardPackDtoFromJson(Map<String, dynamic> json) => CardPackDto(
|
||||
id: json['id'] as String,
|
||||
title: json['title'] as String,
|
||||
subtitle: json['subtitle'] as String,
|
||||
cards: (json['cards'] as List<dynamic>)
|
||||
.map((e) => GameCardDto.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
color: json['color'] as String?,
|
||||
version: json['version'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$CardPackDtoToJson(CardPackDto instance) {
|
||||
final val = <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'title': instance.title,
|
||||
'subtitle': instance.subtitle,
|
||||
};
|
||||
|
||||
void writeNotNull(String key, dynamic value) {
|
||||
if (value != null) {
|
||||
val[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
writeNotNull('color', instance.color);
|
||||
writeNotNull('version', instance.version);
|
||||
val['cards'] = instance.cards.map((e) => e.toJson()).toList();
|
||||
return val;
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
|
||||
import 'card_pack_preview_dto.dart';
|
||||
import 'get_card_pack_response.dart';
|
||||
|
||||
part 'card_pack_loading_dto.g.dart';
|
||||
|
||||
/// For the main screen
|
||||
@JsonSerializable(explicitToJson: true, includeIfNull: false)
|
||||
@CopyWith()
|
||||
class CardPackLoadingDto extends GetCardPackResponse {
|
||||
final String id;
|
||||
final String? title;
|
||||
final String? subtitle;
|
||||
final String? message;
|
||||
final String? imageId;
|
||||
final String? color;
|
||||
final double? loadingProgress;
|
||||
|
||||
const CardPackLoadingDto({
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.subtitle,
|
||||
required this.message,
|
||||
required this.imageId,
|
||||
required this.color,
|
||||
this.loadingProgress,
|
||||
super.responseType = GetCardPackResponseType.loading,
|
||||
});
|
||||
|
||||
factory CardPackLoadingDto.fromId(String id, {String? message}) =>
|
||||
CardPackLoadingDto(
|
||||
id: id,
|
||||
title: null,
|
||||
subtitle: null,
|
||||
message: message,
|
||||
imageId: null,
|
||||
color: null,
|
||||
);
|
||||
|
||||
factory CardPackLoadingDto.fromPreviewDto(CardPackPreviewDto dto) =>
|
||||
CardPackLoadingDto(
|
||||
id: dto.id,
|
||||
title: dto.title,
|
||||
subtitle: dto.subtitle,
|
||||
message: 'Загрузка...',
|
||||
imageId: 'pack_${dto.id}',
|
||||
color: dto.color,
|
||||
);
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => hashCode == other.hashCode;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hashAll([
|
||||
id,
|
||||
title,
|
||||
subtitle,
|
||||
message,
|
||||
imageId,
|
||||
color,
|
||||
loadingProgress,
|
||||
responseType,
|
||||
]);
|
||||
|
||||
factory CardPackLoadingDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$CardPackLoadingDtoFromJson(json);
|
||||
|
||||
Map<String, Object?> toJson() => _$CardPackLoadingDtoToJson(this);
|
||||
}
|
||||
|
|
@ -0,0 +1,185 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'card_pack_loading_dto.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$CardPackLoadingDtoCWProxy {
|
||||
CardPackLoadingDto id(String id);
|
||||
|
||||
CardPackLoadingDto title(String? title);
|
||||
|
||||
CardPackLoadingDto subtitle(String? subtitle);
|
||||
|
||||
CardPackLoadingDto message(String? message);
|
||||
|
||||
CardPackLoadingDto imageId(String? imageId);
|
||||
|
||||
CardPackLoadingDto color(String? color);
|
||||
|
||||
CardPackLoadingDto loadingProgress(double? loadingProgress);
|
||||
|
||||
CardPackLoadingDto responseType(GetCardPackResponseType responseType);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `CardPackLoadingDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// CardPackLoadingDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
CardPackLoadingDto call({
|
||||
String? id,
|
||||
String? title,
|
||||
String? subtitle,
|
||||
String? message,
|
||||
String? imageId,
|
||||
String? color,
|
||||
double? loadingProgress,
|
||||
GetCardPackResponseType? responseType,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfCardPackLoadingDto.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfCardPackLoadingDto.copyWith.fieldName(...)`
|
||||
class _$CardPackLoadingDtoCWProxyImpl implements _$CardPackLoadingDtoCWProxy {
|
||||
const _$CardPackLoadingDtoCWProxyImpl(this._value);
|
||||
|
||||
final CardPackLoadingDto _value;
|
||||
|
||||
@override
|
||||
CardPackLoadingDto id(String id) => this(id: id);
|
||||
|
||||
@override
|
||||
CardPackLoadingDto title(String? title) => this(title: title);
|
||||
|
||||
@override
|
||||
CardPackLoadingDto subtitle(String? subtitle) => this(subtitle: subtitle);
|
||||
|
||||
@override
|
||||
CardPackLoadingDto message(String? message) => this(message: message);
|
||||
|
||||
@override
|
||||
CardPackLoadingDto imageId(String? imageId) => this(imageId: imageId);
|
||||
|
||||
@override
|
||||
CardPackLoadingDto color(String? color) => this(color: color);
|
||||
|
||||
@override
|
||||
CardPackLoadingDto loadingProgress(double? loadingProgress) =>
|
||||
this(loadingProgress: loadingProgress);
|
||||
|
||||
@override
|
||||
CardPackLoadingDto responseType(GetCardPackResponseType responseType) =>
|
||||
this(responseType: responseType);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `CardPackLoadingDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// CardPackLoadingDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
CardPackLoadingDto call({
|
||||
Object? id = const $CopyWithPlaceholder(),
|
||||
Object? title = const $CopyWithPlaceholder(),
|
||||
Object? subtitle = const $CopyWithPlaceholder(),
|
||||
Object? message = const $CopyWithPlaceholder(),
|
||||
Object? imageId = const $CopyWithPlaceholder(),
|
||||
Object? color = const $CopyWithPlaceholder(),
|
||||
Object? loadingProgress = const $CopyWithPlaceholder(),
|
||||
Object? responseType = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return CardPackLoadingDto(
|
||||
id: id == const $CopyWithPlaceholder() || id == null
|
||||
? _value.id
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: id as String,
|
||||
title: title == const $CopyWithPlaceholder()
|
||||
? _value.title
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: title as String?,
|
||||
subtitle: subtitle == const $CopyWithPlaceholder()
|
||||
? _value.subtitle
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: subtitle as String?,
|
||||
message: message == const $CopyWithPlaceholder()
|
||||
? _value.message
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: message as String?,
|
||||
imageId: imageId == const $CopyWithPlaceholder()
|
||||
? _value.imageId
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: imageId as String?,
|
||||
color: color == const $CopyWithPlaceholder()
|
||||
? _value.color
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: color as String?,
|
||||
loadingProgress: loadingProgress == const $CopyWithPlaceholder()
|
||||
? _value.loadingProgress
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: loadingProgress as double?,
|
||||
responseType:
|
||||
responseType == const $CopyWithPlaceholder() || responseType == null
|
||||
? _value.responseType
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: responseType as GetCardPackResponseType,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $CardPackLoadingDtoCopyWith on CardPackLoadingDto {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfCardPackLoadingDto.copyWith(...)` or like so:`instanceOfCardPackLoadingDto.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$CardPackLoadingDtoCWProxy get copyWith =>
|
||||
_$CardPackLoadingDtoCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
CardPackLoadingDto _$CardPackLoadingDtoFromJson(Map<String, dynamic> json) =>
|
||||
CardPackLoadingDto(
|
||||
id: json['id'] as String,
|
||||
title: json['title'] as String?,
|
||||
subtitle: json['subtitle'] as String?,
|
||||
message: json['message'] as String?,
|
||||
imageId: json['imageId'] as String?,
|
||||
color: json['color'] as String?,
|
||||
loadingProgress: (json['loadingProgress'] as num?)?.toDouble(),
|
||||
responseType: $enumDecodeNullable(
|
||||
_$GetCardPackResponseTypeEnumMap, json['responseType'],
|
||||
unknownValue: GetCardPackResponseType.unknown) ??
|
||||
GetCardPackResponseType.loading,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$CardPackLoadingDtoToJson(CardPackLoadingDto instance) {
|
||||
final val = <String, dynamic>{
|
||||
'responseType': _$GetCardPackResponseTypeEnumMap[instance.responseType]!,
|
||||
'id': instance.id,
|
||||
};
|
||||
|
||||
void writeNotNull(String key, dynamic value) {
|
||||
if (value != null) {
|
||||
val[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
writeNotNull('title', instance.title);
|
||||
writeNotNull('subtitle', instance.subtitle);
|
||||
writeNotNull('message', instance.message);
|
||||
writeNotNull('imageId', instance.imageId);
|
||||
writeNotNull('color', instance.color);
|
||||
writeNotNull('loadingProgress', instance.loadingProgress);
|
||||
return val;
|
||||
}
|
||||
|
||||
const _$GetCardPackResponseTypeEnumMap = {
|
||||
GetCardPackResponseType.buy: 'buy',
|
||||
GetCardPackResponseType.dto: 'dto',
|
||||
GetCardPackResponseType.edit: 'edit',
|
||||
GetCardPackResponseType.loading: 'loading',
|
||||
GetCardPackResponseType.unknown: 'unknown',
|
||||
};
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:mnemo_cards_common/mnemo_cards_common.dart';
|
||||
|
||||
import 'pack_tip.dart';
|
||||
|
||||
|
||||
part 'card_pack_preview_dto.g.dart';
|
||||
|
||||
/// For the main screen
|
||||
@JsonSerializable(explicitToJson: true, includeIfNull: false)
|
||||
@CopyWith()
|
||||
class CardPackPreviewDto
|
||||
implements MnemoCardsProductDto {
|
||||
final String id;
|
||||
final String title;
|
||||
final String? subtitle;
|
||||
final int? cards;
|
||||
final int? tests;
|
||||
final String? price;
|
||||
final String? imageBase64;
|
||||
final String? color;
|
||||
@JsonKey(defaultValue: false)
|
||||
final bool isAvailable;
|
||||
final PackTip? tip;
|
||||
final String? version;
|
||||
|
||||
const CardPackPreviewDto({
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.subtitle,
|
||||
required this.cards,
|
||||
required this.tests,
|
||||
required this.price,
|
||||
required this.imageBase64,
|
||||
required this.color,
|
||||
required this.isAvailable,
|
||||
required this.tip,
|
||||
required this.version,
|
||||
});
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => hashCode == other.hashCode;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hashAll([
|
||||
id,
|
||||
title,
|
||||
subtitle,
|
||||
cards,
|
||||
tests,
|
||||
price,
|
||||
imageBase64,
|
||||
color,
|
||||
isAvailable,
|
||||
version,
|
||||
tip,
|
||||
]);
|
||||
|
||||
factory CardPackPreviewDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$CardPackPreviewDtoFromJson(json);
|
||||
|
||||
Map<String, Object?> toJson() => _$CardPackPreviewDtoToJson(this);
|
||||
|
||||
@override
|
||||
MnemoCardsProductType get type => MnemoCardsProductType.pack;
|
||||
}
|
||||
|
|
@ -0,0 +1,215 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'card_pack_preview_dto.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$CardPackPreviewDtoCWProxy {
|
||||
CardPackPreviewDto id(String id);
|
||||
|
||||
CardPackPreviewDto title(String title);
|
||||
|
||||
CardPackPreviewDto subtitle(String? subtitle);
|
||||
|
||||
CardPackPreviewDto cards(int? cards);
|
||||
|
||||
CardPackPreviewDto tests(int? tests);
|
||||
|
||||
CardPackPreviewDto price(String? price);
|
||||
|
||||
CardPackPreviewDto imageBase64(String? imageBase64);
|
||||
|
||||
CardPackPreviewDto color(String? color);
|
||||
|
||||
CardPackPreviewDto isAvailable(bool isAvailable);
|
||||
|
||||
CardPackPreviewDto tip(PackTip? tip);
|
||||
|
||||
CardPackPreviewDto version(String? version);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `CardPackPreviewDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// CardPackPreviewDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
CardPackPreviewDto call({
|
||||
String? id,
|
||||
String? title,
|
||||
String? subtitle,
|
||||
int? cards,
|
||||
int? tests,
|
||||
String? price,
|
||||
String? imageBase64,
|
||||
String? color,
|
||||
bool? isAvailable,
|
||||
PackTip? tip,
|
||||
String? version,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfCardPackPreviewDto.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfCardPackPreviewDto.copyWith.fieldName(...)`
|
||||
class _$CardPackPreviewDtoCWProxyImpl implements _$CardPackPreviewDtoCWProxy {
|
||||
const _$CardPackPreviewDtoCWProxyImpl(this._value);
|
||||
|
||||
final CardPackPreviewDto _value;
|
||||
|
||||
@override
|
||||
CardPackPreviewDto id(String id) => this(id: id);
|
||||
|
||||
@override
|
||||
CardPackPreviewDto title(String title) => this(title: title);
|
||||
|
||||
@override
|
||||
CardPackPreviewDto subtitle(String? subtitle) => this(subtitle: subtitle);
|
||||
|
||||
@override
|
||||
CardPackPreviewDto cards(int? cards) => this(cards: cards);
|
||||
|
||||
@override
|
||||
CardPackPreviewDto tests(int? tests) => this(tests: tests);
|
||||
|
||||
@override
|
||||
CardPackPreviewDto price(String? price) => this(price: price);
|
||||
|
||||
@override
|
||||
CardPackPreviewDto imageBase64(String? imageBase64) =>
|
||||
this(imageBase64: imageBase64);
|
||||
|
||||
@override
|
||||
CardPackPreviewDto color(String? color) => this(color: color);
|
||||
|
||||
@override
|
||||
CardPackPreviewDto isAvailable(bool isAvailable) =>
|
||||
this(isAvailable: isAvailable);
|
||||
|
||||
@override
|
||||
CardPackPreviewDto tip(PackTip? tip) => this(tip: tip);
|
||||
|
||||
@override
|
||||
CardPackPreviewDto version(String? version) => this(version: version);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `CardPackPreviewDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// CardPackPreviewDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
CardPackPreviewDto call({
|
||||
Object? id = const $CopyWithPlaceholder(),
|
||||
Object? title = const $CopyWithPlaceholder(),
|
||||
Object? subtitle = const $CopyWithPlaceholder(),
|
||||
Object? cards = const $CopyWithPlaceholder(),
|
||||
Object? tests = const $CopyWithPlaceholder(),
|
||||
Object? price = const $CopyWithPlaceholder(),
|
||||
Object? imageBase64 = const $CopyWithPlaceholder(),
|
||||
Object? color = const $CopyWithPlaceholder(),
|
||||
Object? isAvailable = const $CopyWithPlaceholder(),
|
||||
Object? tip = const $CopyWithPlaceholder(),
|
||||
Object? version = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return CardPackPreviewDto(
|
||||
id: id == const $CopyWithPlaceholder() || id == null
|
||||
? _value.id
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: id as String,
|
||||
title: title == const $CopyWithPlaceholder() || title == null
|
||||
? _value.title
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: title as String,
|
||||
subtitle: subtitle == const $CopyWithPlaceholder()
|
||||
? _value.subtitle
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: subtitle as String?,
|
||||
cards: cards == const $CopyWithPlaceholder()
|
||||
? _value.cards
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: cards as int?,
|
||||
tests: tests == const $CopyWithPlaceholder()
|
||||
? _value.tests
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: tests as int?,
|
||||
price: price == const $CopyWithPlaceholder()
|
||||
? _value.price
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: price as String?,
|
||||
imageBase64: imageBase64 == const $CopyWithPlaceholder()
|
||||
? _value.imageBase64
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: imageBase64 as String?,
|
||||
color: color == const $CopyWithPlaceholder()
|
||||
? _value.color
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: color as String?,
|
||||
isAvailable:
|
||||
isAvailable == const $CopyWithPlaceholder() || isAvailable == null
|
||||
? _value.isAvailable
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: isAvailable as bool,
|
||||
tip: tip == const $CopyWithPlaceholder()
|
||||
? _value.tip
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: tip as PackTip?,
|
||||
version: version == const $CopyWithPlaceholder()
|
||||
? _value.version
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: version as String?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $CardPackPreviewDtoCopyWith on CardPackPreviewDto {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfCardPackPreviewDto.copyWith(...)` or like so:`instanceOfCardPackPreviewDto.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$CardPackPreviewDtoCWProxy get copyWith =>
|
||||
_$CardPackPreviewDtoCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
CardPackPreviewDto _$CardPackPreviewDtoFromJson(Map<String, dynamic> json) =>
|
||||
CardPackPreviewDto(
|
||||
id: json['id'] as String,
|
||||
title: json['title'] as String,
|
||||
subtitle: json['subtitle'] as String?,
|
||||
cards: json['cards'] as int?,
|
||||
tests: json['tests'] as int?,
|
||||
price: json['price'] as String?,
|
||||
imageBase64: json['imageBase64'] as String?,
|
||||
color: json['color'] as String?,
|
||||
isAvailable: json['isAvailable'] as bool? ?? false,
|
||||
tip: json['tip'] == null
|
||||
? null
|
||||
: PackTip.fromJson(json['tip'] as Map<String, dynamic>),
|
||||
version: json['version'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$CardPackPreviewDtoToJson(CardPackPreviewDto instance) {
|
||||
final val = <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'title': instance.title,
|
||||
};
|
||||
|
||||
void writeNotNull(String key, dynamic value) {
|
||||
if (value != null) {
|
||||
val[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
writeNotNull('subtitle', instance.subtitle);
|
||||
writeNotNull('cards', instance.cards);
|
||||
writeNotNull('tests', instance.tests);
|
||||
writeNotNull('price', instance.price);
|
||||
writeNotNull('imageBase64', instance.imageBase64);
|
||||
writeNotNull('color', instance.color);
|
||||
val['isAvailable'] = instance.isAvailable;
|
||||
writeNotNull('tip', instance.tip?.toJson());
|
||||
writeNotNull('version', instance.version);
|
||||
return val;
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'package:mnemo_cards_common/src/dtos/packs/get_card_pack_response.dart';
|
||||
|
||||
part 'edit_card_pack_dto.g.dart';
|
||||
|
||||
/// Complete info about the pack (except tests)
|
||||
/// Used for available packs
|
||||
@JsonSerializable(explicitToJson: true, includeIfNull: false)
|
||||
@CopyWith()
|
||||
class EditCardPackDto extends GetCardPackResponse {
|
||||
final String? id;
|
||||
final String? title;
|
||||
final String? subtitle;
|
||||
final String? color;
|
||||
final String? cover;
|
||||
final int? size;
|
||||
final String? googlePlayId;
|
||||
final String? rustoreId;
|
||||
final String? appStoreId;
|
||||
final String? price;
|
||||
final String? description;
|
||||
final bool? enabled;
|
||||
final String? version;
|
||||
final List<String>? addCardIds;
|
||||
final List<String>? addTestIds;
|
||||
final List<String>? removeCardIds;
|
||||
final List<String>? removeTestIds;
|
||||
final List<int>? cardsOrder;
|
||||
final int? order;
|
||||
|
||||
final List<String>? previewCards;
|
||||
|
||||
const EditCardPackDto({
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.subtitle,
|
||||
required this.color,
|
||||
required this.cover,
|
||||
required this.size,
|
||||
required this.googlePlayId,
|
||||
required this.rustoreId,
|
||||
required this.appStoreId,
|
||||
required this.price,
|
||||
required this.description,
|
||||
required this.enabled,
|
||||
required this.addCardIds,
|
||||
required this.addTestIds,
|
||||
required this.removeCardIds,
|
||||
required this.removeTestIds,
|
||||
required this.previewCards,
|
||||
required this.version,
|
||||
required this.order,
|
||||
required this.cardsOrder,
|
||||
}) : super(responseType: GetCardPackResponseType.edit);
|
||||
|
||||
factory EditCardPackDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$EditCardPackDtoFromJson(json);
|
||||
|
||||
Map<String, Object?> toJson() => _$EditCardPackDtoToJson(this);
|
||||
}
|
||||
345
mnemo_cards_common/lib/src/dtos/packs/edit_card_pack_dto.g.dart
Normal file
345
mnemo_cards_common/lib/src/dtos/packs/edit_card_pack_dto.g.dart
Normal file
|
|
@ -0,0 +1,345 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'edit_card_pack_dto.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$EditCardPackDtoCWProxy {
|
||||
EditCardPackDto id(String? id);
|
||||
|
||||
EditCardPackDto title(String? title);
|
||||
|
||||
EditCardPackDto subtitle(String? subtitle);
|
||||
|
||||
EditCardPackDto color(String? color);
|
||||
|
||||
EditCardPackDto cover(String? cover);
|
||||
|
||||
EditCardPackDto size(int? size);
|
||||
|
||||
EditCardPackDto googlePlayId(String? googlePlayId);
|
||||
|
||||
EditCardPackDto rustoreId(String? rustoreId);
|
||||
|
||||
EditCardPackDto appStoreId(String? appStoreId);
|
||||
|
||||
EditCardPackDto price(String? price);
|
||||
|
||||
EditCardPackDto description(String? description);
|
||||
|
||||
EditCardPackDto enabled(bool? enabled);
|
||||
|
||||
EditCardPackDto addCardIds(List<String>? addCardIds);
|
||||
|
||||
EditCardPackDto addTestIds(List<String>? addTestIds);
|
||||
|
||||
EditCardPackDto removeCardIds(List<String>? removeCardIds);
|
||||
|
||||
EditCardPackDto removeTestIds(List<String>? removeTestIds);
|
||||
|
||||
EditCardPackDto previewCards(List<String>? previewCards);
|
||||
|
||||
EditCardPackDto version(String? version);
|
||||
|
||||
EditCardPackDto order(int? order);
|
||||
|
||||
EditCardPackDto cardsOrder(List<int>? cardsOrder);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `EditCardPackDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// EditCardPackDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
EditCardPackDto call({
|
||||
String? id,
|
||||
String? title,
|
||||
String? subtitle,
|
||||
String? color,
|
||||
String? cover,
|
||||
int? size,
|
||||
String? googlePlayId,
|
||||
String? rustoreId,
|
||||
String? appStoreId,
|
||||
String? price,
|
||||
String? description,
|
||||
bool? enabled,
|
||||
List<String>? addCardIds,
|
||||
List<String>? addTestIds,
|
||||
List<String>? removeCardIds,
|
||||
List<String>? removeTestIds,
|
||||
List<String>? previewCards,
|
||||
String? version,
|
||||
int? order,
|
||||
List<int>? cardsOrder,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfEditCardPackDto.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfEditCardPackDto.copyWith.fieldName(...)`
|
||||
class _$EditCardPackDtoCWProxyImpl implements _$EditCardPackDtoCWProxy {
|
||||
const _$EditCardPackDtoCWProxyImpl(this._value);
|
||||
|
||||
final EditCardPackDto _value;
|
||||
|
||||
@override
|
||||
EditCardPackDto id(String? id) => this(id: id);
|
||||
|
||||
@override
|
||||
EditCardPackDto title(String? title) => this(title: title);
|
||||
|
||||
@override
|
||||
EditCardPackDto subtitle(String? subtitle) => this(subtitle: subtitle);
|
||||
|
||||
@override
|
||||
EditCardPackDto color(String? color) => this(color: color);
|
||||
|
||||
@override
|
||||
EditCardPackDto cover(String? cover) => this(cover: cover);
|
||||
|
||||
@override
|
||||
EditCardPackDto size(int? size) => this(size: size);
|
||||
|
||||
@override
|
||||
EditCardPackDto googlePlayId(String? googlePlayId) =>
|
||||
this(googlePlayId: googlePlayId);
|
||||
|
||||
@override
|
||||
EditCardPackDto rustoreId(String? rustoreId) => this(rustoreId: rustoreId);
|
||||
|
||||
@override
|
||||
EditCardPackDto appStoreId(String? appStoreId) =>
|
||||
this(appStoreId: appStoreId);
|
||||
|
||||
@override
|
||||
EditCardPackDto price(String? price) => this(price: price);
|
||||
|
||||
@override
|
||||
EditCardPackDto description(String? description) =>
|
||||
this(description: description);
|
||||
|
||||
@override
|
||||
EditCardPackDto enabled(bool? enabled) => this(enabled: enabled);
|
||||
|
||||
@override
|
||||
EditCardPackDto addCardIds(List<String>? addCardIds) =>
|
||||
this(addCardIds: addCardIds);
|
||||
|
||||
@override
|
||||
EditCardPackDto addTestIds(List<String>? addTestIds) =>
|
||||
this(addTestIds: addTestIds);
|
||||
|
||||
@override
|
||||
EditCardPackDto removeCardIds(List<String>? removeCardIds) =>
|
||||
this(removeCardIds: removeCardIds);
|
||||
|
||||
@override
|
||||
EditCardPackDto removeTestIds(List<String>? removeTestIds) =>
|
||||
this(removeTestIds: removeTestIds);
|
||||
|
||||
@override
|
||||
EditCardPackDto previewCards(List<String>? previewCards) =>
|
||||
this(previewCards: previewCards);
|
||||
|
||||
@override
|
||||
EditCardPackDto version(String? version) => this(version: version);
|
||||
|
||||
@override
|
||||
EditCardPackDto order(int? order) => this(order: order);
|
||||
|
||||
@override
|
||||
EditCardPackDto cardsOrder(List<int>? cardsOrder) =>
|
||||
this(cardsOrder: cardsOrder);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `EditCardPackDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// EditCardPackDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
EditCardPackDto call({
|
||||
Object? id = const $CopyWithPlaceholder(),
|
||||
Object? title = const $CopyWithPlaceholder(),
|
||||
Object? subtitle = const $CopyWithPlaceholder(),
|
||||
Object? color = const $CopyWithPlaceholder(),
|
||||
Object? cover = const $CopyWithPlaceholder(),
|
||||
Object? size = const $CopyWithPlaceholder(),
|
||||
Object? googlePlayId = const $CopyWithPlaceholder(),
|
||||
Object? rustoreId = const $CopyWithPlaceholder(),
|
||||
Object? appStoreId = const $CopyWithPlaceholder(),
|
||||
Object? price = const $CopyWithPlaceholder(),
|
||||
Object? description = const $CopyWithPlaceholder(),
|
||||
Object? enabled = const $CopyWithPlaceholder(),
|
||||
Object? addCardIds = const $CopyWithPlaceholder(),
|
||||
Object? addTestIds = const $CopyWithPlaceholder(),
|
||||
Object? removeCardIds = const $CopyWithPlaceholder(),
|
||||
Object? removeTestIds = const $CopyWithPlaceholder(),
|
||||
Object? previewCards = const $CopyWithPlaceholder(),
|
||||
Object? version = const $CopyWithPlaceholder(),
|
||||
Object? order = const $CopyWithPlaceholder(),
|
||||
Object? cardsOrder = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return EditCardPackDto(
|
||||
id: id == const $CopyWithPlaceholder()
|
||||
? _value.id
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: id as String?,
|
||||
title: title == const $CopyWithPlaceholder()
|
||||
? _value.title
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: title as String?,
|
||||
subtitle: subtitle == const $CopyWithPlaceholder()
|
||||
? _value.subtitle
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: subtitle as String?,
|
||||
color: color == const $CopyWithPlaceholder()
|
||||
? _value.color
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: color as String?,
|
||||
cover: cover == const $CopyWithPlaceholder()
|
||||
? _value.cover
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: cover as String?,
|
||||
size: size == const $CopyWithPlaceholder()
|
||||
? _value.size
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: size as int?,
|
||||
googlePlayId: googlePlayId == const $CopyWithPlaceholder()
|
||||
? _value.googlePlayId
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: googlePlayId as String?,
|
||||
rustoreId: rustoreId == const $CopyWithPlaceholder()
|
||||
? _value.rustoreId
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: rustoreId as String?,
|
||||
appStoreId: appStoreId == const $CopyWithPlaceholder()
|
||||
? _value.appStoreId
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: appStoreId as String?,
|
||||
price: price == const $CopyWithPlaceholder()
|
||||
? _value.price
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: price as String?,
|
||||
description: description == const $CopyWithPlaceholder()
|
||||
? _value.description
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: description as String?,
|
||||
enabled: enabled == const $CopyWithPlaceholder()
|
||||
? _value.enabled
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: enabled as bool?,
|
||||
addCardIds: addCardIds == const $CopyWithPlaceholder()
|
||||
? _value.addCardIds
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: addCardIds as List<String>?,
|
||||
addTestIds: addTestIds == const $CopyWithPlaceholder()
|
||||
? _value.addTestIds
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: addTestIds as List<String>?,
|
||||
removeCardIds: removeCardIds == const $CopyWithPlaceholder()
|
||||
? _value.removeCardIds
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: removeCardIds as List<String>?,
|
||||
removeTestIds: removeTestIds == const $CopyWithPlaceholder()
|
||||
? _value.removeTestIds
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: removeTestIds as List<String>?,
|
||||
previewCards: previewCards == const $CopyWithPlaceholder()
|
||||
? _value.previewCards
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: previewCards as List<String>?,
|
||||
version: version == const $CopyWithPlaceholder()
|
||||
? _value.version
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: version as String?,
|
||||
order: order == const $CopyWithPlaceholder()
|
||||
? _value.order
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: order as int?,
|
||||
cardsOrder: cardsOrder == const $CopyWithPlaceholder()
|
||||
? _value.cardsOrder
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: cardsOrder as List<int>?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $EditCardPackDtoCopyWith on EditCardPackDto {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfEditCardPackDto.copyWith(...)` or like so:`instanceOfEditCardPackDto.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$EditCardPackDtoCWProxy get copyWith => _$EditCardPackDtoCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
EditCardPackDto _$EditCardPackDtoFromJson(Map<String, dynamic> json) =>
|
||||
EditCardPackDto(
|
||||
id: json['id'] as String?,
|
||||
title: json['title'] as String?,
|
||||
subtitle: json['subtitle'] as String?,
|
||||
color: json['color'] as String?,
|
||||
cover: json['cover'] as String?,
|
||||
size: json['size'] as int?,
|
||||
googlePlayId: json['googlePlayId'] as String?,
|
||||
rustoreId: json['rustoreId'] as String?,
|
||||
appStoreId: json['appStoreId'] as String?,
|
||||
price: json['price'] as String?,
|
||||
description: json['description'] as String?,
|
||||
enabled: json['enabled'] as bool?,
|
||||
addCardIds: (json['addCardIds'] as List<dynamic>?)
|
||||
?.map((e) => e as String)
|
||||
.toList(),
|
||||
addTestIds: (json['addTestIds'] as List<dynamic>?)
|
||||
?.map((e) => e as String)
|
||||
.toList(),
|
||||
removeCardIds: (json['removeCardIds'] as List<dynamic>?)
|
||||
?.map((e) => e as String)
|
||||
.toList(),
|
||||
removeTestIds: (json['removeTestIds'] as List<dynamic>?)
|
||||
?.map((e) => e as String)
|
||||
.toList(),
|
||||
previewCards: (json['previewCards'] as List<dynamic>?)
|
||||
?.map((e) => e as String)
|
||||
.toList(),
|
||||
version: json['version'] as String?,
|
||||
order: json['order'] as int?,
|
||||
cardsOrder:
|
||||
(json['cardsOrder'] as List<dynamic>?)?.map((e) => e as int).toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$EditCardPackDtoToJson(EditCardPackDto instance) {
|
||||
final val = <String, dynamic>{};
|
||||
|
||||
void writeNotNull(String key, dynamic value) {
|
||||
if (value != null) {
|
||||
val[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
writeNotNull('id', instance.id);
|
||||
writeNotNull('title', instance.title);
|
||||
writeNotNull('subtitle', instance.subtitle);
|
||||
writeNotNull('color', instance.color);
|
||||
writeNotNull('cover', instance.cover);
|
||||
writeNotNull('size', instance.size);
|
||||
writeNotNull('googlePlayId', instance.googlePlayId);
|
||||
writeNotNull('rustoreId', instance.rustoreId);
|
||||
writeNotNull('appStoreId', instance.appStoreId);
|
||||
writeNotNull('price', instance.price);
|
||||
writeNotNull('description', instance.description);
|
||||
writeNotNull('enabled', instance.enabled);
|
||||
writeNotNull('version', instance.version);
|
||||
writeNotNull('addCardIds', instance.addCardIds);
|
||||
writeNotNull('addTestIds', instance.addTestIds);
|
||||
writeNotNull('removeCardIds', instance.removeCardIds);
|
||||
writeNotNull('removeTestIds', instance.removeTestIds);
|
||||
writeNotNull('cardsOrder', instance.cardsOrder);
|
||||
writeNotNull('order', instance.order);
|
||||
writeNotNull('previewCards', instance.previewCards);
|
||||
return val;
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'package:mnemo_cards_common/src/dtos/packs/card_pack_buy_dto.dart';
|
||||
import 'package:mnemo_cards_common/src/dtos/packs/edit_card_pack_dto.dart';
|
||||
|
||||
import 'card_pack_dto.dart';
|
||||
import 'card_pack_loading_dto.dart';
|
||||
|
||||
part 'get_card_pack_response.g.dart';
|
||||
|
||||
/// Actions for cached packs
|
||||
/// Update action
|
||||
@JsonSerializable()
|
||||
@CopyWith()
|
||||
class GetCardPackResponse {
|
||||
@JsonKey(unknownEnumValue: GetCardPackResponseType.unknown)
|
||||
final GetCardPackResponseType responseType;
|
||||
|
||||
String? get id => null;
|
||||
|
||||
const GetCardPackResponse({
|
||||
required this.responseType,
|
||||
});
|
||||
|
||||
factory GetCardPackResponse.fromJson(Map<String, dynamic> json) {
|
||||
final response = _$GetCardPackResponseFromJson(json);
|
||||
switch (response.responseType) {
|
||||
case GetCardPackResponseType.buy:
|
||||
return CardPackBuyDto.fromJson(json);
|
||||
case GetCardPackResponseType.dto:
|
||||
return CardPackDto.fromJson(json);
|
||||
case GetCardPackResponseType.edit:
|
||||
return EditCardPackDto.fromJson(json);
|
||||
case GetCardPackResponseType.loading:
|
||||
return CardPackLoadingDto.fromJson(json);
|
||||
case GetCardPackResponseType.unknown:
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => _$GetCardPackResponseToJson(this);
|
||||
}
|
||||
|
||||
enum GetCardPackResponseType {
|
||||
buy,
|
||||
dto,
|
||||
edit,
|
||||
loading,
|
||||
unknown,
|
||||
}
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'get_card_pack_response.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$GetCardPackResponseCWProxy {
|
||||
GetCardPackResponse responseType(GetCardPackResponseType responseType);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `GetCardPackResponse(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// GetCardPackResponse(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
GetCardPackResponse call({
|
||||
GetCardPackResponseType? responseType,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfGetCardPackResponse.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfGetCardPackResponse.copyWith.fieldName(...)`
|
||||
class _$GetCardPackResponseCWProxyImpl implements _$GetCardPackResponseCWProxy {
|
||||
const _$GetCardPackResponseCWProxyImpl(this._value);
|
||||
|
||||
final GetCardPackResponse _value;
|
||||
|
||||
@override
|
||||
GetCardPackResponse responseType(GetCardPackResponseType responseType) =>
|
||||
this(responseType: responseType);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `GetCardPackResponse(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// GetCardPackResponse(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
GetCardPackResponse call({
|
||||
Object? responseType = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return GetCardPackResponse(
|
||||
responseType:
|
||||
responseType == const $CopyWithPlaceholder() || responseType == null
|
||||
? _value.responseType
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: responseType as GetCardPackResponseType,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $GetCardPackResponseCopyWith on GetCardPackResponse {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfGetCardPackResponse.copyWith(...)` or like so:`instanceOfGetCardPackResponse.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$GetCardPackResponseCWProxy get copyWith =>
|
||||
_$GetCardPackResponseCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
GetCardPackResponse _$GetCardPackResponseFromJson(Map<String, dynamic> json) =>
|
||||
GetCardPackResponse(
|
||||
responseType: $enumDecode(
|
||||
_$GetCardPackResponseTypeEnumMap, json['responseType'],
|
||||
unknownValue: GetCardPackResponseType.unknown),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GetCardPackResponseToJson(
|
||||
GetCardPackResponse instance) =>
|
||||
<String, dynamic>{
|
||||
'responseType': _$GetCardPackResponseTypeEnumMap[instance.responseType]!,
|
||||
};
|
||||
|
||||
const _$GetCardPackResponseTypeEnumMap = {
|
||||
GetCardPackResponseType.buy: 'buy',
|
||||
GetCardPackResponseType.dto: 'dto',
|
||||
GetCardPackResponseType.edit: 'edit',
|
||||
GetCardPackResponseType.loading: 'loading',
|
||||
GetCardPackResponseType.unknown: 'unknown',
|
||||
};
|
||||
105
mnemo_cards_common/lib/src/dtos/packs/pack_tip.dart
Normal file
105
mnemo_cards_common/lib/src/dtos/packs/pack_tip.dart
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
|
||||
part 'pack_tip.g.dart';
|
||||
|
||||
/// Actions for cached packs
|
||||
/// Update action
|
||||
@JsonSerializable()
|
||||
@CopyWith()
|
||||
class PackTip {
|
||||
@JsonKey(unknownEnumValue: PackTipType.unknown)
|
||||
final PackTipType type;
|
||||
final PackTipPosition position;
|
||||
final String? bgColor;
|
||||
|
||||
const PackTip({
|
||||
required this.type,
|
||||
required this.position,
|
||||
required this.bgColor,
|
||||
});
|
||||
|
||||
factory PackTip.fromJson(Map<String, dynamic> json) {
|
||||
final type = _$PackTipFromJson(json).type;
|
||||
switch (type) {
|
||||
case PackTipType.asset:
|
||||
return AssetPackTip.fromJson(json);
|
||||
case PackTipType.base64:
|
||||
return Base64PackTip.fromJson(json);
|
||||
case PackTipType.text:
|
||||
return TextPackTip.fromJson(json);
|
||||
case PackTipType.unknown:
|
||||
return _$PackTipFromJson(json);
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => _$PackTipToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
@CopyWith()
|
||||
class AssetPackTip extends PackTip {
|
||||
String asset;
|
||||
|
||||
AssetPackTip(
|
||||
this.asset, {
|
||||
super.position = PackTipPosition.fullRight,
|
||||
super.type = PackTipType.asset,
|
||||
super.bgColor = null,
|
||||
});
|
||||
|
||||
factory AssetPackTip.fromJson(Map<String, dynamic> json) =>
|
||||
_$AssetPackTipFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$AssetPackTipToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
@CopyWith()
|
||||
class Base64PackTip extends PackTip {
|
||||
String base64;
|
||||
|
||||
Base64PackTip(
|
||||
this.base64, {
|
||||
super.position = PackTipPosition.fullRight,
|
||||
super.type = PackTipType.base64,
|
||||
super.bgColor = null,
|
||||
});
|
||||
|
||||
factory Base64PackTip.fromJson(Map<String, dynamic> json) =>
|
||||
_$Base64PackTipFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$Base64PackTipToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
@CopyWith()
|
||||
class TextPackTip extends PackTip {
|
||||
String text;
|
||||
|
||||
TextPackTip(
|
||||
this.text, {
|
||||
super.position = PackTipPosition.fullRight,
|
||||
super.type = PackTipType.text,
|
||||
super.bgColor = null,
|
||||
});
|
||||
|
||||
factory TextPackTip.fromJson(Map<String, dynamic> json) =>
|
||||
_$TextPackTipFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$TextPackTipToJson(this);
|
||||
}
|
||||
|
||||
enum PackTipType {
|
||||
asset,
|
||||
base64,
|
||||
text,
|
||||
unknown,
|
||||
}
|
||||
|
||||
enum PackTipPosition {
|
||||
topRight,
|
||||
fullRight,
|
||||
bottomRight,
|
||||
unknown,
|
||||
}
|
||||
413
mnemo_cards_common/lib/src/dtos/packs/pack_tip.g.dart
Normal file
413
mnemo_cards_common/lib/src/dtos/packs/pack_tip.g.dart
Normal file
|
|
@ -0,0 +1,413 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'pack_tip.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$PackTipCWProxy {
|
||||
PackTip type(PackTipType type);
|
||||
|
||||
PackTip position(PackTipPosition position);
|
||||
|
||||
PackTip bgColor(String? bgColor);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `PackTip(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// PackTip(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
PackTip call({
|
||||
PackTipType? type,
|
||||
PackTipPosition? position,
|
||||
String? bgColor,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfPackTip.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfPackTip.copyWith.fieldName(...)`
|
||||
class _$PackTipCWProxyImpl implements _$PackTipCWProxy {
|
||||
const _$PackTipCWProxyImpl(this._value);
|
||||
|
||||
final PackTip _value;
|
||||
|
||||
@override
|
||||
PackTip type(PackTipType type) => this(type: type);
|
||||
|
||||
@override
|
||||
PackTip position(PackTipPosition position) => this(position: position);
|
||||
|
||||
@override
|
||||
PackTip bgColor(String? bgColor) => this(bgColor: bgColor);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `PackTip(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// PackTip(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
PackTip call({
|
||||
Object? type = const $CopyWithPlaceholder(),
|
||||
Object? position = const $CopyWithPlaceholder(),
|
||||
Object? bgColor = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return PackTip(
|
||||
type: type == const $CopyWithPlaceholder() || type == null
|
||||
? _value.type
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: type as PackTipType,
|
||||
position: position == const $CopyWithPlaceholder() || position == null
|
||||
? _value.position
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: position as PackTipPosition,
|
||||
bgColor: bgColor == const $CopyWithPlaceholder()
|
||||
? _value.bgColor
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: bgColor as String?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $PackTipCopyWith on PackTip {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfPackTip.copyWith(...)` or like so:`instanceOfPackTip.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$PackTipCWProxy get copyWith => _$PackTipCWProxyImpl(this);
|
||||
}
|
||||
|
||||
abstract class _$AssetPackTipCWProxy {
|
||||
AssetPackTip asset(String asset);
|
||||
|
||||
AssetPackTip position(PackTipPosition position);
|
||||
|
||||
AssetPackTip type(PackTipType type);
|
||||
|
||||
AssetPackTip bgColor(String? bgColor);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `AssetPackTip(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// AssetPackTip(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
AssetPackTip call({
|
||||
String? asset,
|
||||
PackTipPosition? position,
|
||||
PackTipType? type,
|
||||
String? bgColor,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfAssetPackTip.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfAssetPackTip.copyWith.fieldName(...)`
|
||||
class _$AssetPackTipCWProxyImpl implements _$AssetPackTipCWProxy {
|
||||
const _$AssetPackTipCWProxyImpl(this._value);
|
||||
|
||||
final AssetPackTip _value;
|
||||
|
||||
@override
|
||||
AssetPackTip asset(String asset) => this(asset: asset);
|
||||
|
||||
@override
|
||||
AssetPackTip position(PackTipPosition position) => this(position: position);
|
||||
|
||||
@override
|
||||
AssetPackTip type(PackTipType type) => this(type: type);
|
||||
|
||||
@override
|
||||
AssetPackTip bgColor(String? bgColor) => this(bgColor: bgColor);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `AssetPackTip(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// AssetPackTip(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
AssetPackTip call({
|
||||
Object? asset = const $CopyWithPlaceholder(),
|
||||
Object? position = const $CopyWithPlaceholder(),
|
||||
Object? type = const $CopyWithPlaceholder(),
|
||||
Object? bgColor = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return AssetPackTip(
|
||||
asset == const $CopyWithPlaceholder() || asset == null
|
||||
? _value.asset
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: asset as String,
|
||||
position: position == const $CopyWithPlaceholder() || position == null
|
||||
? _value.position
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: position as PackTipPosition,
|
||||
type: type == const $CopyWithPlaceholder() || type == null
|
||||
? _value.type
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: type as PackTipType,
|
||||
bgColor: bgColor == const $CopyWithPlaceholder()
|
||||
? _value.bgColor
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: bgColor as String?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $AssetPackTipCopyWith on AssetPackTip {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfAssetPackTip.copyWith(...)` or like so:`instanceOfAssetPackTip.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$AssetPackTipCWProxy get copyWith => _$AssetPackTipCWProxyImpl(this);
|
||||
}
|
||||
|
||||
abstract class _$Base64PackTipCWProxy {
|
||||
Base64PackTip base64(String base64);
|
||||
|
||||
Base64PackTip position(PackTipPosition position);
|
||||
|
||||
Base64PackTip type(PackTipType type);
|
||||
|
||||
Base64PackTip bgColor(String? bgColor);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `Base64PackTip(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// Base64PackTip(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
Base64PackTip call({
|
||||
String? base64,
|
||||
PackTipPosition? position,
|
||||
PackTipType? type,
|
||||
String? bgColor,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfBase64PackTip.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfBase64PackTip.copyWith.fieldName(...)`
|
||||
class _$Base64PackTipCWProxyImpl implements _$Base64PackTipCWProxy {
|
||||
const _$Base64PackTipCWProxyImpl(this._value);
|
||||
|
||||
final Base64PackTip _value;
|
||||
|
||||
@override
|
||||
Base64PackTip base64(String base64) => this(base64: base64);
|
||||
|
||||
@override
|
||||
Base64PackTip position(PackTipPosition position) => this(position: position);
|
||||
|
||||
@override
|
||||
Base64PackTip type(PackTipType type) => this(type: type);
|
||||
|
||||
@override
|
||||
Base64PackTip bgColor(String? bgColor) => this(bgColor: bgColor);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `Base64PackTip(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// Base64PackTip(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
Base64PackTip call({
|
||||
Object? base64 = const $CopyWithPlaceholder(),
|
||||
Object? position = const $CopyWithPlaceholder(),
|
||||
Object? type = const $CopyWithPlaceholder(),
|
||||
Object? bgColor = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return Base64PackTip(
|
||||
base64 == const $CopyWithPlaceholder() || base64 == null
|
||||
? _value.base64
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: base64 as String,
|
||||
position: position == const $CopyWithPlaceholder() || position == null
|
||||
? _value.position
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: position as PackTipPosition,
|
||||
type: type == const $CopyWithPlaceholder() || type == null
|
||||
? _value.type
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: type as PackTipType,
|
||||
bgColor: bgColor == const $CopyWithPlaceholder()
|
||||
? _value.bgColor
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: bgColor as String?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $Base64PackTipCopyWith on Base64PackTip {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfBase64PackTip.copyWith(...)` or like so:`instanceOfBase64PackTip.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$Base64PackTipCWProxy get copyWith => _$Base64PackTipCWProxyImpl(this);
|
||||
}
|
||||
|
||||
abstract class _$TextPackTipCWProxy {
|
||||
TextPackTip text(String text);
|
||||
|
||||
TextPackTip position(PackTipPosition position);
|
||||
|
||||
TextPackTip type(PackTipType type);
|
||||
|
||||
TextPackTip bgColor(String? bgColor);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `TextPackTip(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// TextPackTip(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
TextPackTip call({
|
||||
String? text,
|
||||
PackTipPosition? position,
|
||||
PackTipType? type,
|
||||
String? bgColor,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfTextPackTip.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfTextPackTip.copyWith.fieldName(...)`
|
||||
class _$TextPackTipCWProxyImpl implements _$TextPackTipCWProxy {
|
||||
const _$TextPackTipCWProxyImpl(this._value);
|
||||
|
||||
final TextPackTip _value;
|
||||
|
||||
@override
|
||||
TextPackTip text(String text) => this(text: text);
|
||||
|
||||
@override
|
||||
TextPackTip position(PackTipPosition position) => this(position: position);
|
||||
|
||||
@override
|
||||
TextPackTip type(PackTipType type) => this(type: type);
|
||||
|
||||
@override
|
||||
TextPackTip bgColor(String? bgColor) => this(bgColor: bgColor);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `TextPackTip(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// TextPackTip(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
TextPackTip call({
|
||||
Object? text = const $CopyWithPlaceholder(),
|
||||
Object? position = const $CopyWithPlaceholder(),
|
||||
Object? type = const $CopyWithPlaceholder(),
|
||||
Object? bgColor = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return TextPackTip(
|
||||
text == const $CopyWithPlaceholder() || text == null
|
||||
? _value.text
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: text as String,
|
||||
position: position == const $CopyWithPlaceholder() || position == null
|
||||
? _value.position
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: position as PackTipPosition,
|
||||
type: type == const $CopyWithPlaceholder() || type == null
|
||||
? _value.type
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: type as PackTipType,
|
||||
bgColor: bgColor == const $CopyWithPlaceholder()
|
||||
? _value.bgColor
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: bgColor as String?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $TextPackTipCopyWith on TextPackTip {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfTextPackTip.copyWith(...)` or like so:`instanceOfTextPackTip.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$TextPackTipCWProxy get copyWith => _$TextPackTipCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
PackTip _$PackTipFromJson(Map<String, dynamic> json) => PackTip(
|
||||
type: $enumDecode(_$PackTipTypeEnumMap, json['type'],
|
||||
unknownValue: PackTipType.unknown),
|
||||
position: $enumDecode(_$PackTipPositionEnumMap, json['position']),
|
||||
bgColor: json['bgColor'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$PackTipToJson(PackTip instance) => <String, dynamic>{
|
||||
'type': _$PackTipTypeEnumMap[instance.type]!,
|
||||
'position': _$PackTipPositionEnumMap[instance.position]!,
|
||||
'bgColor': instance.bgColor,
|
||||
};
|
||||
|
||||
const _$PackTipTypeEnumMap = {
|
||||
PackTipType.asset: 'asset',
|
||||
PackTipType.base64: 'base64',
|
||||
PackTipType.text: 'text',
|
||||
PackTipType.unknown: 'unknown',
|
||||
};
|
||||
|
||||
const _$PackTipPositionEnumMap = {
|
||||
PackTipPosition.topRight: 'topRight',
|
||||
PackTipPosition.fullRight: 'fullRight',
|
||||
PackTipPosition.bottomRight: 'bottomRight',
|
||||
PackTipPosition.unknown: 'unknown',
|
||||
};
|
||||
|
||||
AssetPackTip _$AssetPackTipFromJson(Map<String, dynamic> json) => AssetPackTip(
|
||||
json['asset'] as String,
|
||||
position:
|
||||
$enumDecodeNullable(_$PackTipPositionEnumMap, json['position']) ??
|
||||
PackTipPosition.fullRight,
|
||||
type: $enumDecodeNullable(_$PackTipTypeEnumMap, json['type'],
|
||||
unknownValue: PackTipType.unknown) ??
|
||||
PackTipType.asset,
|
||||
bgColor: json['bgColor'] as String? ?? null,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$AssetPackTipToJson(AssetPackTip instance) =>
|
||||
<String, dynamic>{
|
||||
'type': _$PackTipTypeEnumMap[instance.type]!,
|
||||
'position': _$PackTipPositionEnumMap[instance.position]!,
|
||||
'bgColor': instance.bgColor,
|
||||
'asset': instance.asset,
|
||||
};
|
||||
|
||||
Base64PackTip _$Base64PackTipFromJson(Map<String, dynamic> json) =>
|
||||
Base64PackTip(
|
||||
json['base64'] as String,
|
||||
position:
|
||||
$enumDecodeNullable(_$PackTipPositionEnumMap, json['position']) ??
|
||||
PackTipPosition.fullRight,
|
||||
type: $enumDecodeNullable(_$PackTipTypeEnumMap, json['type'],
|
||||
unknownValue: PackTipType.unknown) ??
|
||||
PackTipType.base64,
|
||||
bgColor: json['bgColor'] as String? ?? null,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$Base64PackTipToJson(Base64PackTip instance) =>
|
||||
<String, dynamic>{
|
||||
'type': _$PackTipTypeEnumMap[instance.type]!,
|
||||
'position': _$PackTipPositionEnumMap[instance.position]!,
|
||||
'bgColor': instance.bgColor,
|
||||
'base64': instance.base64,
|
||||
};
|
||||
|
||||
TextPackTip _$TextPackTipFromJson(Map<String, dynamic> json) => TextPackTip(
|
||||
json['text'] as String,
|
||||
position:
|
||||
$enumDecodeNullable(_$PackTipPositionEnumMap, json['position']) ??
|
||||
PackTipPosition.fullRight,
|
||||
type: $enumDecodeNullable(_$PackTipTypeEnumMap, json['type'],
|
||||
unknownValue: PackTipType.unknown) ??
|
||||
PackTipType.text,
|
||||
bgColor: json['bgColor'] as String? ?? null,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$TextPackTipToJson(TextPackTip instance) =>
|
||||
<String, dynamic>{
|
||||
'type': _$PackTipTypeEnumMap[instance.type]!,
|
||||
'position': _$PackTipPositionEnumMap[instance.position]!,
|
||||
'bgColor': instance.bgColor,
|
||||
'text': instance.text,
|
||||
};
|
||||
3
mnemo_cards_common/lib/src/dtos/payment/export.dart
Normal file
3
mnemo_cards_common/lib/src/dtos/payment/export.dart
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
export 'payment_dto.dart';
|
||||
export 'product_type.dart';
|
||||
export 'yookassa_payment_dto.dart';
|
||||
87
mnemo_cards_common/lib/src/dtos/payment/payment_dto.dart
Normal file
87
mnemo_cards_common/lib/src/dtos/payment/payment_dto.dart
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'product_type.dart';
|
||||
|
||||
part 'payment_dto.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
@CopyWith()
|
||||
class PaymentDto {
|
||||
final String amount;
|
||||
final String currency;
|
||||
final DateTime date;
|
||||
@JsonKey(unknownEnumValue: PaymentStatus.unknown)
|
||||
final PaymentStatus status;
|
||||
@JsonKey(unknownEnumValue: PaymentSystem.unknown)
|
||||
final PaymentSystem paymentSystem;
|
||||
final String? externalToken;
|
||||
final String? meta;
|
||||
|
||||
@deprecated
|
||||
final List<String>? packs;
|
||||
@deprecated
|
||||
final bool? subscription;
|
||||
final List<MnemoCardsProductDto> products;
|
||||
|
||||
const PaymentDto({
|
||||
required this.amount,
|
||||
required this.currency,
|
||||
required this.status,
|
||||
required this.paymentSystem,
|
||||
required this.date,
|
||||
required this.packs,
|
||||
required this.subscription,
|
||||
required this.products,
|
||||
required this.externalToken,
|
||||
required this.meta,
|
||||
});
|
||||
|
||||
factory PaymentDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$PaymentDtoFromJson(json);
|
||||
|
||||
Map<String, Object?> toJson() => _$PaymentDtoToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
@CopyWith()
|
||||
class MnemoCardsProductDto {
|
||||
final String? id;
|
||||
|
||||
final MnemoCardsProductType type;
|
||||
|
||||
const MnemoCardsProductDto({
|
||||
this.id,
|
||||
this.type = MnemoCardsProductType.unknown,
|
||||
});
|
||||
|
||||
factory MnemoCardsProductDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$MnemoCardsProductDtoFromJson(json);
|
||||
|
||||
Map<String, Object?> toJson() => _$MnemoCardsProductDtoToJson(this);
|
||||
}
|
||||
|
||||
extension MnemoCardsProductExt on MnemoCardsProductDto {
|
||||
MnemoCardsProductDto toProduct() => MnemoCardsProductDto(id: id, type: type);
|
||||
|
||||
bool productEquals(MnemoCardsProductDto? other) =>
|
||||
other is MnemoCardsProductDto && other.id == id && other.type == type;
|
||||
}
|
||||
|
||||
enum PaymentStatus {
|
||||
created,
|
||||
waiting,
|
||||
succeeded,
|
||||
canceled,
|
||||
processed,
|
||||
unknown,
|
||||
}
|
||||
|
||||
enum PaymentSystem {
|
||||
google,
|
||||
apple,
|
||||
rustore,
|
||||
yookassa,
|
||||
promoCode,
|
||||
adView,
|
||||
unknown,
|
||||
}
|
||||
300
mnemo_cards_common/lib/src/dtos/payment/payment_dto.g.dart
Normal file
300
mnemo_cards_common/lib/src/dtos/payment/payment_dto.g.dart
Normal file
|
|
@ -0,0 +1,300 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'payment_dto.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$PaymentDtoCWProxy {
|
||||
PaymentDto amount(String amount);
|
||||
|
||||
PaymentDto currency(String currency);
|
||||
|
||||
PaymentDto status(PaymentStatus status);
|
||||
|
||||
PaymentDto paymentSystem(PaymentSystem paymentSystem);
|
||||
|
||||
PaymentDto date(DateTime date);
|
||||
|
||||
PaymentDto packs(List<String>? packs);
|
||||
|
||||
PaymentDto subscription(bool? subscription);
|
||||
|
||||
PaymentDto products(List<MnemoCardsProductDto> products);
|
||||
|
||||
PaymentDto externalToken(String? externalToken);
|
||||
|
||||
PaymentDto meta(String? meta);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `PaymentDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// PaymentDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
PaymentDto call({
|
||||
String? amount,
|
||||
String? currency,
|
||||
PaymentStatus? status,
|
||||
PaymentSystem? paymentSystem,
|
||||
DateTime? date,
|
||||
List<String>? packs,
|
||||
bool? subscription,
|
||||
List<MnemoCardsProductDto>? products,
|
||||
String? externalToken,
|
||||
String? meta,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfPaymentDto.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfPaymentDto.copyWith.fieldName(...)`
|
||||
class _$PaymentDtoCWProxyImpl implements _$PaymentDtoCWProxy {
|
||||
const _$PaymentDtoCWProxyImpl(this._value);
|
||||
|
||||
final PaymentDto _value;
|
||||
|
||||
@override
|
||||
PaymentDto amount(String amount) => this(amount: amount);
|
||||
|
||||
@override
|
||||
PaymentDto currency(String currency) => this(currency: currency);
|
||||
|
||||
@override
|
||||
PaymentDto status(PaymentStatus status) => this(status: status);
|
||||
|
||||
@override
|
||||
PaymentDto paymentSystem(PaymentSystem paymentSystem) =>
|
||||
this(paymentSystem: paymentSystem);
|
||||
|
||||
@override
|
||||
PaymentDto date(DateTime date) => this(date: date);
|
||||
|
||||
@override
|
||||
PaymentDto packs(List<String>? packs) => this(packs: packs);
|
||||
|
||||
@override
|
||||
PaymentDto subscription(bool? subscription) =>
|
||||
this(subscription: subscription);
|
||||
|
||||
@override
|
||||
PaymentDto products(List<MnemoCardsProductDto> products) =>
|
||||
this(products: products);
|
||||
|
||||
@override
|
||||
PaymentDto externalToken(String? externalToken) =>
|
||||
this(externalToken: externalToken);
|
||||
|
||||
@override
|
||||
PaymentDto meta(String? meta) => this(meta: meta);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `PaymentDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// PaymentDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
PaymentDto call({
|
||||
Object? amount = const $CopyWithPlaceholder(),
|
||||
Object? currency = const $CopyWithPlaceholder(),
|
||||
Object? status = const $CopyWithPlaceholder(),
|
||||
Object? paymentSystem = const $CopyWithPlaceholder(),
|
||||
Object? date = const $CopyWithPlaceholder(),
|
||||
Object? packs = const $CopyWithPlaceholder(),
|
||||
Object? subscription = const $CopyWithPlaceholder(),
|
||||
Object? products = const $CopyWithPlaceholder(),
|
||||
Object? externalToken = const $CopyWithPlaceholder(),
|
||||
Object? meta = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return PaymentDto(
|
||||
amount: amount == const $CopyWithPlaceholder() || amount == null
|
||||
? _value.amount
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: amount as String,
|
||||
currency: currency == const $CopyWithPlaceholder() || currency == null
|
||||
? _value.currency
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: currency as String,
|
||||
status: status == const $CopyWithPlaceholder() || status == null
|
||||
? _value.status
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: status as PaymentStatus,
|
||||
paymentSystem:
|
||||
paymentSystem == const $CopyWithPlaceholder() || paymentSystem == null
|
||||
? _value.paymentSystem
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: paymentSystem as PaymentSystem,
|
||||
date: date == const $CopyWithPlaceholder() || date == null
|
||||
? _value.date
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: date as DateTime,
|
||||
packs: packs == const $CopyWithPlaceholder()
|
||||
? _value.packs
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: packs as List<String>?,
|
||||
subscription: subscription == const $CopyWithPlaceholder()
|
||||
? _value.subscription
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: subscription as bool?,
|
||||
products: products == const $CopyWithPlaceholder() || products == null
|
||||
? _value.products
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: products as List<MnemoCardsProductDto>,
|
||||
externalToken: externalToken == const $CopyWithPlaceholder()
|
||||
? _value.externalToken
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: externalToken as String?,
|
||||
meta: meta == const $CopyWithPlaceholder()
|
||||
? _value.meta
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: meta as String?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $PaymentDtoCopyWith on PaymentDto {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfPaymentDto.copyWith(...)` or like so:`instanceOfPaymentDto.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$PaymentDtoCWProxy get copyWith => _$PaymentDtoCWProxyImpl(this);
|
||||
}
|
||||
|
||||
abstract class _$MnemoCardsProductDtoCWProxy {
|
||||
MnemoCardsProductDto id(String? id);
|
||||
|
||||
MnemoCardsProductDto type(MnemoCardsProductType type);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `MnemoCardsProductDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// MnemoCardsProductDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
MnemoCardsProductDto call({
|
||||
String? id,
|
||||
MnemoCardsProductType? type,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfMnemoCardsProductDto.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfMnemoCardsProductDto.copyWith.fieldName(...)`
|
||||
class _$MnemoCardsProductDtoCWProxyImpl
|
||||
implements _$MnemoCardsProductDtoCWProxy {
|
||||
const _$MnemoCardsProductDtoCWProxyImpl(this._value);
|
||||
|
||||
final MnemoCardsProductDto _value;
|
||||
|
||||
@override
|
||||
MnemoCardsProductDto id(String? id) => this(id: id);
|
||||
|
||||
@override
|
||||
MnemoCardsProductDto type(MnemoCardsProductType type) => this(type: type);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `MnemoCardsProductDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// MnemoCardsProductDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
MnemoCardsProductDto call({
|
||||
Object? id = const $CopyWithPlaceholder(),
|
||||
Object? type = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return MnemoCardsProductDto(
|
||||
id: id == const $CopyWithPlaceholder()
|
||||
? _value.id
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: id as String?,
|
||||
type: type == const $CopyWithPlaceholder() || type == null
|
||||
? _value.type
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: type as MnemoCardsProductType,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $MnemoCardsProductDtoCopyWith on MnemoCardsProductDto {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfMnemoCardsProductDto.copyWith(...)` or like so:`instanceOfMnemoCardsProductDto.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$MnemoCardsProductDtoCWProxy get copyWith =>
|
||||
_$MnemoCardsProductDtoCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
PaymentDto _$PaymentDtoFromJson(Map<String, dynamic> json) => PaymentDto(
|
||||
amount: json['amount'] as String,
|
||||
currency: json['currency'] as String,
|
||||
status: $enumDecode(_$PaymentStatusEnumMap, json['status'],
|
||||
unknownValue: PaymentStatus.unknown),
|
||||
paymentSystem: $enumDecode(_$PaymentSystemEnumMap, json['paymentSystem'],
|
||||
unknownValue: PaymentSystem.unknown),
|
||||
date: DateTime.parse(json['date'] as String),
|
||||
packs:
|
||||
(json['packs'] as List<dynamic>?)?.map((e) => e as String).toList(),
|
||||
subscription: json['subscription'] as bool?,
|
||||
products: (json['products'] as List<dynamic>)
|
||||
.map((e) => MnemoCardsProductDto.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
externalToken: json['externalToken'] as String?,
|
||||
meta: json['meta'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$PaymentDtoToJson(PaymentDto instance) =>
|
||||
<String, dynamic>{
|
||||
'amount': instance.amount,
|
||||
'currency': instance.currency,
|
||||
'date': instance.date.toIso8601String(),
|
||||
'status': _$PaymentStatusEnumMap[instance.status]!,
|
||||
'paymentSystem': _$PaymentSystemEnumMap[instance.paymentSystem]!,
|
||||
'externalToken': instance.externalToken,
|
||||
'meta': instance.meta,
|
||||
'packs': instance.packs,
|
||||
'subscription': instance.subscription,
|
||||
'products': instance.products,
|
||||
};
|
||||
|
||||
const _$PaymentStatusEnumMap = {
|
||||
PaymentStatus.created: 'created',
|
||||
PaymentStatus.waiting: 'waiting',
|
||||
PaymentStatus.succeeded: 'succeeded',
|
||||
PaymentStatus.canceled: 'canceled',
|
||||
PaymentStatus.processed: 'processed',
|
||||
PaymentStatus.unknown: 'unknown',
|
||||
};
|
||||
|
||||
const _$PaymentSystemEnumMap = {
|
||||
PaymentSystem.google: 'google',
|
||||
PaymentSystem.apple: 'apple',
|
||||
PaymentSystem.rustore: 'rustore',
|
||||
PaymentSystem.yookassa: 'yookassa',
|
||||
PaymentSystem.promoCode: 'promoCode',
|
||||
PaymentSystem.adView: 'adView',
|
||||
PaymentSystem.unknown: 'unknown',
|
||||
};
|
||||
|
||||
MnemoCardsProductDto _$MnemoCardsProductDtoFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
MnemoCardsProductDto(
|
||||
id: json['id'] as String?,
|
||||
type: $enumDecodeNullable(_$MnemoCardsProductTypeEnumMap, json['type']) ??
|
||||
MnemoCardsProductType.unknown,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$MnemoCardsProductDtoToJson(
|
||||
MnemoCardsProductDto instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'type': _$MnemoCardsProductTypeEnumMap[instance.type]!,
|
||||
};
|
||||
|
||||
const _$MnemoCardsProductTypeEnumMap = {
|
||||
MnemoCardsProductType.pack: 'pack',
|
||||
MnemoCardsProductType.subscription: 'subscription',
|
||||
MnemoCardsProductType.discount: 'discount',
|
||||
MnemoCardsProductType.game: 'game',
|
||||
MnemoCardsProductType.unknown: 'unknown',
|
||||
};
|
||||
22
mnemo_cards_common/lib/src/dtos/payment/product_type.dart
Normal file
22
mnemo_cards_common/lib/src/dtos/payment/product_type.dart
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:mnemo_cards_common/mnemo_cards_common.dart';
|
||||
|
||||
part 'product_type.g.dart';
|
||||
|
||||
@JsonEnum(alwaysCreate: true)
|
||||
enum MnemoCardsProductType {
|
||||
pack,
|
||||
subscription,
|
||||
discount,
|
||||
game,
|
||||
unknown;
|
||||
|
||||
factory MnemoCardsProductType.fromName(String name) =>
|
||||
_$MnemoCardsProductTypeEnumMap.entries
|
||||
.firstWhereOrNull((entry) => entry.value == name)
|
||||
?.key ??
|
||||
MnemoCardsProductType.unknown;
|
||||
|
||||
static String toName(MnemoCardsProductType type) =>
|
||||
_$MnemoCardsProductTypeEnumMap[type]!;
|
||||
}
|
||||
15
mnemo_cards_common/lib/src/dtos/payment/product_type.g.dart
Normal file
15
mnemo_cards_common/lib/src/dtos/payment/product_type.g.dart
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'product_type.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
const _$MnemoCardsProductTypeEnumMap = {
|
||||
MnemoCardsProductType.pack: 'pack',
|
||||
MnemoCardsProductType.subscription: 'subscription',
|
||||
MnemoCardsProductType.discount: 'discount',
|
||||
MnemoCardsProductType.game: 'game',
|
||||
MnemoCardsProductType.unknown: 'unknown',
|
||||
};
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
|
||||
part 'yookassa_payment_dto.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
@CopyWith()
|
||||
class YookassaPaymentDto {
|
||||
final String purchaseUrl;
|
||||
final String checkUrl;
|
||||
|
||||
YookassaPaymentDto({
|
||||
required this.purchaseUrl,
|
||||
required this.checkUrl,
|
||||
});
|
||||
|
||||
factory YookassaPaymentDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$YookassaPaymentDtoFromJson(json);
|
||||
|
||||
Map<String, Object?> toJson() => _$YookassaPaymentDtoToJson(this);
|
||||
}
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'yookassa_payment_dto.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$YookassaPaymentDtoCWProxy {
|
||||
YookassaPaymentDto purchaseUrl(String purchaseUrl);
|
||||
|
||||
YookassaPaymentDto checkUrl(String checkUrl);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `YookassaPaymentDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// YookassaPaymentDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
YookassaPaymentDto call({
|
||||
String? purchaseUrl,
|
||||
String? checkUrl,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfYookassaPaymentDto.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfYookassaPaymentDto.copyWith.fieldName(...)`
|
||||
class _$YookassaPaymentDtoCWProxyImpl implements _$YookassaPaymentDtoCWProxy {
|
||||
const _$YookassaPaymentDtoCWProxyImpl(this._value);
|
||||
|
||||
final YookassaPaymentDto _value;
|
||||
|
||||
@override
|
||||
YookassaPaymentDto purchaseUrl(String purchaseUrl) =>
|
||||
this(purchaseUrl: purchaseUrl);
|
||||
|
||||
@override
|
||||
YookassaPaymentDto checkUrl(String checkUrl) => this(checkUrl: checkUrl);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `YookassaPaymentDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// YookassaPaymentDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
YookassaPaymentDto call({
|
||||
Object? purchaseUrl = const $CopyWithPlaceholder(),
|
||||
Object? checkUrl = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return YookassaPaymentDto(
|
||||
purchaseUrl:
|
||||
purchaseUrl == const $CopyWithPlaceholder() || purchaseUrl == null
|
||||
? _value.purchaseUrl
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: purchaseUrl as String,
|
||||
checkUrl: checkUrl == const $CopyWithPlaceholder() || checkUrl == null
|
||||
? _value.checkUrl
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: checkUrl as String,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $YookassaPaymentDtoCopyWith on YookassaPaymentDto {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfYookassaPaymentDto.copyWith(...)` or like so:`instanceOfYookassaPaymentDto.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$YookassaPaymentDtoCWProxy get copyWith =>
|
||||
_$YookassaPaymentDtoCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
YookassaPaymentDto _$YookassaPaymentDtoFromJson(Map<String, dynamic> json) =>
|
||||
YookassaPaymentDto(
|
||||
purchaseUrl: json['purchaseUrl'] as String,
|
||||
checkUrl: json['checkUrl'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$YookassaPaymentDtoToJson(YookassaPaymentDto instance) =>
|
||||
<String, dynamic>{
|
||||
'purchaseUrl': instance.purchaseUrl,
|
||||
'checkUrl': instance.checkUrl,
|
||||
};
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
|
||||
import '../payment/payment_dto.dart';
|
||||
|
||||
part 'promo_codes_campaign_dto.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
@CopyWith()
|
||||
class PromoCodesCampaignDto {
|
||||
final int? id;
|
||||
final List<MnemoCardsProductDto> products;
|
||||
final int activationsPerCode;
|
||||
final int activationsPerUser;
|
||||
final List<String>? promoCodes;
|
||||
final List<String> tags;
|
||||
final int generationSize;
|
||||
final DateTime start;
|
||||
final DateTime finish;
|
||||
final PromoCodeCampaignStatus status;
|
||||
final String? name;
|
||||
final String template;
|
||||
|
||||
const PromoCodesCampaignDto({
|
||||
required this.products,
|
||||
required this.activationsPerCode,
|
||||
required this.activationsPerUser,
|
||||
required this.generationSize,
|
||||
required this.start,
|
||||
required this.finish,
|
||||
required this.status,
|
||||
required this.template,
|
||||
required this.tags,
|
||||
this.name,
|
||||
this.id,
|
||||
this.promoCodes,
|
||||
});
|
||||
|
||||
factory PromoCodesCampaignDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$PromoCodesCampaignDtoFromJson(json);
|
||||
|
||||
Map<String, Object?> toJson() => _$PromoCodesCampaignDtoToJson(this);
|
||||
}
|
||||
|
||||
enum PromoCodeCampaignStatus {
|
||||
created,
|
||||
preparing,
|
||||
ready,
|
||||
active,
|
||||
disabled,
|
||||
}
|
||||
|
|
@ -0,0 +1,238 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'promo_codes_campaign_dto.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$PromoCodesCampaignDtoCWProxy {
|
||||
PromoCodesCampaignDto products(List<MnemoCardsProductDto> products);
|
||||
|
||||
PromoCodesCampaignDto activationsPerCode(int activationsPerCode);
|
||||
|
||||
PromoCodesCampaignDto activationsPerUser(int activationsPerUser);
|
||||
|
||||
PromoCodesCampaignDto generationSize(int generationSize);
|
||||
|
||||
PromoCodesCampaignDto start(DateTime start);
|
||||
|
||||
PromoCodesCampaignDto finish(DateTime finish);
|
||||
|
||||
PromoCodesCampaignDto status(PromoCodeCampaignStatus status);
|
||||
|
||||
PromoCodesCampaignDto template(String template);
|
||||
|
||||
PromoCodesCampaignDto tags(List<String> tags);
|
||||
|
||||
PromoCodesCampaignDto name(String? name);
|
||||
|
||||
PromoCodesCampaignDto id(int? id);
|
||||
|
||||
PromoCodesCampaignDto promoCodes(List<String>? promoCodes);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `PromoCodesCampaignDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// PromoCodesCampaignDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
PromoCodesCampaignDto call({
|
||||
List<MnemoCardsProductDto>? products,
|
||||
int? activationsPerCode,
|
||||
int? activationsPerUser,
|
||||
int? generationSize,
|
||||
DateTime? start,
|
||||
DateTime? finish,
|
||||
PromoCodeCampaignStatus? status,
|
||||
String? template,
|
||||
List<String>? tags,
|
||||
String? name,
|
||||
int? id,
|
||||
List<String>? promoCodes,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfPromoCodesCampaignDto.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfPromoCodesCampaignDto.copyWith.fieldName(...)`
|
||||
class _$PromoCodesCampaignDtoCWProxyImpl
|
||||
implements _$PromoCodesCampaignDtoCWProxy {
|
||||
const _$PromoCodesCampaignDtoCWProxyImpl(this._value);
|
||||
|
||||
final PromoCodesCampaignDto _value;
|
||||
|
||||
@override
|
||||
PromoCodesCampaignDto products(List<MnemoCardsProductDto> products) =>
|
||||
this(products: products);
|
||||
|
||||
@override
|
||||
PromoCodesCampaignDto activationsPerCode(int activationsPerCode) =>
|
||||
this(activationsPerCode: activationsPerCode);
|
||||
|
||||
@override
|
||||
PromoCodesCampaignDto activationsPerUser(int activationsPerUser) =>
|
||||
this(activationsPerUser: activationsPerUser);
|
||||
|
||||
@override
|
||||
PromoCodesCampaignDto generationSize(int generationSize) =>
|
||||
this(generationSize: generationSize);
|
||||
|
||||
@override
|
||||
PromoCodesCampaignDto start(DateTime start) => this(start: start);
|
||||
|
||||
@override
|
||||
PromoCodesCampaignDto finish(DateTime finish) => this(finish: finish);
|
||||
|
||||
@override
|
||||
PromoCodesCampaignDto status(PromoCodeCampaignStatus status) =>
|
||||
this(status: status);
|
||||
|
||||
@override
|
||||
PromoCodesCampaignDto template(String template) => this(template: template);
|
||||
|
||||
@override
|
||||
PromoCodesCampaignDto tags(List<String> tags) => this(tags: tags);
|
||||
|
||||
@override
|
||||
PromoCodesCampaignDto name(String? name) => this(name: name);
|
||||
|
||||
@override
|
||||
PromoCodesCampaignDto id(int? id) => this(id: id);
|
||||
|
||||
@override
|
||||
PromoCodesCampaignDto promoCodes(List<String>? promoCodes) =>
|
||||
this(promoCodes: promoCodes);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `PromoCodesCampaignDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// PromoCodesCampaignDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
PromoCodesCampaignDto call({
|
||||
Object? products = const $CopyWithPlaceholder(),
|
||||
Object? activationsPerCode = const $CopyWithPlaceholder(),
|
||||
Object? activationsPerUser = const $CopyWithPlaceholder(),
|
||||
Object? generationSize = const $CopyWithPlaceholder(),
|
||||
Object? start = const $CopyWithPlaceholder(),
|
||||
Object? finish = const $CopyWithPlaceholder(),
|
||||
Object? status = const $CopyWithPlaceholder(),
|
||||
Object? template = const $CopyWithPlaceholder(),
|
||||
Object? tags = const $CopyWithPlaceholder(),
|
||||
Object? name = const $CopyWithPlaceholder(),
|
||||
Object? id = const $CopyWithPlaceholder(),
|
||||
Object? promoCodes = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return PromoCodesCampaignDto(
|
||||
products: products == const $CopyWithPlaceholder() || products == null
|
||||
? _value.products
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: products as List<MnemoCardsProductDto>,
|
||||
activationsPerCode: activationsPerCode == const $CopyWithPlaceholder() ||
|
||||
activationsPerCode == null
|
||||
? _value.activationsPerCode
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: activationsPerCode as int,
|
||||
activationsPerUser: activationsPerUser == const $CopyWithPlaceholder() ||
|
||||
activationsPerUser == null
|
||||
? _value.activationsPerUser
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: activationsPerUser as int,
|
||||
generationSize: generationSize == const $CopyWithPlaceholder() ||
|
||||
generationSize == null
|
||||
? _value.generationSize
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: generationSize as int,
|
||||
start: start == const $CopyWithPlaceholder() || start == null
|
||||
? _value.start
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: start as DateTime,
|
||||
finish: finish == const $CopyWithPlaceholder() || finish == null
|
||||
? _value.finish
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: finish as DateTime,
|
||||
status: status == const $CopyWithPlaceholder() || status == null
|
||||
? _value.status
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: status as PromoCodeCampaignStatus,
|
||||
template: template == const $CopyWithPlaceholder() || template == null
|
||||
? _value.template
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: template as String,
|
||||
tags: tags == const $CopyWithPlaceholder() || tags == null
|
||||
? _value.tags
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: tags as List<String>,
|
||||
name: name == const $CopyWithPlaceholder()
|
||||
? _value.name
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: name as String?,
|
||||
id: id == const $CopyWithPlaceholder()
|
||||
? _value.id
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: id as int?,
|
||||
promoCodes: promoCodes == const $CopyWithPlaceholder()
|
||||
? _value.promoCodes
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: promoCodes as List<String>?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $PromoCodesCampaignDtoCopyWith on PromoCodesCampaignDto {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfPromoCodesCampaignDto.copyWith(...)` or like so:`instanceOfPromoCodesCampaignDto.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$PromoCodesCampaignDtoCWProxy get copyWith =>
|
||||
_$PromoCodesCampaignDtoCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
PromoCodesCampaignDto _$PromoCodesCampaignDtoFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
PromoCodesCampaignDto(
|
||||
products: (json['products'] as List<dynamic>)
|
||||
.map((e) => MnemoCardsProductDto.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
activationsPerCode: json['activationsPerCode'] as int,
|
||||
activationsPerUser: json['activationsPerUser'] as int,
|
||||
generationSize: json['generationSize'] as int,
|
||||
start: DateTime.parse(json['start'] as String),
|
||||
finish: DateTime.parse(json['finish'] as String),
|
||||
status: $enumDecode(_$PromoCodeCampaignStatusEnumMap, json['status']),
|
||||
template: json['template'] as String,
|
||||
tags: (json['tags'] as List<dynamic>).map((e) => e as String).toList(),
|
||||
name: json['name'] as String?,
|
||||
id: json['id'] as int?,
|
||||
promoCodes: (json['promoCodes'] as List<dynamic>?)
|
||||
?.map((e) => e as String)
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$PromoCodesCampaignDtoToJson(
|
||||
PromoCodesCampaignDto instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'products': instance.products,
|
||||
'activationsPerCode': instance.activationsPerCode,
|
||||
'activationsPerUser': instance.activationsPerUser,
|
||||
'promoCodes': instance.promoCodes,
|
||||
'tags': instance.tags,
|
||||
'generationSize': instance.generationSize,
|
||||
'start': instance.start.toIso8601String(),
|
||||
'finish': instance.finish.toIso8601String(),
|
||||
'status': _$PromoCodeCampaignStatusEnumMap[instance.status]!,
|
||||
'name': instance.name,
|
||||
'template': instance.template,
|
||||
};
|
||||
|
||||
const _$PromoCodeCampaignStatusEnumMap = {
|
||||
PromoCodeCampaignStatus.created: 'created',
|
||||
PromoCodeCampaignStatus.preparing: 'preparing',
|
||||
PromoCodeCampaignStatus.ready: 'ready',
|
||||
PromoCodeCampaignStatus.active: 'active',
|
||||
PromoCodeCampaignStatus.disabled: 'disabled',
|
||||
};
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
enum SubscriptionFeatureEnum {
|
||||
ads,
|
||||
packs,
|
||||
unknown,
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'package:mnemo_cards_common/mnemo_cards_common.dart';
|
||||
|
||||
|
||||
part 'subscription_plan_admin_dto.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
@CopyWith()
|
||||
class SubscriptionPlanAdminDto implements MnemoCardsProductDto {
|
||||
final String? id;
|
||||
final SubscriptionPlanUIDto ui;
|
||||
final String price;
|
||||
final String currency;
|
||||
final int durationDays;
|
||||
final List<SubscriptionFeatureEnum> features;
|
||||
final PaymentSystem paymentSystem;
|
||||
final String? paymentId;
|
||||
|
||||
const SubscriptionPlanAdminDto({
|
||||
this.id,
|
||||
required this.ui,
|
||||
required this.price,
|
||||
required this.currency,
|
||||
required this.durationDays,
|
||||
required this.features,
|
||||
required this.paymentSystem,
|
||||
required this.paymentId,
|
||||
});
|
||||
|
||||
factory SubscriptionPlanAdminDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$SubscriptionPlanAdminDtoFromJson(json);
|
||||
|
||||
Map<String, Object?> toJson() => _$SubscriptionPlanAdminDtoToJson(this);
|
||||
|
||||
@override
|
||||
MnemoCardsProductType get type => MnemoCardsProductType.subscription;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,192 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'subscription_plan_admin_dto.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$SubscriptionPlanAdminDtoCWProxy {
|
||||
SubscriptionPlanAdminDto id(String? id);
|
||||
|
||||
SubscriptionPlanAdminDto ui(SubscriptionPlanUIDto ui);
|
||||
|
||||
SubscriptionPlanAdminDto price(String price);
|
||||
|
||||
SubscriptionPlanAdminDto currency(String currency);
|
||||
|
||||
SubscriptionPlanAdminDto durationDays(int durationDays);
|
||||
|
||||
SubscriptionPlanAdminDto features(List<SubscriptionFeatureEnum> features);
|
||||
|
||||
SubscriptionPlanAdminDto paymentSystem(PaymentSystem paymentSystem);
|
||||
|
||||
SubscriptionPlanAdminDto paymentId(String? paymentId);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `SubscriptionPlanAdminDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// SubscriptionPlanAdminDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
SubscriptionPlanAdminDto call({
|
||||
String? id,
|
||||
SubscriptionPlanUIDto? ui,
|
||||
String? price,
|
||||
String? currency,
|
||||
int? durationDays,
|
||||
List<SubscriptionFeatureEnum>? features,
|
||||
PaymentSystem? paymentSystem,
|
||||
String? paymentId,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfSubscriptionPlanAdminDto.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfSubscriptionPlanAdminDto.copyWith.fieldName(...)`
|
||||
class _$SubscriptionPlanAdminDtoCWProxyImpl
|
||||
implements _$SubscriptionPlanAdminDtoCWProxy {
|
||||
const _$SubscriptionPlanAdminDtoCWProxyImpl(this._value);
|
||||
|
||||
final SubscriptionPlanAdminDto _value;
|
||||
|
||||
@override
|
||||
SubscriptionPlanAdminDto id(String? id) => this(id: id);
|
||||
|
||||
@override
|
||||
SubscriptionPlanAdminDto ui(SubscriptionPlanUIDto ui) => this(ui: ui);
|
||||
|
||||
@override
|
||||
SubscriptionPlanAdminDto price(String price) => this(price: price);
|
||||
|
||||
@override
|
||||
SubscriptionPlanAdminDto currency(String currency) =>
|
||||
this(currency: currency);
|
||||
|
||||
@override
|
||||
SubscriptionPlanAdminDto durationDays(int durationDays) =>
|
||||
this(durationDays: durationDays);
|
||||
|
||||
@override
|
||||
SubscriptionPlanAdminDto features(List<SubscriptionFeatureEnum> features) =>
|
||||
this(features: features);
|
||||
|
||||
@override
|
||||
SubscriptionPlanAdminDto paymentSystem(PaymentSystem paymentSystem) =>
|
||||
this(paymentSystem: paymentSystem);
|
||||
|
||||
@override
|
||||
SubscriptionPlanAdminDto paymentId(String? paymentId) =>
|
||||
this(paymentId: paymentId);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `SubscriptionPlanAdminDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// SubscriptionPlanAdminDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
SubscriptionPlanAdminDto call({
|
||||
Object? id = const $CopyWithPlaceholder(),
|
||||
Object? ui = const $CopyWithPlaceholder(),
|
||||
Object? price = const $CopyWithPlaceholder(),
|
||||
Object? currency = const $CopyWithPlaceholder(),
|
||||
Object? durationDays = const $CopyWithPlaceholder(),
|
||||
Object? features = const $CopyWithPlaceholder(),
|
||||
Object? paymentSystem = const $CopyWithPlaceholder(),
|
||||
Object? paymentId = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return SubscriptionPlanAdminDto(
|
||||
id: id == const $CopyWithPlaceholder()
|
||||
? _value.id
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: id as String?,
|
||||
ui: ui == const $CopyWithPlaceholder() || ui == null
|
||||
? _value.ui
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: ui as SubscriptionPlanUIDto,
|
||||
price: price == const $CopyWithPlaceholder() || price == null
|
||||
? _value.price
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: price as String,
|
||||
currency: currency == const $CopyWithPlaceholder() || currency == null
|
||||
? _value.currency
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: currency as String,
|
||||
durationDays:
|
||||
durationDays == const $CopyWithPlaceholder() || durationDays == null
|
||||
? _value.durationDays
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: durationDays as int,
|
||||
features: features == const $CopyWithPlaceholder() || features == null
|
||||
? _value.features
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: features as List<SubscriptionFeatureEnum>,
|
||||
paymentSystem:
|
||||
paymentSystem == const $CopyWithPlaceholder() || paymentSystem == null
|
||||
? _value.paymentSystem
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: paymentSystem as PaymentSystem,
|
||||
paymentId: paymentId == const $CopyWithPlaceholder()
|
||||
? _value.paymentId
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: paymentId as String?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $SubscriptionPlanAdminDtoCopyWith on SubscriptionPlanAdminDto {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfSubscriptionPlanAdminDto.copyWith(...)` or like so:`instanceOfSubscriptionPlanAdminDto.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$SubscriptionPlanAdminDtoCWProxy get copyWith =>
|
||||
_$SubscriptionPlanAdminDtoCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
SubscriptionPlanAdminDto _$SubscriptionPlanAdminDtoFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
SubscriptionPlanAdminDto(
|
||||
id: json['id'] as String?,
|
||||
ui: SubscriptionPlanUIDto.fromJson(json['ui'] as Map<String, dynamic>),
|
||||
price: json['price'] as String,
|
||||
currency: json['currency'] as String,
|
||||
durationDays: json['durationDays'] as int,
|
||||
features: (json['features'] as List<dynamic>)
|
||||
.map((e) => $enumDecode(_$SubscriptionFeatureEnumEnumMap, e))
|
||||
.toList(),
|
||||
paymentSystem: $enumDecode(_$PaymentSystemEnumMap, json['paymentSystem']),
|
||||
paymentId: json['paymentId'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$SubscriptionPlanAdminDtoToJson(
|
||||
SubscriptionPlanAdminDto instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'ui': instance.ui,
|
||||
'price': instance.price,
|
||||
'currency': instance.currency,
|
||||
'durationDays': instance.durationDays,
|
||||
'features': instance.features
|
||||
.map((e) => _$SubscriptionFeatureEnumEnumMap[e]!)
|
||||
.toList(),
|
||||
'paymentSystem': _$PaymentSystemEnumMap[instance.paymentSystem]!,
|
||||
'paymentId': instance.paymentId,
|
||||
};
|
||||
|
||||
const _$SubscriptionFeatureEnumEnumMap = {
|
||||
SubscriptionFeatureEnum.ads: 'ads',
|
||||
SubscriptionFeatureEnum.packs: 'packs',
|
||||
SubscriptionFeatureEnum.unknown: 'unknown',
|
||||
};
|
||||
|
||||
const _$PaymentSystemEnumMap = {
|
||||
PaymentSystem.google: 'google',
|
||||
PaymentSystem.apple: 'apple',
|
||||
PaymentSystem.rustore: 'rustore',
|
||||
PaymentSystem.yookassa: 'yookassa',
|
||||
PaymentSystem.promoCode: 'promoCode',
|
||||
PaymentSystem.adView: 'adView',
|
||||
PaymentSystem.unknown: 'unknown',
|
||||
};
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'package:mnemo_cards_common/mnemo_cards_common.dart';
|
||||
|
||||
|
||||
part 'subscription_plan_dto.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
@CopyWith()
|
||||
class SubscriptionDto {
|
||||
final SubscriptionPageDto? page;
|
||||
final bool isActive;
|
||||
final DateTime? start;
|
||||
final DateTime? finish;
|
||||
|
||||
SubscriptionDto({
|
||||
required this.page,
|
||||
required this.isActive,
|
||||
required this.start,
|
||||
required this.finish,
|
||||
});
|
||||
|
||||
factory SubscriptionDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$SubscriptionDtoFromJson(json);
|
||||
|
||||
Map<String, Object?> toJson() => _$SubscriptionDtoToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
@CopyWith()
|
||||
class SubscriptionPageDto {
|
||||
final String title;
|
||||
final List<Item> items;
|
||||
final List<SubscriptionPlanDto> plans;
|
||||
|
||||
SubscriptionPageDto({
|
||||
required this.title,
|
||||
required this.items,
|
||||
required this.plans,
|
||||
});
|
||||
|
||||
factory SubscriptionPageDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$SubscriptionPageDtoFromJson(json);
|
||||
|
||||
Map<String, Object?> toJson() => _$SubscriptionPageDtoToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
@CopyWith()
|
||||
class SubscriptionPlanDto implements MnemoCardsProductDto {
|
||||
final String id;
|
||||
|
||||
final String? titleLead;
|
||||
final String? title;
|
||||
|
||||
final String? subtitleCrossed;
|
||||
final String? subtitle;
|
||||
|
||||
final String price;
|
||||
final String? pricePerMonth;
|
||||
final String currency;
|
||||
|
||||
final String? tip;
|
||||
final String? tipColor;
|
||||
|
||||
final String? deeplink;
|
||||
|
||||
final List<SubscriptionFeatureEnum> features;
|
||||
|
||||
SubscriptionPlanDto({
|
||||
required this.id,
|
||||
required this.titleLead,
|
||||
required this.title,
|
||||
required this.subtitle,
|
||||
required this.subtitleCrossed,
|
||||
required this.price,
|
||||
required this.pricePerMonth,
|
||||
required this.currency,
|
||||
required this.tip,
|
||||
required this.tipColor,
|
||||
required this.features,
|
||||
required this.deeplink,
|
||||
});
|
||||
|
||||
factory SubscriptionPlanDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$SubscriptionPlanDtoFromJson(json);
|
||||
|
||||
Map<String, Object?> toJson() => _$SubscriptionPlanDtoToJson(this);
|
||||
|
||||
@override
|
||||
MnemoCardsProductType get type => MnemoCardsProductType.subscription;
|
||||
|
||||
// String? get googlePlaySubscriptionId => paymentSystem == PaymentSystem.google
|
||||
// ? paymentId?.split('|').firstOrNull
|
||||
// : null;
|
||||
//
|
||||
// String? get googlePlayPlanId => paymentSystem == PaymentSystem.google
|
||||
// ? paymentId?.split('|').lastOrNull
|
||||
// : null;
|
||||
}
|
||||
|
|
@ -0,0 +1,425 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'subscription_plan_dto.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$SubscriptionDtoCWProxy {
|
||||
SubscriptionDto page(SubscriptionPageDto? page);
|
||||
|
||||
SubscriptionDto isActive(bool isActive);
|
||||
|
||||
SubscriptionDto start(DateTime? start);
|
||||
|
||||
SubscriptionDto finish(DateTime? finish);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `SubscriptionDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// SubscriptionDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
SubscriptionDto call({
|
||||
SubscriptionPageDto? page,
|
||||
bool? isActive,
|
||||
DateTime? start,
|
||||
DateTime? finish,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfSubscriptionDto.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfSubscriptionDto.copyWith.fieldName(...)`
|
||||
class _$SubscriptionDtoCWProxyImpl implements _$SubscriptionDtoCWProxy {
|
||||
const _$SubscriptionDtoCWProxyImpl(this._value);
|
||||
|
||||
final SubscriptionDto _value;
|
||||
|
||||
@override
|
||||
SubscriptionDto page(SubscriptionPageDto? page) => this(page: page);
|
||||
|
||||
@override
|
||||
SubscriptionDto isActive(bool isActive) => this(isActive: isActive);
|
||||
|
||||
@override
|
||||
SubscriptionDto start(DateTime? start) => this(start: start);
|
||||
|
||||
@override
|
||||
SubscriptionDto finish(DateTime? finish) => this(finish: finish);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `SubscriptionDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// SubscriptionDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
SubscriptionDto call({
|
||||
Object? page = const $CopyWithPlaceholder(),
|
||||
Object? isActive = const $CopyWithPlaceholder(),
|
||||
Object? start = const $CopyWithPlaceholder(),
|
||||
Object? finish = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return SubscriptionDto(
|
||||
page: page == const $CopyWithPlaceholder()
|
||||
? _value.page
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: page as SubscriptionPageDto?,
|
||||
isActive: isActive == const $CopyWithPlaceholder() || isActive == null
|
||||
? _value.isActive
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: isActive as bool,
|
||||
start: start == const $CopyWithPlaceholder()
|
||||
? _value.start
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: start as DateTime?,
|
||||
finish: finish == const $CopyWithPlaceholder()
|
||||
? _value.finish
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: finish as DateTime?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $SubscriptionDtoCopyWith on SubscriptionDto {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfSubscriptionDto.copyWith(...)` or like so:`instanceOfSubscriptionDto.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$SubscriptionDtoCWProxy get copyWith => _$SubscriptionDtoCWProxyImpl(this);
|
||||
}
|
||||
|
||||
abstract class _$SubscriptionPageDtoCWProxy {
|
||||
SubscriptionPageDto title(String title);
|
||||
|
||||
SubscriptionPageDto items(List<Item> items);
|
||||
|
||||
SubscriptionPageDto plans(List<SubscriptionPlanDto> plans);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `SubscriptionPageDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// SubscriptionPageDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
SubscriptionPageDto call({
|
||||
String? title,
|
||||
List<Item>? items,
|
||||
List<SubscriptionPlanDto>? plans,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfSubscriptionPageDto.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfSubscriptionPageDto.copyWith.fieldName(...)`
|
||||
class _$SubscriptionPageDtoCWProxyImpl implements _$SubscriptionPageDtoCWProxy {
|
||||
const _$SubscriptionPageDtoCWProxyImpl(this._value);
|
||||
|
||||
final SubscriptionPageDto _value;
|
||||
|
||||
@override
|
||||
SubscriptionPageDto title(String title) => this(title: title);
|
||||
|
||||
@override
|
||||
SubscriptionPageDto items(List<Item> items) => this(items: items);
|
||||
|
||||
@override
|
||||
SubscriptionPageDto plans(List<SubscriptionPlanDto> plans) =>
|
||||
this(plans: plans);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `SubscriptionPageDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// SubscriptionPageDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
SubscriptionPageDto call({
|
||||
Object? title = const $CopyWithPlaceholder(),
|
||||
Object? items = const $CopyWithPlaceholder(),
|
||||
Object? plans = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return SubscriptionPageDto(
|
||||
title: title == const $CopyWithPlaceholder() || title == null
|
||||
? _value.title
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: title as String,
|
||||
items: items == const $CopyWithPlaceholder() || items == null
|
||||
? _value.items
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: items as List<Item>,
|
||||
plans: plans == const $CopyWithPlaceholder() || plans == null
|
||||
? _value.plans
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: plans as List<SubscriptionPlanDto>,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $SubscriptionPageDtoCopyWith on SubscriptionPageDto {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfSubscriptionPageDto.copyWith(...)` or like so:`instanceOfSubscriptionPageDto.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$SubscriptionPageDtoCWProxy get copyWith =>
|
||||
_$SubscriptionPageDtoCWProxyImpl(this);
|
||||
}
|
||||
|
||||
abstract class _$SubscriptionPlanDtoCWProxy {
|
||||
SubscriptionPlanDto id(String id);
|
||||
|
||||
SubscriptionPlanDto titleLead(String? titleLead);
|
||||
|
||||
SubscriptionPlanDto title(String? title);
|
||||
|
||||
SubscriptionPlanDto subtitle(String? subtitle);
|
||||
|
||||
SubscriptionPlanDto subtitleCrossed(String? subtitleCrossed);
|
||||
|
||||
SubscriptionPlanDto price(String price);
|
||||
|
||||
SubscriptionPlanDto pricePerMonth(String? pricePerMonth);
|
||||
|
||||
SubscriptionPlanDto currency(String currency);
|
||||
|
||||
SubscriptionPlanDto tip(String? tip);
|
||||
|
||||
SubscriptionPlanDto tipColor(String? tipColor);
|
||||
|
||||
SubscriptionPlanDto features(List<SubscriptionFeatureEnum> features);
|
||||
|
||||
SubscriptionPlanDto deeplink(String? deeplink);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `SubscriptionPlanDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// SubscriptionPlanDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
SubscriptionPlanDto call({
|
||||
String? id,
|
||||
String? titleLead,
|
||||
String? title,
|
||||
String? subtitle,
|
||||
String? subtitleCrossed,
|
||||
String? price,
|
||||
String? pricePerMonth,
|
||||
String? currency,
|
||||
String? tip,
|
||||
String? tipColor,
|
||||
List<SubscriptionFeatureEnum>? features,
|
||||
String? deeplink,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfSubscriptionPlanDto.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfSubscriptionPlanDto.copyWith.fieldName(...)`
|
||||
class _$SubscriptionPlanDtoCWProxyImpl implements _$SubscriptionPlanDtoCWProxy {
|
||||
const _$SubscriptionPlanDtoCWProxyImpl(this._value);
|
||||
|
||||
final SubscriptionPlanDto _value;
|
||||
|
||||
@override
|
||||
SubscriptionPlanDto id(String id) => this(id: id);
|
||||
|
||||
@override
|
||||
SubscriptionPlanDto titleLead(String? titleLead) =>
|
||||
this(titleLead: titleLead);
|
||||
|
||||
@override
|
||||
SubscriptionPlanDto title(String? title) => this(title: title);
|
||||
|
||||
@override
|
||||
SubscriptionPlanDto subtitle(String? subtitle) => this(subtitle: subtitle);
|
||||
|
||||
@override
|
||||
SubscriptionPlanDto subtitleCrossed(String? subtitleCrossed) =>
|
||||
this(subtitleCrossed: subtitleCrossed);
|
||||
|
||||
@override
|
||||
SubscriptionPlanDto price(String price) => this(price: price);
|
||||
|
||||
@override
|
||||
SubscriptionPlanDto pricePerMonth(String? pricePerMonth) =>
|
||||
this(pricePerMonth: pricePerMonth);
|
||||
|
||||
@override
|
||||
SubscriptionPlanDto currency(String currency) => this(currency: currency);
|
||||
|
||||
@override
|
||||
SubscriptionPlanDto tip(String? tip) => this(tip: tip);
|
||||
|
||||
@override
|
||||
SubscriptionPlanDto tipColor(String? tipColor) => this(tipColor: tipColor);
|
||||
|
||||
@override
|
||||
SubscriptionPlanDto features(List<SubscriptionFeatureEnum> features) =>
|
||||
this(features: features);
|
||||
|
||||
@override
|
||||
SubscriptionPlanDto deeplink(String? deeplink) => this(deeplink: deeplink);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `SubscriptionPlanDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// SubscriptionPlanDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
SubscriptionPlanDto call({
|
||||
Object? id = const $CopyWithPlaceholder(),
|
||||
Object? titleLead = const $CopyWithPlaceholder(),
|
||||
Object? title = const $CopyWithPlaceholder(),
|
||||
Object? subtitle = const $CopyWithPlaceholder(),
|
||||
Object? subtitleCrossed = const $CopyWithPlaceholder(),
|
||||
Object? price = const $CopyWithPlaceholder(),
|
||||
Object? pricePerMonth = const $CopyWithPlaceholder(),
|
||||
Object? currency = const $CopyWithPlaceholder(),
|
||||
Object? tip = const $CopyWithPlaceholder(),
|
||||
Object? tipColor = const $CopyWithPlaceholder(),
|
||||
Object? features = const $CopyWithPlaceholder(),
|
||||
Object? deeplink = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return SubscriptionPlanDto(
|
||||
id: id == const $CopyWithPlaceholder() || id == null
|
||||
? _value.id
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: id as String,
|
||||
titleLead: titleLead == const $CopyWithPlaceholder()
|
||||
? _value.titleLead
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: titleLead as String?,
|
||||
title: title == const $CopyWithPlaceholder()
|
||||
? _value.title
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: title as String?,
|
||||
subtitle: subtitle == const $CopyWithPlaceholder()
|
||||
? _value.subtitle
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: subtitle as String?,
|
||||
subtitleCrossed: subtitleCrossed == const $CopyWithPlaceholder()
|
||||
? _value.subtitleCrossed
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: subtitleCrossed as String?,
|
||||
price: price == const $CopyWithPlaceholder() || price == null
|
||||
? _value.price
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: price as String,
|
||||
pricePerMonth: pricePerMonth == const $CopyWithPlaceholder()
|
||||
? _value.pricePerMonth
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: pricePerMonth as String?,
|
||||
currency: currency == const $CopyWithPlaceholder() || currency == null
|
||||
? _value.currency
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: currency as String,
|
||||
tip: tip == const $CopyWithPlaceholder()
|
||||
? _value.tip
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: tip as String?,
|
||||
tipColor: tipColor == const $CopyWithPlaceholder()
|
||||
? _value.tipColor
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: tipColor as String?,
|
||||
features: features == const $CopyWithPlaceholder() || features == null
|
||||
? _value.features
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: features as List<SubscriptionFeatureEnum>,
|
||||
deeplink: deeplink == const $CopyWithPlaceholder()
|
||||
? _value.deeplink
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: deeplink as String?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $SubscriptionPlanDtoCopyWith on SubscriptionPlanDto {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfSubscriptionPlanDto.copyWith(...)` or like so:`instanceOfSubscriptionPlanDto.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$SubscriptionPlanDtoCWProxy get copyWith =>
|
||||
_$SubscriptionPlanDtoCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
SubscriptionDto _$SubscriptionDtoFromJson(Map<String, dynamic> json) =>
|
||||
SubscriptionDto(
|
||||
page: json['page'] == null
|
||||
? null
|
||||
: SubscriptionPageDto.fromJson(json['page'] as Map<String, dynamic>),
|
||||
isActive: json['isActive'] as bool,
|
||||
start: json['start'] == null
|
||||
? null
|
||||
: DateTime.parse(json['start'] as String),
|
||||
finish: json['finish'] == null
|
||||
? null
|
||||
: DateTime.parse(json['finish'] as String),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$SubscriptionDtoToJson(SubscriptionDto instance) =>
|
||||
<String, dynamic>{
|
||||
'page': instance.page,
|
||||
'isActive': instance.isActive,
|
||||
'start': instance.start?.toIso8601String(),
|
||||
'finish': instance.finish?.toIso8601String(),
|
||||
};
|
||||
|
||||
SubscriptionPageDto _$SubscriptionPageDtoFromJson(Map<String, dynamic> json) =>
|
||||
SubscriptionPageDto(
|
||||
title: json['title'] as String,
|
||||
items: (json['items'] as List<dynamic>)
|
||||
.map((e) => Item.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
plans: (json['plans'] as List<dynamic>)
|
||||
.map((e) => SubscriptionPlanDto.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$SubscriptionPageDtoToJson(
|
||||
SubscriptionPageDto instance) =>
|
||||
<String, dynamic>{
|
||||
'title': instance.title,
|
||||
'items': instance.items,
|
||||
'plans': instance.plans,
|
||||
};
|
||||
|
||||
SubscriptionPlanDto _$SubscriptionPlanDtoFromJson(Map<String, dynamic> json) =>
|
||||
SubscriptionPlanDto(
|
||||
id: json['id'] as String,
|
||||
titleLead: json['titleLead'] as String?,
|
||||
title: json['title'] as String?,
|
||||
subtitle: json['subtitle'] as String?,
|
||||
subtitleCrossed: json['subtitleCrossed'] as String?,
|
||||
price: json['price'] as String,
|
||||
pricePerMonth: json['pricePerMonth'] as String?,
|
||||
currency: json['currency'] as String,
|
||||
tip: json['tip'] as String?,
|
||||
tipColor: json['tipColor'] as String?,
|
||||
features: (json['features'] as List<dynamic>)
|
||||
.map((e) => $enumDecode(_$SubscriptionFeatureEnumEnumMap, e))
|
||||
.toList(),
|
||||
deeplink: json['deeplink'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$SubscriptionPlanDtoToJson(
|
||||
SubscriptionPlanDto instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'titleLead': instance.titleLead,
|
||||
'title': instance.title,
|
||||
'subtitleCrossed': instance.subtitleCrossed,
|
||||
'subtitle': instance.subtitle,
|
||||
'price': instance.price,
|
||||
'pricePerMonth': instance.pricePerMonth,
|
||||
'currency': instance.currency,
|
||||
'tip': instance.tip,
|
||||
'tipColor': instance.tipColor,
|
||||
'deeplink': instance.deeplink,
|
||||
'features': instance.features
|
||||
.map((e) => _$SubscriptionFeatureEnumEnumMap[e]!)
|
||||
.toList(),
|
||||
};
|
||||
|
||||
const _$SubscriptionFeatureEnumEnumMap = {
|
||||
SubscriptionFeatureEnum.ads: 'ads',
|
||||
SubscriptionFeatureEnum.packs: 'packs',
|
||||
SubscriptionFeatureEnum.unknown: 'unknown',
|
||||
};
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
|
||||
part 'subscription_plan_ui_dto.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
@CopyWith()
|
||||
class SubscriptionPlanUIDto {
|
||||
final String? titleLead;
|
||||
final String? title;
|
||||
|
||||
final String? subtitleCrossed;
|
||||
final String? subtitle;
|
||||
|
||||
final String? pricePerMonth;
|
||||
final String? currency;
|
||||
|
||||
final String? tip;
|
||||
final String? tipColor;
|
||||
|
||||
const SubscriptionPlanUIDto({
|
||||
this.titleLead,
|
||||
this.title,
|
||||
this.subtitleCrossed,
|
||||
this.subtitle,
|
||||
this.pricePerMonth,
|
||||
this.currency,
|
||||
this.tip,
|
||||
this.tipColor,
|
||||
});
|
||||
|
||||
factory SubscriptionPlanUIDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$SubscriptionPlanUIDtoFromJson(json);
|
||||
|
||||
Map<String, Object?> toJson() => _$SubscriptionPlanUIDtoToJson(this);
|
||||
}
|
||||
|
|
@ -0,0 +1,168 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'subscription_plan_ui_dto.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$SubscriptionPlanUIDtoCWProxy {
|
||||
SubscriptionPlanUIDto titleLead(String? titleLead);
|
||||
|
||||
SubscriptionPlanUIDto title(String? title);
|
||||
|
||||
SubscriptionPlanUIDto subtitleCrossed(String? subtitleCrossed);
|
||||
|
||||
SubscriptionPlanUIDto subtitle(String? subtitle);
|
||||
|
||||
SubscriptionPlanUIDto pricePerMonth(String? pricePerMonth);
|
||||
|
||||
SubscriptionPlanUIDto currency(String? currency);
|
||||
|
||||
SubscriptionPlanUIDto tip(String? tip);
|
||||
|
||||
SubscriptionPlanUIDto tipColor(String? tipColor);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `SubscriptionPlanUIDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// SubscriptionPlanUIDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
SubscriptionPlanUIDto call({
|
||||
String? titleLead,
|
||||
String? title,
|
||||
String? subtitleCrossed,
|
||||
String? subtitle,
|
||||
String? pricePerMonth,
|
||||
String? currency,
|
||||
String? tip,
|
||||
String? tipColor,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfSubscriptionPlanUIDto.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfSubscriptionPlanUIDto.copyWith.fieldName(...)`
|
||||
class _$SubscriptionPlanUIDtoCWProxyImpl
|
||||
implements _$SubscriptionPlanUIDtoCWProxy {
|
||||
const _$SubscriptionPlanUIDtoCWProxyImpl(this._value);
|
||||
|
||||
final SubscriptionPlanUIDto _value;
|
||||
|
||||
@override
|
||||
SubscriptionPlanUIDto titleLead(String? titleLead) =>
|
||||
this(titleLead: titleLead);
|
||||
|
||||
@override
|
||||
SubscriptionPlanUIDto title(String? title) => this(title: title);
|
||||
|
||||
@override
|
||||
SubscriptionPlanUIDto subtitleCrossed(String? subtitleCrossed) =>
|
||||
this(subtitleCrossed: subtitleCrossed);
|
||||
|
||||
@override
|
||||
SubscriptionPlanUIDto subtitle(String? subtitle) => this(subtitle: subtitle);
|
||||
|
||||
@override
|
||||
SubscriptionPlanUIDto pricePerMonth(String? pricePerMonth) =>
|
||||
this(pricePerMonth: pricePerMonth);
|
||||
|
||||
@override
|
||||
SubscriptionPlanUIDto currency(String? currency) => this(currency: currency);
|
||||
|
||||
@override
|
||||
SubscriptionPlanUIDto tip(String? tip) => this(tip: tip);
|
||||
|
||||
@override
|
||||
SubscriptionPlanUIDto tipColor(String? tipColor) => this(tipColor: tipColor);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `SubscriptionPlanUIDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// SubscriptionPlanUIDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
SubscriptionPlanUIDto call({
|
||||
Object? titleLead = const $CopyWithPlaceholder(),
|
||||
Object? title = const $CopyWithPlaceholder(),
|
||||
Object? subtitleCrossed = const $CopyWithPlaceholder(),
|
||||
Object? subtitle = const $CopyWithPlaceholder(),
|
||||
Object? pricePerMonth = const $CopyWithPlaceholder(),
|
||||
Object? currency = const $CopyWithPlaceholder(),
|
||||
Object? tip = const $CopyWithPlaceholder(),
|
||||
Object? tipColor = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return SubscriptionPlanUIDto(
|
||||
titleLead: titleLead == const $CopyWithPlaceholder()
|
||||
? _value.titleLead
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: titleLead as String?,
|
||||
title: title == const $CopyWithPlaceholder()
|
||||
? _value.title
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: title as String?,
|
||||
subtitleCrossed: subtitleCrossed == const $CopyWithPlaceholder()
|
||||
? _value.subtitleCrossed
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: subtitleCrossed as String?,
|
||||
subtitle: subtitle == const $CopyWithPlaceholder()
|
||||
? _value.subtitle
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: subtitle as String?,
|
||||
pricePerMonth: pricePerMonth == const $CopyWithPlaceholder()
|
||||
? _value.pricePerMonth
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: pricePerMonth as String?,
|
||||
currency: currency == const $CopyWithPlaceholder()
|
||||
? _value.currency
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: currency as String?,
|
||||
tip: tip == const $CopyWithPlaceholder()
|
||||
? _value.tip
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: tip as String?,
|
||||
tipColor: tipColor == const $CopyWithPlaceholder()
|
||||
? _value.tipColor
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: tipColor as String?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $SubscriptionPlanUIDtoCopyWith on SubscriptionPlanUIDto {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfSubscriptionPlanUIDto.copyWith(...)` or like so:`instanceOfSubscriptionPlanUIDto.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$SubscriptionPlanUIDtoCWProxy get copyWith =>
|
||||
_$SubscriptionPlanUIDtoCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
SubscriptionPlanUIDto _$SubscriptionPlanUIDtoFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
SubscriptionPlanUIDto(
|
||||
titleLead: json['titleLead'] as String?,
|
||||
title: json['title'] as String?,
|
||||
subtitleCrossed: json['subtitleCrossed'] as String?,
|
||||
subtitle: json['subtitle'] as String?,
|
||||
pricePerMonth: json['pricePerMonth'] as String?,
|
||||
currency: json['currency'] as String?,
|
||||
tip: json['tip'] as String?,
|
||||
tipColor: json['tipColor'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$SubscriptionPlanUIDtoToJson(
|
||||
SubscriptionPlanUIDto instance) =>
|
||||
<String, dynamic>{
|
||||
'titleLead': instance.titleLead,
|
||||
'title': instance.title,
|
||||
'subtitleCrossed': instance.subtitleCrossed,
|
||||
'subtitle': instance.subtitle,
|
||||
'pricePerMonth': instance.pricePerMonth,
|
||||
'currency': instance.currency,
|
||||
'tip': instance.tip,
|
||||
'tipColor': instance.tipColor,
|
||||
};
|
||||
366
mnemo_cards_common/lib/src/dtos/user/achievement_dto.dart
Normal file
366
mnemo_cards_common/lib/src/dtos/user/achievement_dto.dart
Normal file
|
|
@ -0,0 +1,366 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
|
||||
part 'achievement_dto.g.dart';
|
||||
|
||||
/// Achievement types available in the system
|
||||
enum AchievementType {
|
||||
/// First steps achievements
|
||||
firstWordLearned,
|
||||
firstTestCompleted,
|
||||
firstPackCompleted,
|
||||
|
||||
/// Streak achievements
|
||||
streak3Days,
|
||||
streak7Days,
|
||||
streak30Days,
|
||||
streak100Days,
|
||||
|
||||
/// Words mastery achievements
|
||||
words10Learned,
|
||||
words50Learned,
|
||||
words100Learned,
|
||||
words500Learned,
|
||||
words1000Learned,
|
||||
|
||||
/// Test performance achievements
|
||||
perfectTestScore,
|
||||
speedLearner, // Complete pack in less than 1 day
|
||||
dedicatedLearner, // Study time milestones
|
||||
|
||||
/// Time-based achievements
|
||||
nightOwl, // Study after 10 PM
|
||||
earlyBird, // Study before 6 AM
|
||||
|
||||
/// Special achievements
|
||||
consistentLearner, // Study every day for a month
|
||||
languageMaster, // Complete multiple packs
|
||||
}
|
||||
|
||||
/// Achievement data structure
|
||||
@JsonSerializable()
|
||||
@CopyWith()
|
||||
class AchievementDto {
|
||||
/// Unique achievement identifier
|
||||
final String id;
|
||||
|
||||
/// Achievement title (localized)
|
||||
final String title;
|
||||
|
||||
/// Achievement description (localized)
|
||||
final String description;
|
||||
|
||||
/// URL to achievement icon/badge image
|
||||
final String? iconUrl;
|
||||
|
||||
/// When this achievement was unlocked (null if locked)
|
||||
final DateTime? unlockedAt;
|
||||
|
||||
/// Achievement type for categorization
|
||||
final AchievementType type;
|
||||
|
||||
/// Progress towards unlocking (0.0 to 1.0 for locked achievements)
|
||||
final double progress;
|
||||
|
||||
const AchievementDto({
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.description,
|
||||
this.iconUrl,
|
||||
this.unlockedAt,
|
||||
required this.type,
|
||||
this.progress = 0.0,
|
||||
});
|
||||
|
||||
factory AchievementDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$AchievementDtoFromJson(json);
|
||||
|
||||
Map<String, Object?> toJson() => _$AchievementDtoToJson(this);
|
||||
|
||||
/// Check if achievement is unlocked
|
||||
bool get isUnlocked => unlockedAt != null;
|
||||
|
||||
/// Check if achievement is locked
|
||||
bool get isLocked => unlockedAt == null;
|
||||
|
||||
/// Create achievement with current unlock time
|
||||
AchievementDto unlock() => AchievementDto(
|
||||
id: id,
|
||||
title: title,
|
||||
description: description,
|
||||
iconUrl: iconUrl,
|
||||
unlockedAt: DateTime.now(),
|
||||
type: type,
|
||||
progress: 1.0,
|
||||
);
|
||||
|
||||
/// Update progress
|
||||
AchievementDto updateProgress(double newProgress) => AchievementDto(
|
||||
id: id,
|
||||
title: title,
|
||||
description: description,
|
||||
iconUrl: iconUrl,
|
||||
unlockedAt: unlockedAt,
|
||||
type: type,
|
||||
progress: newProgress.clamp(0.0, 1.0),
|
||||
);
|
||||
|
||||
/// Get achievement category
|
||||
String get category {
|
||||
switch (type) {
|
||||
case AchievementType.firstWordLearned:
|
||||
case AchievementType.firstTestCompleted:
|
||||
case AchievementType.firstPackCompleted:
|
||||
return 'first_steps';
|
||||
|
||||
case AchievementType.streak3Days:
|
||||
case AchievementType.streak7Days:
|
||||
case AchievementType.streak30Days:
|
||||
case AchievementType.streak100Days:
|
||||
return 'streaks';
|
||||
|
||||
case AchievementType.words10Learned:
|
||||
case AchievementType.words50Learned:
|
||||
case AchievementType.words100Learned:
|
||||
case AchievementType.words500Learned:
|
||||
case AchievementType.words1000Learned:
|
||||
return 'words_mastery';
|
||||
|
||||
case AchievementType.perfectTestScore:
|
||||
case AchievementType.speedLearner:
|
||||
return 'performance';
|
||||
|
||||
case AchievementType.dedicatedLearner:
|
||||
return 'dedication';
|
||||
|
||||
case AchievementType.nightOwl:
|
||||
case AchievementType.earlyBird:
|
||||
return 'time_based';
|
||||
|
||||
case AchievementType.consistentLearner:
|
||||
case AchievementType.languageMaster:
|
||||
return 'special';
|
||||
}
|
||||
}
|
||||
|
||||
/// Get sort order within category
|
||||
int get sortOrder {
|
||||
switch (type) {
|
||||
case AchievementType.firstWordLearned:
|
||||
return 1;
|
||||
case AchievementType.firstTestCompleted:
|
||||
return 2;
|
||||
case AchievementType.firstPackCompleted:
|
||||
return 3;
|
||||
|
||||
case AchievementType.streak3Days:
|
||||
return 1;
|
||||
case AchievementType.streak7Days:
|
||||
return 2;
|
||||
case AchievementType.streak30Days:
|
||||
return 3;
|
||||
case AchievementType.streak100Days:
|
||||
return 4;
|
||||
|
||||
case AchievementType.words10Learned:
|
||||
return 1;
|
||||
case AchievementType.words50Learned:
|
||||
return 2;
|
||||
case AchievementType.words100Learned:
|
||||
return 3;
|
||||
case AchievementType.words500Learned:
|
||||
return 4;
|
||||
case AchievementType.words1000Learned:
|
||||
return 5;
|
||||
|
||||
case AchievementType.perfectTestScore:
|
||||
return 1;
|
||||
case AchievementType.speedLearner:
|
||||
return 2;
|
||||
case AchievementType.dedicatedLearner:
|
||||
return 3;
|
||||
|
||||
case AchievementType.earlyBird:
|
||||
return 1;
|
||||
case AchievementType.nightOwl:
|
||||
return 2;
|
||||
|
||||
case AchievementType.consistentLearner:
|
||||
return 1;
|
||||
case AchievementType.languageMaster:
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is AchievementDto &&
|
||||
runtimeType == other.runtimeType &&
|
||||
id == other.id &&
|
||||
title == other.title &&
|
||||
description == other.description &&
|
||||
iconUrl == other.iconUrl &&
|
||||
unlockedAt == other.unlockedAt &&
|
||||
type == other.type &&
|
||||
progress == other.progress;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
id.hashCode ^
|
||||
title.hashCode ^
|
||||
description.hashCode ^
|
||||
iconUrl.hashCode ^
|
||||
unlockedAt.hashCode ^
|
||||
type.hashCode ^
|
||||
progress.hashCode;
|
||||
|
||||
@override
|
||||
String toString() =>
|
||||
'AchievementDto(id: $id, title: $title, unlocked: $isUnlocked, progress: $progress)';
|
||||
}
|
||||
|
||||
/// Predefined achievements configuration
|
||||
class AchievementDefinitions {
|
||||
static const allAchievements = [
|
||||
AchievementDto(
|
||||
id: 'first_word',
|
||||
title: 'First Word',
|
||||
description: 'Learn your first word',
|
||||
type: AchievementType.firstWordLearned,
|
||||
),
|
||||
AchievementDto(
|
||||
id: 'first_test',
|
||||
title: 'First Test',
|
||||
description: 'Complete your first test',
|
||||
type: AchievementType.firstTestCompleted,
|
||||
),
|
||||
AchievementDto(
|
||||
id: 'first_pack',
|
||||
title: 'First Pack',
|
||||
description: 'Complete your first pack',
|
||||
type: AchievementType.firstPackCompleted,
|
||||
),
|
||||
|
||||
AchievementDto(
|
||||
id: 'streak_3',
|
||||
title: '3-Day Streak',
|
||||
description: 'Study for 3 consecutive days',
|
||||
type: AchievementType.streak3Days,
|
||||
),
|
||||
AchievementDto(
|
||||
id: 'streak_7',
|
||||
title: 'Week Warrior',
|
||||
description: 'Study for 7 consecutive days',
|
||||
type: AchievementType.streak7Days,
|
||||
),
|
||||
AchievementDto(
|
||||
id: 'streak_30',
|
||||
title: 'Monthly Master',
|
||||
description: 'Study for 30 consecutive days',
|
||||
type: AchievementType.streak30Days,
|
||||
),
|
||||
AchievementDto(
|
||||
id: 'streak_100',
|
||||
title: 'Century Champion',
|
||||
description: 'Study for 100 consecutive days',
|
||||
type: AchievementType.streak100Days,
|
||||
),
|
||||
|
||||
AchievementDto(
|
||||
id: 'words_10',
|
||||
title: 'Word Explorer',
|
||||
description: 'Learn 10 words',
|
||||
type: AchievementType.words10Learned,
|
||||
),
|
||||
AchievementDto(
|
||||
id: 'words_50',
|
||||
title: 'Vocabulary Builder',
|
||||
description: 'Learn 50 words',
|
||||
type: AchievementType.words50Learned,
|
||||
),
|
||||
AchievementDto(
|
||||
id: 'words_100',
|
||||
title: 'Language Learner',
|
||||
description: 'Learn 100 words',
|
||||
type: AchievementType.words100Learned,
|
||||
),
|
||||
AchievementDto(
|
||||
id: 'words_500',
|
||||
title: 'Word Master',
|
||||
description: 'Learn 500 words',
|
||||
type: AchievementType.words500Learned,
|
||||
),
|
||||
AchievementDto(
|
||||
id: 'words_1000',
|
||||
title: 'Vocabulary Expert',
|
||||
description: 'Learn 1000 words',
|
||||
type: AchievementType.words1000Learned,
|
||||
),
|
||||
|
||||
AchievementDto(
|
||||
id: 'perfect_test',
|
||||
title: 'Perfect Score',
|
||||
description: 'Get 100% on a test',
|
||||
type: AchievementType.perfectTestScore,
|
||||
),
|
||||
AchievementDto(
|
||||
id: 'speed_learner',
|
||||
title: 'Speed Learner',
|
||||
description: 'Complete a pack in less than 24 hours',
|
||||
type: AchievementType.speedLearner,
|
||||
),
|
||||
AchievementDto(
|
||||
id: 'dedicated_learner',
|
||||
title: 'Dedicated Learner',
|
||||
description: 'Study for 100 hours total',
|
||||
type: AchievementType.dedicatedLearner,
|
||||
),
|
||||
|
||||
AchievementDto(
|
||||
id: 'early_bird',
|
||||
title: 'Early Bird',
|
||||
description: 'Study before 6 AM',
|
||||
type: AchievementType.earlyBird,
|
||||
),
|
||||
AchievementDto(
|
||||
id: 'night_owl',
|
||||
title: 'Night Owl',
|
||||
description: 'Study after 10 PM',
|
||||
type: AchievementType.nightOwl,
|
||||
),
|
||||
|
||||
AchievementDto(
|
||||
id: 'consistent_learner',
|
||||
title: 'Consistent Learner',
|
||||
description: 'Study every day for 30 days',
|
||||
type: AchievementType.consistentLearner,
|
||||
),
|
||||
AchievementDto(
|
||||
id: 'language_master',
|
||||
title: 'Language Master',
|
||||
description: 'Complete 10 packs',
|
||||
type: AchievementType.languageMaster,
|
||||
),
|
||||
];
|
||||
|
||||
/// Get achievement definition by ID
|
||||
static AchievementDto? getById(String id) {
|
||||
return allAchievements.where((achievement) => achievement.id == id).firstOrNull;
|
||||
}
|
||||
|
||||
/// Get achievements by category
|
||||
static List<AchievementDto> getByCategory(String category) {
|
||||
return allAchievements.where((achievement) => achievement.category == category).toList();
|
||||
}
|
||||
}
|
||||
|
||||
extension on Iterable<AchievementDto> {
|
||||
AchievementDto? get firstOrNull {
|
||||
try {
|
||||
return first;
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
53
mnemo_cards_common/lib/src/dtos/user/achievement_dto.g.dart
Normal file
53
mnemo_cards_common/lib/src/dtos/user/achievement_dto.g.dart
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'achievement_dto.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
AchievementDto _$AchievementDtoFromJson(Map<String, dynamic> json) =>
|
||||
AchievementDto(
|
||||
id: json['id'] as String,
|
||||
title: json['title'] as String,
|
||||
description: json['description'] as String,
|
||||
iconUrl: json['iconUrl'] as String?,
|
||||
unlockedAt: json['unlockedAt'] == null
|
||||
? null
|
||||
: DateTime.parse(json['unlockedAt'] as String),
|
||||
type: $enumDecode(_$AchievementTypeEnumMap, json['type']),
|
||||
progress: (json['progress'] as num?)?.toDouble() ?? 0.0,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$AchievementDtoToJson(AchievementDto instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'title': instance.title,
|
||||
'description': instance.description,
|
||||
'iconUrl': instance.iconUrl,
|
||||
'unlockedAt': instance.unlockedAt?.toIso8601String(),
|
||||
'type': _$AchievementTypeEnumMap[instance.type],
|
||||
'progress': instance.progress,
|
||||
};
|
||||
|
||||
const _$AchievementTypeEnumMap = {
|
||||
AchievementType.firstWordLearned: 'firstWordLearned',
|
||||
AchievementType.firstTestCompleted: 'firstTestCompleted',
|
||||
AchievementType.firstPackCompleted: 'firstPackCompleted',
|
||||
AchievementType.streak3Days: 'streak3Days',
|
||||
AchievementType.streak7Days: 'streak7Days',
|
||||
AchievementType.streak30Days: 'streak30Days',
|
||||
AchievementType.streak100Days: 'streak100Days',
|
||||
AchievementType.words10Learned: 'words10Learned',
|
||||
AchievementType.words50Learned: 'words50Learned',
|
||||
AchievementType.words100Learned: 'words100Learned',
|
||||
AchievementType.words500Learned: 'words500Learned',
|
||||
AchievementType.words1000Learned: 'words1000Learned',
|
||||
AchievementType.perfectTestScore: 'perfectTestScore',
|
||||
AchievementType.speedLearner: 'speedLearner',
|
||||
AchievementType.dedicatedLearner: 'dedicatedLearner',
|
||||
AchievementType.nightOwl: 'nightOwl',
|
||||
AchievementType.earlyBird: 'earlyBird',
|
||||
AchievementType.consistentLearner: 'consistentLearner',
|
||||
AchievementType.languageMaster: 'languageMaster',
|
||||
};
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'package:mnemo_cards_common/mnemo_cards_common.dart';
|
||||
|
||||
part 'all_tests_statistics_dto.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
@CopyWith()
|
||||
class AllTestsStatisticsDto {
|
||||
final Map<int, TestStatisticsDto> tests;
|
||||
final String? lastSessionToken;
|
||||
|
||||
AllTestsStatisticsDto({
|
||||
required this.tests,
|
||||
required this.lastSessionToken,
|
||||
});
|
||||
|
||||
AllTestsStatisticsDto.empty()
|
||||
: tests = const {},
|
||||
lastSessionToken = null;
|
||||
|
||||
factory AllTestsStatisticsDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$AllTestsStatisticsDtoFromJson(json);
|
||||
|
||||
Map<String, Object?> toJson() => _$AllTestsStatisticsDtoToJson(this);
|
||||
|
||||
AllTestsStatisticsDto add(TestStatisticsDto testStat) {
|
||||
return copyWith(
|
||||
tests: Map.from(tests)..[testStat.testId] = testStat,
|
||||
lastSessionToken: testStat.sessionToken,
|
||||
);
|
||||
}
|
||||
|
||||
// AllTestsStatisticsDto merge(
|
||||
// AllTestsStatisticsDto other,
|
||||
// String? sessionKey,
|
||||
// ) {
|
||||
// final updatedTests = Map.of(tests);
|
||||
// for (final entry in other.tests.entries) {
|
||||
// updatedTests[entry.key] =
|
||||
// tests[entry.key]?.merge(entry.value) ?? entry.value;
|
||||
// }
|
||||
// return copyWith(
|
||||
// tests: updatedTests,
|
||||
// lastSessionToken: sessionKey,
|
||||
// );
|
||||
// }
|
||||
}
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'all_tests_statistics_dto.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$AllTestsStatisticsDtoCWProxy {
|
||||
AllTestsStatisticsDto tests(Map<int, TestStatisticsDto> tests);
|
||||
|
||||
AllTestsStatisticsDto lastSessionToken(String? lastSessionToken);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `AllTestsStatisticsDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// AllTestsStatisticsDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
AllTestsStatisticsDto call({
|
||||
Map<int, TestStatisticsDto>? tests,
|
||||
String? lastSessionToken,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfAllTestsStatisticsDto.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfAllTestsStatisticsDto.copyWith.fieldName(...)`
|
||||
class _$AllTestsStatisticsDtoCWProxyImpl
|
||||
implements _$AllTestsStatisticsDtoCWProxy {
|
||||
const _$AllTestsStatisticsDtoCWProxyImpl(this._value);
|
||||
|
||||
final AllTestsStatisticsDto _value;
|
||||
|
||||
@override
|
||||
AllTestsStatisticsDto tests(Map<int, TestStatisticsDto> tests) =>
|
||||
this(tests: tests);
|
||||
|
||||
@override
|
||||
AllTestsStatisticsDto lastSessionToken(String? lastSessionToken) =>
|
||||
this(lastSessionToken: lastSessionToken);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `AllTestsStatisticsDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// AllTestsStatisticsDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
AllTestsStatisticsDto call({
|
||||
Object? tests = const $CopyWithPlaceholder(),
|
||||
Object? lastSessionToken = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return AllTestsStatisticsDto(
|
||||
tests: tests == const $CopyWithPlaceholder() || tests == null
|
||||
? _value.tests
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: tests as Map<int, TestStatisticsDto>,
|
||||
lastSessionToken: lastSessionToken == const $CopyWithPlaceholder()
|
||||
? _value.lastSessionToken
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: lastSessionToken as String?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $AllTestsStatisticsDtoCopyWith on AllTestsStatisticsDto {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfAllTestsStatisticsDto.copyWith(...)` or like so:`instanceOfAllTestsStatisticsDto.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$AllTestsStatisticsDtoCWProxy get copyWith =>
|
||||
_$AllTestsStatisticsDtoCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
AllTestsStatisticsDto _$AllTestsStatisticsDtoFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
AllTestsStatisticsDto(
|
||||
tests: (json['tests'] as Map<String, dynamic>).map(
|
||||
(k, e) => MapEntry(int.parse(k),
|
||||
TestStatisticsDto.fromJson(e as Map<String, dynamic>)),
|
||||
),
|
||||
lastSessionToken: json['lastSessionToken'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$AllTestsStatisticsDtoToJson(
|
||||
AllTestsStatisticsDto instance) =>
|
||||
<String, dynamic>{
|
||||
'tests': instance.tests.map((k, e) => MapEntry(k.toString(), e)),
|
||||
'lastSessionToken': instance.lastSessionToken,
|
||||
};
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'package:mnemo_cards_common/mnemo_cards_common.dart';
|
||||
import 'package:mnemo_cards_common/src/utils/word_statistics.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
part 'all_words_statistics_dto.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
@CopyWith()
|
||||
class AllWordsStatisticsDto {
|
||||
// final Map<String, WordStatisticsDto> words;
|
||||
final List<WordStatisticsDto> words;
|
||||
|
||||
AllWordsStatisticsDto({
|
||||
this.words = const [],
|
||||
});
|
||||
|
||||
double get correct => words.correct;
|
||||
|
||||
double get incorrect => words.incorrect;
|
||||
|
||||
double get skipped => words.skipped;
|
||||
|
||||
double get total => words.fold(
|
||||
0.0,
|
||||
(s, v) => s + v.skipped + v.correct + v.incorrect,
|
||||
);
|
||||
|
||||
AllWordsStatisticsDto.empty() : words = const [];
|
||||
|
||||
factory AllWordsStatisticsDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$AllWordsStatisticsDtoFromJson(json);
|
||||
|
||||
Map<String, Object?> toJson() => _$AllWordsStatisticsDtoToJson(this);
|
||||
|
||||
@override
|
||||
int get hashCode => words.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
|
||||
return other is AllWordsStatisticsDto &&
|
||||
const ListEquality().equals(other.words, words);
|
||||
}
|
||||
|
||||
// AllWordsStatisticsDto merge(AllWordsStatisticsDto? other) {
|
||||
// if (other == null) {
|
||||
// return copyWith();
|
||||
// }
|
||||
// final updatedWords = Map.of(words);
|
||||
// for (final entry in other.words.entries) {
|
||||
// updatedWords[entry.key] =
|
||||
// words[entry.key]?.merge(entry.value) ?? entry.value;
|
||||
// }
|
||||
// return copyWith.words(updatedWords);
|
||||
// }
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'all_words_statistics_dto.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$AllWordsStatisticsDtoCWProxy {
|
||||
AllWordsStatisticsDto words(List<WordStatisticsDto> words);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `AllWordsStatisticsDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// AllWordsStatisticsDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
AllWordsStatisticsDto call({
|
||||
List<WordStatisticsDto>? words,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfAllWordsStatisticsDto.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfAllWordsStatisticsDto.copyWith.fieldName(...)`
|
||||
class _$AllWordsStatisticsDtoCWProxyImpl
|
||||
implements _$AllWordsStatisticsDtoCWProxy {
|
||||
const _$AllWordsStatisticsDtoCWProxyImpl(this._value);
|
||||
|
||||
final AllWordsStatisticsDto _value;
|
||||
|
||||
@override
|
||||
AllWordsStatisticsDto words(List<WordStatisticsDto> words) =>
|
||||
this(words: words);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `AllWordsStatisticsDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// AllWordsStatisticsDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
AllWordsStatisticsDto call({
|
||||
Object? words = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return AllWordsStatisticsDto(
|
||||
words: words == const $CopyWithPlaceholder() || words == null
|
||||
? _value.words
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: words as List<WordStatisticsDto>,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $AllWordsStatisticsDtoCopyWith on AllWordsStatisticsDto {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfAllWordsStatisticsDto.copyWith(...)` or like so:`instanceOfAllWordsStatisticsDto.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$AllWordsStatisticsDtoCWProxy get copyWith =>
|
||||
_$AllWordsStatisticsDtoCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
AllWordsStatisticsDto _$AllWordsStatisticsDtoFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
AllWordsStatisticsDto(
|
||||
words: (json['words'] as List<dynamic>?)
|
||||
?.map(
|
||||
(e) => WordStatisticsDto.fromJson(e as Map<String, dynamic>))
|
||||
.toList() ??
|
||||
const [],
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$AllWordsStatisticsDtoToJson(
|
||||
AllWordsStatisticsDto instance) =>
|
||||
<String, dynamic>{
|
||||
'words': instance.words,
|
||||
};
|
||||
|
|
@ -0,0 +1,339 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:mnemo_cards_common/mnemo_cards_common.dart';
|
||||
|
||||
part 'detailed_word_statistics_dto.g.dart';
|
||||
|
||||
/// Extended word statistics with additional tracking data
|
||||
@JsonSerializable()
|
||||
@CopyWith()
|
||||
class DetailedWordStatisticsDto extends WordStatisticsDto {
|
||||
/// When this word was last reviewed
|
||||
final DateTime? lastReviewed;
|
||||
|
||||
/// When this word was first learned
|
||||
final DateTime? firstLearned;
|
||||
|
||||
/// Recent attempts (last 10, for trend analysis)
|
||||
final List<WordAttemptDto> recentAttempts;
|
||||
|
||||
/// Difficulty score (0.0 = easy, 1.0 = hard, based on incorrect/correct ratio)
|
||||
final double difficultyScore;
|
||||
|
||||
/// Whether this word needs review (based on performance and time since last review)
|
||||
final bool needsReview;
|
||||
|
||||
/// Which pack this word belongs to
|
||||
final String? packId;
|
||||
|
||||
DetailedWordStatisticsDto({
|
||||
required String word,
|
||||
double correct = 0,
|
||||
double incorrect = 0,
|
||||
double skipped = 0,
|
||||
Set<TestQuestionType> questionTypes = const {},
|
||||
this.lastReviewed,
|
||||
this.firstLearned,
|
||||
this.recentAttempts = const [],
|
||||
this.difficultyScore = 0.0,
|
||||
this.needsReview = false,
|
||||
this.packId,
|
||||
}) : super(
|
||||
word: word,
|
||||
correct: correct,
|
||||
incorrect: incorrect,
|
||||
skipped: skipped,
|
||||
questionTypes: questionTypes,
|
||||
);
|
||||
|
||||
factory DetailedWordStatisticsDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$DetailedWordStatisticsDtoFromJson(json);
|
||||
|
||||
@override
|
||||
Map<String, Object?> toJson() => _$DetailedWordStatisticsDtoToJson(this);
|
||||
|
||||
/// Create from base WordStatisticsDto
|
||||
factory DetailedWordStatisticsDto.fromWordStatisticsDto(
|
||||
WordStatisticsDto base, {
|
||||
DateTime? lastReviewed,
|
||||
DateTime? firstLearned,
|
||||
List<WordAttemptDto>? recentAttempts,
|
||||
double? difficultyScore,
|
||||
bool? needsReview,
|
||||
String? packId,
|
||||
}) =>
|
||||
DetailedWordStatisticsDto(
|
||||
word: base.word,
|
||||
correct: base.correct,
|
||||
incorrect: base.incorrect,
|
||||
skipped: base.skipped,
|
||||
questionTypes: base.questionTypes,
|
||||
lastReviewed: lastReviewed,
|
||||
firstLearned: firstLearned,
|
||||
recentAttempts: recentAttempts ?? [],
|
||||
difficultyScore: difficultyScore ?? _calculateDifficultyScore(base),
|
||||
needsReview: needsReview ?? false,
|
||||
packId: packId,
|
||||
);
|
||||
|
||||
/// Calculate difficulty score from basic statistics
|
||||
static double _calculateDifficultyScore(WordStatisticsDto stats) {
|
||||
final total = stats.total;
|
||||
if (total == 0) return 0.0;
|
||||
|
||||
// Difficulty based on incorrect ratio
|
||||
final incorrectRatio = stats.incorrect / total;
|
||||
|
||||
// Also consider if word has many skips
|
||||
final skipRatio = stats.skipped / total;
|
||||
|
||||
// Weighted formula
|
||||
return (incorrectRatio * 0.7 + skipRatio * 0.3).clamp(0.0, 1.0);
|
||||
}
|
||||
|
||||
/// Update statistics with new attempt
|
||||
DetailedWordStatisticsDto addAttempt({
|
||||
required bool wasCorrect,
|
||||
required TestQuestionType questionType,
|
||||
DateTime? timestamp,
|
||||
String? packId,
|
||||
}) {
|
||||
final now = timestamp ?? DateTime.now();
|
||||
|
||||
final newCorrect = wasCorrect ? correct + 1 : correct;
|
||||
final newIncorrect = wasCorrect ? incorrect : incorrect + 1;
|
||||
|
||||
final newQuestionTypes = {...questionTypes, questionType};
|
||||
|
||||
final newRecentAttempts = [
|
||||
WordAttemptDto(
|
||||
timestamp: now,
|
||||
wasCorrect: wasCorrect,
|
||||
questionType: questionType,
|
||||
),
|
||||
...recentAttempts.take(9), // Keep only last 10
|
||||
];
|
||||
|
||||
final newDifficultyScore = _calculateDifficultyScore(
|
||||
WordStatisticsDto(
|
||||
word: word,
|
||||
correct: newCorrect,
|
||||
incorrect: newIncorrect,
|
||||
skipped: skipped,
|
||||
questionTypes: newQuestionTypes,
|
||||
),
|
||||
);
|
||||
|
||||
// Word needs review if:
|
||||
// - Difficulty score > 0.5, OR
|
||||
// - Last reviewed more than 7 days ago and has errors, OR
|
||||
// - Never reviewed but has attempts
|
||||
final daysSinceLastReview = lastReviewed != null
|
||||
? now.difference(lastReviewed!).inDays
|
||||
: null;
|
||||
|
||||
final needsReviewNow =
|
||||
newDifficultyScore > 0.5 ||
|
||||
(daysSinceLastReview != null &&
|
||||
daysSinceLastReview > 7 &&
|
||||
(newIncorrect > 0 || newRecentAttempts.where((a) => !a.wasCorrect).length > 2));
|
||||
|
||||
return DetailedWordStatisticsDto(
|
||||
word: word,
|
||||
correct: newCorrect,
|
||||
incorrect: newIncorrect,
|
||||
skipped: skipped,
|
||||
questionTypes: newQuestionTypes,
|
||||
lastReviewed: now,
|
||||
firstLearned: firstLearned ?? now,
|
||||
recentAttempts: newRecentAttempts,
|
||||
difficultyScore: newDifficultyScore,
|
||||
needsReview: needsReviewNow,
|
||||
packId: packId ?? this.packId,
|
||||
);
|
||||
}
|
||||
|
||||
/// Mark word as skipped
|
||||
DetailedWordStatisticsDto addSkip({
|
||||
required TestQuestionType questionType,
|
||||
DateTime? timestamp,
|
||||
String? packId,
|
||||
}) {
|
||||
final now = timestamp ?? DateTime.now();
|
||||
|
||||
final newQuestionTypes = {...questionTypes, questionType};
|
||||
|
||||
final newRecentAttempts = [
|
||||
WordAttemptDto(
|
||||
timestamp: now,
|
||||
wasCorrect: false,
|
||||
questionType: questionType,
|
||||
wasSkipped: true,
|
||||
),
|
||||
...recentAttempts.take(9),
|
||||
];
|
||||
|
||||
final newDifficultyScore = _calculateDifficultyScore(
|
||||
WordStatisticsDto(
|
||||
word: word,
|
||||
correct: correct,
|
||||
incorrect: incorrect,
|
||||
skipped: skipped + 1,
|
||||
questionTypes: newQuestionTypes,
|
||||
),
|
||||
);
|
||||
|
||||
return DetailedWordStatisticsDto(
|
||||
word: word,
|
||||
correct: correct,
|
||||
incorrect: incorrect,
|
||||
skipped: skipped + 1,
|
||||
questionTypes: newQuestionTypes,
|
||||
lastReviewed: now,
|
||||
firstLearned: firstLearned ?? now,
|
||||
recentAttempts: newRecentAttempts,
|
||||
difficultyScore: newDifficultyScore,
|
||||
needsReview: needsReview,
|
||||
packId: packId ?? this.packId,
|
||||
);
|
||||
}
|
||||
|
||||
/// Get recent performance trend (last 5 attempts)
|
||||
PerformanceTrend get performanceTrend {
|
||||
if (recentAttempts.length < 3) return PerformanceTrend.insufficientData;
|
||||
|
||||
final last5 = recentAttempts.take(5);
|
||||
final correctCount = last5.where((a) => a.wasCorrect).length;
|
||||
final accuracy = correctCount / last5.length;
|
||||
|
||||
if (accuracy >= 0.8) return PerformanceTrend.improving;
|
||||
if (accuracy <= 0.4) return PerformanceTrend.declining;
|
||||
return PerformanceTrend.stable;
|
||||
}
|
||||
|
||||
/// Check if word should be prioritized for review
|
||||
bool get shouldPrioritize {
|
||||
return needsReview ||
|
||||
difficultyScore > 0.6 ||
|
||||
(performanceTrend == PerformanceTrend.declining);
|
||||
}
|
||||
|
||||
/// Get days since last review
|
||||
int? get daysSinceLastReview {
|
||||
if (lastReviewed == null) return null;
|
||||
return DateTime.now().difference(lastReviewed!).inDays;
|
||||
}
|
||||
|
||||
/// Get total review count
|
||||
int get reviewCount => recentAttempts.length;
|
||||
|
||||
/// Get accuracy from recent attempts
|
||||
double get recentAccuracy {
|
||||
if (recentAttempts.isEmpty) return 0.0;
|
||||
final correctCount = recentAttempts.where((a) => a.wasCorrect).length;
|
||||
return correctCount / recentAttempts.length;
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is DetailedWordStatisticsDto &&
|
||||
runtimeType == other.runtimeType &&
|
||||
word == other.word &&
|
||||
correct == other.correct &&
|
||||
incorrect == other.incorrect &&
|
||||
skipped == other.skipped &&
|
||||
const SetEquality().equals(questionTypes, other.questionTypes) &&
|
||||
lastReviewed == other.lastReviewed &&
|
||||
firstLearned == other.firstLearned &&
|
||||
_listEquals(recentAttempts, other.recentAttempts) &&
|
||||
difficultyScore == other.difficultyScore &&
|
||||
needsReview == other.needsReview &&
|
||||
packId == other.packId;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
word.hashCode ^
|
||||
correct.hashCode ^
|
||||
incorrect.hashCode ^
|
||||
skipped.hashCode ^
|
||||
questionTypes.hashCode ^
|
||||
lastReviewed.hashCode ^
|
||||
firstLearned.hashCode ^
|
||||
recentAttempts.hashCode ^
|
||||
difficultyScore.hashCode ^
|
||||
needsReview.hashCode ^
|
||||
packId.hashCode;
|
||||
|
||||
@override
|
||||
String toString() =>
|
||||
'DetailedWordStatisticsDto(word: $word, accuracy: ${(correct / total * 100).toStringAsFixed(1)}%, difficulty: ${difficultyScore.toStringAsFixed(2)}, needsReview: $needsReview)';
|
||||
}
|
||||
|
||||
/// Individual word attempt data
|
||||
@JsonSerializable()
|
||||
@CopyWith()
|
||||
class WordAttemptDto {
|
||||
/// When the attempt happened
|
||||
final DateTime timestamp;
|
||||
|
||||
/// Whether the answer was correct
|
||||
final bool wasCorrect;
|
||||
|
||||
/// Type of question asked
|
||||
final TestQuestionType questionType;
|
||||
|
||||
/// Whether the question was skipped
|
||||
final bool wasSkipped;
|
||||
|
||||
const WordAttemptDto({
|
||||
required this.timestamp,
|
||||
required this.wasCorrect,
|
||||
required this.questionType,
|
||||
this.wasSkipped = false,
|
||||
});
|
||||
|
||||
factory WordAttemptDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$WordAttemptDtoFromJson(json);
|
||||
|
||||
Map<String, Object?> toJson() => _$WordAttemptDtoToJson(this);
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is WordAttemptDto &&
|
||||
runtimeType == other.runtimeType &&
|
||||
timestamp == other.timestamp &&
|
||||
wasCorrect == other.wasCorrect &&
|
||||
questionType == other.questionType &&
|
||||
wasSkipped == other.wasSkipped;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
timestamp.hashCode ^
|
||||
wasCorrect.hashCode ^
|
||||
questionType.hashCode ^
|
||||
wasSkipped.hashCode;
|
||||
|
||||
@override
|
||||
String toString() =>
|
||||
'WordAttemptDto(timestamp: $timestamp, correct: $wasCorrect, type: $questionType, skipped: $wasSkipped)';
|
||||
}
|
||||
|
||||
/// Performance trend analysis
|
||||
enum PerformanceTrend {
|
||||
improving,
|
||||
stable,
|
||||
declining,
|
||||
insufficientData,
|
||||
}
|
||||
|
||||
|
||||
bool _listEquals(List<WordAttemptDto> a, List<WordAttemptDto> b) {
|
||||
if (a.length != b.length) return false;
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
if (a[i] != b[i]) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'detailed_word_statistics_dto.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
DetailedWordStatisticsDto _$DetailedWordStatisticsDtoFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
DetailedWordStatisticsDto(
|
||||
word: json['word'] as String,
|
||||
correct: (json['correct'] as num).toDouble(),
|
||||
incorrect: (json['incorrect'] as num).toDouble(),
|
||||
skipped: (json['skipped'] as num).toDouble(),
|
||||
questionTypes: (json['questionTypes'] as List<dynamic>?)
|
||||
?.map((e) => $enumDecode(_$TestQuestionTypeEnumMap, e))
|
||||
.toSet() ??
|
||||
{},
|
||||
lastReviewed: json['lastReviewed'] == null
|
||||
? null
|
||||
: DateTime.parse(json['lastReviewed'] as String),
|
||||
firstLearned: json['firstLearned'] == null
|
||||
? null
|
||||
: DateTime.parse(json['firstLearned'] as String),
|
||||
recentAttempts: (json['recentAttempts'] as List<dynamic>?)
|
||||
?.map((e) => WordAttemptDto.fromJson(e as Map<String, dynamic>))
|
||||
.toList() ??
|
||||
[],
|
||||
difficultyScore: (json['difficultyScore'] as num?)?.toDouble() ?? 0.0,
|
||||
needsReview: json['needsReview'] as bool? ?? false,
|
||||
packId: json['packId'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$DetailedWordStatisticsDtoToJson(
|
||||
DetailedWordStatisticsDto instance) =>
|
||||
<String, dynamic>{
|
||||
'word': instance.word,
|
||||
'correct': instance.correct,
|
||||
'incorrect': instance.incorrect,
|
||||
'skipped': instance.skipped,
|
||||
'questionTypes': instance.questionTypes
|
||||
.map((e) => _$TestQuestionTypeEnumMap[e])
|
||||
.toList(),
|
||||
'lastReviewed': instance.lastReviewed?.toIso8601String(),
|
||||
'firstLearned': instance.firstLearned?.toIso8601String(),
|
||||
'recentAttempts': instance.recentAttempts.map((e) => e.toJson()).toList(),
|
||||
'difficultyScore': instance.difficultyScore,
|
||||
'needsReview': instance.needsReview,
|
||||
'packId': instance.packId,
|
||||
};
|
||||
|
||||
WordAttemptDto _$WordAttemptDtoFromJson(Map<String, dynamic> json) =>
|
||||
WordAttemptDto(
|
||||
timestamp: DateTime.parse(json['timestamp'] as String),
|
||||
wasCorrect: json['wasCorrect'] as bool,
|
||||
questionType: $enumDecode(_$TestQuestionTypeEnumMap, json['questionType']),
|
||||
wasSkipped: json['wasSkipped'] as bool? ?? false,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$WordAttemptDtoToJson(WordAttemptDto instance) =>
|
||||
<String, dynamic>{
|
||||
'timestamp': instance.timestamp.toIso8601String(),
|
||||
'wasCorrect': instance.wasCorrect,
|
||||
'questionType': _$TestQuestionTypeEnumMap[instance.questionType],
|
||||
'wasSkipped': instance.wasSkipped,
|
||||
};
|
||||
|
||||
const _$TestQuestionTypeEnumMap = {
|
||||
TestQuestionType.simple: 'simple',
|
||||
TestQuestionType.input_buttons: 'input_buttons',
|
||||
TestQuestionType.matrix: 'matrix',
|
||||
TestQuestionType.match: 'match',
|
||||
TestQuestionType.undefined: 'undefined',
|
||||
};
|
||||
120
mnemo_cards_common/lib/src/dtos/user/data/pack_progress_dto.dart
Normal file
120
mnemo_cards_common/lib/src/dtos/user/data/pack_progress_dto.dart
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
|
||||
part 'pack_progress_dto.g.dart';
|
||||
|
||||
|
||||
/// Statistics about user's progress on a specific pack
|
||||
@JsonSerializable()
|
||||
@CopyWith()
|
||||
class PackProgressDto {
|
||||
/// Pack ID
|
||||
final String packId;
|
||||
|
||||
/// Total number of cards in the pack
|
||||
final int totalCards;
|
||||
|
||||
/// Number of cards learned by the user
|
||||
final int learnedCards;
|
||||
|
||||
/// Total study time spent on this pack in minutes
|
||||
final int studyTimeMinutes;
|
||||
|
||||
/// Date when user last studied this pack
|
||||
final DateTime? lastStudyDate;
|
||||
|
||||
/// Date when user first started studying this pack
|
||||
final DateTime? firstStudyDate;
|
||||
|
||||
/// Map of card ID to number of attempts for that card
|
||||
final Map<String, int> cardAttempts;
|
||||
|
||||
/// Average accuracy across all attempts on this pack (0.0 to 1.0)
|
||||
final double averageAccuracy;
|
||||
|
||||
/// Calculated progress percentage (0.0 to 1.0)
|
||||
double get progress => totalCards > 0 ? learnedCards / totalCards : 0.0;
|
||||
|
||||
/// Average attempts per card
|
||||
double get averageAttempts =>
|
||||
cardAttempts.isNotEmpty ? _calculateAverage(cardAttempts.values) : 0.0;
|
||||
|
||||
/// Total attempts across all cards
|
||||
int get totalAttempts => _calculateSum(cardAttempts.values);
|
||||
|
||||
const PackProgressDto({
|
||||
required this.packId,
|
||||
required this.totalCards,
|
||||
this.learnedCards = 0,
|
||||
this.studyTimeMinutes = 0,
|
||||
this.lastStudyDate,
|
||||
this.firstStudyDate,
|
||||
this.cardAttempts = const {},
|
||||
this.averageAccuracy = 0.0,
|
||||
});
|
||||
|
||||
factory PackProgressDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$PackProgressDtoFromJson(json);
|
||||
|
||||
Map<String, Object?> toJson() => _$PackProgressDtoToJson(this);
|
||||
|
||||
/// Create empty progress for a pack
|
||||
factory PackProgressDto.empty(String packId, int totalCards) =>
|
||||
PackProgressDto(
|
||||
packId: packId,
|
||||
totalCards: totalCards,
|
||||
);
|
||||
|
||||
/// Check if user has started studying this pack
|
||||
bool get hasStarted => learnedCards > 0 || studyTimeMinutes > 0;
|
||||
|
||||
/// Get attempts for a specific card
|
||||
int getAttemptsForCard(String cardId) => cardAttempts[cardId] ?? 0;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is PackProgressDto &&
|
||||
runtimeType == other.runtimeType &&
|
||||
packId == other.packId &&
|
||||
totalCards == other.totalCards &&
|
||||
learnedCards == other.learnedCards &&
|
||||
studyTimeMinutes == other.studyTimeMinutes &&
|
||||
lastStudyDate == other.lastStudyDate &&
|
||||
firstStudyDate == other.firstStudyDate &&
|
||||
_mapEquals(cardAttempts, other.cardAttempts) &&
|
||||
averageAccuracy == other.averageAccuracy;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
packId.hashCode ^
|
||||
totalCards.hashCode ^
|
||||
learnedCards.hashCode ^
|
||||
studyTimeMinutes.hashCode ^
|
||||
lastStudyDate.hashCode ^
|
||||
firstStudyDate.hashCode ^
|
||||
cardAttempts.hashCode ^
|
||||
averageAccuracy.hashCode;
|
||||
|
||||
@override
|
||||
String toString() => 'PackProgressDto(packId: $packId, progress: ${progress.toStringAsFixed(2)}, learned: $learnedCards/$totalCards)';
|
||||
}
|
||||
|
||||
// Helper functions
|
||||
double _calculateAverage(Iterable<int> values) {
|
||||
if (values.isEmpty) return 0.0;
|
||||
final sum = values.fold<int>(0, (a, b) => a + b);
|
||||
return sum / values.length;
|
||||
}
|
||||
|
||||
int _calculateSum(Iterable<int> values) {
|
||||
return values.fold<int>(0, (a, b) => a + b);
|
||||
}
|
||||
|
||||
bool _mapEquals(Map<String, int> a, Map<String, int> b) {
|
||||
if (a.length != b.length) return false;
|
||||
for (final key in a.keys) {
|
||||
if (a[key] != b[key]) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'pack_progress_dto.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
PackProgressDto _$PackProgressDtoFromJson(Map<String, dynamic> json) =>
|
||||
PackProgressDto(
|
||||
packId: json['packId'] as String,
|
||||
totalCards: json['totalCards'] as int,
|
||||
learnedCards: json['learnedCards'] as int? ?? 0,
|
||||
studyTimeMinutes: json['studyTimeMinutes'] as int? ?? 0,
|
||||
lastStudyDate: json['lastStudyDate'] == null
|
||||
? null
|
||||
: DateTime.parse(json['lastStudyDate'] as String),
|
||||
firstStudyDate: json['firstStudyDate'] == null
|
||||
? null
|
||||
: DateTime.parse(json['firstStudyDate'] as String),
|
||||
cardAttempts: (json['cardAttempts'] as Map<String, dynamic>?)?.map(
|
||||
(k, e) => MapEntry(k, e as int),
|
||||
) ??
|
||||
{},
|
||||
averageAccuracy: (json['averageAccuracy'] as num?)?.toDouble() ?? 0.0,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$PackProgressDtoToJson(PackProgressDto instance) =>
|
||||
<String, dynamic>{
|
||||
'packId': instance.packId,
|
||||
'totalCards': instance.totalCards,
|
||||
'learnedCards': instance.learnedCards,
|
||||
'studyTimeMinutes': instance.studyTimeMinutes,
|
||||
'lastStudyDate': instance.lastStudyDate?.toIso8601String(),
|
||||
'firstStudyDate': instance.firstStudyDate?.toIso8601String(),
|
||||
'cardAttempts': instance.cardAttempts,
|
||||
'averageAccuracy': instance.averageAccuracy,
|
||||
};
|
||||
184
mnemo_cards_common/lib/src/dtos/user/data/user_data_dto.dart
Normal file
184
mnemo_cards_common/lib/src/dtos/user/data/user_data_dto.dart
Normal file
|
|
@ -0,0 +1,184 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'package:mnemo_cards_common/src/dtos/user/data/all_tests_statistics_dto.dart';
|
||||
import 'package:mnemo_cards_common/src/dtos/user/achievement_dto.dart';
|
||||
|
||||
import 'all_words_statistics_dto.dart';
|
||||
import 'pack_progress_dto.dart';
|
||||
|
||||
part 'user_data_dto.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
@CopyWith()
|
||||
class UserDataDto {
|
||||
// Existing fields
|
||||
final AllWordsStatisticsDto? allWordsStatistics;
|
||||
final AllTestsStatisticsDto? allTestsStatistics;
|
||||
|
||||
// NEW FIELDS: Extended statistics tracking
|
||||
|
||||
/// When user was last online
|
||||
final DateTime? lastTimeOnline;
|
||||
|
||||
/// Total study time in minutes across all sessions
|
||||
final int totalStudyTimeMinutes;
|
||||
|
||||
/// Current streak (consecutive days with study activity)
|
||||
final int currentStreak;
|
||||
|
||||
/// Longest streak ever achieved
|
||||
final int longestStreak;
|
||||
|
||||
/// Progress tracking for each pack
|
||||
final Map<String, PackProgressDto> packProgress;
|
||||
|
||||
/// List of dates when user studied (for streak calculation)
|
||||
final List<DateTime> studyDates;
|
||||
|
||||
/// Study time by category/language in minutes
|
||||
final Map<String, int> categoryMinutes;
|
||||
|
||||
/// User's achievements
|
||||
final List<AchievementDto> achievements;
|
||||
|
||||
UserDataDto({
|
||||
this.allWordsStatistics,
|
||||
this.allTestsStatistics,
|
||||
this.lastTimeOnline,
|
||||
this.totalStudyTimeMinutes = 0,
|
||||
this.currentStreak = 0,
|
||||
this.longestStreak = 0,
|
||||
this.packProgress = const {},
|
||||
this.studyDates = const [],
|
||||
this.categoryMinutes = const {},
|
||||
this.achievements = const [],
|
||||
});
|
||||
|
||||
factory UserDataDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$UserDataDtoFromJson(json);
|
||||
|
||||
Map<String, Object?> toJson() => _$UserDataDtoToJson(this);
|
||||
|
||||
/// Create empty user data
|
||||
factory UserDataDto.empty() => UserDataDto();
|
||||
|
||||
/// Get total learned words count
|
||||
int get totalLearnedWords {
|
||||
return allWordsStatistics?.words.length ?? 0;
|
||||
}
|
||||
|
||||
/// Get total completed tests count
|
||||
int get totalTestsCompleted {
|
||||
return allTestsStatistics?.tests.length ?? 0;
|
||||
}
|
||||
|
||||
/// Get total study time as Duration
|
||||
Duration get totalStudyTime => Duration(minutes: totalStudyTimeMinutes);
|
||||
|
||||
/// Get total study time in hours
|
||||
double get totalStudyTimeHours => totalStudyTimeMinutes / 60.0;
|
||||
|
||||
/// Get progress for specific pack
|
||||
PackProgressDto? getPackProgress(String packId) => packProgress[packId];
|
||||
|
||||
/// Get completed packs count
|
||||
int get completedPacksCount =>
|
||||
packProgress.values.where((p) => p.progress >= 1.0).length;
|
||||
|
||||
/// Get in-progress packs count
|
||||
int get inProgressPacksCount =>
|
||||
packProgress.values.where((p) => p.hasStarted && p.progress < 1.0).length;
|
||||
|
||||
/// Get unlocked achievements count
|
||||
int get unlockedAchievementsCount =>
|
||||
achievements.where((a) => a.isUnlocked).length;
|
||||
|
||||
/// Get total achievements count
|
||||
int get totalAchievementsCount => achievements.length;
|
||||
|
||||
/// Get recent achievements (last 7 days)
|
||||
List<AchievementDto> get recentAchievements {
|
||||
final weekAgo = DateTime.now().subtract(const Duration(days: 7));
|
||||
return achievements
|
||||
.where((a) => a.isUnlocked && a.unlockedAt!.isAfter(weekAgo))
|
||||
.toList();
|
||||
}
|
||||
|
||||
/// Check if user is currently on a streak
|
||||
bool get isOnStreak {
|
||||
if (studyDates.isEmpty || currentStreak == 0) return false;
|
||||
final lastStudyDate = studyDates.reduce((a, b) => a.isAfter(b) ? a : b);
|
||||
final daysSinceLastStudy = DateTime.now().difference(lastStudyDate).inDays;
|
||||
return daysSinceLastStudy <= 1; // Allow 1 day gap
|
||||
}
|
||||
|
||||
/// Get streak status message
|
||||
String get streakStatus {
|
||||
if (currentStreak == 0) return 'No current streak';
|
||||
if (!isOnStreak) return 'Streak broken (${currentStreak} days)';
|
||||
return 'Current streak: $currentStreak days';
|
||||
}
|
||||
|
||||
/// Get achievement progress summary
|
||||
Map<String, int> get achievementsSummary {
|
||||
final categories = <String, int>{};
|
||||
for (final achievement in achievements.where((a) => a.isUnlocked)) {
|
||||
categories[achievement.category] = (categories[achievement.category] ?? 0) + 1;
|
||||
}
|
||||
return categories;
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is UserDataDto &&
|
||||
runtimeType == other.runtimeType &&
|
||||
allWordsStatistics == other.allWordsStatistics &&
|
||||
allTestsStatistics == other.allTestsStatistics &&
|
||||
lastTimeOnline == other.lastTimeOnline &&
|
||||
totalStudyTimeMinutes == other.totalStudyTimeMinutes &&
|
||||
currentStreak == other.currentStreak &&
|
||||
longestStreak == other.longestStreak &&
|
||||
_mapEquals(packProgress, other.packProgress) &&
|
||||
_listEquals(studyDates, other.studyDates) &&
|
||||
_mapEqualsStringInt(categoryMinutes, other.categoryMinutes) &&
|
||||
_listEquals(achievements, other.achievements);
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
allWordsStatistics.hashCode ^
|
||||
allTestsStatistics.hashCode ^
|
||||
lastTimeOnline.hashCode ^
|
||||
totalStudyTimeMinutes.hashCode ^
|
||||
currentStreak.hashCode ^
|
||||
longestStreak.hashCode ^
|
||||
packProgress.hashCode ^
|
||||
studyDates.hashCode ^
|
||||
categoryMinutes.hashCode ^
|
||||
achievements.hashCode;
|
||||
}
|
||||
|
||||
// Helper functions for equality checks
|
||||
bool _mapEquals<K, V>(Map<K, V> a, Map<K, V> b) {
|
||||
if (a.length != b.length) return false;
|
||||
for (final key in a.keys) {
|
||||
if (a[key] != b[key]) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool _mapEqualsStringInt(Map<String, int> a, Map<String, int> b) {
|
||||
if (a.length != b.length) return false;
|
||||
for (final key in a.keys) {
|
||||
if (a[key] != b[key]) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool _listEquals<T>(List<T> a, List<T> b) {
|
||||
if (a.length != b.length) return false;
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
if (a[i] != b[i]) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'user_data_dto.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$UserDataDtoCWProxy {
|
||||
UserDataDto allTestsStatistics(AllTestsStatisticsDto? allTestsStatistics);
|
||||
|
||||
UserDataDto allWordsStatistics(AllWordsStatisticsDto? allWordsStatistics);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `UserDataDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// UserDataDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
UserDataDto call({
|
||||
AllTestsStatisticsDto? allTestsStatistics,
|
||||
AllWordsStatisticsDto? allWordsStatistics,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfUserDataDto.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfUserDataDto.copyWith.fieldName(...)`
|
||||
class _$UserDataDtoCWProxyImpl implements _$UserDataDtoCWProxy {
|
||||
const _$UserDataDtoCWProxyImpl(this._value);
|
||||
|
||||
final UserDataDto _value;
|
||||
|
||||
@override
|
||||
UserDataDto allTestsStatistics(AllTestsStatisticsDto? allTestsStatistics) =>
|
||||
this(allTestsStatistics: allTestsStatistics);
|
||||
|
||||
@override
|
||||
UserDataDto allWordsStatistics(AllWordsStatisticsDto? allWordsStatistics) =>
|
||||
this(allWordsStatistics: allWordsStatistics);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `UserDataDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// UserDataDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
UserDataDto call({
|
||||
Object? allTestsStatistics = const $CopyWithPlaceholder(),
|
||||
Object? allWordsStatistics = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return UserDataDto(
|
||||
allTestsStatistics: allTestsStatistics == const $CopyWithPlaceholder()
|
||||
? _value.allTestsStatistics
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: allTestsStatistics as AllTestsStatisticsDto?,
|
||||
allWordsStatistics: allWordsStatistics == const $CopyWithPlaceholder()
|
||||
? _value.allWordsStatistics
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: allWordsStatistics as AllWordsStatisticsDto?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $UserDataDtoCopyWith on UserDataDto {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfUserDataDto.copyWith(...)` or like so:`instanceOfUserDataDto.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$UserDataDtoCWProxy get copyWith => _$UserDataDtoCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
UserDataDto _$UserDataDtoFromJson(Map<String, dynamic> json) => UserDataDto(
|
||||
allTestsStatistics: json['allTestsStatistics'] == null
|
||||
? null
|
||||
: AllTestsStatisticsDto.fromJson(
|
||||
json['allTestsStatistics'] as Map<String, dynamic>),
|
||||
allWordsStatistics: json['allWordsStatistics'] == null
|
||||
? null
|
||||
: AllWordsStatisticsDto.fromJson(
|
||||
json['allWordsStatistics'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$UserDataDtoToJson(UserDataDto instance) =>
|
||||
<String, dynamic>{
|
||||
'allWordsStatistics': instance.allWordsStatistics,
|
||||
'allTestsStatistics': instance.allTestsStatistics,
|
||||
};
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'package:mnemo_cards_common/src/utils/json_helper.dart';
|
||||
|
||||
import '../../game_tests/test_question_type.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
part 'word_statistics_dto.g.dart';
|
||||
|
||||
@JsonSerializable(includeIfNull: false)
|
||||
@CopyWith()
|
||||
class WordStatisticsDto {
|
||||
final String word;
|
||||
@JsonKey(fromJson: doubleFromJson, toJson: doubleToJson)
|
||||
final double correct;
|
||||
@JsonKey(fromJson: doubleFromJson, toJson: doubleToJson)
|
||||
final double incorrect;
|
||||
@JsonKey(fromJson: doubleFromJson, toJson: doubleToJson)
|
||||
final double skipped;
|
||||
final Set<TestQuestionType> questionTypes;
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
double get total => correct + incorrect + skipped;
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
double get accuracy => total == 0 ? 0.0 : correct / total;
|
||||
|
||||
WordStatisticsDto({
|
||||
this.word = '',
|
||||
this.correct = 0,
|
||||
this.incorrect = 0,
|
||||
this.skipped = 0,
|
||||
this.questionTypes = const {},
|
||||
});
|
||||
|
||||
WordStatisticsDto.empty(this.word)
|
||||
: correct = 0,
|
||||
incorrect = 0,
|
||||
skipped = 0,
|
||||
questionTypes = {};
|
||||
|
||||
factory WordStatisticsDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$WordStatisticsDtoFromJson(json);
|
||||
|
||||
Map<String, Object?> toJson() => _$WordStatisticsDtoToJson(this);
|
||||
|
||||
WordStatisticsDto merge(WordStatisticsDto other) {
|
||||
if (other.word != word)
|
||||
throw Exception('Cant merge different word statistics');
|
||||
return copyWith(
|
||||
correct: correct + other.correct,
|
||||
incorrect: incorrect + other.incorrect,
|
||||
skipped: skipped + other.skipped,
|
||||
questionTypes: {
|
||||
...questionTypes,
|
||||
...other.questionTypes,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
word.hashCode ^
|
||||
correct.hashCode ^
|
||||
incorrect.hashCode ^
|
||||
skipped.hashCode ^
|
||||
questionTypes.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
|
||||
return other is WordStatisticsDto &&
|
||||
other.word == word &&
|
||||
other.correct == correct &&
|
||||
other.incorrect == incorrect &&
|
||||
other.skipped == skipped &&
|
||||
const SetEquality().equals(other.questionTypes, questionTypes);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,152 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'word_statistics_dto.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$WordStatisticsDtoCWProxy {
|
||||
WordStatisticsDto word(String word);
|
||||
|
||||
WordStatisticsDto correct(double correct);
|
||||
|
||||
WordStatisticsDto incorrect(double incorrect);
|
||||
|
||||
WordStatisticsDto skipped(double skipped);
|
||||
|
||||
WordStatisticsDto questionTypes(Set<TestQuestionType> questionTypes);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `WordStatisticsDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// WordStatisticsDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
WordStatisticsDto call({
|
||||
String? word,
|
||||
double? correct,
|
||||
double? incorrect,
|
||||
double? skipped,
|
||||
Set<TestQuestionType>? questionTypes,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfWordStatisticsDto.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfWordStatisticsDto.copyWith.fieldName(...)`
|
||||
class _$WordStatisticsDtoCWProxyImpl implements _$WordStatisticsDtoCWProxy {
|
||||
const _$WordStatisticsDtoCWProxyImpl(this._value);
|
||||
|
||||
final WordStatisticsDto _value;
|
||||
|
||||
@override
|
||||
WordStatisticsDto word(String word) => this(word: word);
|
||||
|
||||
@override
|
||||
WordStatisticsDto correct(double correct) => this(correct: correct);
|
||||
|
||||
@override
|
||||
WordStatisticsDto incorrect(double incorrect) => this(incorrect: incorrect);
|
||||
|
||||
@override
|
||||
WordStatisticsDto skipped(double skipped) => this(skipped: skipped);
|
||||
|
||||
@override
|
||||
WordStatisticsDto questionTypes(Set<TestQuestionType> questionTypes) =>
|
||||
this(questionTypes: questionTypes);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `WordStatisticsDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// WordStatisticsDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
WordStatisticsDto call({
|
||||
Object? word = const $CopyWithPlaceholder(),
|
||||
Object? correct = const $CopyWithPlaceholder(),
|
||||
Object? incorrect = const $CopyWithPlaceholder(),
|
||||
Object? skipped = const $CopyWithPlaceholder(),
|
||||
Object? questionTypes = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return WordStatisticsDto(
|
||||
word: word == const $CopyWithPlaceholder() || word == null
|
||||
? _value.word
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: word as String,
|
||||
correct: correct == const $CopyWithPlaceholder() || correct == null
|
||||
? _value.correct
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: correct as double,
|
||||
incorrect: incorrect == const $CopyWithPlaceholder() || incorrect == null
|
||||
? _value.incorrect
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: incorrect as double,
|
||||
skipped: skipped == const $CopyWithPlaceholder() || skipped == null
|
||||
? _value.skipped
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: skipped as double,
|
||||
questionTypes:
|
||||
questionTypes == const $CopyWithPlaceholder() || questionTypes == null
|
||||
? _value.questionTypes
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: questionTypes as Set<TestQuestionType>,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $WordStatisticsDtoCopyWith on WordStatisticsDto {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfWordStatisticsDto.copyWith(...)` or like so:`instanceOfWordStatisticsDto.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$WordStatisticsDtoCWProxy get copyWith =>
|
||||
_$WordStatisticsDtoCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
WordStatisticsDto _$WordStatisticsDtoFromJson(Map<String, dynamic> json) =>
|
||||
WordStatisticsDto(
|
||||
word: json['word'] as String? ?? '',
|
||||
correct: json['correct'] == null
|
||||
? 0
|
||||
: doubleFromJson(json['correct'] as double?),
|
||||
incorrect: json['incorrect'] == null
|
||||
? 0
|
||||
: doubleFromJson(json['incorrect'] as double?),
|
||||
skipped: json['skipped'] == null
|
||||
? 0
|
||||
: doubleFromJson(json['skipped'] as double?),
|
||||
questionTypes: (json['questionTypes'] as List<dynamic>?)
|
||||
?.map((e) => $enumDecode(_$TestQuestionTypeEnumMap, e))
|
||||
.toSet() ??
|
||||
const {},
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$WordStatisticsDtoToJson(WordStatisticsDto instance) {
|
||||
final val = <String, dynamic>{
|
||||
'word': instance.word,
|
||||
};
|
||||
|
||||
void writeNotNull(String key, dynamic value) {
|
||||
if (value != null) {
|
||||
val[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
writeNotNull('correct', doubleToJson(instance.correct));
|
||||
writeNotNull('incorrect', doubleToJson(instance.incorrect));
|
||||
writeNotNull('skipped', doubleToJson(instance.skipped));
|
||||
val['questionTypes'] =
|
||||
instance.questionTypes.map((e) => _$TestQuestionTypeEnumMap[e]!).toList();
|
||||
return val;
|
||||
}
|
||||
|
||||
const _$TestQuestionTypeEnumMap = {
|
||||
TestQuestionType.simple: 'simple',
|
||||
TestQuestionType.input_buttons: 'input_buttons',
|
||||
TestQuestionType.matrix: 'matrix',
|
||||
TestQuestionType.match: 'match',
|
||||
TestQuestionType.undefined: 'undefined',
|
||||
};
|
||||
1
mnemo_cards_common/lib/src/dtos/user/enums.dart
Normal file
1
mnemo_cards_common/lib/src/dtos/user/enums.dart
Normal file
|
|
@ -0,0 +1 @@
|
|||
enum ExternalIdType { google, telegram, device }
|
||||
23
mnemo_cards_common/lib/src/dtos/user/promo_code_dto.dart
Normal file
23
mnemo_cards_common/lib/src/dtos/user/promo_code_dto.dart
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
|
||||
part 'promo_code_dto.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
@CopyWith()
|
||||
class PromoCodeDto {
|
||||
final String? code;
|
||||
final String? message;
|
||||
final bool? success;
|
||||
|
||||
const PromoCodeDto({
|
||||
this.code,
|
||||
this.message,
|
||||
this.success,
|
||||
});
|
||||
|
||||
factory PromoCodeDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$PromoCodeDtoFromJson(json);
|
||||
|
||||
Map<String, Object?> toJson() => _$PromoCodeDtoToJson(this);
|
||||
}
|
||||
95
mnemo_cards_common/lib/src/dtos/user/promo_code_dto.g.dart
Normal file
95
mnemo_cards_common/lib/src/dtos/user/promo_code_dto.g.dart
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'promo_code_dto.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$PromoCodeDtoCWProxy {
|
||||
PromoCodeDto code(String? code);
|
||||
|
||||
PromoCodeDto message(String? message);
|
||||
|
||||
PromoCodeDto success(bool? success);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `PromoCodeDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// PromoCodeDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
PromoCodeDto call({
|
||||
String? code,
|
||||
String? message,
|
||||
bool? success,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfPromoCodeDto.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfPromoCodeDto.copyWith.fieldName(...)`
|
||||
class _$PromoCodeDtoCWProxyImpl implements _$PromoCodeDtoCWProxy {
|
||||
const _$PromoCodeDtoCWProxyImpl(this._value);
|
||||
|
||||
final PromoCodeDto _value;
|
||||
|
||||
@override
|
||||
PromoCodeDto code(String? code) => this(code: code);
|
||||
|
||||
@override
|
||||
PromoCodeDto message(String? message) => this(message: message);
|
||||
|
||||
@override
|
||||
PromoCodeDto success(bool? success) => this(success: success);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `PromoCodeDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// PromoCodeDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
PromoCodeDto call({
|
||||
Object? code = const $CopyWithPlaceholder(),
|
||||
Object? message = const $CopyWithPlaceholder(),
|
||||
Object? success = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return PromoCodeDto(
|
||||
code: code == const $CopyWithPlaceholder()
|
||||
? _value.code
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: code as String?,
|
||||
message: message == const $CopyWithPlaceholder()
|
||||
? _value.message
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: message as String?,
|
||||
success: success == const $CopyWithPlaceholder()
|
||||
? _value.success
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: success as bool?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $PromoCodeDtoCopyWith on PromoCodeDto {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfPromoCodeDto.copyWith(...)` or like so:`instanceOfPromoCodeDto.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$PromoCodeDtoCWProxy get copyWith => _$PromoCodeDtoCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
PromoCodeDto _$PromoCodeDtoFromJson(Map<String, dynamic> json) => PromoCodeDto(
|
||||
code: json['code'] as String?,
|
||||
message: json['message'] as String?,
|
||||
success: json['success'] as bool?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$PromoCodeDtoToJson(PromoCodeDto instance) =>
|
||||
<String, dynamic>{
|
||||
'code': instance.code,
|
||||
'message': instance.message,
|
||||
'success': instance.success,
|
||||
};
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
|
||||
part 'user_settings_dto.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
@CopyWith()
|
||||
class UserSettingsDto {
|
||||
final Map<int, PackCardsOrderDto> packCardsOrder;
|
||||
|
||||
UserSettingsDto({this.packCardsOrder = const {}});
|
||||
|
||||
factory UserSettingsDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$UserSettingsDtoFromJson(json);
|
||||
|
||||
Map<String, Object?> toJson() => _$UserSettingsDtoToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
@CopyWith()
|
||||
class PackCardsOrderDto {
|
||||
final int packId;
|
||||
final List<int> cardsOrder;
|
||||
|
||||
PackCardsOrderDto({this.packId = -1, this.cardsOrder = const []});
|
||||
|
||||
factory PackCardsOrderDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$PackCardsOrderDtoFromJson(json);
|
||||
|
||||
Map<String, Object?> toJson() => _$PackCardsOrderDtoToJson(this);
|
||||
}
|
||||
|
|
@ -0,0 +1,155 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'user_settings_dto.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$UserSettingsDtoCWProxy {
|
||||
UserSettingsDto packCardsOrder(Map<int, PackCardsOrderDto> packCardsOrder);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `UserSettingsDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// UserSettingsDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
UserSettingsDto call({
|
||||
Map<int, PackCardsOrderDto>? packCardsOrder,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfUserSettingsDto.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfUserSettingsDto.copyWith.fieldName(...)`
|
||||
class _$UserSettingsDtoCWProxyImpl implements _$UserSettingsDtoCWProxy {
|
||||
const _$UserSettingsDtoCWProxyImpl(this._value);
|
||||
|
||||
final UserSettingsDto _value;
|
||||
|
||||
@override
|
||||
UserSettingsDto packCardsOrder(Map<int, PackCardsOrderDto> packCardsOrder) =>
|
||||
this(packCardsOrder: packCardsOrder);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `UserSettingsDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// UserSettingsDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
UserSettingsDto call({
|
||||
Object? packCardsOrder = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return UserSettingsDto(
|
||||
packCardsOrder: packCardsOrder == const $CopyWithPlaceholder() ||
|
||||
packCardsOrder == null
|
||||
? _value.packCardsOrder
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: packCardsOrder as Map<int, PackCardsOrderDto>,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $UserSettingsDtoCopyWith on UserSettingsDto {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfUserSettingsDto.copyWith(...)` or like so:`instanceOfUserSettingsDto.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$UserSettingsDtoCWProxy get copyWith => _$UserSettingsDtoCWProxyImpl(this);
|
||||
}
|
||||
|
||||
abstract class _$PackCardsOrderDtoCWProxy {
|
||||
PackCardsOrderDto packId(int packId);
|
||||
|
||||
PackCardsOrderDto cardsOrder(List<int> cardsOrder);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `PackCardsOrderDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// PackCardsOrderDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
PackCardsOrderDto call({
|
||||
int? packId,
|
||||
List<int>? cardsOrder,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfPackCardsOrderDto.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfPackCardsOrderDto.copyWith.fieldName(...)`
|
||||
class _$PackCardsOrderDtoCWProxyImpl implements _$PackCardsOrderDtoCWProxy {
|
||||
const _$PackCardsOrderDtoCWProxyImpl(this._value);
|
||||
|
||||
final PackCardsOrderDto _value;
|
||||
|
||||
@override
|
||||
PackCardsOrderDto packId(int packId) => this(packId: packId);
|
||||
|
||||
@override
|
||||
PackCardsOrderDto cardsOrder(List<int> cardsOrder) =>
|
||||
this(cardsOrder: cardsOrder);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `PackCardsOrderDto(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// PackCardsOrderDto(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
PackCardsOrderDto call({
|
||||
Object? packId = const $CopyWithPlaceholder(),
|
||||
Object? cardsOrder = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return PackCardsOrderDto(
|
||||
packId: packId == const $CopyWithPlaceholder() || packId == null
|
||||
? _value.packId
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: packId as int,
|
||||
cardsOrder:
|
||||
cardsOrder == const $CopyWithPlaceholder() || cardsOrder == null
|
||||
? _value.cardsOrder
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: cardsOrder as List<int>,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $PackCardsOrderDtoCopyWith on PackCardsOrderDto {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfPackCardsOrderDto.copyWith(...)` or like so:`instanceOfPackCardsOrderDto.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$PackCardsOrderDtoCWProxy get copyWith =>
|
||||
_$PackCardsOrderDtoCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
UserSettingsDto _$UserSettingsDtoFromJson(Map<String, dynamic> json) =>
|
||||
UserSettingsDto(
|
||||
packCardsOrder: (json['packCardsOrder'] as Map<String, dynamic>?)?.map(
|
||||
(k, e) => MapEntry(int.parse(k),
|
||||
PackCardsOrderDto.fromJson(e as Map<String, dynamic>)),
|
||||
) ??
|
||||
const {},
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$UserSettingsDtoToJson(UserSettingsDto instance) =>
|
||||
<String, dynamic>{
|
||||
'packCardsOrder':
|
||||
instance.packCardsOrder.map((k, e) => MapEntry(k.toString(), e)),
|
||||
};
|
||||
|
||||
PackCardsOrderDto _$PackCardsOrderDtoFromJson(Map<String, dynamic> json) =>
|
||||
PackCardsOrderDto(
|
||||
packId: json['packId'] as int? ?? -1,
|
||||
cardsOrder: (json['cardsOrder'] as List<dynamic>?)
|
||||
?.map((e) => e as int)
|
||||
.toList() ??
|
||||
const [],
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$PackCardsOrderDtoToJson(PackCardsOrderDto instance) =>
|
||||
<String, dynamic>{
|
||||
'packId': instance.packId,
|
||||
'cardsOrder': instance.cardsOrder,
|
||||
};
|
||||
237
mnemo_cards_common/lib/src/dtos/user/study_session_dto.dart
Normal file
237
mnemo_cards_common/lib/src/dtos/user/study_session_dto.dart
Normal file
|
|
@ -0,0 +1,237 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
|
||||
part 'study_session_dto.g.dart';
|
||||
|
||||
/// Study session data for tracking learning activity
|
||||
@JsonSerializable()
|
||||
@CopyWith()
|
||||
class StudySessionDto {
|
||||
/// Unique session identifier
|
||||
final String? sessionId;
|
||||
|
||||
/// When the session started
|
||||
final DateTime startTime;
|
||||
|
||||
/// When the session ended (null if still active)
|
||||
final DateTime? endTime;
|
||||
|
||||
/// Number of words learned during this session
|
||||
final int wordsLearned;
|
||||
|
||||
/// Number of tests completed during this session
|
||||
final int testsCompleted;
|
||||
|
||||
/// Overall accuracy during this session (0.0 to 1.0)
|
||||
final double accuracy;
|
||||
|
||||
/// Pack being studied (if focused on specific pack)
|
||||
final String? packId;
|
||||
|
||||
/// Test being taken (if part of a test)
|
||||
final String? testId;
|
||||
|
||||
StudySessionDto({
|
||||
this.sessionId,
|
||||
required this.startTime,
|
||||
this.endTime,
|
||||
this.wordsLearned = 0,
|
||||
this.testsCompleted = 0,
|
||||
this.accuracy = 0.0,
|
||||
this.packId,
|
||||
this.testId,
|
||||
});
|
||||
|
||||
factory StudySessionDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$StudySessionDtoFromJson(json);
|
||||
|
||||
Map<String, Object?> toJson() => _$StudySessionDtoToJson(this);
|
||||
|
||||
/// Check if session is currently active
|
||||
bool get isActive => endTime == null;
|
||||
|
||||
/// Get session duration in minutes
|
||||
Duration get duration {
|
||||
final end = endTime ?? DateTime.now();
|
||||
return end.difference(startTime);
|
||||
}
|
||||
|
||||
/// Get session duration in minutes (integer)
|
||||
int get durationMinutes => duration.inMinutes;
|
||||
|
||||
/// Create new session
|
||||
factory StudySessionDto.start({
|
||||
String? sessionId,
|
||||
String? packId,
|
||||
String? testId,
|
||||
}) => StudySessionDto(
|
||||
sessionId: sessionId ?? _generateSessionId(),
|
||||
startTime: DateTime.now(),
|
||||
packId: packId,
|
||||
testId: testId,
|
||||
);
|
||||
|
||||
/// End the session with final statistics
|
||||
StudySessionDto end({
|
||||
int wordsLearned = 0,
|
||||
int testsCompleted = 0,
|
||||
double accuracy = 0.0,
|
||||
}) => StudySessionDto(
|
||||
sessionId: sessionId,
|
||||
startTime: startTime,
|
||||
endTime: DateTime.now(),
|
||||
wordsLearned: wordsLearned,
|
||||
testsCompleted: testsCompleted,
|
||||
accuracy: accuracy,
|
||||
packId: packId,
|
||||
testId: testId,
|
||||
);
|
||||
|
||||
/// Add progress to active session
|
||||
StudySessionDto addProgress({
|
||||
int wordsLearned = 0,
|
||||
int testsCompleted = 0,
|
||||
double? accuracy,
|
||||
}) => StudySessionDto(
|
||||
sessionId: sessionId,
|
||||
startTime: startTime,
|
||||
endTime: endTime,
|
||||
wordsLearned: this.wordsLearned + wordsLearned,
|
||||
testsCompleted: this.testsCompleted + testsCompleted,
|
||||
accuracy: accuracy ?? this.accuracy,
|
||||
packId: packId,
|
||||
testId: testId,
|
||||
);
|
||||
|
||||
/// Get session type description
|
||||
String get sessionType {
|
||||
if (testId != null) return 'Test Session';
|
||||
if (packId != null) return 'Pack Study';
|
||||
return 'General Study';
|
||||
}
|
||||
|
||||
/// Get productivity score (words per minute)
|
||||
double get productivityScore {
|
||||
final minutes = duration.inMinutes;
|
||||
if (minutes == 0) return 0.0;
|
||||
return wordsLearned / minutes;
|
||||
}
|
||||
|
||||
/// Check if session was productive
|
||||
bool get isProductive {
|
||||
return wordsLearned >= 5 && accuracy >= 0.7 && duration.inMinutes >= 5;
|
||||
}
|
||||
|
||||
static String _generateSessionId() =>
|
||||
'session_${DateTime.now().millisecondsSinceEpoch}_${DateTime.now().microsecond}';
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is StudySessionDto &&
|
||||
runtimeType == other.runtimeType &&
|
||||
sessionId == other.sessionId &&
|
||||
startTime == other.startTime &&
|
||||
endTime == other.endTime &&
|
||||
wordsLearned == other.wordsLearned &&
|
||||
testsCompleted == other.testsCompleted &&
|
||||
accuracy == other.accuracy &&
|
||||
packId == other.packId &&
|
||||
testId == other.testId;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
sessionId.hashCode ^
|
||||
startTime.hashCode ^
|
||||
endTime.hashCode ^
|
||||
wordsLearned.hashCode ^
|
||||
testsCompleted.hashCode ^
|
||||
accuracy.hashCode ^
|
||||
packId.hashCode ^
|
||||
testId.hashCode;
|
||||
|
||||
@override
|
||||
String toString() =>
|
||||
'StudySessionDto(id: $sessionId, duration: ${duration.inMinutes}min, words: $wordsLearned, accuracy: ${(accuracy * 100).toStringAsFixed(1)}%, type: $sessionType)';
|
||||
}
|
||||
|
||||
/// Study session summary for aggregated statistics
|
||||
class StudySessionSummary {
|
||||
final int totalSessions;
|
||||
final Duration totalTime;
|
||||
final int totalWordsLearned;
|
||||
final int totalTestsCompleted;
|
||||
final double averageAccuracy;
|
||||
final double averageProductivity;
|
||||
|
||||
const StudySessionSummary({
|
||||
required this.totalSessions,
|
||||
required this.totalTime,
|
||||
required this.totalWordsLearned,
|
||||
required this.totalTestsCompleted,
|
||||
required this.averageAccuracy,
|
||||
required this.averageProductivity,
|
||||
});
|
||||
|
||||
factory StudySessionSummary.fromSessions(List<StudySessionDto> sessions) {
|
||||
if (sessions.isEmpty) {
|
||||
return const StudySessionSummary(
|
||||
totalSessions: 0,
|
||||
totalTime: Duration.zero,
|
||||
totalWordsLearned: 0,
|
||||
totalTestsCompleted: 0,
|
||||
averageAccuracy: 0.0,
|
||||
averageProductivity: 0.0,
|
||||
);
|
||||
}
|
||||
|
||||
final totalTime = sessions.fold<Duration>(
|
||||
Duration.zero,
|
||||
(sum, session) => sum + session.duration,
|
||||
);
|
||||
|
||||
final totalWordsLearned = sessions.fold<int>(
|
||||
0,
|
||||
(sum, session) => sum + session.wordsLearned,
|
||||
);
|
||||
|
||||
final totalTestsCompleted = sessions.fold<int>(
|
||||
0,
|
||||
(sum, session) => sum + session.testsCompleted,
|
||||
);
|
||||
|
||||
final totalAccuracy = sessions.fold<double>(
|
||||
0,
|
||||
(sum, session) => sum + session.accuracy,
|
||||
);
|
||||
|
||||
final totalProductivity = sessions.fold<double>(
|
||||
0,
|
||||
(sum, session) => sum + session.productivityScore,
|
||||
);
|
||||
|
||||
return StudySessionSummary(
|
||||
totalSessions: sessions.length,
|
||||
totalTime: totalTime,
|
||||
totalWordsLearned: totalWordsLearned,
|
||||
totalTestsCompleted: totalTestsCompleted,
|
||||
averageAccuracy: totalAccuracy / sessions.length,
|
||||
averageProductivity: totalProductivity / sessions.length,
|
||||
);
|
||||
}
|
||||
|
||||
/// Get average session duration
|
||||
Duration get averageSessionDuration =>
|
||||
totalSessions > 0 ? totalTime ~/ totalSessions : Duration.zero;
|
||||
|
||||
/// Get average words per session
|
||||
double get averageWordsPerSession =>
|
||||
totalSessions > 0 ? totalWordsLearned / totalSessions : 0.0;
|
||||
|
||||
/// Get total study time in hours
|
||||
double get totalHours => totalTime.inMinutes / 60.0;
|
||||
|
||||
@override
|
||||
String toString() =>
|
||||
'StudySessionSummary(sessions: $totalSessions, time: ${totalHours.toStringAsFixed(1)}h, words: $totalWordsLearned, accuracy: ${(averageAccuracy * 100).toStringAsFixed(1)}%)';
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue