forked from eatvio/eatvio_app
updated error handling, consultant rating layout and complaining logic
This commit is contained in:
@@ -17,7 +17,7 @@ class ProfileCubit extends Cubit<ProfileState> {
|
||||
required this.chatRepository,
|
||||
}) : super(const ProfileState.loading());
|
||||
|
||||
getProfileBySlug(String slug) async {
|
||||
Future<void> getProfileBySlug(String slug) async {
|
||||
try {
|
||||
emit(
|
||||
ProfileState.loaded(
|
||||
@@ -31,7 +31,7 @@ class ProfileCubit extends Cubit<ProfileState> {
|
||||
}
|
||||
}
|
||||
|
||||
getMyProfile({
|
||||
Future<void> getMyProfile({
|
||||
String period = '1',
|
||||
}) async {
|
||||
_currentPeriod = period;
|
||||
|
||||
@@ -3,10 +3,13 @@ import 'dart:io';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:dismissible_page/dismissible_page.dart';
|
||||
import 'package:eatvio_app/core/const.dart';
|
||||
import 'package:eatvio_app/core/enums/complained_content.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';
|
||||
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/profile/models/circumference_model.dart';
|
||||
@@ -88,14 +91,10 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
}
|
||||
return widget.author == null ? _myProfileScreen(state) : _profileScreen(state);
|
||||
} else if (state is ProfileStateError) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(),
|
||||
body: Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Text(state.errorMessage),
|
||||
),
|
||||
),
|
||||
return DataErrorWidget(
|
||||
onReload: () async {
|
||||
widget.author == null ? await profileCubit.getMyProfile() : await profileCubit.getProfileBySlug(widget.author!.authorSlug);
|
||||
},
|
||||
);
|
||||
} else {
|
||||
return Scaffold(
|
||||
@@ -578,7 +577,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
() {
|
||||
launchUrl(
|
||||
Uri.parse(
|
||||
state.profile.educationResource?.vkLink ?? '',
|
||||
state.profile.educationResource?.vkLink ?? '',
|
||||
),
|
||||
mode: LaunchMode.externalApplication,
|
||||
);
|
||||
@@ -1011,19 +1010,34 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
const Spacer(),
|
||||
PopupMenuButton(
|
||||
onSelected: (value) {
|
||||
final box = context.findRenderObject() as RenderBox?;
|
||||
Share.shareUri(
|
||||
Uri.parse(
|
||||
baseUrl + '/ru/profile/' + state.profile.slug,
|
||||
),
|
||||
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
|
||||
);
|
||||
if (value == 'share') {
|
||||
final box = context.findRenderObject() as RenderBox?;
|
||||
Share.shareUri(
|
||||
Uri.parse(
|
||||
baseUrl + '/ru/profile/' + state.profile.slug,
|
||||
),
|
||||
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
|
||||
);
|
||||
} else {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (context) => ComplainingBottomSheet(
|
||||
complainedContentType: ComplainedContent.profile,
|
||||
slug: widget.author?.authorSlug,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
itemBuilder: (context) => [
|
||||
PopupMenuItem(
|
||||
value: 'share',
|
||||
child: Text('Поделиться'),
|
||||
),
|
||||
if (widget.author != null)
|
||||
PopupMenuItem(
|
||||
value: 'complain',
|
||||
child: Text('Пожаловаться'),
|
||||
),
|
||||
],
|
||||
child: Icon(Icons.more_horiz_rounded),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user