-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1bf099e
commit a40c3a6
Showing
25 changed files
with
1,566 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
# This is a generated file; do not edit or check into version control. | ||
cloud_firestore=/home/mayank/.pub-cache/hosted/pub.dev/cloud_firestore-5.4.4/ | ||
cloud_firestore_web=/home/mayank/.pub-cache/hosted/pub.dev/cloud_firestore_web-4.3.2/ | ||
cloud_functions=/home/mayank/.pub-cache/hosted/pub.dev/cloud_functions-5.1.3/ | ||
cloud_functions_web=/home/mayank/.pub-cache/hosted/pub.dev/cloud_functions_web-4.10.2/ | ||
device_info_plus=/home/mayank/.pub-cache/hosted/pub.dev/device_info_plus-10.1.2/ | ||
firebase_auth=/home/mayank/.pub-cache/hosted/pub.dev/firebase_auth-5.3.1/ | ||
firebase_auth_web=/home/mayank/.pub-cache/hosted/pub.dev/firebase_auth_web-5.13.2/ | ||
firebase_core=/home/mayank/.pub-cache/hosted/pub.dev/firebase_core-3.6.0/ | ||
firebase_core_web=/home/mayank/.pub-cache/hosted/pub.dev/firebase_core_web-2.18.1/ | ||
firebase_messaging=/home/mayank/.pub-cache/hosted/pub.dev/firebase_messaging-15.1.3/ | ||
firebase_messaging_web=/home/mayank/.pub-cache/hosted/pub.dev/firebase_messaging_web-3.9.2/ | ||
firebase_storage=/home/mayank/.pub-cache/hosted/pub.dev/firebase_storage-12.3.2/ | ||
firebase_storage_web=/home/mayank/.pub-cache/hosted/pub.dev/firebase_storage_web-3.10.2/ | ||
flutter_timezone=/home/mayank/.pub-cache/hosted/pub.dev/flutter_timezone-3.0.1/ | ||
package_info_plus=/home/mayank/.pub-cache/hosted/pub.dev/package_info_plus-8.0.2/ | ||
path_provider_linux=/home/mayank/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/ | ||
path_provider_windows=/home/mayank/.pub-cache/hosted/pub.dev/path_provider_windows-2.3.0/ | ||
shared_preferences=/home/mayank/.pub-cache/hosted/pub.dev/shared_preferences-2.3.2/ | ||
shared_preferences_android=/home/mayank/.pub-cache/hosted/pub.dev/shared_preferences_android-2.3.3/ | ||
shared_preferences_foundation=/home/mayank/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.5.3/ | ||
shared_preferences_linux=/home/mayank/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.4.1/ | ||
shared_preferences_web=/home/mayank/.pub-cache/hosted/pub.dev/shared_preferences_web-2.4.2/ | ||
shared_preferences_windows=/home/mayank/.pub-cache/hosted/pub.dev/shared_preferences_windows-2.4.1/ | ||
cloud_firestore=/Users/sidhdhi.p/.pub-cache/hosted/pub.dev/cloud_firestore-5.4.4/ | ||
cloud_firestore_web=/Users/sidhdhi.p/.pub-cache/hosted/pub.dev/cloud_firestore_web-4.3.2/ | ||
cloud_functions=/Users/sidhdhi.p/.pub-cache/hosted/pub.dev/cloud_functions-5.1.3/ | ||
cloud_functions_web=/Users/sidhdhi.p/.pub-cache/hosted/pub.dev/cloud_functions_web-4.10.2/ | ||
device_info_plus=/Users/sidhdhi.p/.pub-cache/hosted/pub.dev/device_info_plus-10.1.2/ | ||
firebase_auth=/Users/sidhdhi.p/.pub-cache/hosted/pub.dev/firebase_auth-5.3.1/ | ||
firebase_auth_web=/Users/sidhdhi.p/.pub-cache/hosted/pub.dev/firebase_auth_web-5.13.2/ | ||
firebase_core=/Users/sidhdhi.p/.pub-cache/hosted/pub.dev/firebase_core-3.6.0/ | ||
firebase_core_web=/Users/sidhdhi.p/.pub-cache/hosted/pub.dev/firebase_core_web-2.18.1/ | ||
firebase_messaging=/Users/sidhdhi.p/.pub-cache/hosted/pub.dev/firebase_messaging-15.0.2/ | ||
firebase_messaging_web=/Users/sidhdhi.p/.pub-cache/hosted/pub.dev/firebase_messaging_web-3.9.0/ | ||
firebase_storage=/Users/sidhdhi.p/.pub-cache/hosted/pub.dev/firebase_storage-12.3.3/ | ||
firebase_storage_web=/Users/sidhdhi.p/.pub-cache/hosted/pub.dev/firebase_storage_web-3.10.3/ | ||
flutter_timezone=/Users/sidhdhi.p/.pub-cache/hosted/pub.dev/flutter_timezone-3.0.1/ | ||
package_info_plus=/Users/sidhdhi.p/.pub-cache/hosted/pub.dev/package_info_plus-8.0.2/ | ||
path_provider_linux=/Users/sidhdhi.p/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/ | ||
path_provider_windows=/Users/sidhdhi.p/.pub-cache/hosted/pub.dev/path_provider_windows-2.2.1/ | ||
shared_preferences=/Users/sidhdhi.p/.pub-cache/hosted/pub.dev/shared_preferences-2.3.2/ | ||
shared_preferences_android=/Users/sidhdhi.p/.pub-cache/hosted/pub.dev/shared_preferences_android-2.3.3/ | ||
shared_preferences_foundation=/Users/sidhdhi.p/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.5.3/ | ||
shared_preferences_linux=/Users/sidhdhi.p/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.4.1/ | ||
shared_preferences_web=/Users/sidhdhi.p/.pub-cache/hosted/pub.dev/shared_preferences_web-2.4.2/ | ||
shared_preferences_windows=/Users/sidhdhi.p/.pub-cache/hosted/pub.dev/shared_preferences_windows-2.4.1/ |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import 'package:cloud_firestore/cloud_firestore.dart'; | ||
import 'package:freezed_annotation/freezed_annotation.dart'; | ||
|
||
import '../../converter/timestamp_json_converter.dart'; | ||
import '../../utils/constant/firestore_constant.dart'; | ||
import '../user/user_models.dart'; | ||
|
||
part 'leaderboard_model.freezed.dart'; | ||
|
||
part 'leaderboard_model.g.dart'; | ||
|
||
@freezed | ||
class LeaderboardModel with _$LeaderboardModel { | ||
const factory LeaderboardModel({ | ||
required LeaderboardField type, | ||
@Default([]) List<LeaderboardPlayer> players, | ||
}) = _LeaderboardModel; | ||
|
||
factory LeaderboardModel.fromJson(Map<String, dynamic> json) => | ||
_$LeaderboardModelFromJson(json); | ||
|
||
factory LeaderboardModel.fromFireStore( | ||
DocumentSnapshot<Map<String, dynamic>> snapshot, | ||
SnapshotOptions? options, | ||
) => | ||
LeaderboardModel.fromJson(snapshot.data()!); | ||
} | ||
|
||
@freezed | ||
class LeaderboardPlayer with _$LeaderboardPlayer { | ||
const factory LeaderboardPlayer({ | ||
@TimeStampJsonConverter() required DateTime date, | ||
required String id, | ||
@Default(0) int runs, | ||
@Default(0) int wickets, | ||
@Default(0) int catches, | ||
@JsonKey(includeToJson: false, includeFromJson: false) UserModel? user, | ||
}) = _LeaderboardPlayer; | ||
|
||
factory LeaderboardPlayer.fromJson(Map<String, dynamic> json) => | ||
_$LeaderboardPlayerFromJson(json); | ||
|
||
factory LeaderboardPlayer.fromFireStore( | ||
DocumentSnapshot<Map<String, dynamic>> snapshot, | ||
SnapshotOptions? options, | ||
) => | ||
LeaderboardPlayer.fromJson(snapshot.data()!); | ||
} | ||
|
||
enum LeaderboardType { | ||
weekly, | ||
monthly, | ||
allTime; | ||
|
||
String getDatabaseConst() { | ||
switch (this) { | ||
case LeaderboardType.weekly: | ||
return FireStoreConst.weeklyDocument; | ||
case LeaderboardType.monthly: | ||
return FireStoreConst.monthlyDocument; | ||
case LeaderboardType.allTime: | ||
return FireStoreConst.allTimeDocument; | ||
} | ||
} | ||
} | ||
|
||
enum LeaderboardField { | ||
batting, | ||
bowling, | ||
fielding; | ||
|
||
String getDatabaseConst() { | ||
switch (this) { | ||
case LeaderboardField.batting: | ||
return FireStoreConst.runs; | ||
case LeaderboardField.bowling: | ||
return FireStoreConst.wickets; | ||
case LeaderboardField.fielding: | ||
return FireStoreConst.catches; | ||
} | ||
} | ||
} |
Oops, something went wrong.