forked from eatvio/eatvio_app
merged main into deepLinks
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
import 'dart:developer';
|
||||
import 'dart:io';
|
||||
import 'package:eatvio_app/core/app_router.dart';
|
||||
import 'package:eatvio_app/core/image_compressing/image_compress_utility.dart';
|
||||
import 'package:eatvio_app/core/utils/toasts.dart';
|
||||
import 'package:eatvio_app/features/chat/repositories/chat_repository.dart';
|
||||
import 'package:eatvio_app/features/consultant/become_consultant/repositories/consultant_repository.dart';
|
||||
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
|
||||
import 'package:eatvio_app/features/feed/models/feed_blog_post_model.dart';
|
||||
import 'package:eatvio_app/features/profile/presentation/bloc/profile_cubit/profile_state.dart';
|
||||
import 'package:eatvio_app/features/profile/repositories/profile_repository.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
class ProfileCubit extends Cubit<ProfileState> {
|
||||
final ProfileRepository profileRepository;
|
||||
@@ -103,11 +107,26 @@ class ProfileCubit extends Cubit<ProfileState> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> getChatRoomIdBySlug({
|
||||
required String slug,
|
||||
getChatRoomIdBySlug({
|
||||
required Author author,
|
||||
}) async {
|
||||
try {
|
||||
return (await chatRepository.getChatRoomIdByUserSlug(slug: slug)).id;
|
||||
final chatIdOrError = await chatRepository.getChatByUserSlug(author.authorSlug);
|
||||
if (chatIdOrError == '404') {
|
||||
AppRouter.navigatorKey.currentContext?.pushNamed(
|
||||
'emptyChatScreen',
|
||||
extra: author,
|
||||
);
|
||||
} else if (chatIdOrError == 'error') {
|
||||
showErrorToast('Ошибка создания чата');
|
||||
} else {
|
||||
AppRouter.navigatorKey.currentContext?.pushNamed(
|
||||
'chatScreen',
|
||||
extra: {
|
||||
'chatId': chatIdOrError,
|
||||
},
|
||||
);
|
||||
}
|
||||
} catch (e, st) {
|
||||
log(e.toString(), stackTrace: st);
|
||||
return '';
|
||||
|
||||
@@ -1085,7 +1085,9 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
tag: state.profile.profilePhotoUrl,
|
||||
child: CircleAvatar(
|
||||
radius: 32,
|
||||
foregroundImage: NetworkImage(baseUrl + state.profile.profilePhotoUrl),
|
||||
foregroundImage: NetworkImage(
|
||||
state.profile.profilePhotoUrl.contains('https') ? state.profile.profilePhotoUrl : baseUrl + state.profile.profilePhotoUrl,
|
||||
),
|
||||
backgroundImage: const AssetImage('assets/images/no_avatar.png'),
|
||||
),
|
||||
),
|
||||
@@ -1230,14 +1232,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
children: [
|
||||
const SizedBox(width: 16),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
GoRouter.of(context).pushNamed(
|
||||
'chatScreen',
|
||||
extra: {
|
||||
'chatId': await profileCubit.getChatRoomIdBySlug(slug: widget.author!.authorSlug),
|
||||
},
|
||||
);
|
||||
},
|
||||
onTap: () async => await profileCubit.getChatRoomIdBySlug(author: widget.author!),
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
padding: const EdgeInsets.all(8),
|
||||
|
||||
@@ -67,7 +67,9 @@ class _ProfileBlogPostWidgetState extends State<ProfileBlogPostWidget> {
|
||||
radius: 20,
|
||||
backgroundColor: Colors.black12,
|
||||
foregroundImage: NetworkImage(
|
||||
baseUrl + state.blogPosts[widget.index].author.authorProfileIcon,
|
||||
state.blogPosts[widget.index].author.authorProfileIcon.contains('https')
|
||||
? state.blogPosts[widget.index].author.authorProfileIcon
|
||||
: baseUrl + state.blogPosts[widget.index].author.authorProfileIcon,
|
||||
),
|
||||
backgroundImage: const AssetImage('assets/images/no_avatar.png'),
|
||||
),
|
||||
@@ -119,8 +121,7 @@ class _ProfileBlogPostWidgetState extends State<ProfileBlogPostWidget> {
|
||||
),
|
||||
],
|
||||
if (state.blogPosts[widget.index].title.isEmpty) const SizedBox(height: 8),
|
||||
if (state.blogPosts[widget.index].title.isNotEmpty && state.blogPosts[widget.index].description.isNotEmpty)
|
||||
const SizedBox(height: 8),
|
||||
if (state.blogPosts[widget.index].title.isNotEmpty && state.blogPosts[widget.index].description.isNotEmpty) const SizedBox(height: 8),
|
||||
if (state.blogPosts[widget.index].description.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:eatvio_app/core/locator_service.dart';
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
|
||||
import 'package:eatvio_app/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart';
|
||||
import 'package:eatvio_app/features/profile/presentation/bloc/sub_cubit/sub_cubit.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -11,11 +12,15 @@ enum SubActionType { sendMessage, subscribe }
|
||||
class SubActionButtonWidget extends StatefulWidget {
|
||||
final SubActionType subActionType;
|
||||
final String slug;
|
||||
final String name;
|
||||
final String porfileIcon;
|
||||
|
||||
const SubActionButtonWidget({
|
||||
super.key,
|
||||
required this.subActionType,
|
||||
required this.slug,
|
||||
required this.name,
|
||||
required this.porfileIcon,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -64,7 +69,14 @@ class _SubActionButtonWidgetState extends State<SubActionButtonWidget> {
|
||||
GoRouter.of(context).pushNamed(
|
||||
'chatScreen',
|
||||
extra: {
|
||||
'chatId': await sl<ProfileCubit>().getChatRoomIdBySlug(slug: widget.slug),
|
||||
'chatId': await sl<ProfileCubit>().getChatRoomIdBySlug(
|
||||
author: Author(
|
||||
authorSlug: widget.slug,
|
||||
authorName: widget.name,
|
||||
authorProfileIcon: widget.porfileIcon,
|
||||
authorIsMe: false,
|
||||
),
|
||||
),
|
||||
},
|
||||
);
|
||||
},
|
||||
|
||||
@@ -70,6 +70,8 @@ class _SubWidgetState extends State<SubWidget> {
|
||||
SubActionButtonWidget(
|
||||
subActionType: widget.subModel.isEntitySubscribedByMe ? SubActionType.sendMessage : SubActionType.subscribe,
|
||||
slug: widget.subModel.slug,
|
||||
name: widget.subModel.name,
|
||||
porfileIcon: widget.subModel.profilePhotoUrl,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user