feat(chat): Classes added to chat select

This commit is contained in:
2024-04-04 13:26:17 +03:00
parent 79a6fcbd88
commit 28d6525c78
5 changed files with 117 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';
import '/core/app_export.dart';
import 'package:eatvio_app/presentation/chat/chat_select_screen/models/chat_select_model.dart';
part 'chat_select_event.dart';
part 'chat_select_state.dart';
/// A bloc that manages the state of a ChatSelect according to the event that is dispatched to it.
class ChatSelectBloc extends Bloc<ChatSelectEvent, ChatSelectState> {
ChatSelectBloc(ChatSelectState initialState) : super(initialState) {
on<ChatSelectInitialEvent>(_onInitialize);
}
_onInitialize(
ChatSelectInitialEvent event,
Emitter<ChatSelectState> emit,
) async {
emit(state.copyWith(
chatSelectModelObj: state.chatSelectModelObj?.copyWith()));
}
}

View File

@@ -0,0 +1,28 @@
// ignore_for_file: must_be_immutable
part of 'chat_select_bloc.dart';
/// Abstract class for all events that can be dispatched from the
///ChatSelect widget.
///
/// Events must be immutable and implement the [Equatable] interface.
@immutable
abstract class ChatSelectEvent extends Equatable {}
/// Event that is dispatched when the ChatSelect widget is first created.
class ChatSelectInitialEvent extends ChatSelectEvent {
@override
List<Object?> get props => [];
}
///event for dropdown selection
class ChangeDropDownEvent extends ChatSelectEvent {
ChangeDropDownEvent({required this.value});
SelectionPopupModel value;
@override
List<Object?> get props => [
value,
];
}

View File

@@ -0,0 +1,31 @@
// ignore_for_file: must_be_immutable
part of 'chat_select_bloc.dart';
/// Represents the state of ChatSelect in the application.
class ChatSelectState extends Equatable {
ChatSelectState({
this.selectedDropDownValue,
this.chatSelectModelObj,
});
SelectionPopupModel? selectedDropDownValue;
ChatSelectModel? chatSelectModelObj;
@override
List<Object?> get props => [
selectedDropDownValue,
chatSelectModelObj,
];
ChatSelectState copyWith({
SelectionPopupModel? selectedDropDownValue,
ChatSelectModel? chatSelectModelObj,
}) {
return ChatSelectState(
selectedDropDownValue:
selectedDropDownValue ?? this.selectedDropDownValue,
chatSelectModelObj: chatSelectModelObj ?? this.chatSelectModelObj,
);
}
}