forked from eatvio/eatvio_app
Merge remote-tracking branch 'upstream/main' into issue-701
This commit is contained in:
@@ -18,11 +18,7 @@ class ProfileCubit extends Cubit<ProfileState> {
|
||||
final ConsultantRepository consultantRepository;
|
||||
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 {
|
||||
emit(const ProfileState.loading());
|
||||
@@ -42,9 +38,7 @@ class ProfileCubit extends Cubit<ProfileState> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> getMyProfile({
|
||||
String period = '1',
|
||||
}) async {
|
||||
Future<void> getMyProfile({String period = '1'}) async {
|
||||
emit(const ProfileState.loading());
|
||||
_currentPeriod = period;
|
||||
try {
|
||||
@@ -77,15 +71,14 @@ class ProfileCubit extends Cubit<ProfileState> {
|
||||
profile: (state as ProfileStateLoaded).profile,
|
||||
profileDetails: (state as ProfileStateLoaded).profileDetails,
|
||||
blogPosts: feedBlogPostList,
|
||||
weightPoints: (state as ProfileStateLoaded).weightPoints,
|
||||
circumferencePoints: (state as ProfileStateLoaded).circumferencePoints,
|
||||
consultantInfo: (state as ProfileStateLoaded).consultantInfo,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> addCircumference({
|
||||
required int chestCircumference,
|
||||
required int waistCircumference,
|
||||
required int hipCircumference,
|
||||
}) async {
|
||||
Future<void> addCircumference({required int chestCircumference, required int waistCircumference, required int hipCircumference}) async {
|
||||
try {
|
||||
await profileRepository.addCircumference(
|
||||
chestCircumference: chestCircumference,
|
||||
@@ -98,9 +91,7 @@ class ProfileCubit extends Cubit<ProfileState> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> addWeight({
|
||||
required double weight,
|
||||
}) async {
|
||||
Future<void> addWeight({required double weight}) async {
|
||||
try {
|
||||
await profileRepository.addWeight(weight: weight);
|
||||
await getMyProfile(period: _currentPeriod);
|
||||
@@ -109,25 +100,15 @@ class ProfileCubit extends Cubit<ProfileState> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<String?> getChatRoomIdBySlug({
|
||||
required Author author,
|
||||
}) async {
|
||||
Future<String?> getChatRoomIdBySlug({required Author author}) async {
|
||||
try {
|
||||
final chatIdOrError = await chatRepository.getChatByUserSlug(author.authorSlug);
|
||||
if (chatIdOrError == '404') {
|
||||
AppRouter.navigatorKey.currentContext?.pushNamed(
|
||||
'emptyChatScreen',
|
||||
extra: author,
|
||||
);
|
||||
AppRouter.navigatorKey.currentContext?.pushNamed('emptyChatScreen', extra: author);
|
||||
} else if (chatIdOrError == 'error') {
|
||||
showErrorToast('Ошибка создания чата');
|
||||
} else {
|
||||
AppRouter.navigatorKey.currentContext?.pushNamed(
|
||||
'chatScreen',
|
||||
extra: {
|
||||
'uuid': chatIdOrError,
|
||||
},
|
||||
);
|
||||
AppRouter.navigatorKey.currentContext?.pushNamed('chatScreen', extra: {'uuid': chatIdOrError});
|
||||
return chatIdOrError;
|
||||
}
|
||||
} catch (e, st) {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:dismissible_page/dismissible_page.dart';
|
||||
import 'package:eatvio_app/core/app_router.dart';
|
||||
import 'package:eatvio_app/core/const.dart';
|
||||
import 'package:eatvio_app/core/enums/complained_content.dart';
|
||||
import 'package:eatvio_app/core/permission_handler/permission_handler.dart';
|
||||
import 'package:eatvio_app/core/theme/custom_text_style.dart';
|
||||
import 'package:eatvio_app/core/utils/date_time_utils.dart';
|
||||
import 'package:eatvio_app/core/widgets/data_error_widget.dart';
|
||||
import 'package:eatvio_app/core/widgets/loader.dart';
|
||||
@@ -200,11 +200,34 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
),
|
||||
_subscriptionsAndSubscribers(state),
|
||||
if (state.profile.badges.isNotEmpty) Padding(padding: const EdgeInsets.only(bottom: 16), child: _badges(state)),
|
||||
if (state.profile.roles.contains('consultant') && state.consultantInfo != null && !state.profile.isBlockedByMe) _socialLinks(state),
|
||||
if (state.profile.roles.contains('consultant') && state.consultantInfo != null && !state.profile.isBlockedByMe) _education(state),
|
||||
if (state.profile.roles.contains('consultant') && state.consultantInfo != null && !state.profile.isBlockedByMe) _diplomasAndCertificates(state),
|
||||
if (state.profile.roles.contains('consultant') && state.consultantInfo != null && !hidePlans && !state.profile.isBlockedByMe) _activePlans(state),
|
||||
if (state.blogPosts.isNotEmpty)
|
||||
if (state.profile.isBlockedByAuthor)
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.block, size: 48, color: appTheme.grey7B),
|
||||
const SizedBox(height: 16),
|
||||
Center(
|
||||
child: Text(
|
||||
'Пользователь ограничил доступ\nк своей странице',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyles.textMSemibold.copyWith(color: appTheme.grey7B),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (state.profile.roles.contains('consultant') && state.consultantInfo != null && !state.profile.isBlockedByMe && !state.profile.isBlockedByAuthor)
|
||||
_socialLinks(state),
|
||||
if (state.profile.roles.contains('consultant') && state.consultantInfo != null && !state.profile.isBlockedByMe && !state.profile.isBlockedByAuthor)
|
||||
_education(state),
|
||||
if (state.profile.roles.contains('consultant') && state.consultantInfo != null && !state.profile.isBlockedByMe && !state.profile.isBlockedByAuthor)
|
||||
_diplomasAndCertificates(state),
|
||||
if (state.profile.roles.contains('consultant') &&
|
||||
state.consultantInfo != null &&
|
||||
!hidePlans &&
|
||||
!state.profile.isBlockedByMe &&
|
||||
!state.profile.isBlockedByAuthor)
|
||||
_activePlans(state),
|
||||
if (state.blogPosts.isNotEmpty && !state.profile.isBlockedByAuthor && !state.profile.isBlockedByMe)
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(left: 8, top: 16, bottom: 8),
|
||||
child: Text(
|
||||
@@ -212,7 +235,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
style: TextStyle(color: Color(0xFF323F4B), fontSize: 24, fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
_blogPosts(state),
|
||||
if (state.blogPosts.isNotEmpty && !state.profile.isBlockedByAuthor && !state.profile.isBlockedByMe) _blogPosts(state),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user