feat(deepLinks): added chat and profile deeplinks

This commit is contained in:
Username1548
2025-09-10 08:08:58 +03:00
parent 77666aca0e
commit 82bc51e45c
17 changed files with 69 additions and 122 deletions

View File

@@ -12,7 +12,6 @@ import 'package:eatvio_app/core/widgets/loader.dart';
import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_cubit.dart';
import 'package:eatvio_app/features/chat/presentation/pages/photo_view_screen.dart';
import 'package:eatvio_app/features/complaining/presentation/complaining_bottom_sheet.dart';
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
import 'package:eatvio_app/features/feed/presentation/widgets/plan_widget.dart';
import 'package:eatvio_app/features/menu/presentation/blocked_user_cubit/blocked_users_cubit.dart';
import 'package:eatvio_app/features/profile/models/circumference_model.dart';
@@ -43,9 +42,9 @@ import 'package:share_plus/share_plus.dart';
import 'package:url_launcher/url_launcher.dart';
class ProfileScreen extends StatefulWidget {
final Author? author;
final String? slug;
const ProfileScreen({super.key, this.author});
const ProfileScreen({super.key, this.slug});
@override
State<ProfileScreen> createState() => _ProfileScreenState();
@@ -70,7 +69,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
@override
void initState() {
super.initState();
widget.author == null || widget.author!.authorIsMe ? profileCubit.getMyProfile() : profileCubit.getProfileBySlug(widget.author!.authorSlug);
widget.slug == null ? profileCubit.getMyProfile() : profileCubit.getProfileBySlug(widget.slug!);
}
@override
@@ -93,7 +92,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
}
isFirstFetch = false;
}
// Проверяем, заблокировал ли пользователь меня
if (state.profile.isBlockedByUser) {
return Scaffold(
@@ -104,20 +103,12 @@ class _ProfileScreenState extends State<ProfileScreen> {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.block,
size: 64,
color: Colors.grey[400],
),
Icon(Icons.block, size: 64, color: Colors.grey[400]),
const SizedBox(height: 16),
Text(
'Пользователь ограничил доступ к своей странице',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w500,
color: Colors.grey[600],
),
style: TextStyle(fontSize: 18, fontWeight: FontWeight.w500, color: Colors.grey[600]),
),
],
),
@@ -125,16 +116,14 @@ class _ProfileScreenState extends State<ProfileScreen> {
),
);
}
return widget.author == null || widget.author!.authorIsMe ? _myProfileScreen(state) : _profileScreen(state);
return state.isMyProfile ? _myProfileScreen(state) : _profileScreen(state);
} else if (state is ProfileStateError) {
return Scaffold(
appBar: AppBar(),
body: DataErrorWidget(
onReload: () async {
widget.author == null || widget.author!.authorIsMe
? await profileCubit.getMyProfile()
: await profileCubit.getProfileBySlug(widget.author!.authorSlug);
widget.slug == null ? await profileCubit.getMyProfile() : await profileCubit.getProfileBySlug(widget.slug!);
},
),
);
@@ -221,7 +210,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
Scaffold _myProfileScreen(ProfileStateLoaded state) {
return Scaffold(
backgroundColor: Colors.grey.shade200,
appBar: AppBar(toolbarHeight: widget.author == null ? 0 : null),
appBar: AppBar(toolbarHeight: widget.slug == null ? 0 : null),
body: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -415,7 +404,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
GoRouter.of(context).pushNamed('stepperBecomeConsultantScreen', extra: state.profile.slug);
},
child: Text(
widget.author == null || widget.author!.authorIsMe ? 'Редактировать' : '',
state.isMyProfile ? 'Редактировать' : '',
style: const TextStyle(color: Color(0xFF2F80ED), fontSize: 16, fontWeight: FontWeight.w500),
),
),
@@ -493,7 +482,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
GoRouter.of(context).pushNamed('stepperBecomeConsultantScreen', extra: state.profile.slug);
},
child: Text(
widget.author == null || widget.author!.authorIsMe ? 'Редактировать' : '',
state.isMyProfile ? 'Редактировать' : '',
style: const TextStyle(color: Color(0xFF2F80ED), fontSize: 16, fontWeight: FontWeight.w500),
),
),
@@ -806,7 +795,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
context.pushTransparentRoute(rootNavigator: true, PhotoViewScreen(imageUrls: [baseUrl + state.profile.profilePhotoUrl], index: 0));
},
),
if (widget.author == null || widget.author!.authorIsMe) ...[
if (state.isMyProfile) ...[
_buildDivider(),
_buildCompactItem(
icon: 'assets/icons/edit_paint.svg',
@@ -964,7 +953,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
);
},
),
if (widget.author != null) ...[
if (!state.isMyProfile ) ...[
_buildDivider(),
_buildCompactItem(
icon: 'assets/icons/complain.svg',
@@ -973,12 +962,12 @@ class _ProfileScreenState extends State<ProfileScreen> {
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (context) => ComplainingBottomSheet(complainedContentType: ComplainedContent.profile, slug: widget.author?.authorSlug),
builder: (context) => ComplainingBottomSheet(complainedContentType: ComplainedContent.profile, slug: widget.slug),
);
},
),
],
if (widget.author != null && !state.profile.isBlockedByMe) ...[
if (!state.isMyProfile && !state.profile.isBlockedByMe) ...[
_buildDivider(),
_buildCompactItem(
icon: 'assets/icons/complain.svg',
@@ -986,7 +975,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
onTap: () {
isFirstFetch = true;
sl<BlockedUsersCubit>().blockUser(state.profile.slug);
widget.author == null || widget.author!.authorIsMe ? profileCubit.getMyProfile() : profileCubit.getProfileBySlug(widget.author!.authorSlug);
state.isMyProfile ? profileCubit.getMyProfile() : profileCubit.getProfileBySlug(state.profile.slug);
if (state.profile.roles.contains('consultant')) {
plansCubit.getPlans(state.profile.slug);
}
@@ -994,7 +983,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
},
),
],
if (widget.author != null && state.profile.isBlockedByMe) ...[
if (!state.isMyProfile && state.profile.isBlockedByMe) ...[
_buildDivider(),
_buildCompactItem(
icon: 'assets/icons/complain.svg',
@@ -1002,7 +991,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
onTap: () {
isFirstFetch = true;
sl<BlockedUsersCubit>().unblockUser(state.profile.slug);
widget.author == null || widget.author!.authorIsMe ? profileCubit.getMyProfile() : profileCubit.getProfileBySlug(widget.author!.authorSlug);
state.isMyProfile ? profileCubit.getMyProfile() : profileCubit.getProfileBySlug(state.profile.slug);
if (state.profile.roles.contains('consultant')) {
plansCubit.getPlans(state.profile.slug);
}
@@ -1065,7 +1054,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
children: [
const SizedBox(width: 16),
GestureDetector(
onTap: () async => await profileCubit.getChatRoomIdBySlug(author: widget.author!),
onTap: () async => await profileCubit.getChatRoomIdBySlug(slug: widget.slug!),
child: Container(
alignment: Alignment.center,
padding: const EdgeInsets.all(8),