forked from eatvio/eatvio_app
feat(chat): hero animation + chat select scren
This commit is contained in:
@@ -27,17 +27,22 @@ class ChatSelectBloc extends Bloc<ChatSelectEvent, ChatSelectState> {
|
||||
List<ChatItemModel> chats = [];
|
||||
for (int i = 0; i < chatRooms.length; i++) {
|
||||
String text = chatRooms[i]['last_message']['data'];
|
||||
if (chatRooms[i]['last_message']['is_author_from_user']) {
|
||||
if (chatRooms[i]['last_message']['is_author_message_auth_user'] != null) {
|
||||
text = "Вы: " + text;
|
||||
}
|
||||
chats.add(ChatItemModel(
|
||||
chats.add(
|
||||
ChatItemModel(
|
||||
id: chatRooms[i]['id'],
|
||||
userImage: chatRooms[i]['users']['to_chat_user']
|
||||
['profile_photo_path'],
|
||||
userImage: chatRooms[i]['users']['to_chat_user']['profile_photo_path'],
|
||||
username: chatRooms[i]['users']['to_chat_user']['name'],
|
||||
dateText: DateFormat('dd.MM').format(
|
||||
DateTime.parse(chatRooms[i]['last_message']['updated_at'])),
|
||||
greetingText: text));
|
||||
DateTime.parse(
|
||||
chatRooms[i]['last_message']['updated_at'],
|
||||
),
|
||||
),
|
||||
greetingText: text,
|
||||
),
|
||||
);
|
||||
}
|
||||
return chats;
|
||||
}
|
||||
@@ -75,8 +80,7 @@ class ChatSelectBloc extends Bloc<ChatSelectEvent, ChatSelectState> {
|
||||
}
|
||||
} else {
|
||||
// Один или несколько ключевых полей отсутствуют, обрабатываем ошибку
|
||||
emit(ChatSelectErrorState(
|
||||
'Некоторые необходимые данные отсутствуют.'));
|
||||
emit(ChatSelectErrorState('Некоторые необходимые данные отсутствуют.'));
|
||||
}
|
||||
} else {
|
||||
// Статус ответа не равен 200, обрабатываем ошибку
|
||||
|
||||
@@ -64,7 +64,10 @@ class ChatSelectScreen extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
} else if (state is ChatSelectErrorState) {
|
||||
return Center(child: Text(state.errorMessage));
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Center(child: Text(state.errorMessage)),
|
||||
);
|
||||
} else {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
|
||||
@@ -4,26 +4,23 @@ import 'package:eatvio_app/core/app_export.dart';
|
||||
// ignore_for_file: must_be_immutable
|
||||
|
||||
class ChatItemModel {
|
||||
ChatItemModel(
|
||||
{this.userImage,
|
||||
this.username,
|
||||
this.dateText,
|
||||
this.greetingText,
|
||||
required this.id}) {
|
||||
String? userImage;
|
||||
String? username;
|
||||
String? dateText;
|
||||
String? greetingText;
|
||||
String id;
|
||||
|
||||
ChatItemModel({
|
||||
this.userImage,
|
||||
this.username,
|
||||
this.dateText,
|
||||
this.greetingText,
|
||||
required this.id,
|
||||
}) {
|
||||
userImage = userImage ?? ImageConstant.imageNotFound;
|
||||
username = username;
|
||||
dateText = dateText;
|
||||
greetingText = greetingText;
|
||||
id = id;
|
||||
}
|
||||
|
||||
String? userImage;
|
||||
|
||||
String? username;
|
||||
|
||||
String? dateText;
|
||||
|
||||
String? greetingText;
|
||||
|
||||
String id;
|
||||
}
|
||||
|
||||
@@ -5,9 +5,11 @@ import 'package:equatable/equatable.dart';
|
||||
|
||||
/// This class defines the variables used in the [chat_select_screen],
|
||||
/// and is typically used to hold data that is passed between different parts of the application.
|
||||
|
||||
class ChatSelectModel extends Equatable {
|
||||
ChatSelectModel({this.chatList = const []});
|
||||
List<ChatItemModel> chatList;
|
||||
|
||||
ChatSelectModel copyWith({List<ChatItemModel>? chatList}) {
|
||||
return ChatSelectModel(
|
||||
chatList: chatList ?? this.chatList,
|
||||
|
||||
@@ -15,12 +15,13 @@ class ChatEntryWidget extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () => GoRouter.of(context).goNamed(
|
||||
return InkWell(
|
||||
borderRadius: BorderRadiusStyle.circleBorder8,
|
||||
onTap: () => GoRouter.of(context).pushNamed(
|
||||
'chatScreen',
|
||||
extra: chatEntryObj.id.toString(),
|
||||
),
|
||||
child: Container(
|
||||
child: Ink(
|
||||
padding: EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadiusStyle.circleBorder8,
|
||||
|
||||
Reference in New Issue
Block a user