Files
eatvio_app/lib/presentation/chat/chat_screen/chat_screen.dart

225 lines
6.2 KiB
Dart

import 'bloc/chat_bloc.dart';
import 'models/chat_model.dart';
import 'package:eatvio_app/core/app_export.dart';
import 'package:flutter/material.dart';
import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart';
import 'package:eatvio_app/widgets/app_bar/appbar_subtitle.dart';
import 'package:eatvio_app/widgets/app_bar/appbar_leading_image.dart';
import 'package:eatvio_app/widgets/app_bar/appbar_title_image.dart';
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
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) {
return BlocProvider<ChatBloc>(
create: (context) => ChatBloc(ChatState(chatModelObj: ChatModel()))
..add(ChatInitialEvent()),
child: ChatScreen());
}
@override
Widget build(BuildContext context) {
mediaQueryData = MediaQuery.of(context);
return Scaffold(
resizeToAvoidBottomInset: false,
appBar: _buildAppbar(context),
body: SizedBox(
width: double.maxFinite,
child: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(
children: [
SizedBox(height: 30.v),
],
),
),
),
bottomNavigationBar: _buildTextField(context),
);
}
/// Section Widget
_buildAppbar(BuildContext context) {
return CustomAppBar(
leadingWidth: 26.h,
leading: AppbarLeadingImage(
imagePath: ImageConstant.imgArrowLeft,
margin: EdgeInsets.only(
left: 16.h,
top: 18.v,
bottom: 25.v,
),
onTap: () {
onTapArrowleftone(context);
},
),
title: Padding(
padding: EdgeInsets.only(left: 12.h),
child: Row(
children: [
AppbarTitleImage(
imagePath: ImageConstant.imgIconMoreHorizontal,
margin: EdgeInsets.only(bottom: 3.v),
),
Padding(
padding: EdgeInsets.only(
left: 12.h,
top: 2.v,
),
child: Column(
children: [
AppbarSubtitle(
text: "Валерий Леонтьев",
),
SizedBox(height: 3.v),
Text("Был в сети вчера", style: theme.textTheme.bodySmall!)
],
),
)
],
),
),
);
}
/// Section Widget
_buildTextField(BuildContext context) {
return Container(
width: double.maxFinite,
padding: EdgeInsets.symmetric(
horizontal: 7.h,
vertical: 6.v,
),
decoration: AppDecoration.outlineBlueGray,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CustomImageView(
imagePath: ImageConstant.imgAttach,
height: 29.adaptSize,
width: 29.adaptSize,
margin: EdgeInsets.only(
top: 1.v,
bottom: 6.v,
),
),
Expanded(
child: Padding(
padding: EdgeInsets.only(
left: 4.h,
bottom: 4.v,
),
child: BlocSelector<ChatBloc, ChatState, TextEditingController?>(
selector: (state) => TextEditingController(),
builder: (context, messageController) {
return CustomTextFormField(
controller: messageController,
hintText: "Напишите сообщение...",
textInputAction: TextInputAction.done,
);
},
),
),
),
CustomImageView(
imagePath: ImageConstant.imgMic,
height: 24.v,
width: 18.h,
margin: EdgeInsets.only(
left: 11.h,
top: 4.v,
bottom: 8.v,
),
)
],
),
);
}
/// Common widget
Widget _buildColumncheckmark(
BuildContext context, {
required String imageOne,
required String time,
}) {
return Container(
padding: EdgeInsets.all(9.h),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(ImageConstant.imageNotFound),
fit: BoxFit.cover,
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
CustomImageView(
imagePath: imageOne,
height: 186.v,
width: 254.h,
radius: BorderRadius.circular(
8.h,
),
margin: EdgeInsets.only(right: 1.h),
),
SizedBox(height: 10.v),
Row(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
time,
style: theme.textTheme.bodySmall!.copyWith(
color: appTheme.blueA400,
),
),
CustomImageView(
imagePath: ImageConstant.imageNotFound,
height: 7.v,
width: 14.h,
margin: EdgeInsets.only(
left: 3.h,
bottom: 4.v,
),
)
],
)
],
),
);
}
/// Common widget
///Handling route based on bottom click actions
String getCurrentRoute(BottomBarEnum type) {
switch (type) {
case BottomBarEnum.tf:
return AppRoutes.chatScreen;
default:
return "/";
}
}
///Handling page based on route
Widget getCurrentPage(
BuildContext context,
String currentRoute,
) {
switch (currentRoute) {
case AppRoutes.chatScreen:
return ChatScreen.builder(context);
default:
return ChatScreen();
}
}
/// Navigates to the previous screen.
onTapArrowleftone(BuildContext context) {
NavigatorService.goBack();
}
}