-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Another important work (refactoring, Clean Architecture)
- Loading branch information
1 parent
560853c
commit c6fd0ce
Showing
215 changed files
with
3,042 additions
and
2,380 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import 'package:sj_manager/core/algorithms/filter/filter.dart'; | ||
|
||
class CompositeFilter<T> implements Filter<T> { | ||
const CompositeFilter({ | ||
required this.filters, | ||
}); | ||
|
||
final Iterable<Filter<T>> filters; | ||
|
||
@override | ||
Iterable<T> call(Iterable<T> source) { | ||
Iterable<T> currentItems = List.of(source); | ||
for (var filter in filters) { | ||
currentItems = filter(currentItems); | ||
} | ||
return currentItems; | ||
} | ||
|
||
@override | ||
bool get isValid => | ||
filters.isNotEmpty ? filters.every((filter) => filter.isValid) : false; | ||
} |
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,6 @@ | ||
abstract interface class Filter<T> { | ||
const Filter(); | ||
|
||
bool get isValid; | ||
Iterable<T> call(Iterable<T> source); | ||
} |
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,56 @@ | ||
import 'package:sj_manager/core/classes/country/country.dart'; | ||
import 'package:sj_manager/core/algorithms/filter/filter.dart'; | ||
import 'package:sj_manager/core/mixins/country_mixin.dart'; | ||
import 'package:sj_manager/core/mixins/name_and_surname_mixin.dart'; | ||
import 'package:sj_manager/utilities/filters/matching_algorithms/matching_by_text_algorithm.dart'; | ||
|
||
class NoFilter<T> implements Filter<T> { | ||
@override | ||
Iterable<T> call(Iterable<T> source) { | ||
return source; | ||
} | ||
|
||
@override | ||
bool get isValid => false; | ||
} | ||
|
||
class NameSurnameFilter<T extends NameAndSurnameMixin> implements Filter<T> { | ||
const NameSurnameFilter({ | ||
required this.text, | ||
}); | ||
|
||
final String text; | ||
|
||
@override | ||
Iterable<T> call(Iterable<T> source) { | ||
bool shouldPass(NameAndSurnameMixin data) { | ||
final base = data.nameAndSurname(); | ||
return DefaultMatchingByTextAlgorithm(target: base, text: text).matches(); | ||
} | ||
|
||
return source.where(shouldPass); | ||
} | ||
|
||
@override | ||
bool get isValid => text.isNotEmpty; | ||
} | ||
|
||
class CountryFilter<T extends CountryMixin> implements Filter<T> { | ||
const CountryFilter({ | ||
required this.country, | ||
}); | ||
|
||
final Country? country; | ||
|
||
@override | ||
Iterable<T> call(Iterable<T> source) { | ||
bool shouldPass(CountryMixin data) { | ||
return data.country == country; | ||
} | ||
|
||
return source.where(shouldPass); | ||
} | ||
|
||
@override | ||
bool get isValid => country != null; | ||
} |
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
lib/core/team/country_team/country_team.dart → ...re/classes/country_team/country_team.dart
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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...ountry_team/country_team_facts_model.dart → ...ountry_team/country_team_facts_model.dart
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
File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions
20
lib/core/countries/countries_repository/countries_repository.dart
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,20 @@ | ||
import 'package:sj_manager/core/classes/country/country.dart'; | ||
|
||
abstract interface class CountriesRepository { | ||
Future<Iterable<Country>> getAll(); | ||
Future<Country> byCode(String code); | ||
Future<Country> get none; | ||
} | ||
|
||
class CountryNotFoundError extends Error { | ||
CountryNotFoundError({ | ||
required this.countryCode, | ||
}); | ||
|
||
final String countryCode; | ||
|
||
@override | ||
String toString() { | ||
return 'Didn\'t find a country with the code of \'$countryCode\''; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
lib/core/countries/countries_repository/in_memory_countries_repository.dart
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,32 @@ | ||
import 'package:collection/collection.dart'; | ||
import 'package:equatable/equatable.dart'; | ||
import 'package:sj_manager/core/classes/country/country.dart'; | ||
import 'package:sj_manager/core/countries/countries_repository/countries_repository.dart'; | ||
|
||
class InMemoryCountriesRepository with EquatableMixin implements CountriesRepository { | ||
const InMemoryCountriesRepository({ | ||
required this.countries, | ||
}); | ||
|
||
final Iterable<Country> countries; | ||
|
||
@override | ||
Future<Iterable<Country>> getAll() async => countries; | ||
|
||
@override | ||
Future<Country> byCode(String code) async { | ||
final toReturn = countries.singleWhereOrNull( | ||
(country) => country.code.toLowerCase() == code.toLowerCase(), | ||
); | ||
if (toReturn == null) { | ||
throw CountryNotFoundError(countryCode: code.toLowerCase()); | ||
} | ||
return toReturn; | ||
} | ||
|
||
@override | ||
Future<Country> get none async => byCode('none'); | ||
|
||
@override | ||
List<Object?> get props => [countries]; | ||
} |
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,4 @@ | ||
enum DatabaseEditorFilterType { | ||
nameSurname, | ||
country, | ||
} |
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,9 @@ | ||
enum DatabaseEditorItemsType { | ||
maleJumper, | ||
femaleJumper, | ||
} | ||
|
||
const sjmDatabaseEditorItemsTypeOrder = [ | ||
DatabaseEditorItemsType.maleJumper, | ||
DatabaseEditorItemsType.femaleJumper, | ||
]; |
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,5 @@ | ||
import 'package:sj_manager/core/classes/country/country.dart'; | ||
|
||
mixin CountryMixin { | ||
Country get country; | ||
} |
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,12 @@ | ||
mixin NameAndSurnameMixin { | ||
String get name; | ||
String get surname; | ||
|
||
String nameAndSurname({bool capitalizeSurname = false, bool reverse = false}) { | ||
var appropriateSurname = surname; | ||
if (capitalizeSurname) { | ||
appropriateSurname = appropriateSurname.toUpperCase(); | ||
} | ||
return reverse ? '$appropriateSurname $name ' : '$name $appropriateSurname'; | ||
} | ||
} |
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,5 @@ | ||
import 'package:sj_manager/features/game_variants/data/models/game_variant_database.dart/sex.dart'; | ||
|
||
mixin SexMixin { | ||
Sex get sex; | ||
} |
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,5 @@ | ||
import 'package:sj_manager/core/mixins/sex_mixin.dart'; | ||
import 'package:sj_manager/features/game_variants/data/models/game_variant_database.dart/sex.dart'; | ||
|
||
bool jumperIsMale(SexMixin jumper) => jumper.sex == Sex.male; | ||
bool jumperIsFemale(SexMixin jumper) => jumper.sex == Sex.female; |
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
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
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
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
2 changes: 1 addition & 1 deletion
2
...ities/simulation/competition/calendar_records/calendar_main_competition_record_setup.dart
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
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
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
2 changes: 1 addition & 1 deletion
2
...ties/simulation/competition/rules/competition_rules/default_competition_rules_preset.dart
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
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
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
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
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
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
2 changes: 1 addition & 1 deletion
2
...ation/competition/rules/utils/competition_score_creator/concrete/team/default_linear.dart
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
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
4 changes: 2 additions & 2 deletions
4
lib/domain/entities/simulation/database/simulation_wizard_options_repo.dart
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
Oops, something went wrong.