diff --git a/lib/features/profile/models/profile_model.dart b/lib/features/profile/models/profile_model.dart index df06dee5..374111cc 100644 --- a/lib/features/profile/models/profile_model.dart +++ b/lib/features/profile/models/profile_model.dart @@ -22,11 +22,27 @@ class ProfileModel with _$ProfileModel { @JsonKey(name: "badges") required List badges, @JsonKey(name: "subscriptions") required List subscriptions, @JsonKey(name: "subscribers") required List subscribers, + @JsonKey(name: "education_resource") EducationResource? educationResource, }) = _ProfileModel; factory ProfileModel.fromJson(Map json) => _$ProfileModelFromJson(json); } +@freezed +class EducationResource with _$EducationResource { + const factory EducationResource({ + @JsonKey(name: "has_medical_education") int? hasMedical_Education, + @JsonKey(name: "vk_link") String? vkLink, + @JsonKey(name: "insta_link") String? instaLink, + @JsonKey(name: "fb_link") String? fbLink, + @JsonKey(name: "tg_link") String? tgLink, + @JsonKey(name: "personal_site_link") String? personalSiteLink, + @JsonKey(name: "request_state") String? requestState, + }) = _EducationResource; + + factory EducationResource.fromJson(Map json) => _$EducationResourceFromJson(json); +} + @freezed class ProfileDetailsModel with _$ProfileDetailsModel { const factory ProfileDetailsModel({ diff --git a/lib/features/profile/models/profile_model.freezed.dart b/lib/features/profile/models/profile_model.freezed.dart index d5ec2486..95be8ea8 100644 --- a/lib/features/profile/models/profile_model.freezed.dart +++ b/lib/features/profile/models/profile_model.freezed.dart @@ -50,6 +50,9 @@ mixin _$ProfileModel { @JsonKey(name: "subscribers") List get subscribers => throw _privateConstructorUsedError; + @JsonKey(name: "education_resource") + EducationResource? get educationResource => + throw _privateConstructorUsedError; /// Serializes this ProfileModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; @@ -81,7 +84,11 @@ abstract class $ProfileModelCopyWith<$Res> { @JsonKey(name: "role") String role, @JsonKey(name: "badges") List badges, @JsonKey(name: "subscriptions") List subscriptions, - @JsonKey(name: "subscribers") List subscribers}); + @JsonKey(name: "subscribers") List subscribers, + @JsonKey(name: "education_resource") + EducationResource? educationResource}); + + $EducationResourceCopyWith<$Res>? get educationResource; } /// @nodoc @@ -113,6 +120,7 @@ class _$ProfileModelCopyWithImpl<$Res, $Val extends ProfileModel> Object? badges = null, Object? subscriptions = null, Object? subscribers = null, + Object? educationResource = freezed, }) { return _then(_value.copyWith( id: null == id @@ -171,8 +179,26 @@ class _$ProfileModelCopyWithImpl<$Res, $Val extends ProfileModel> ? _value.subscribers : subscribers // ignore: cast_nullable_to_non_nullable as List, + educationResource: freezed == educationResource + ? _value.educationResource + : educationResource // ignore: cast_nullable_to_non_nullable + as EducationResource?, ) as $Val); } + + /// Create a copy of ProfileModel + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $EducationResourceCopyWith<$Res>? get educationResource { + if (_value.educationResource == null) { + return null; + } + + return $EducationResourceCopyWith<$Res>(_value.educationResource!, (value) { + return _then(_value.copyWith(educationResource: value) as $Val); + }); + } } /// @nodoc @@ -197,7 +223,12 @@ abstract class _$$ProfileModelImplCopyWith<$Res> @JsonKey(name: "role") String role, @JsonKey(name: "badges") List badges, @JsonKey(name: "subscriptions") List subscriptions, - @JsonKey(name: "subscribers") List subscribers}); + @JsonKey(name: "subscribers") List subscribers, + @JsonKey(name: "education_resource") + EducationResource? educationResource}); + + @override + $EducationResourceCopyWith<$Res>? get educationResource; } /// @nodoc @@ -227,6 +258,7 @@ class __$$ProfileModelImplCopyWithImpl<$Res> Object? badges = null, Object? subscriptions = null, Object? subscribers = null, + Object? educationResource = freezed, }) { return _then(_$ProfileModelImpl( id: null == id @@ -285,6 +317,10 @@ class __$$ProfileModelImplCopyWithImpl<$Res> ? _value._subscribers : subscribers // ignore: cast_nullable_to_non_nullable as List, + educationResource: freezed == educationResource + ? _value.educationResource + : educationResource // ignore: cast_nullable_to_non_nullable + as EducationResource?, )); } } @@ -309,7 +345,8 @@ class _$ProfileModelImpl implements _ProfileModel { @JsonKey(name: "subscriptions") required final List subscriptions, @JsonKey(name: "subscribers") - required final List subscribers}) + required final List subscribers, + @JsonKey(name: "education_resource") this.educationResource}) : _badges = badges, _subscriptions = subscriptions, _subscribers = subscribers; @@ -377,9 +414,13 @@ class _$ProfileModelImpl implements _ProfileModel { return EqualUnmodifiableListView(_subscribers); } + @override + @JsonKey(name: "education_resource") + final EducationResource? educationResource; + @override String toString() { - return 'ProfileModel(id: $id, name: $name, email: $email, emailVerifiedAt: $emailVerifiedAt, createdAt: $createdAt, updatedAt: $updatedAt, isPublicProfile: $isPublicProfile, isEntitySubscribedByMe: $isEntitySubscribedByMe, slug: $slug, profilePhotoUrl: $profilePhotoUrl, role: $role, badges: $badges, subscriptions: $subscriptions, subscribers: $subscribers)'; + return 'ProfileModel(id: $id, name: $name, email: $email, emailVerifiedAt: $emailVerifiedAt, createdAt: $createdAt, updatedAt: $updatedAt, isPublicProfile: $isPublicProfile, isEntitySubscribedByMe: $isEntitySubscribedByMe, slug: $slug, profilePhotoUrl: $profilePhotoUrl, role: $role, badges: $badges, subscriptions: $subscriptions, subscribers: $subscribers, educationResource: $educationResource)'; } @override @@ -408,7 +449,9 @@ class _$ProfileModelImpl implements _ProfileModel { const DeepCollectionEquality() .equals(other._subscriptions, _subscriptions) && const DeepCollectionEquality() - .equals(other._subscribers, _subscribers)); + .equals(other._subscribers, _subscribers) && + (identical(other.educationResource, educationResource) || + other.educationResource == educationResource)); } @JsonKey(includeFromJson: false, includeToJson: false) @@ -428,7 +471,8 @@ class _$ProfileModelImpl implements _ProfileModel { role, const DeepCollectionEquality().hash(_badges), const DeepCollectionEquality().hash(_subscriptions), - const DeepCollectionEquality().hash(_subscribers)); + const DeepCollectionEquality().hash(_subscribers), + educationResource); /// Create a copy of ProfileModel /// with the given fields replaced by the non-null parameter values. @@ -464,8 +508,9 @@ abstract class _ProfileModel implements ProfileModel { @JsonKey(name: "subscriptions") required final List subscriptions, @JsonKey(name: "subscribers") - required final List - subscribers}) = _$ProfileModelImpl; + required final List subscribers, + @JsonKey(name: "education_resource") + final EducationResource? educationResource}) = _$ProfileModelImpl; factory _ProfileModel.fromJson(Map json) = _$ProfileModelImpl.fromJson; @@ -512,6 +557,9 @@ abstract class _ProfileModel implements ProfileModel { @override @JsonKey(name: "subscribers") List get subscribers; + @override + @JsonKey(name: "education_resource") + EducationResource? get educationResource; /// Create a copy of ProfileModel /// with the given fields replaced by the non-null parameter values. @@ -521,6 +569,307 @@ abstract class _ProfileModel implements ProfileModel { throw _privateConstructorUsedError; } +EducationResource _$EducationResourceFromJson(Map json) { + return _EducationResource.fromJson(json); +} + +/// @nodoc +mixin _$EducationResource { + @JsonKey(name: "has_medical_education") + int? get hasMedical_Education => throw _privateConstructorUsedError; + @JsonKey(name: "vk_link") + String? get vkLink => throw _privateConstructorUsedError; + @JsonKey(name: "insta_link") + String? get instaLink => throw _privateConstructorUsedError; + @JsonKey(name: "fb_link") + String? get fbLink => throw _privateConstructorUsedError; + @JsonKey(name: "tg_link") + String? get tgLink => throw _privateConstructorUsedError; + @JsonKey(name: "personal_site_link") + String? get personalSiteLink => throw _privateConstructorUsedError; + @JsonKey(name: "request_state") + String? get requestState => throw _privateConstructorUsedError; + + /// Serializes this EducationResource to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of EducationResource + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $EducationResourceCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $EducationResourceCopyWith<$Res> { + factory $EducationResourceCopyWith( + EducationResource value, $Res Function(EducationResource) then) = + _$EducationResourceCopyWithImpl<$Res, EducationResource>; + @useResult + $Res call( + {@JsonKey(name: "has_medical_education") int? hasMedical_Education, + @JsonKey(name: "vk_link") String? vkLink, + @JsonKey(name: "insta_link") String? instaLink, + @JsonKey(name: "fb_link") String? fbLink, + @JsonKey(name: "tg_link") String? tgLink, + @JsonKey(name: "personal_site_link") String? personalSiteLink, + @JsonKey(name: "request_state") String? requestState}); +} + +/// @nodoc +class _$EducationResourceCopyWithImpl<$Res, $Val extends EducationResource> + implements $EducationResourceCopyWith<$Res> { + _$EducationResourceCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of EducationResource + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? hasMedical_Education = freezed, + Object? vkLink = freezed, + Object? instaLink = freezed, + Object? fbLink = freezed, + Object? tgLink = freezed, + Object? personalSiteLink = freezed, + Object? requestState = freezed, + }) { + return _then(_value.copyWith( + hasMedical_Education: freezed == hasMedical_Education + ? _value.hasMedical_Education + : hasMedical_Education // ignore: cast_nullable_to_non_nullable + as int?, + vkLink: freezed == vkLink + ? _value.vkLink + : vkLink // ignore: cast_nullable_to_non_nullable + as String?, + instaLink: freezed == instaLink + ? _value.instaLink + : instaLink // ignore: cast_nullable_to_non_nullable + as String?, + fbLink: freezed == fbLink + ? _value.fbLink + : fbLink // ignore: cast_nullable_to_non_nullable + as String?, + tgLink: freezed == tgLink + ? _value.tgLink + : tgLink // ignore: cast_nullable_to_non_nullable + as String?, + personalSiteLink: freezed == personalSiteLink + ? _value.personalSiteLink + : personalSiteLink // ignore: cast_nullable_to_non_nullable + as String?, + requestState: freezed == requestState + ? _value.requestState + : requestState // ignore: cast_nullable_to_non_nullable + as String?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$EducationResourceImplCopyWith<$Res> + implements $EducationResourceCopyWith<$Res> { + factory _$$EducationResourceImplCopyWith(_$EducationResourceImpl value, + $Res Function(_$EducationResourceImpl) then) = + __$$EducationResourceImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: "has_medical_education") int? hasMedical_Education, + @JsonKey(name: "vk_link") String? vkLink, + @JsonKey(name: "insta_link") String? instaLink, + @JsonKey(name: "fb_link") String? fbLink, + @JsonKey(name: "tg_link") String? tgLink, + @JsonKey(name: "personal_site_link") String? personalSiteLink, + @JsonKey(name: "request_state") String? requestState}); +} + +/// @nodoc +class __$$EducationResourceImplCopyWithImpl<$Res> + extends _$EducationResourceCopyWithImpl<$Res, _$EducationResourceImpl> + implements _$$EducationResourceImplCopyWith<$Res> { + __$$EducationResourceImplCopyWithImpl(_$EducationResourceImpl _value, + $Res Function(_$EducationResourceImpl) _then) + : super(_value, _then); + + /// Create a copy of EducationResource + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? hasMedical_Education = freezed, + Object? vkLink = freezed, + Object? instaLink = freezed, + Object? fbLink = freezed, + Object? tgLink = freezed, + Object? personalSiteLink = freezed, + Object? requestState = freezed, + }) { + return _then(_$EducationResourceImpl( + hasMedical_Education: freezed == hasMedical_Education + ? _value.hasMedical_Education + : hasMedical_Education // ignore: cast_nullable_to_non_nullable + as int?, + vkLink: freezed == vkLink + ? _value.vkLink + : vkLink // ignore: cast_nullable_to_non_nullable + as String?, + instaLink: freezed == instaLink + ? _value.instaLink + : instaLink // ignore: cast_nullable_to_non_nullable + as String?, + fbLink: freezed == fbLink + ? _value.fbLink + : fbLink // ignore: cast_nullable_to_non_nullable + as String?, + tgLink: freezed == tgLink + ? _value.tgLink + : tgLink // ignore: cast_nullable_to_non_nullable + as String?, + personalSiteLink: freezed == personalSiteLink + ? _value.personalSiteLink + : personalSiteLink // ignore: cast_nullable_to_non_nullable + as String?, + requestState: freezed == requestState + ? _value.requestState + : requestState // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$EducationResourceImpl implements _EducationResource { + const _$EducationResourceImpl( + {@JsonKey(name: "has_medical_education") this.hasMedical_Education, + @JsonKey(name: "vk_link") this.vkLink, + @JsonKey(name: "insta_link") this.instaLink, + @JsonKey(name: "fb_link") this.fbLink, + @JsonKey(name: "tg_link") this.tgLink, + @JsonKey(name: "personal_site_link") this.personalSiteLink, + @JsonKey(name: "request_state") this.requestState}); + + factory _$EducationResourceImpl.fromJson(Map json) => + _$$EducationResourceImplFromJson(json); + + @override + @JsonKey(name: "has_medical_education") + final int? hasMedical_Education; + @override + @JsonKey(name: "vk_link") + final String? vkLink; + @override + @JsonKey(name: "insta_link") + final String? instaLink; + @override + @JsonKey(name: "fb_link") + final String? fbLink; + @override + @JsonKey(name: "tg_link") + final String? tgLink; + @override + @JsonKey(name: "personal_site_link") + final String? personalSiteLink; + @override + @JsonKey(name: "request_state") + final String? requestState; + + @override + String toString() { + return 'EducationResource(hasMedical_Education: $hasMedical_Education, vkLink: $vkLink, instaLink: $instaLink, fbLink: $fbLink, tgLink: $tgLink, personalSiteLink: $personalSiteLink, requestState: $requestState)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$EducationResourceImpl && + (identical(other.hasMedical_Education, hasMedical_Education) || + other.hasMedical_Education == hasMedical_Education) && + (identical(other.vkLink, vkLink) || other.vkLink == vkLink) && + (identical(other.instaLink, instaLink) || + other.instaLink == instaLink) && + (identical(other.fbLink, fbLink) || other.fbLink == fbLink) && + (identical(other.tgLink, tgLink) || other.tgLink == tgLink) && + (identical(other.personalSiteLink, personalSiteLink) || + other.personalSiteLink == personalSiteLink) && + (identical(other.requestState, requestState) || + other.requestState == requestState)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, hasMedical_Education, vkLink, + instaLink, fbLink, tgLink, personalSiteLink, requestState); + + /// Create a copy of EducationResource + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$EducationResourceImplCopyWith<_$EducationResourceImpl> get copyWith => + __$$EducationResourceImplCopyWithImpl<_$EducationResourceImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$EducationResourceImplToJson( + this, + ); + } +} + +abstract class _EducationResource implements EducationResource { + const factory _EducationResource( + {@JsonKey(name: "has_medical_education") final int? hasMedical_Education, + @JsonKey(name: "vk_link") final String? vkLink, + @JsonKey(name: "insta_link") final String? instaLink, + @JsonKey(name: "fb_link") final String? fbLink, + @JsonKey(name: "tg_link") final String? tgLink, + @JsonKey(name: "personal_site_link") final String? personalSiteLink, + @JsonKey(name: "request_state") + final String? requestState}) = _$EducationResourceImpl; + + factory _EducationResource.fromJson(Map json) = + _$EducationResourceImpl.fromJson; + + @override + @JsonKey(name: "has_medical_education") + int? get hasMedical_Education; + @override + @JsonKey(name: "vk_link") + String? get vkLink; + @override + @JsonKey(name: "insta_link") + String? get instaLink; + @override + @JsonKey(name: "fb_link") + String? get fbLink; + @override + @JsonKey(name: "tg_link") + String? get tgLink; + @override + @JsonKey(name: "personal_site_link") + String? get personalSiteLink; + @override + @JsonKey(name: "request_state") + String? get requestState; + + /// Create a copy of EducationResource + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$EducationResourceImplCopyWith<_$EducationResourceImpl> get copyWith => + throw _privateConstructorUsedError; +} + ProfileDetailsModel _$ProfileDetailsModelFromJson(Map json) { return _ProfileDetailsModel.fromJson(json); } diff --git a/lib/features/profile/models/profile_model.g.dart b/lib/features/profile/models/profile_model.g.dart index 47755454..f22b5656 100644 --- a/lib/features/profile/models/profile_model.g.dart +++ b/lib/features/profile/models/profile_model.g.dart @@ -34,6 +34,10 @@ _$ProfileModelImpl _$$ProfileModelImplFromJson(Map json) => subscribers: (json['subscribers'] as List) .map((e) => ProfilePreviewModel.fromJson(e as Map)) .toList(), + educationResource: json['education_resource'] == null + ? null + : EducationResource.fromJson( + json['education_resource'] as Map), ); Map _$$ProfileModelImplToJson(_$ProfileModelImpl instance) => @@ -52,6 +56,31 @@ Map _$$ProfileModelImplToJson(_$ProfileModelImpl instance) => 'badges': instance.badges, 'subscriptions': instance.subscriptions, 'subscribers': instance.subscribers, + 'education_resource': instance.educationResource, + }; + +_$EducationResourceImpl _$$EducationResourceImplFromJson( + Map json) => + _$EducationResourceImpl( + hasMedical_Education: (json['has_medical_education'] as num?)?.toInt(), + vkLink: json['vk_link'] as String?, + instaLink: json['insta_link'] as String?, + fbLink: json['fb_link'] as String?, + tgLink: json['tg_link'] as String?, + personalSiteLink: json['personal_site_link'] as String?, + requestState: json['request_state'] as String?, + ); + +Map _$$EducationResourceImplToJson( + _$EducationResourceImpl instance) => + { + 'has_medical_education': instance.hasMedical_Education, + 'vk_link': instance.vkLink, + 'insta_link': instance.instaLink, + 'fb_link': instance.fbLink, + 'tg_link': instance.tgLink, + 'personal_site_link': instance.personalSiteLink, + 'request_state': instance.requestState, }; _$ProfileDetailsModelImpl _$$ProfileDetailsModelImplFromJson( diff --git a/lib/features/profile/presentation/pages/profile_screen.dart b/lib/features/profile/presentation/pages/profile_screen.dart index 2abd3feb..36d6628a 100644 --- a/lib/features/profile/presentation/pages/profile_screen.dart +++ b/lib/features/profile/presentation/pages/profile_screen.dart @@ -27,6 +27,7 @@ import 'package:go_router/go_router.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:image_picker/image_picker.dart'; import 'package:share_plus/share_plus.dart'; +import 'package:url_launcher/url_launcher.dart'; class ProfileScreen extends StatefulWidget { final Author? author; @@ -460,11 +461,38 @@ class _ProfileScreenState extends State { padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), child: Row( children: [ - _socialLinkButton(() {}, 'assets/icons/vk.svg'), + _socialLinkButton( + () { + launchUrl( + Uri.parse( + state.profile.educationResource?.vkLink ?? '', + ), + ); + }, + 'assets/icons/vk.svg', + ), const SizedBox(width: 12), - _socialLinkButton(() {}, 'assets/icons/telegram.svg'), + _socialLinkButton( + () { + launchUrl( + Uri.parse( + state.profile.educationResource?.tgLink ?? '', + ), + ); + }, + 'assets/icons/telegram.svg', + ), const SizedBox(width: 12), - _socialLinkButton(() {}, 'assets/icons/web.svg'), + _socialLinkButton( + () { + launchUrl( + Uri.parse( + state.profile.educationResource?.personalSiteLink ?? '', + ), + ); + }, + 'assets/icons/web.svg', + ), ], ), ),