CourseWork - refactoring
This commit is contained in:
parent
a251967084
commit
5d7e5d61ce
@ -1 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"><g fill="none" fill-rule="evenodd"><path d="M24 0v24H0V0zM12.593 23.258l-.011.002-.071.035-.02.004-.014-.004-.071-.035c-.01-.004-.019-.001-.024.005l-.004.01-.017.428.005.02.01.013.104.074.015.004.012-.004.104-.074.012-.016.004-.017-.017-.427c-.002-.01-.009-.017-.017-.018m.265-.113-.013.002-.185.093-.01.01-.003.011.018.43.005.012.008.007.201.093c.012.004.023 0 .029-.008l.004-.014-.034-.614c-.003-.012-.01-.02-.02-.022m-.715.002a.023.023 0 0 0-.027.006l-.006.014-.034.614c0 .012.007.02.017.024l.015-.002.201-.093.01-.008.004-.011.017-.43-.003-.012-.01-.01z"/><path fill="#09244B" d="M6 8a6 6 0 1 1 8.4 5.5.301.301 0 0 0-.139.123L14.36 15H18a3 3 0 0 1 3 3v2a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-2a3 3 0 0 1 3-3h3.64l.099-1.376a.301.301 0 0 0-.14-.124A6.001 6.001 0 0 1 6 8"/></g></svg>
|
Before Width: | Height: | Size: 842 B |
@ -1,7 +0,0 @@
|
||||
enum CourseStatus {
|
||||
Math,
|
||||
Physics,
|
||||
Chemistry,
|
||||
Biology,
|
||||
ComputerScience,
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
import 'domain/models/Student.dart';
|
||||
|
||||
extension StudentCourseStatus on Student {
|
||||
String getCourseStatus(String course) {
|
||||
if (courses.contains(course)) {
|
||||
return "Студент присутствует на этих курсах";
|
||||
} else {
|
||||
return "Студент отсутствует на этих курсах";
|
||||
}
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
import 'domain/models/Student.dart';
|
||||
|
||||
class University {
|
||||
List<Student> students = [];
|
||||
|
||||
void addStudent(Student student) {
|
||||
students.add(student);
|
||||
}
|
||||
|
||||
List<Student> getStudentsByCourse(String course) {
|
||||
return students.where((student) => student.courses.contains(course)).toList();
|
||||
}
|
||||
}
|
@ -82,8 +82,7 @@ abstract class AppLocale {
|
||||
/// Additional delegates can be added by appending to this list in
|
||||
/// MaterialApp. This list does not have to be used at all if a custom list
|
||||
/// of delegates is preferred or required.
|
||||
static const List<LocalizationsDelegate<dynamic>> localizationsDelegates =
|
||||
<LocalizationsDelegate<dynamic>>[
|
||||
static const List<LocalizationsDelegate<dynamic>> localizationsDelegates = <LocalizationsDelegate<dynamic>>[
|
||||
delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
@ -91,7 +90,10 @@ abstract class AppLocale {
|
||||
];
|
||||
|
||||
/// A list of this localizations delegate's supported locales.
|
||||
static const List<Locale> supportedLocales = <Locale>[Locale('en'), Locale('ru')];
|
||||
static const List<Locale> supportedLocales = <Locale>[
|
||||
Locale('en'),
|
||||
Locale('ru')
|
||||
];
|
||||
|
||||
/// No description provided for @search.
|
||||
///
|
||||
@ -164,17 +166,18 @@ class _AppLocaleDelegate extends LocalizationsDelegate<AppLocale> {
|
||||
}
|
||||
|
||||
AppLocale lookupAppLocale(Locale locale) {
|
||||
|
||||
|
||||
// Lookup logic when only language code is specified.
|
||||
switch (locale.languageCode) {
|
||||
case 'en':
|
||||
return AppLocaleEn();
|
||||
case 'ru':
|
||||
return AppLocaleRu();
|
||||
case 'en': return AppLocaleEn();
|
||||
case 'ru': return AppLocaleRu();
|
||||
}
|
||||
|
||||
throw FlutterError(
|
||||
'AppLocale.delegate failed to load unsupported locale "$locale". This is likely '
|
||||
'an issue with the localizations generation tool. Please file an issue '
|
||||
'on GitHub with a reproducible sample app and the gen-l10n configuration '
|
||||
'that was used.');
|
||||
'AppLocale.delegate failed to load unsupported locale "$locale". This is likely '
|
||||
'an issue with the localizations generation tool. Please file an issue '
|
||||
'on GitHub with a reproducible sample app and the gen-l10n configuration '
|
||||
'that was used.'
|
||||
);
|
||||
}
|
||||
|
@ -6,11 +6,14 @@ part of 'activity_dto.dart';
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
ActivitiesDto _$ActivitiesDtoFromJson(Map<String, dynamic> json) => ActivitiesDto(
|
||||
ActivitiesDto _$ActivitiesDtoFromJson(Map<String, dynamic> json) =>
|
||||
ActivitiesDto(
|
||||
data: (json['data'] as List<dynamic>?)
|
||||
?.map((e) => ActivityDataDto.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
meta: json['meta'] == null ? null : MetaDto.fromJson(json['meta'] as Map<String, dynamic>),
|
||||
meta: json['meta'] == null
|
||||
? null
|
||||
: MetaDto.fromJson(json['meta'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
MetaDto _$MetaDtoFromJson(Map<String, dynamic> json) => MetaDto(
|
||||
@ -19,21 +22,25 @@ MetaDto _$MetaDtoFromJson(Map<String, dynamic> json) => MetaDto(
|
||||
: PaginationDto.fromJson(json['pagination'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
PaginationDto _$PaginationDtoFromJson(Map<String, dynamic> json) => PaginationDto(
|
||||
PaginationDto _$PaginationDtoFromJson(Map<String, dynamic> json) =>
|
||||
PaginationDto(
|
||||
current: (json['current'] as num?)?.toInt(),
|
||||
next: (json['next'] as num?)?.toInt(),
|
||||
last: (json['last'] as num?)?.toInt(),
|
||||
);
|
||||
|
||||
ActivityDataDto _$ActivityDataDtoFromJson(Map<String, dynamic> json) => ActivityDataDto(
|
||||
ActivityDataDto _$ActivityDataDtoFromJson(Map<String, dynamic> json) =>
|
||||
ActivityDataDto(
|
||||
id: json['id'] as String?,
|
||||
type: json['type'] as String?,
|
||||
attributes: json['attributes'] == null
|
||||
? null
|
||||
: ActivityAttributesDataDto.fromJson(json['attributes'] as Map<String, dynamic>),
|
||||
: ActivityAttributesDataDto.fromJson(
|
||||
json['attributes'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
ActivityAttributesDataDto _$ActivityAttributesDataDtoFromJson(Map<String, dynamic> json) =>
|
||||
ActivityAttributesDataDto _$ActivityAttributesDataDtoFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
ActivityAttributesDataDto(
|
||||
name: json['name'] as String?,
|
||||
description: json['description'] as String?,
|
||||
|
@ -1,18 +0,0 @@
|
||||
import 'package:labs/data/dtos/characters_dto.dart';
|
||||
import 'package:labs/domain/models/Student.dart';
|
||||
import 'package:labs/domain/models/home.dart';
|
||||
|
||||
extension CharacterDataDtoToModel on CharacterDataDto {
|
||||
Student toDomain() => Student(attributes?.name ?? 'Undefined', int.parse(attributes?.age ?? '-1'),
|
||||
attributes?.courses ?? ['Undefined'],
|
||||
id: id,
|
||||
image: attributes?.image ??
|
||||
'https://gryazoveckij-r19.gosweb.gosuslugi.ru/netcat_files/460/2008/net_foto_muzh.jpg');
|
||||
}
|
||||
|
||||
/*extension CharactersDtoToModel on CharactersDto {
|
||||
HomeData toDomain() => HomeData(
|
||||
data: data?.map((e) => e.toDomain()).toList(),
|
||||
nextPage: meta?.pagination?.next,
|
||||
);
|
||||
}*/
|
@ -1,27 +0,0 @@
|
||||
class Student {
|
||||
String name;
|
||||
int age;
|
||||
List<String> courses;
|
||||
final String? image;
|
||||
final String? id;
|
||||
|
||||
Student(this.name, this.age, this.courses, {this.image, this.id});
|
||||
|
||||
static String getYearWord(int age) {
|
||||
if (age == -1) {
|
||||
return "Undefined";
|
||||
}
|
||||
if (age % 10 == 1) {
|
||||
return age.toString() + " год";
|
||||
} else if (age % 10 < 5 && age % 10 != 0) {
|
||||
return age.toString() + " года";
|
||||
} else {
|
||||
return age.toString() + " лет";
|
||||
}
|
||||
}
|
||||
|
||||
void displayInfo() {
|
||||
print('Name: $name, Age: $age');
|
||||
print('Courses: ${courses.join(", ")}');
|
||||
}
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
import 'package:labs/domain/models/Activity.dart';
|
||||
|
||||
import 'Student.dart';
|
||||
|
||||
class HomeData {
|
||||
final List<Activity>? data;
|
||||
final int? nextPage;
|
||||
|
@ -72,7 +72,8 @@ class _$HomeStateCWProxyImpl implements _$HomeStateCWProxy {
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: isLoading as bool,
|
||||
isPaginationLoading:
|
||||
isPaginationLoading == const $CopyWithPlaceholder() || isPaginationLoading == null
|
||||
isPaginationLoading == const $CopyWithPlaceholder() ||
|
||||
isPaginationLoading == null
|
||||
? _value.isPaginationLoading
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: isPaginationLoading as bool,
|
||||
|
@ -1,17 +0,0 @@
|
||||
import 'package:labs/CourseStatus.dart';
|
||||
import 'package:labs/domain/models/Student.dart';
|
||||
|
||||
import '../domain/models/home.dart';
|
||||
import 'api_interface.dart';
|
||||
|
||||
class MockRepo extends ApiInterface {
|
||||
@override
|
||||
Future<HomeData?> loadData({OnErrorCallback? onError}) async {
|
||||
return HomeData();
|
||||
/*return [
|
||||
Student('Stroev V.', 19, [CourseStatus.Biology.name]),
|
||||
Student('Samoilov K.', 20, [CourseStatus.Chemistry.name]),
|
||||
Student('Belov M.', 21, [CourseStatus.ComputerScience.name]),
|
||||
];*/
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:labs/data/mapper/CharacterDataDtoModel.dart';
|
||||
import 'package:pretty_dio_logger/pretty_dio_logger.dart';
|
||||
|
||||
import '../data/dtos/characters_dto.dart';
|
||||
import '../domain/models/Student.dart';
|
||||
import '../domain/models/home.dart';
|
||||
import 'api_interface.dart';
|
||||
|
||||
class PotterRepo extends ApiInterface {
|
||||
static final Dio _dio = Dio()
|
||||
..interceptors.add(PrettyDioLogger(
|
||||
requestHeader: true,
|
||||
requestBody: true,
|
||||
));
|
||||
|
||||
static const String _baseUrl = 'https://api.potterdb.com';
|
||||
|
||||
@override
|
||||
Future<HomeData?> loadData(
|
||||
{OnErrorCallback? onError, String? q, int page = 1, int pageSize = 25}) async {
|
||||
try {
|
||||
const String url = '$_baseUrl/v1/characters';
|
||||
|
||||
final Response<dynamic> response = await _dio.get<Map<dynamic, dynamic>>(
|
||||
url,
|
||||
queryParameters: {
|
||||
'filter[name_cont]': q,
|
||||
'page[number]': page,
|
||||
'page[size]': pageSize,
|
||||
},
|
||||
);
|
||||
|
||||
final CharactersDto dto = CharactersDto.fromJson(response.data as Map<String, dynamic>);
|
||||
/*final HomeData data = dto.toDomain();
|
||||
return data;*/
|
||||
} on DioException catch (e) {
|
||||
onError?.call(e.error?.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
56
pubspec.lock
56
pubspec.lock
@ -34,10 +34,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: archive
|
||||
sha256: cb6a278ef2dbb298455e1a713bda08524a175630ec643a242c399c932a0a1f7d
|
||||
sha256: "08064924cbf0ab88280a0c3f60db9dd24fec693927e725ecb176f16c629d1cb8"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.6.1"
|
||||
version: "4.0.1"
|
||||
args:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -130,10 +130,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: built_value
|
||||
sha256: c7913a9737ee4007efedaffc968c049fd0f3d0e49109e778edc10de9426005cb
|
||||
sha256: "28a712df2576b63c6c005c465989a348604960c0958d28be5303ba9baa841ac2"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "8.9.2"
|
||||
version: "8.9.3"
|
||||
characters:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -382,10 +382,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: http_multi_server
|
||||
sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b"
|
||||
sha256: aa6199f908078bb1c5efb8d8638d4ae191aac11b311132c3ef48ce352fb52ef8
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.2.1"
|
||||
version: "3.2.2"
|
||||
http_parser:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -398,10 +398,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image
|
||||
sha256: f31d52537dc417fdcde36088fdf11d191026fd5e4fae742491ebd40e5a8bea7d
|
||||
sha256: b50b415345578583de0f1cf4c7bd389f164de0b316d890c707b41133047dbc2a
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.3.0"
|
||||
version: "4.5.1"
|
||||
intl:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
@ -534,10 +534,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: package_config
|
||||
sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd"
|
||||
sha256: "92d4488434b520a62570293fbd33bb556c7d49230791c1b4bbd973baf6d2dc67"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
version: "2.1.1"
|
||||
path:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -610,6 +610,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.5.1"
|
||||
posix:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: posix
|
||||
sha256: a0117dc2167805aa9125b82eee515cc891819bac2f538c83646d355b16f58b9a
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.0.1"
|
||||
pretty_dio_logger:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -630,10 +638,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pub_semver
|
||||
sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c"
|
||||
sha256: "7b3cfbf654f3edd0c6298ecd5be782ce997ddf0e00531b9464b55245185bbbbd"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.4"
|
||||
version: "2.1.5"
|
||||
pubspec_parse:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -654,18 +662,18 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_android
|
||||
sha256: "7f172d1b06de5da47b6264c2692ee2ead20bbbc246690427cdb4fc301cd0c549"
|
||||
sha256: "02a7d8a9ef346c9af715811b01fbd8e27845ad2c41148eefd31321471b41863d"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.4"
|
||||
version: "2.4.0"
|
||||
shared_preferences_foundation:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_foundation
|
||||
sha256: "07e050c7cd39bad516f8d64c455f04508d09df104be326d8c02551590a0d513d"
|
||||
sha256: "6a52cfcdaeac77cad8c97b539ff688ccfc458c007b4db12be584fbe5c0e49e03"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.5.3"
|
||||
version: "2.5.4"
|
||||
shared_preferences_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -731,10 +739,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: source_helper
|
||||
sha256: "6adebc0006c37dd63fe05bca0a929b99f06402fc95aa35bf36d67f5c06de01fd"
|
||||
sha256: "86d247119aedce8e63f4751bd9626fc9613255935558447569ad42f9f5b48b3c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.4"
|
||||
version: "1.3.5"
|
||||
source_span:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -763,10 +771,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stream_transform
|
||||
sha256: "14a00e794c7c11aa145a170587321aedce29769c08d7f58b1d141da75e3b1c6f"
|
||||
sha256: ad47125e588cfd37a9a7f86c7d6356dde8dfe89d071d293f80ca9e9273a33871
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
version: "2.1.1"
|
||||
string_scanner:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -795,10 +803,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: timing
|
||||
sha256: "70a3b636575d4163c477e6de42f247a23b315ae20e86442bebe32d3cabf61c32"
|
||||
sha256: "62ee18aca144e4a9f29d212f5a4c6a053be252b895ab14b5821996cff4ed90fe"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
version: "1.0.2"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -851,10 +859,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: watcher
|
||||
sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8"
|
||||
sha256: "69da27e49efa56a15f8afe8f4438c4ec02eff0a117df1b22ea4aad194fe1c104"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
version: "1.1.1"
|
||||
web:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
Loading…
x
Reference in New Issue
Block a user