diff --git a/lib/presentation/chat/chat_screen/bloc/chat_bloc.dart b/lib/presentation/chat/chat_screen/bloc/chat_bloc.dart index bc91ba8d..c53410db 100644 --- a/lib/presentation/chat/chat_screen/bloc/chat_bloc.dart +++ b/lib/presentation/chat/chat_screen/bloc/chat_bloc.dart @@ -27,9 +27,10 @@ class ChatBloc extends Bloc { AppRoutes.authScreen, ); } - final String? id = state.chatModelObj?.chatID; + final String? chatID = state.chatModelObj?.chatID; + print(chatID); final response = await http.get( - Uri.parse(dotenv.env['SERVER_ROOT']! + '/chat/show/$id'), + Uri.parse(dotenv.env['SERVER_ROOT']! + '/chat/show/$chatID'), headers: { 'Authorization': 'Bearer $token', }, diff --git a/lib/presentation/chat/chat_screen/bloc/chat_event.dart b/lib/presentation/chat/chat_screen/bloc/chat_event.dart index a3778f98..1fe6df94 100644 --- a/lib/presentation/chat/chat_screen/bloc/chat_event.dart +++ b/lib/presentation/chat/chat_screen/bloc/chat_event.dart @@ -14,15 +14,3 @@ class ChatInitialEvent extends ChatEvent { @override List get props => []; } - -///event for dropdown selection -class ChangeDropDownEvent extends ChatEvent { - ChangeDropDownEvent({required this.value}); - - SelectionPopupModel value; - - @override - List get props => [ - value, - ]; -} diff --git a/lib/presentation/chat/chat_screen/chat_screen.dart b/lib/presentation/chat/chat_screen/chat_screen.dart index 28c42e27..0a7e8c29 100644 --- a/lib/presentation/chat/chat_screen/chat_screen.dart +++ b/lib/presentation/chat/chat_screen/chat_screen.dart @@ -12,11 +12,12 @@ import 'package:eatvio_app/widgets/custom_text_form_field.dart'; class ChatScreen extends StatelessWidget { const ChatScreen({Key? key}) : super(key: key); static Widget builder(BuildContext context) { - final String chatID = ModalRoute.of(context)!.settings.arguments as String; + final chatID = ModalRoute.of(context)!.settings.arguments; + print(chatID.toString()); return BlocProvider( - create: (context) => - ChatBloc(ChatState(chatModelObj: ChatModel(chatID: chatID))) - ..add(ChatInitialEvent()), + create: (context) => ChatBloc( + ChatState(chatModelObj: ChatModel(chatID: chatID.toString()))) + ..add(ChatInitialEvent()), child: ChatScreen()); } diff --git a/lib/presentation/chat/chat_screen/models/chat_model.dart b/lib/presentation/chat/chat_screen/models/chat_model.dart index 4c6e566b..970b9ada 100644 --- a/lib/presentation/chat/chat_screen/models/chat_model.dart +++ b/lib/presentation/chat/chat_screen/models/chat_model.dart @@ -4,9 +4,11 @@ import 'package:equatable/equatable.dart'; /// This class defines the variables used in the [chat_screen], /// and is typically used to hold data that is passed between different parts of the application. + class ChatModel extends Equatable { - String? chatID; - ChatModel({String? chatID}); + final String chatID; + + ChatModel({required String chatID}) : chatID = chatID; ChatModel copyWith(String chatID) { return ChatModel(chatID: chatID); diff --git a/lib/presentation/chat/chat_select_screen/widgets/chat_entry_widget.dart b/lib/presentation/chat/chat_select_screen/widgets/chat_entry_widget.dart index a26b602b..52f9de3a 100644 --- a/lib/presentation/chat/chat_select_screen/widgets/chat_entry_widget.dart +++ b/lib/presentation/chat/chat_select_screen/widgets/chat_entry_widget.dart @@ -16,29 +16,35 @@ class ChatEntryWidget extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( - padding: EdgeInsets.all(8.h), - decoration: AppDecoration.fillGray100.copyWith( - borderRadius: BorderRadiusStyle.circleBorder8, + return GestureDetector( + onTap: () => Navigator.pushNamed( + context, + AppRoutes.chatScreen, + arguments: chatEntryObj.id.toString(), ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CachedNetworkImage( - imageUrl: dotenv.env['STORAGE_URL']! + chatEntryObj.userImage!, - imageBuilder: (context, imageProvider) => CircleAvatar( - backgroundImage: imageProvider, - radius: 25, - ), - placeholder: (context, url) => CircularProgressIndicator(), - errorWidget: (context, url, error) => CircleAvatar( - child: Icon(Icons.person), - backgroundColor: Colors.white, - radius: 25, - ), - ), - /*CustomImageView( + child: Container( + padding: EdgeInsets.all(8.h), + decoration: AppDecoration.fillGray100.copyWith( + borderRadius: BorderRadiusStyle.circleBorder8, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CachedNetworkImage( + imageUrl: dotenv.env['STORAGE_URL']! + chatEntryObj.userImage!, + imageBuilder: (context, imageProvider) => CircleAvatar( + backgroundImage: imageProvider, + radius: 25, + ), + placeholder: (context, url) => CircularProgressIndicator(), + errorWidget: (context, url, error) => CircleAvatar( + child: Icon(Icons.person), + backgroundColor: Colors.white, + radius: 25, + ), + ), + /*CustomImageView( imagePath: dotenv.env['STORAGE_URL']! + chatEntryObj.userImage!, height: 60.adaptSize, @@ -47,62 +53,57 @@ class ChatEntryWidget extends StatelessWidget { 30.h, ), ),*/ - Expanded( - child: Padding( - padding: EdgeInsets.only( - left: 12.h, - top: 2.v, - bottom: 11.v, - ), - child: GestureDetector( - onTap: () => Navigator.pushNamed( - context, - AppRoutes.chatScreen, - arguments: chatEntryObj.id, - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: 227.h, - child: Row( - children: [ - Text( - chatEntryObj.username!.length <= 15 - ? chatEntryObj.username! - : chatEntryObj.username!.substring(0, 15) + '...', - style: theme.textTheme.titleMedium, - ), - Spacer(), - CustomImageView( - imagePath: ImageConstant.imageNotFound, - height: 9.v, - width: 16.h, - margin: EdgeInsets.only( - top: 4.v, - bottom: 6.v, - ), - ), - Padding( - padding: EdgeInsets.only(left: 6.h), - child: Text( - chatEntryObj.dateText!, - style: theme.textTheme.bodyMedium, - ), - ) - ], - ), + Expanded( + child: Padding( + padding: EdgeInsets.only( + left: 12.h, + top: 2.v, + bottom: 11.v, ), - SizedBox(height: 6.v), - Text( - chatEntryObj.greetingText!, - style: CustomTextStyles.bodyMediumBluegray800, - ) - ], - ), - ), - )) - ], + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: 227.h, + child: Row( + children: [ + Text( + chatEntryObj.username!.length <= 15 + ? chatEntryObj.username! + : chatEntryObj.username!.substring(0, 15) + + '...', + style: theme.textTheme.titleMedium, + ), + Spacer(), + CustomImageView( + imagePath: ImageConstant.imageNotFound, + height: 9.v, + width: 16.h, + margin: EdgeInsets.only( + top: 4.v, + bottom: 6.v, + ), + ), + Padding( + padding: EdgeInsets.only(left: 6.h), + child: Text( + chatEntryObj.dateText!, + style: theme.textTheme.bodyMedium, + ), + ) + ], + ), + ), + SizedBox(height: 6.v), + Text( + chatEntryObj.greetingText!, + style: CustomTextStyles.bodyMediumBluegray800, + ) + ], + ), + ), + ) + ]), ), ); }