forked from eatvio/eatvio_app
feat(deepLinks): added chat and profile deeplinks
This commit is contained in:
@@ -53,6 +53,12 @@
|
|||||||
|
|
||||||
<data android:pathPattern="/ru/plan/.*" />
|
<data android:pathPattern="/ru/plan/.*" />
|
||||||
<data android:pathPattern="/en/plan/.*" />
|
<data android:pathPattern="/en/plan/.*" />
|
||||||
|
|
||||||
|
<data android:pathPattern="/ru/chat/.*" />
|
||||||
|
<data android:pathPattern="/en/chat/.*" />
|
||||||
|
|
||||||
|
<data android:pathPattern="/ru/chat/" />
|
||||||
|
<data android:pathPattern="/en/chat/" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<!-- Don't delete the meta-data below.
|
<!-- Don't delete the meta-data below.
|
||||||
|
|||||||
@@ -410,6 +410,7 @@
|
|||||||
PRODUCT_BUNDLE_IDENTIFIER = com.eatvioapp.app;
|
PRODUCT_BUNDLE_IDENTIFIER = com.eatvioapp.app;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
PROVISIONING_PROFILE_SPECIFIER = "match AppStore com.eatvioapp.app 1747050044";
|
PROVISIONING_PROFILE_SPECIFIER = "match AppStore com.eatvioapp.app 1747050044";
|
||||||
|
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
|
||||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
VERSIONING_SYSTEM = "apple-generic";
|
VERSIONING_SYSTEM = "apple-generic";
|
||||||
@@ -560,6 +561,7 @@
|
|||||||
PRODUCT_BUNDLE_IDENTIFIER = com.eatvioapp.app;
|
PRODUCT_BUNDLE_IDENTIFIER = com.eatvioapp.app;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
PROVISIONING_PROFILE_SPECIFIER = "match AppStore com.eatvioapp.app 1747050044";
|
PROVISIONING_PROFILE_SPECIFIER = "match AppStore com.eatvioapp.app 1747050044";
|
||||||
|
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
|
||||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
@@ -598,6 +600,7 @@
|
|||||||
PRODUCT_BUNDLE_IDENTIFIER = com.eatvioapp.app;
|
PRODUCT_BUNDLE_IDENTIFIER = com.eatvioapp.app;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
PROVISIONING_PROFILE_SPECIFIER = "match AppStore com.eatvioapp.app 1747050044";
|
PROVISIONING_PROFILE_SPECIFIER = "match AppStore com.eatvioapp.app 1747050044";
|
||||||
|
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
|
||||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
VERSIONING_SYSTEM = "apple-generic";
|
VERSIONING_SYSTEM = "apple-generic";
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ class AppRouter {
|
|||||||
navigatorKey: navigatorKey,
|
navigatorKey: navigatorKey,
|
||||||
redirect: (context, state) {
|
redirect: (context, state) {
|
||||||
final segments = state.uri.pathSegments;
|
final segments = state.uri.pathSegments;
|
||||||
if (segments.length >= 3) {
|
if (segments.length == 3) {
|
||||||
final type = segments[1];
|
final type = segments[1];
|
||||||
final contentIdentifier = segments[2];
|
final contentIdentifier = segments[2];
|
||||||
|
|
||||||
@@ -101,6 +101,17 @@ class AppRouter {
|
|||||||
case 'diet':
|
case 'diet':
|
||||||
FlutterNativeSplash.remove();
|
FlutterNativeSplash.remove();
|
||||||
return '/about-diet-screen?slug=$contentIdentifier';
|
return '/about-diet-screen?slug=$contentIdentifier';
|
||||||
|
case 'chat':
|
||||||
|
FlutterNativeSplash.remove();
|
||||||
|
return '/chat-screen';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (segments.length == 2) {
|
||||||
|
final type = segments[1];
|
||||||
|
switch (type) {
|
||||||
|
case 'chat':
|
||||||
|
FlutterNativeSplash.remove();
|
||||||
|
return '/chat-screen';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,7 +290,7 @@ class AppRouter {
|
|||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/profile-screen',
|
path: '/profile-screen',
|
||||||
name: 'profileScreen',
|
name: 'profileScreen',
|
||||||
builder: (context, state) => ProfileScreen(author: state.extra as Author),
|
builder: (context, state) => ProfileScreen(slug: state.extra as String),
|
||||||
),
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/subs-screen/:slug',
|
path: '/subs-screen/:slug',
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import 'package:eatvio_app/core/env_config.dart';
|
import 'package:eatvio_app/core/env_config.dart';
|
||||||
|
|
||||||
String baseUrl = EnvConfig.baseUrl;
|
String baseUrl = EnvConfig.devBaseUrl;
|
||||||
bool hidePlans = const bool.fromEnvironment('HIDE_PLANS', defaultValue: false);
|
bool hidePlans = const bool.fromEnvironment('HIDE_PLANS', defaultValue: false);
|
||||||
const buildDate = String.fromEnvironment('BUILD_DATE', defaultValue: '');
|
const buildDate = String.fromEnvironment('BUILD_DATE', defaultValue: '');
|
||||||
|
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ class _BlogPostScreenState extends State<BlogPostScreen> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => GoRouter.of(context).pushNamed('profileScreen', extra: blogPostState.blogPostModel?.author),
|
onTap: () => GoRouter.of(context).pushNamed('profileScreen', extra: blogPostState.blogPostModel?.author.authorSlug),
|
||||||
child: Ink(
|
child: Ink(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
child: Row(
|
child: Row(
|
||||||
|
|||||||
@@ -152,12 +152,7 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
GoRouter.of(context).pushNamed(
|
GoRouter.of(context).pushNamed(
|
||||||
'profileScreen',
|
'profileScreen',
|
||||||
extra: Author(
|
extra: state.chatRoom.users.receiver.slug,
|
||||||
authorSlug: state.chatRoom.users.receiver.slug,
|
|
||||||
authorName: state.chatRoom.users.receiver.name,
|
|
||||||
authorProfileIcon: state.chatRoom.users.receiver.profilePhotoUrl ?? '',
|
|
||||||
authorIsMe: false,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: Row(
|
child: Row(
|
||||||
|
|||||||
@@ -42,12 +42,7 @@ class _EmptyChatScreenState extends State<EmptyChatScreen> {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
GoRouter.of(context).pushNamed(
|
GoRouter.of(context).pushNamed(
|
||||||
'profileScreen',
|
'profileScreen',
|
||||||
extra: Author(
|
extra: widget.author.authorSlug,
|
||||||
authorSlug: widget.author.authorSlug,
|
|
||||||
authorName: widget.author.authorName,
|
|
||||||
authorProfileIcon: widget.author.authorProfileIcon,
|
|
||||||
authorIsMe: false,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: Row(
|
child: Row(
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class AuthorCard extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
GoRouter.of(context).pushNamed('profileScreen', extra: author);
|
GoRouter.of(context).pushNamed('profileScreen', extra: author.authorSlug);
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
width: MediaQuery.sizeOf(context).width,
|
width: MediaQuery.sizeOf(context).width,
|
||||||
|
|||||||
@@ -65,14 +65,7 @@ class _BlogPostWidgetState extends State<BlogPostWidget> {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
GoRouter.of(context).pushNamed(
|
GoRouter.of(context).pushNamed(
|
||||||
'profileScreen',
|
'profileScreen',
|
||||||
extra: Author(
|
extra: state.feedBlogPostList[widget.index].author.authorSlug,
|
||||||
authorSlug: state.feedBlogPostList[widget.index].author.authorSlug,
|
|
||||||
authorName: state.feedBlogPostList[widget.index].author.authorName,
|
|
||||||
authorProfileIcon: state.feedBlogPostList[widget.index].author.authorProfileIcon.contains('https')
|
|
||||||
? state.feedBlogPostList[widget.index].author.authorProfileIcon
|
|
||||||
: baseUrl + state.feedBlogPostList[widget.index].author.authorProfileIcon,
|
|
||||||
authorIsMe: state.feedBlogPostList[widget.index].author.authorIsMe,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: CircleAvatar(
|
child: CircleAvatar(
|
||||||
|
|||||||
@@ -108,12 +108,7 @@ class _CommentsWidgetState extends State<CommentsWidget> {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
GoRouter.of(context).pushNamed(
|
GoRouter.of(context).pushNamed(
|
||||||
'profileScreen',
|
'profileScreen',
|
||||||
extra: Author(
|
extra: comment.authorSlug,
|
||||||
authorSlug: comment.authorSlug,
|
|
||||||
authorName: comment.authorName,
|
|
||||||
authorProfileIcon: comment.authorProfileIcon.contains('https') ? comment.authorProfileIcon : baseUrl + comment.authorProfileIcon,
|
|
||||||
authorIsMe: isMe,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: CircleAvatar(
|
child: CircleAvatar(
|
||||||
|
|||||||
@@ -25,12 +25,7 @@ class ConsultantWidget extends StatelessWidget {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
GoRouter.of(context).pushNamed(
|
GoRouter.of(context).pushNamed(
|
||||||
'profileScreen',
|
'profileScreen',
|
||||||
extra: Author(
|
extra: consultant.slug,
|
||||||
authorSlug: consultant.slug,
|
|
||||||
authorName: consultant.name,
|
|
||||||
authorProfileIcon: consultant.photo,
|
|
||||||
authorIsMe: (sl<ProfileAvatarCubit>().state as ProfileAvatarStateLoaded).profile.slug == consultant.slug ? true : false,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius: BorderRadius.circular(20),
|
||||||
|
|||||||
@@ -169,12 +169,7 @@ class _PlanWidgetState extends State<PlanWidget> {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
GoRouter.of(context).pushNamed(
|
GoRouter.of(context).pushNamed(
|
||||||
'profileScreen',
|
'profileScreen',
|
||||||
extra: Author(
|
extra: widget.plan.author.authorSlug,
|
||||||
authorSlug: widget.plan.author.authorSlug,
|
|
||||||
authorName: widget.plan.author.authorName,
|
|
||||||
authorProfileIcon: widget.plan.author.authorProfileIcon,
|
|
||||||
authorIsMe: widget.plan.author.authorIsMe,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
|
|||||||
@@ -20,13 +20,7 @@ class _BlockedUserWidgetState extends State<BlockedUserWidget> {
|
|||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () => GoRouter.of(context).pushNamed(
|
onTap: () => GoRouter.of(context).pushNamed(
|
||||||
'profileScreen',
|
'profileScreen',
|
||||||
extra: Author(
|
extra: widget.profile.slug,
|
||||||
authorSlug: widget.profile.slug,
|
|
||||||
authorName: widget.profile.name,
|
|
||||||
authorProfileIcon: widget.profile.profilePhotoUrl,
|
|
||||||
authorIsMe: false,
|
|
||||||
isEntitySubscribedByMe: false,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
child: Ink(
|
child: Ink(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||||
|
|||||||
@@ -16,21 +16,18 @@ class ProfileCubit extends Cubit<ProfileState> {
|
|||||||
final ProfileRepository profileRepository;
|
final ProfileRepository profileRepository;
|
||||||
final ChatRepository chatRepository;
|
final ChatRepository chatRepository;
|
||||||
final ConsultantRepository consultantRepository;
|
final ConsultantRepository consultantRepository;
|
||||||
String _currentPeriod = '1';
|
String _currentPeriod = '1';
|
||||||
|
ProfileCubit({required this.profileRepository, required this.chatRepository, required this.consultantRepository}) : super(const ProfileState.loading());
|
||||||
ProfileCubit({
|
|
||||||
required this.profileRepository,
|
|
||||||
required this.chatRepository,
|
|
||||||
required this.consultantRepository,
|
|
||||||
}) : super(const ProfileState.loading());
|
|
||||||
|
|
||||||
Future<void> getProfileBySlug(String slug) async {
|
Future<void> getProfileBySlug(String slug) async {
|
||||||
emit(const ProfileState.loading());
|
emit(const ProfileState.loading());
|
||||||
try {
|
try {
|
||||||
final profile = await profileRepository.getProfileBySlug(slug);
|
final profile = await profileRepository.getProfileBySlug(slug);
|
||||||
|
final myProfile = await profileRepository.getMyProfile();
|
||||||
emit(
|
emit(
|
||||||
ProfileState.loaded(
|
ProfileState.loaded(
|
||||||
profile: profile,
|
profile: profile,
|
||||||
|
isMyProfile: myProfile.slug == profile.slug,
|
||||||
profileDetails: await profileRepository.getProfileDetailsBySlug(slug),
|
profileDetails: await profileRepository.getProfileDetailsBySlug(slug),
|
||||||
blogPosts: await profileRepository.getBlogPostsByAuthorSlug(slug: slug),
|
blogPosts: await profileRepository.getBlogPostsByAuthorSlug(slug: slug),
|
||||||
consultantInfo: profile.roles.contains('consultant') ? await consultantRepository.getConsultantRequestStatus(slug) : null,
|
consultantInfo: profile.roles.contains('consultant') ? await consultantRepository.getConsultantRequestStatus(slug) : null,
|
||||||
@@ -42,9 +39,8 @@ class ProfileCubit extends Cubit<ProfileState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getMyProfile({
|
|
||||||
String period = '1',
|
Future<void> getMyProfile({String period = '1'}) async {
|
||||||
}) async {
|
|
||||||
emit(const ProfileState.loading());
|
emit(const ProfileState.loading());
|
||||||
_currentPeriod = period;
|
_currentPeriod = period;
|
||||||
try {
|
try {
|
||||||
@@ -52,6 +48,7 @@ class ProfileCubit extends Cubit<ProfileState> {
|
|||||||
emit(
|
emit(
|
||||||
ProfileState.loaded(
|
ProfileState.loaded(
|
||||||
profile: profile,
|
profile: profile,
|
||||||
|
isMyProfile: true,
|
||||||
profileDetails: await profileRepository.getMyProfileDetails(),
|
profileDetails: await profileRepository.getMyProfileDetails(),
|
||||||
blogPosts: await profileRepository.getBlogPostsByAuthorSlug(slug: profile.slug),
|
blogPosts: await profileRepository.getBlogPostsByAuthorSlug(slug: profile.slug),
|
||||||
weightPoints: await profileRepository.getWeight(period: period),
|
weightPoints: await profileRepository.getWeight(period: period),
|
||||||
@@ -77,15 +74,12 @@ class ProfileCubit extends Cubit<ProfileState> {
|
|||||||
profile: (state as ProfileStateLoaded).profile,
|
profile: (state as ProfileStateLoaded).profile,
|
||||||
profileDetails: (state as ProfileStateLoaded).profileDetails,
|
profileDetails: (state as ProfileStateLoaded).profileDetails,
|
||||||
blogPosts: feedBlogPostList,
|
blogPosts: feedBlogPostList,
|
||||||
|
isMyProfile: (state as ProfileStateLoaded).isMyProfile,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> addCircumference({
|
Future<void> addCircumference({required int chestCircumference, required int waistCircumference, required int hipCircumference}) async {
|
||||||
required int chestCircumference,
|
|
||||||
required int waistCircumference,
|
|
||||||
required int hipCircumference,
|
|
||||||
}) async {
|
|
||||||
try {
|
try {
|
||||||
await profileRepository.addCircumference(
|
await profileRepository.addCircumference(
|
||||||
chestCircumference: chestCircumference,
|
chestCircumference: chestCircumference,
|
||||||
@@ -98,9 +92,7 @@ class ProfileCubit extends Cubit<ProfileState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> addWeight({
|
Future<void> addWeight({required double weight}) async {
|
||||||
required double weight,
|
|
||||||
}) async {
|
|
||||||
try {
|
try {
|
||||||
await profileRepository.addWeight(weight: weight);
|
await profileRepository.addWeight(weight: weight);
|
||||||
await getMyProfile(period: _currentPeriod);
|
await getMyProfile(period: _currentPeriod);
|
||||||
@@ -109,25 +101,15 @@ class ProfileCubit extends Cubit<ProfileState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String?> getChatRoomIdBySlug({
|
Future<String?> getChatRoomIdBySlug({required String slug}) async {
|
||||||
required Author author,
|
|
||||||
}) async {
|
|
||||||
try {
|
try {
|
||||||
final chatIdOrError = await chatRepository.getChatByUserSlug(author.authorSlug);
|
final chatIdOrError = await chatRepository.getChatByUserSlug(slug);
|
||||||
if (chatIdOrError == '404') {
|
if (chatIdOrError == '404') {
|
||||||
AppRouter.navigatorKey.currentContext?.pushNamed(
|
AppRouter.navigatorKey.currentContext?.pushNamed('emptyChatScreen', extra: author);
|
||||||
'emptyChatScreen',
|
|
||||||
extra: author,
|
|
||||||
);
|
|
||||||
} else if (chatIdOrError == 'error') {
|
} else if (chatIdOrError == 'error') {
|
||||||
showErrorToast('Ошибка создания чата');
|
showErrorToast('Ошибка создания чата');
|
||||||
} else {
|
} else {
|
||||||
AppRouter.navigatorKey.currentContext?.pushNamed(
|
AppRouter.navigatorKey.currentContext?.pushNamed('chatScreen', extra: {'uuid': chatIdOrError});
|
||||||
'chatScreen',
|
|
||||||
extra: {
|
|
||||||
'uuid': chatIdOrError,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
return chatIdOrError;
|
return chatIdOrError;
|
||||||
}
|
}
|
||||||
} catch (e, st) {
|
} catch (e, st) {
|
||||||
|
|||||||
@@ -14,9 +14,10 @@ abstract class ProfileState with _$ProfileState {
|
|||||||
const factory ProfileState.loading() = ProfileStateLoading;
|
const factory ProfileState.loading() = ProfileStateLoading;
|
||||||
|
|
||||||
const factory ProfileState.loaded({
|
const factory ProfileState.loaded({
|
||||||
required ProfileModel profile,
|
required ProfileModel profile,
|
||||||
required ProfileDetailsModel profileDetails,
|
required ProfileDetailsModel profileDetails,
|
||||||
required List<FeedBlogPostModel> blogPosts,
|
required List<FeedBlogPostModel> blogPosts,
|
||||||
|
required bool isMyProfile,
|
||||||
List<WeightModel>? weightPoints,
|
List<WeightModel>? weightPoints,
|
||||||
List<CircumferenceModel>? circumferencePoints,
|
List<CircumferenceModel>? circumferencePoints,
|
||||||
ConsultationRequestModel? consultantInfo,
|
ConsultationRequestModel? consultantInfo,
|
||||||
|
|||||||
@@ -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/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/chat/presentation/pages/photo_view_screen.dart';
|
||||||
import 'package:eatvio_app/features/complaining/presentation/complaining_bottom_sheet.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/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/menu/presentation/blocked_user_cubit/blocked_users_cubit.dart';
|
||||||
import 'package:eatvio_app/features/profile/models/circumference_model.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';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
class ProfileScreen extends StatefulWidget {
|
class ProfileScreen extends StatefulWidget {
|
||||||
final Author? author;
|
final String? slug;
|
||||||
|
|
||||||
const ProfileScreen({super.key, this.author});
|
const ProfileScreen({super.key, this.slug});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ProfileScreen> createState() => _ProfileScreenState();
|
State<ProfileScreen> createState() => _ProfileScreenState();
|
||||||
@@ -70,7 +69,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.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
|
@override
|
||||||
@@ -93,7 +92,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
|||||||
}
|
}
|
||||||
isFirstFetch = false;
|
isFirstFetch = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Проверяем, заблокировал ли пользователь меня
|
// Проверяем, заблокировал ли пользователь меня
|
||||||
if (state.profile.isBlockedByUser) {
|
if (state.profile.isBlockedByUser) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@@ -104,20 +103,12 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Icon(
|
Icon(Icons.block, size: 64, color: Colors.grey[400]),
|
||||||
Icons.block,
|
|
||||||
size: 64,
|
|
||||||
color: Colors.grey[400],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Text(
|
Text(
|
||||||
'Пользователь ограничил доступ к своей странице',
|
'Пользователь ограничил доступ к своей странице',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(
|
style: TextStyle(fontSize: 18, fontWeight: FontWeight.w500, color: Colors.grey[600]),
|
||||||
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) {
|
} else if (state is ProfileStateError) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(),
|
appBar: AppBar(),
|
||||||
body: DataErrorWidget(
|
body: DataErrorWidget(
|
||||||
onReload: () async {
|
onReload: () async {
|
||||||
widget.author == null || widget.author!.authorIsMe
|
widget.slug == null ? await profileCubit.getMyProfile() : await profileCubit.getProfileBySlug(widget.slug!);
|
||||||
? await profileCubit.getMyProfile()
|
|
||||||
: await profileCubit.getProfileBySlug(widget.author!.authorSlug);
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -221,7 +210,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
|||||||
Scaffold _myProfileScreen(ProfileStateLoaded state) {
|
Scaffold _myProfileScreen(ProfileStateLoaded state) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Colors.grey.shade200,
|
backgroundColor: Colors.grey.shade200,
|
||||||
appBar: AppBar(toolbarHeight: widget.author == null ? 0 : null),
|
appBar: AppBar(toolbarHeight: widget.slug == null ? 0 : null),
|
||||||
body: SingleChildScrollView(
|
body: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@@ -415,7 +404,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
|||||||
GoRouter.of(context).pushNamed('stepperBecomeConsultantScreen', extra: state.profile.slug);
|
GoRouter.of(context).pushNamed('stepperBecomeConsultantScreen', extra: state.profile.slug);
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
widget.author == null || widget.author!.authorIsMe ? 'Редактировать' : '',
|
state.isMyProfile ? 'Редактировать' : '',
|
||||||
style: const TextStyle(color: Color(0xFF2F80ED), fontSize: 16, fontWeight: FontWeight.w500),
|
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);
|
GoRouter.of(context).pushNamed('stepperBecomeConsultantScreen', extra: state.profile.slug);
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
widget.author == null || widget.author!.authorIsMe ? 'Редактировать' : '',
|
state.isMyProfile ? 'Редактировать' : '',
|
||||||
style: const TextStyle(color: Color(0xFF2F80ED), fontSize: 16, fontWeight: FontWeight.w500),
|
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));
|
context.pushTransparentRoute(rootNavigator: true, PhotoViewScreen(imageUrls: [baseUrl + state.profile.profilePhotoUrl], index: 0));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
if (widget.author == null || widget.author!.authorIsMe) ...[
|
if (state.isMyProfile) ...[
|
||||||
_buildDivider(),
|
_buildDivider(),
|
||||||
_buildCompactItem(
|
_buildCompactItem(
|
||||||
icon: 'assets/icons/edit_paint.svg',
|
icon: 'assets/icons/edit_paint.svg',
|
||||||
@@ -964,7 +953,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
if (widget.author != null) ...[
|
if (!state.isMyProfile ) ...[
|
||||||
_buildDivider(),
|
_buildDivider(),
|
||||||
_buildCompactItem(
|
_buildCompactItem(
|
||||||
icon: 'assets/icons/complain.svg',
|
icon: 'assets/icons/complain.svg',
|
||||||
@@ -973,12 +962,12 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
|||||||
showModalBottomSheet(
|
showModalBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
isScrollControlled: true,
|
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(),
|
_buildDivider(),
|
||||||
_buildCompactItem(
|
_buildCompactItem(
|
||||||
icon: 'assets/icons/complain.svg',
|
icon: 'assets/icons/complain.svg',
|
||||||
@@ -986,7 +975,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
isFirstFetch = true;
|
isFirstFetch = true;
|
||||||
sl<BlockedUsersCubit>().blockUser(state.profile.slug);
|
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')) {
|
if (state.profile.roles.contains('consultant')) {
|
||||||
plansCubit.getPlans(state.profile.slug);
|
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(),
|
_buildDivider(),
|
||||||
_buildCompactItem(
|
_buildCompactItem(
|
||||||
icon: 'assets/icons/complain.svg',
|
icon: 'assets/icons/complain.svg',
|
||||||
@@ -1002,7 +991,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
isFirstFetch = true;
|
isFirstFetch = true;
|
||||||
sl<BlockedUsersCubit>().unblockUser(state.profile.slug);
|
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')) {
|
if (state.profile.roles.contains('consultant')) {
|
||||||
plansCubit.getPlans(state.profile.slug);
|
plansCubit.getPlans(state.profile.slug);
|
||||||
}
|
}
|
||||||
@@ -1065,7 +1054,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
|||||||
children: [
|
children: [
|
||||||
const SizedBox(width: 16),
|
const SizedBox(width: 16),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () async => await profileCubit.getChatRoomIdBySlug(author: widget.author!),
|
onTap: () async => await profileCubit.getChatRoomIdBySlug(slug: widget.slug!),
|
||||||
child: Container(
|
child: Container(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
padding: const EdgeInsets.all(8),
|
padding: const EdgeInsets.all(8),
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import 'package:eatvio_app/core/const.dart';
|
import 'package:eatvio_app/core/const.dart';
|
||||||
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
|
|
||||||
import 'package:eatvio_app/features/profile/models/sub_model.dart';
|
import 'package:eatvio_app/features/profile/models/sub_model.dart';
|
||||||
import 'package:eatvio_app/features/profile/presentation/widgets/sub_action_button_widget.dart';
|
import 'package:eatvio_app/features/profile/presentation/widgets/sub_action_button_widget.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@@ -23,13 +22,7 @@ class _SubWidgetState extends State<SubWidget> {
|
|||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () => GoRouter.of(context).pushNamed(
|
onTap: () => GoRouter.of(context).pushNamed(
|
||||||
'profileScreen',
|
'profileScreen',
|
||||||
extra: Author(
|
extra: widget.subModel.slug,
|
||||||
authorSlug: widget.subModel.slug,
|
|
||||||
authorName: widget.subModel.name,
|
|
||||||
authorProfileIcon: widget.subModel.profilePhotoUrl,
|
|
||||||
authorIsMe: false,
|
|
||||||
isEntitySubscribedByMe: false,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
child: Ink(
|
child: Ink(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||||
|
|||||||
Reference in New Issue
Block a user