Merge pull request 'feat(chat+qr+devtools): fix chat first message, add pick images from gallery, qrcode, devtools' (#526) from mso7nueh/eatvio_app:main into main

Reviewed-on: eatvio/eatvio_app#526
This commit is contained in:
mso7nueh
2025-06-25 09:24:28 +00:00
17 changed files with 512 additions and 101 deletions

View File

@@ -388,7 +388,7 @@
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "Apple Distribution: ITVIO, OOO (VL68C36HYS)"; CODE_SIGN_IDENTITY = "Apple Distribution: ITVIO, OOO (VL68C36HYS)";
CODE_SIGN_STYLE = Manual; CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 30; CURRENT_PROJECT_VERSION = 31;
DEVELOPMENT_TEAM = VL68C36HYS; DEVELOPMENT_TEAM = VL68C36HYS;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
@@ -538,7 +538,7 @@
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "Apple Distribution: ITVIO, OOO (VL68C36HYS)"; CODE_SIGN_IDENTITY = "Apple Distribution: ITVIO, OOO (VL68C36HYS)";
CODE_SIGN_STYLE = Manual; CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 30; CURRENT_PROJECT_VERSION = 31;
DEVELOPMENT_TEAM = VL68C36HYS; DEVELOPMENT_TEAM = VL68C36HYS;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
@@ -576,7 +576,7 @@
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "Apple Distribution: ITVIO, OOO (VL68C36HYS)"; CODE_SIGN_IDENTITY = "Apple Distribution: ITVIO, OOO (VL68C36HYS)";
CODE_SIGN_STYLE = Manual; CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 30; CURRENT_PROJECT_VERSION = 31;
DEVELOPMENT_TEAM = VL68C36HYS; DEVELOPMENT_TEAM = VL68C36HYS;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (

View File

@@ -21,7 +21,7 @@
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>30</string> <string>31</string>
<key>ITSAppUsesNonExemptEncryption</key> <key>ITSAppUsesNonExemptEncryption</key>
<false/> <false/>
<key>LSRequiresIPhoneOS</key> <key>LSRequiresIPhoneOS</key>

View File

@@ -17,6 +17,7 @@ import 'package:eatvio_app/features/bottom_navigation_bar/presentation/widgets/b
import 'package:eatvio_app/features/calendar/presentation/pages/calendar_screen.dart'; import 'package:eatvio_app/features/calendar/presentation/pages/calendar_screen.dart';
import 'package:eatvio_app/features/chat/presentation/pages/chat_screen.dart'; import 'package:eatvio_app/features/chat/presentation/pages/chat_screen.dart';
import 'package:eatvio_app/features/chat/presentation/pages/chats_screen.dart'; import 'package:eatvio_app/features/chat/presentation/pages/chats_screen.dart';
import 'package:eatvio_app/features/chat/presentation/pages/empty_chat_screen.dart';
import 'package:eatvio_app/features/chat/presentation/pages/payment_screen.dart'; import 'package:eatvio_app/features/chat/presentation/pages/payment_screen.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/consultant/become_consultant/presentation/pages/become_consultant_screen.dart'; import 'package:eatvio_app/features/consultant/become_consultant/presentation/pages/become_consultant_screen.dart';
@@ -173,7 +174,6 @@ class AppRouter {
name: 'welcomeScreen', name: 'welcomeScreen',
builder: (context, state) => const WelcomeScreen(), builder: (context, state) => const WelcomeScreen(),
redirect: (context, state) async { redirect: (context, state) async {
try { try {
if (await TokenStorage.haveTokenInStorage()) { if (await TokenStorage.haveTokenInStorage()) {
final firebaseApi = sl<FirebaseApi>(); final firebaseApi = sl<FirebaseApi>();
@@ -312,6 +312,11 @@ class AppRouter {
); );
}, },
), ),
GoRoute(
path: '/empty-chat-screen',
name: 'emptyChatScreen',
builder: (context, state) => EmptyChatScreen(author: state.extra as Author),
),
GoRoute( GoRoute(
path: '/settings-screen', path: '/settings-screen',
name: 'settingsScreen', name: 'settingsScreen',

View File

@@ -39,6 +39,7 @@ class WsManager {
metadata: const PusherChannelsOptionsMetadata.byDefault(), metadata: const PusherChannelsOptionsMetadata.byDefault(),
port: 443, port: 443,
); );
client = PusherChannelsClient.websocket( client = PusherChannelsClient.websocket(
options: options, options: options,
connectionErrorHandler: (exception, trace, refresh) { connectionErrorHandler: (exception, trace, refresh) {
@@ -136,7 +137,7 @@ class WsManager {
_privateDirectChatChannel?.unsubscribe(); _privateDirectChatChannel?.unsubscribe();
} }
Future<void> clear() async{ Future<void> clear() async {
await client?.disconnect(); await client?.disconnect();
client = null; client = null;
userId = null; userId = null;

View File

@@ -88,10 +88,10 @@ class _AuthScreenState extends State<AuthScreen> {
title: GestureDetector( title: GestureDetector(
onTap: () { onTap: () {
tapsCount++; tapsCount++;
if (tapsCount == 6) { if (tapsCount == 7) {
tapsCount = 0; tapsCount = 0;
GoRouter.of(context).pushNamed(DevToolsScreen.name);
} }
GoRouter.of(context).pushNamed(DevToolsScreen.name);
}, },
child: SvgPicture.asset( child: SvgPicture.asset(
ImageConstant.imgLogoEatvio, ImageConstant.imgLogoEatvio,
@@ -244,7 +244,7 @@ class _AuthScreenState extends State<AuthScreen> {
height: 48, height: 48,
width: 48, width: 48,
child: FloatingActionButton.extended( child: FloatingActionButton.extended(
heroTag: 'authButton', heroTag: 'scanQrCodeButton',
highlightElevation: 0, highlightElevation: 0,
elevation: 0, elevation: 0,
focusElevation: 0, focusElevation: 0,

View File

@@ -1,4 +1,14 @@
import 'dart:io';
import 'package:dio/dio.dart';
import 'package:eatvio_app/core/app_router.dart';
import 'package:eatvio_app/core/const.dart';
import 'package:eatvio_app/core/locator_service.dart';
import 'package:eatvio_app/core/token_storage.dart';
import 'package:eatvio_app/core/utils/toasts.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:qr_code_scanner_plus/qr_code_scanner_plus.dart';
class ScanQRCodeScreen extends StatefulWidget { class ScanQRCodeScreen extends StatefulWidget {
const ScanQRCodeScreen({super.key}); const ScanQRCodeScreen({super.key});
@@ -8,6 +18,20 @@ class ScanQRCodeScreen extends StatefulWidget {
} }
class _ScanQRCodeScreenState extends State<ScanQRCodeScreen> { class _ScanQRCodeScreenState extends State<ScanQRCodeScreen> {
final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
Barcode? result;
QRViewController? controller;
@override
void reassemble() {
super.reassemble();
if (Platform.isAndroid) {
controller!.pauseCamera();
} else if (Platform.isIOS) {
controller!.resumeCamera();
}
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@@ -15,6 +39,52 @@ class _ScanQRCodeScreenState extends State<ScanQRCodeScreen> {
title: const Text('Сканирование QR-кода'), title: const Text('Сканирование QR-кода'),
centerTitle: true, centerTitle: true,
), ),
body: Column(
children: <Widget>[
Expanded(
child: QRView(
key: qrKey,
onQRViewCreated: _onQRViewCreated,
),
),
],
),
); );
} }
void _onQRViewCreated(QRViewController controller) {
this.controller = controller;
controller.scannedDataStream.listen((scanData) async {
setState(() {
result = scanData;
});
controller.pauseCamera();
try {
final scannedUrl = scanData.code;
final uri = Uri.parse(scannedUrl ?? '');
final scannedBaseUrl = (uri.hasAuthority) ? '${uri.scheme}://${uri.host}' : '';
baseUrl = scannedBaseUrl;
sl<Dio>().options.baseUrl = baseUrl;
final response = await Dio().getUri(
uri,
options: Options(
headers: {
'accept': 'application/json',
'content-type': 'application/json',
},
),
);
final token = response.data['token'];
await TokenStorage.saveTokenInStorage(token);
AppRouter.navigatorKey.currentContext?.go(
'/feed-screen',
extra: {'needToInitializeWebSocket': false},
);
showSuccessToast('Добро пожаловать!');
} catch (e) {
controller.resumeCamera();
showErrorToast('Что-то пошло не так, попробуйте обновить страницу с qr кодом или используйте вход через логин и пароль');
}
});
}
} }

View File

@@ -1,6 +1,7 @@
import 'package:badges/badges.dart' as badges; import 'package:badges/badges.dart' as badges;
import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/core/const.dart';
import 'package:eatvio_app/core/utils/image_constant.dart'; import 'package:eatvio_app/core/utils/image_constant.dart';
import 'package:eatvio_app/features/dev_tools/presentation/dev_tools_screen.dart';
import 'package:eatvio_app/features/notifications/presentation/notifications_cubit/notifications_cubit.dart'; import 'package:eatvio_app/features/notifications/presentation/notifications_cubit/notifications_cubit.dart';
import 'package:eatvio_app/features/notifications/presentation/notifications_cubit/notifications_state.dart'; import 'package:eatvio_app/features/notifications/presentation/notifications_cubit/notifications_state.dart';
import 'package:eatvio_app/features/profile/models/profile_model.dart'; import 'package:eatvio_app/features/profile/models/profile_model.dart';
@@ -30,6 +31,7 @@ class BottomNavigationBarWidget extends StatefulWidget {
class _BottomNavigationBarWidgetState extends State<BottomNavigationBarWidget> { class _BottomNavigationBarWidgetState extends State<BottomNavigationBarWidget> {
int currentBottomNavBarIndex = 1; int currentBottomNavBarIndex = 1;
late final List<String> pages; late final List<String> pages;
int tapsCount = 0;
@override @override
void initState() { void initState() {
@@ -58,12 +60,29 @@ class _BottomNavigationBarWidgetState extends State<BottomNavigationBarWidget> {
} }
void _onItemTapped(int index) async { void _onItemTapped(int index) async {
if (pages.length == 7) {
if (index == 6) {
tapsCount++;
if (tapsCount == 7) {
tapsCount = 0;
GoRouter.of(context).pushNamed(DevToolsScreen.name);
}
}
} else {
if (index == 5) {
tapsCount++;
if (tapsCount == 7) {
tapsCount = 0;
GoRouter.of(context).pushNamed(DevToolsScreen.name);
}
}
}
if (currentBottomNavBarIndex != index) { if (currentBottomNavBarIndex != index) {
setState(() { setState(() {
currentBottomNavBarIndex = index; currentBottomNavBarIndex = index;
}); });
GoRouter.of(context).replace(pages[currentBottomNavBarIndex]);
} }
GoRouter.of(context).replace(pages[currentBottomNavBarIndex]);
} }
@override @override

View File

@@ -177,14 +177,12 @@ class ChatRoomCubit extends Cubit<ChatRoomState> {
} }
Future<bool> sendMessage({ Future<bool> sendMessage({
required String chatId,
String? data, String? data,
List<File>? files, List<File>? files,
required String userSlug, required String userSlug,
}) async { }) async {
try { try {
await chatRepository.sendMessage( await chatRepository.sendMessage(
chatId: chatId,
data: data, data: data,
files: files != null ? await ImageCompressUtility.compressFilesList(files) : null, files: files != null ? await ImageCompressUtility.compressFilesList(files) : null,
slug: userSlug, slug: userSlug,

View File

@@ -387,7 +387,6 @@ class _ChatScreenState extends State<ChatScreen> {
onTap: () { onTap: () {
if (textEditingController.text.isNotEmpty) { if (textEditingController.text.isNotEmpty) {
chatRoomCubit.sendMessage( chatRoomCubit.sendMessage(
chatId: widget.chatId,
data: textEditingController.text.trim(), data: textEditingController.text.trim(),
userSlug: state.chatRoom.users.receiver.slug, userSlug: state.chatRoom.users.receiver.slug,
); );
@@ -411,14 +410,15 @@ class _ChatScreenState extends State<ChatScreen> {
), ),
if (showAboutOrderButton) if (showAboutOrderButton)
Positioned( Positioned(
top: 8, top: 8,
right: 15, right: 15,
left: 16, left: 16,
child: AboutOrderButton( child: AboutOrderButton(
onTap: () async { onTap: () async {
GoRouter.of(context).push(InfoByOrderScreen.path, extra: {'planId': state.chatRoom.chosenPlan?.id}); GoRouter.of(context).push(InfoByOrderScreen.path, extra: {'planId': state.chatRoom.chosenPlan?.id});
}, },
)), ),
),
], ],
), ),
), ),
@@ -436,7 +436,7 @@ class _ChatScreenState extends State<ChatScreen> {
final picker = ImagePicker(); final picker = ImagePicker();
XFile? image = await picker.pickImage(source: ImageSource.camera); XFile? image = await picker.pickImage(source: ImageSource.camera);
if (image != null) { if (image != null) {
await chatRoomCubit.sendMessage(chatId: widget.chatId, files: [File(image.path)], userSlug: slug); await chatRoomCubit.sendMessage(files: [File(image.path)], userSlug: slug);
} }
}, },
child: const Row( child: const Row(
@@ -447,6 +447,24 @@ class _ChatScreenState extends State<ChatScreen> {
], ],
), ),
), ),
CupertinoActionSheetAction(
onPressed: () async {
Navigator.of(context).pop();
final picker = ImagePicker();
List<XFile> images = await picker.pickMultiImage();
if (images != []) {
List<File> files = images.map((image) => File(image.path)).toList();
await chatRoomCubit.sendMessage(files: files, userSlug: slug);
}
},
child: const Row(
children: [
Icon(Icons.photo_library_rounded),
SizedBox(width: 8),
Text('Галерея'),
],
),
),
CupertinoActionSheetAction( CupertinoActionSheetAction(
onPressed: () async { onPressed: () async {
Navigator.of(context).pop(); Navigator.of(context).pop();
@@ -476,7 +494,7 @@ class _ChatScreenState extends State<ChatScreen> {
); );
if (result != null) { if (result != null) {
List<File> files = result.paths.map((path) => File(path!)).toList(); List<File> files = result.paths.map((path) => File(path!)).toList();
await chatRoomCubit.sendMessage(chatId: widget.chatId, files: files, userSlug: slug); await chatRoomCubit.sendMessage(files: files, userSlug: slug);
} }
}, },
child: const Row( child: const Row(

View File

@@ -0,0 +1,289 @@
import 'dart:io';
import 'dart:math';
import 'package:eatvio_app/core/app_router.dart';
import 'package:eatvio_app/core/locator_service.dart';
import 'package:eatvio_app/core/theme/custom_text_style.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/features/chat/repositories/chat_repository.dart';
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:image_picker/image_picker.dart';
class EmptyChatScreen extends StatefulWidget {
final Author author;
const EmptyChatScreen({
super.key,
required this.author,
});
@override
State<EmptyChatScreen> createState() => _EmptyChatScreenState();
}
class _EmptyChatScreenState extends State<EmptyChatScreen> {
final TextEditingController textEditingController = TextEditingController();
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: true,
appBar: AppBar(
titleSpacing: 0,
backgroundColor: appTheme.gray100,
centerTitle: false,
title: GestureDetector(
onTap: () {
GoRouter.of(context).pushNamed(
'profileScreen',
extra: Author(
authorSlug: widget.author.authorSlug,
authorName: widget.author.authorName,
authorProfileIcon: widget.author.authorProfileIcon,
authorIsMe: false,
),
);
},
child: Row(
children: [
CircleAvatar(
radius: 20,
foregroundImage: NetworkImage(widget.author.authorProfileIcon),
backgroundImage: const AssetImage('assets/images/no_avatar.png'),
),
const SizedBox(width: 16),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget.author.authorName,
style: CustomTextStyles.titleSmallBold.copyWith(
color: PrimaryColors().black,
),
),
],
),
],
),
),
),
body: SafeArea(
child: Column(
children: [
const Spacer(),
Container(
padding: const EdgeInsets.symmetric(vertical: 8),
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
const SizedBox(width: 8),
InkWell(
onTap: () => showImagePicker(widget.author.authorSlug),
customBorder: const CircleBorder(),
child: Ink(
height: 40,
width: 40,
child: Transform.rotate(
angle: pi / 4,
child: const Icon(
Icons.attach_file_rounded,
size: 30,
color: Color(0xFF858E99),
),
),
),
),
const SizedBox(width: 8),
Expanded(
child: SizedBox(
height: 40,
child: TextFormField(
expands: true,
textCapitalization: TextCapitalization.sentences,
controller: textEditingController,
maxLines: null,
minLines: null,
keyboardType: TextInputType.multiline,
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w400, color: Colors.black, height: 1),
decoration: InputDecoration(
isDense: true,
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
hintText: 'Сообщение',
hintStyle: const TextStyle(fontSize: 14, fontWeight: FontWeight.w400, height: 1, color: Color(0xFFAEAEB2)),
filled: true,
border:
OutlineInputBorder(borderRadius: BorderRadius.circular(100), borderSide: const BorderSide(color: Color(0xFFD1D1D6), width: 1)),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(100),
borderSide: const BorderSide(color: Color(0xFFD1D1D6), width: 1),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(100),
borderSide: const BorderSide(color: Color(0xFFD1D1D6), width: 1),
),
),
),
),
),
const SizedBox(width: 8),
InkWell(
customBorder: const CircleBorder(),
onTap: () async {
if (textEditingController.text.isNotEmpty) {
await sl<ChatRepository>().sendMessage(
data: textEditingController.text.trim(),
slug: widget.author.authorSlug,
);
setState(() {
textEditingController.clear();
});
final chatIdOrError = await sl<ChatRepository>().getChatByUserSlug(widget.author.authorSlug);
AppRouter.navigatorKey.currentContext?.pushReplacementNamed(
'chatScreen',
extra: {
'chatId': chatIdOrError,
},
);
}
},
child: Ink(
decoration: BoxDecoration(color: appTheme.blueA400, shape: BoxShape.circle),
height: 40,
width: 40,
child: const Icon(Icons.arrow_upward_rounded, size: 24, color: Colors.white),
),
),
const SizedBox(width: 8),
],
),
),
],
),
),
);
}
showImagePicker(String slug) {
showCupertinoModalPopup<void>(
context: context,
builder: (context) => CupertinoActionSheet(
actions: [
CupertinoActionSheetAction(
onPressed: () async {
Navigator.of(context).pop();
final picker = ImagePicker();
XFile? image = await picker.pickImage(source: ImageSource.camera);
if (image != null) {
await sl<ChatRepository>().sendMessage(
files: [File(image.path)],
slug: widget.author.authorSlug,
);
final chatIdOrError = await sl<ChatRepository>().getChatByUserSlug(widget.author.authorSlug);
AppRouter.navigatorKey.currentContext?.pushReplacementNamed(
'chatScreen',
extra: {
'chatId': chatIdOrError,
},
);
}
},
child: const Row(
children: [
Icon(Icons.photo_library_rounded),
SizedBox(width: 8),
Text('Галерея'),
],
),
),
CupertinoActionSheetAction(
onPressed: () async {
Navigator.of(context).pop();
final picker = ImagePicker();
List<XFile>? images = await picker.pickMultiImage();
if (images.isNotEmpty) {
List<File> files = images.map((image) => File(image.path)).toList();
await sl<ChatRepository>().sendMessage(
files: files,
slug: widget.author.authorSlug,
);
final chatIdOrError = await sl<ChatRepository>().getChatByUserSlug(widget.author.authorSlug);
AppRouter.navigatorKey.currentContext?.pushReplacementNamed(
'chatScreen',
extra: {
'chatId': chatIdOrError,
},
);
}
},
child: const Row(
children: [
Icon(Icons.photo_camera),
SizedBox(width: 8),
Text('Фото'),
],
),
),
CupertinoActionSheetAction(
onPressed: () async {
Navigator.of(context).pop();
FilePickerResult? result = await FilePicker.platform.pickFiles(
allowMultiple: true,
type: FileType.custom,
allowedExtensions: [
'pdf',
'doc',
'docx',
'json',
'ppt',
'pptx',
'rtf',
'txt',
'xls',
'xlsx',
'csv',
'jpeg',
'jpg',
'png',
'gif',
'svg',
'xml',
'webp',
],
);
if (result != null) {
List<File> files = result.paths.map((path) => File(path!)).toList();
await sl<ChatRepository>().sendMessage(
files: files,
slug: widget.author.authorSlug,
);
final chatIdOrError = await sl<ChatRepository>().getChatByUserSlug(widget.author.authorSlug);
AppRouter.navigatorKey.currentContext?.pushReplacementNamed(
'chatScreen',
extra: {
'chatId': chatIdOrError,
},
);
}
},
child: const Row(
children: [
Icon(Icons.file_present_rounded),
SizedBox(width: 8),
Text('Файлы'),
],
),
),
],
cancelButton: CupertinoActionSheetAction(
onPressed: () => Navigator.of(context).pop(),
isDestructiveAction: true,
child: const Text('Отмена'),
),
),
);
}
}

View File

@@ -27,7 +27,6 @@ class ChatRepository {
} }
Future<void> sendMessage({ Future<void> sendMessage({
required String chatId,
required String slug, required String slug,
String? data, String? data,
List<File>? files, List<File>? files,
@@ -168,12 +167,4 @@ class ChatRepository {
return 'error'; return 'error';
} }
} }
Future<void> sendFirstChatMessageForCreateChatRoom(String userSlug) async {
try {
return await chatService.sendMessageByUserSlug(userSlug: userSlug, data: 'Создал чат!');
} catch (e) {
rethrow;
}
}
} }

View File

@@ -81,6 +81,8 @@ class _DevToolsScreenContentState extends State<DevToolsScreenContent> {
onPressed: () { onPressed: () {
setState(() { setState(() {
baseUrlForTest = controller.text; baseUrlForTest = controller.text;
baseUrl = baseUrlForTest.toLowerCase();
sl<Dio>().options.baseUrl = baseUrl;
controller.clear(); controller.clear();
}); });
}, },
@@ -89,73 +91,79 @@ class _DevToolsScreenContentState extends State<DevToolsScreenContent> {
], ],
), ),
const SizedBox(height: 10), const SizedBox(height: 10),
if (baseUrlForTest != baseUrl) CustomOutlinedButton(
CustomOutlinedButton( text: baseUrl == 'https://dev2.eatvio.com' ? 'Set production base url' : 'Set dev2 base url',
text: 'Set dev2 base url', onPressed: () {
onPressed: () { setState(() {
setState(() { if (baseUrl == 'https://eatvio.ru') {
baseUrlForTest = baseUrl; baseUrlForTest = 'https://dev2.eatvio.com';
}); } else {
}, baseUrlForTest = 'https://eatvio.ru';
buttonStyle: const ButtonStyle(), }
), baseUrl = baseUrlForTest.toLowerCase();
sl<Dio>().options.baseUrl = baseUrl;
controller.clear();
});
},
buttonStyle: const ButtonStyle(),
),
SizedBox(height: baseUrlForTest != baseUrl ? 40 : 10), SizedBox(height: baseUrlForTest != baseUrl ? 40 : 10),
ListView.builder( if (baseUrl.toLowerCase() != 'https://eatvio.ru')
shrinkWrap: true, ListView.builder(
itemCount: testCases.length, shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(), itemCount: testCases.length,
itemBuilder: physics: const NeverScrollableScrollPhysics(),
(context, index) => Padding( itemBuilder: (context, index) => Padding(
padding: const EdgeInsets.only(bottom: 10.0), padding: const EdgeInsets.only(bottom: 10.0),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Expanded(child: Text('${index + 1}. ${testCases[index].name}')), Expanded(child: Text('${index + 1}. ${testCases[index].name}')),
Row( Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
CustomOutlinedButton( CustomOutlinedButton(
text: 'run', text: 'run',
height: 20, height: 20,
width: 60, width: 60,
onPressed: () async { onPressed: () async {
if (testsStates[index] == TestState.loading) return; if (testsStates[index] == TestState.loading) return;
setState(() {
testsStates[index] = TestState.loading;
});
final result = await testCases[index].run(baseUrl: baseUrlForTest);
if (result) {
setState(() { setState(() {
testsStates[index] = TestState.loading; testsStates[index] = TestState.success;
}); });
final result = await testCases[index].run(baseUrl: baseUrlForTest); showSuccessToast('${testCases[index].name} passed');
if (result) { } else {
setState(() { setState(() {
testsStates[index] = TestState.success; testsStates[index] = TestState.fail;
}); });
showSuccessToast('${testCases[index].name} passed'); showErrorToast('${testCases[index].name} failed');
} else { }
setState(() { },
testsStates[index] = TestState.fail; buttonStyle: const ButtonStyle(),
}); ),
showErrorToast('${testCases[index].name} failed'); const SizedBox(width: 5),
} switch (testsStates[index]) {
}, TestState.success => Container(width: 20, height: 20, color: Colors.green),
buttonStyle: const ButtonStyle(), TestState.fail => Container(width: 20, height: 20, color: Colors.red),
), TestState.notRun => Container(width: 20, height: 20, color: Colors.grey),
const SizedBox(width: 5), TestState.loading => const SizedBox(
switch (testsStates[index]) {
TestState.success => Container(width: 20, height: 20, color: Colors.green),
TestState.fail => Container(width: 20, height: 20, color: Colors.red),
TestState.notRun => Container(width: 20, height: 20, color: Colors.grey),
TestState.loading => const SizedBox(
width: 20, width: 20,
height: 20, height: 20,
child: SizedBox(height: 20, width: 20, child: Center(child: CircularProgressIndicator())), child: SizedBox(height: 20, width: 20, child: Center(child: CircularProgressIndicator())),
), ),
}, },
], ],
), ),
], ],
),
), ),
), ),
),
const SizedBox(height: 10), const SizedBox(height: 10),
CustomOutlinedButton( CustomOutlinedButton(
text: 'add token to server', text: 'add token to server',

View File

@@ -5,6 +5,7 @@ import 'package:eatvio_app/core/image_compressing/image_compress_utility.dart';
import 'package:eatvio_app/core/utils/toasts.dart'; import 'package:eatvio_app/core/utils/toasts.dart';
import 'package:eatvio_app/features/chat/repositories/chat_repository.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/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/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/presentation/bloc/profile_cubit/profile_state.dart';
import 'package:eatvio_app/features/profile/repositories/profile_repository.dart'; import 'package:eatvio_app/features/profile/repositories/profile_repository.dart';
@@ -107,18 +108,14 @@ class ProfileCubit extends Cubit<ProfileState> {
} }
getChatRoomIdBySlug({ getChatRoomIdBySlug({
required String slug, required Author author,
}) async { }) async {
try { try {
final chatIdOrError = await chatRepository.getChatByUserSlug(slug); final chatIdOrError = await chatRepository.getChatByUserSlug(author.authorSlug);
if (chatIdOrError == '404') { if (chatIdOrError == '404') {
await chatRepository.sendFirstChatMessageForCreateChatRoom(slug);
final chatIdOrError = await chatRepository.getChatByUserSlug(slug);
AppRouter.navigatorKey.currentContext?.pushNamed( AppRouter.navigatorKey.currentContext?.pushNamed(
'chatScreen', 'emptyChatScreen',
extra: { extra: author,
'chatId': chatIdOrError,
},
); );
} else if (chatIdOrError == 'error') { } else if (chatIdOrError == 'error') {
showErrorToast('Ошибка создания чата'); showErrorToast('Ошибка создания чата');

View File

@@ -1232,7 +1232,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
children: [ children: [
const SizedBox(width: 16), const SizedBox(width: 16),
GestureDetector( GestureDetector(
onTap: () async => await profileCubit.getChatRoomIdBySlug(slug: widget.author!.authorSlug), onTap: () async => await profileCubit.getChatRoomIdBySlug(author: widget.author!),
child: Container( child: Container(
alignment: Alignment.center, alignment: Alignment.center,
padding: const EdgeInsets.all(8), padding: const EdgeInsets.all(8),

View File

@@ -1,5 +1,6 @@
import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/core/locator_service.dart';
import 'package:eatvio_app/core/theme/theme_helper.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/profile_cubit/profile_cubit.dart';
import 'package:eatvio_app/features/profile/presentation/bloc/sub_cubit/sub_cubit.dart'; import 'package:eatvio_app/features/profile/presentation/bloc/sub_cubit/sub_cubit.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -11,11 +12,15 @@ enum SubActionType { sendMessage, subscribe }
class SubActionButtonWidget extends StatefulWidget { class SubActionButtonWidget extends StatefulWidget {
final SubActionType subActionType; final SubActionType subActionType;
final String slug; final String slug;
final String name;
final String porfileIcon;
const SubActionButtonWidget({ const SubActionButtonWidget({
super.key, super.key,
required this.subActionType, required this.subActionType,
required this.slug, required this.slug,
required this.name,
required this.porfileIcon,
}); });
@override @override
@@ -64,7 +69,14 @@ class _SubActionButtonWidgetState extends State<SubActionButtonWidget> {
GoRouter.of(context).pushNamed( GoRouter.of(context).pushNamed(
'chatScreen', 'chatScreen',
extra: { 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,
),
),
}, },
); );
}, },

View File

@@ -70,6 +70,8 @@ class _SubWidgetState extends State<SubWidget> {
SubActionButtonWidget( SubActionButtonWidget(
subActionType: widget.subModel.isEntitySubscribedByMe ? SubActionType.sendMessage : SubActionType.subscribe, subActionType: widget.subModel.isEntitySubscribedByMe ? SubActionType.sendMessage : SubActionType.subscribe,
slug: widget.subModel.slug, slug: widget.subModel.slug,
name: widget.subModel.name,
porfileIcon: widget.subModel.profilePhotoUrl,
), ),
], ],
), ),

View File

@@ -1,6 +1,6 @@
name: eatvio_app name: eatvio_app
description: A new Flutter project. description: A new Flutter project.
version: 1.1.7+37 version: 1.1.8+38
publish_to: 'none' publish_to: 'none'
environment: environment:
@@ -71,6 +71,7 @@ dependencies:
package_info_plus: ^8.3.0 package_info_plus: ^8.3.0
device_info_plus: ^11.4.0 device_info_plus: ^11.4.0
permission_handler: ^12.0.0+1 permission_handler: ^12.0.0+1
qr_code_scanner_plus: ^2.0.10+1
dev_dependencies: dev_dependencies:
build_runner: ^2.4.15 build_runner: ^2.4.15