forked from eatvio/eatvio_app
feat(chat): Classes added to chat screen
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '/core/app_export.dart';
|
||||
import 'package:eatvio_app/presentation/chat/chat_screen/models/chat_model.dart';
|
||||
part 'chat_event.dart';
|
||||
part 'chat_state.dart';
|
||||
|
||||
/// A bloc that manages the state of a Chat according to the event that is dispatched to it.
|
||||
class ChatBloc extends Bloc<ChatEvent, ChatState> {
|
||||
ChatBloc(ChatState initialState) : super(initialState) {
|
||||
on<ChatInitialEvent>(_onInitialize);
|
||||
}
|
||||
|
||||
_onInitialize(
|
||||
ChatInitialEvent event,
|
||||
Emitter<ChatState> emit,
|
||||
) async {
|
||||
emit(state.copyWith(chatModelObj: state.chatModelObj?.copyWith()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// ignore_for_file: must_be_immutable
|
||||
|
||||
part of 'chat_bloc.dart';
|
||||
|
||||
/// Abstract class for all events that can be dispatched from the
|
||||
///Chat widget.
|
||||
///
|
||||
/// Events must be immutable and implement the [Equatable] interface.
|
||||
@immutable
|
||||
abstract class ChatEvent extends Equatable {}
|
||||
|
||||
/// Event that is dispatched when the Chat widget is first created.
|
||||
class ChatInitialEvent extends ChatEvent {
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
///event for dropdown selection
|
||||
class ChangeDropDownEvent extends ChatEvent {
|
||||
ChangeDropDownEvent({required this.value});
|
||||
|
||||
SelectionPopupModel value;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
value,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
// ignore_for_file: must_be_immutable
|
||||
|
||||
part of 'chat_bloc.dart';
|
||||
|
||||
/// Represents the state of Chat in the application.
|
||||
class ChatState extends Equatable {
|
||||
ChatState({
|
||||
this.selectedDropDownValue,
|
||||
this.chatModelObj,
|
||||
});
|
||||
|
||||
SelectionPopupModel? selectedDropDownValue;
|
||||
|
||||
ChatModel? chatModelObj;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
selectedDropDownValue,
|
||||
chatModelObj,
|
||||
];
|
||||
ChatState copyWith({
|
||||
SelectionPopupModel? selectedDropDownValue,
|
||||
ChatModel? chatModelObj,
|
||||
}) {
|
||||
return ChatState(
|
||||
selectedDropDownValue:
|
||||
selectedDropDownValue ?? this.selectedDropDownValue,
|
||||
chatModelObj: chatModelObj ?? this.chatModelObj,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import 'bloc/chat_bloc.dart';
|
||||
import 'models/chat_model.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ChatScreen extends StatelessWidget {
|
||||
const ChatScreen({Key? key}) : super(key: key);
|
||||
static Widget builder(BuildContext context) {
|
||||
return BlocProvider<ChatBloc>(
|
||||
create: (context) => ChatBloc(ChatState(chatModelObj: ChatModel()))
|
||||
..add(ChatInitialEvent()),
|
||||
child: ChatScreen());
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
mediaQueryData = MediaQuery.of(context);
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// ignore_for_file: must_be_immutable
|
||||
|
||||
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 {
|
||||
ChatModel();
|
||||
|
||||
ChatModel copyWith() {
|
||||
return ChatModel();
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user