Merge pull request 'BloC и верстка для экрана выбора чата' (#44) from maxxkim/eatvio_app:diary into main

Reviewed-on: eatvio/eatvio_app#44
Reviewed-by: apoloz <anatoliy.poloz@gmail.com>
This commit is contained in:
apoloz
2024-04-19 13:58:26 +00:00
6 changed files with 197 additions and 6 deletions

View File

@@ -2,6 +2,8 @@ import 'bloc/chat_select_bloc.dart';
import 'models/chat_select_model.dart';
import 'package:eatvio_app/core/app_export.dart';
import 'package:flutter/material.dart';
import 'package:eatvio_app/presentation/chat/chat_select_screen/models/chat_entry.dart'; // ignore: must_be_immutable
import 'package:eatvio_app/presentation/chat/chat_select_screen/widgets/chat_entry_widget.dart'; // ignore: must_be_immutable
class ChatSelectScreen extends StatelessWidget {
const ChatSelectScreen({Key? key}) : super(key: key);
@@ -16,6 +18,69 @@ class ChatSelectScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
mediaQueryData = MediaQuery.of(context);
return Container();
return SafeArea(
child: Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: Column(
children: [
SizedBox(height: 30.v),
Container(
margin: EdgeInsets.only(
left: 16.h,
right: 20.h,
),
padding: EdgeInsets.all(12.h),
decoration: AppDecoration.outlinePrimary.copyWith(
borderRadius: BorderRadiusStyle.circleBorder8,
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
BlocSelector<ChatSelectBloc, ChatSelectState,
TextEditingController?>(
selector: (state) => TextEditingController(),
builder: (context, searchController) {
return Container();
},
),
SizedBox(height: 20.v),
_buildUserprofile(context)
],
),
)
],
),
),
),
);
}
_buildUserprofile(BuildContext context) {
return BlocSelector<ChatSelectBloc, ChatSelectState, ChatSelectModel?>(
selector: (state) => state.chatSelectModelObj,
builder: (context, chatSelectModelObj) {
return ListView.separated(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
separatorBuilder: (context, index) {
return SizedBox(
height: 10.v,
);
},
itemCount: chatSelectModelObj?.userprofileItemList.length ?? 0,
itemBuilder: (context, index) {
UserprofileItemModel model =
chatSelectModelObj?.userprofileItemList[index] ??
UserprofileItemModel();
return UserprofileItemWidget(
model,
);
},
);
},
);
}
}

View File

@@ -0,0 +1,29 @@
import 'package:eatvio_app/core/app_export.dart';
/// This class is used in the [userprofile_item_widget] screen.
// ignore_for_file: must_be_immutable
class UserprofileItemModel {
UserprofileItemModel(
{this.userImage,
this.username,
this.dateText,
this.greetingText,
this.id}) {
userImage = userImage ?? ImageConstant.imageNotFound;
username = username ?? "Ксения Обрамова";
dateText = dateText ?? "9/29";
greetingText = greetingText ?? "Привет, хорошая статья";
id = id ?? "";
}
String? userImage;
String? username;
String? dateText;
String? greetingText;
String? id;
}

View File

@@ -1,16 +1,20 @@
// ignore_for_file: must_be_immutable
import 'package:equatable/equatable.dart';
import 'package:eatvio_app/presentation/chat/chat_select_screen/models/chat_entry.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();
ChatSelectModel({this.userprofileItemList = const []});
ChatSelectModel copyWith() {
return ChatSelectModel();
List<UserprofileItemModel> userprofileItemList;
ChatSelectModel copyWith({List<UserprofileItemModel>? userprofileItemList}) {
return ChatSelectModel(
userprofileItemList: userprofileItemList ?? this.userprofileItemList,
);
}
@override
List<Object?> get props => [];
List<Object?> get props => [userprofileItemList];
}

View File

@@ -0,0 +1,85 @@
// ignore_for_file: must_be_immutable
import 'package:flutter/material.dart';
import 'package:eatvio_app/core/app_export.dart';
import 'package:eatvio_app/presentation/chat/chat_select_screen/models/chat_entry.dart';
class UserprofileItemWidget extends StatelessWidget {
UserprofileItemWidget(this.userprofileItemModelObj, {Key? key})
: super(
key: key,
);
UserprofileItemModel userprofileItemModelObj;
@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.all(8.h),
decoration: AppDecoration.fillGray100.copyWith(
borderRadius: BorderRadiusStyle.circleBorder8,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CustomImageView(
imagePath: userprofileItemModelObj.userImage!,
height: 60.adaptSize,
width: 60.adaptSize,
radius: BorderRadius.circular(
30.h,
),
),
Expanded(
child: Padding(
padding: EdgeInsets.only(
left: 12.h,
top: 2.v,
bottom: 11.v,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
width: 227.h,
child: Row(
children: [
Text(
userprofileItemModelObj.username!,
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(
userprofileItemModelObj.dateText!,
style: theme.textTheme.bodyMedium,
),
)
],
),
),
SizedBox(height: 6.v),
Text(
userprofileItemModelObj.greetingText!,
style: CustomTextStyles.bodyMediumBluegray800,
)
],
),
),
)
],
),
);
}
}

View File

@@ -20,6 +20,8 @@ import 'package:eatvio_app/presentation/auth/auth_screen/auth_screen.dart';
import 'package:eatvio_app/presentation/profile/my_profile_screen/my_profile_screen.dart';
import 'package:eatvio_app/presentation/profile/my_profile_screen/my_settings_screen.dart';
import 'package:eatvio_app/presentation/diary/diary_edit_screen/diary_edit_screen.dart';
import 'package:eatvio_app/presentation/chat/chat_screen/chat_screen.dart';
import 'package:eatvio_app/presentation/chat/chat_select_screen/chat_select_screen.dart';
class AppRoutes {
// REGISTRATION
@@ -72,6 +74,10 @@ class AppRoutes {
static const String diaryEdit = '/diaryEdit';
static const String chatScreen = '/chat';
static const String chatSelectScreen = '/chatSelect';
static Map<String, WidgetBuilder> get routes => {
dateOfBirthScreen: DateOfBirthScreen.builder,
cityOfLivingScreen: CityOfLivingScreen.builder,
@@ -95,5 +101,7 @@ class AppRoutes {
myProfile: MyProfileScreen.builder,
mySettings: MySettingsScreen.builder,
diaryEdit: DiaryEditScreen.builder,
chatScreen: ChatScreen.builder,
chatSelectScreen: ChatSelectScreen.builder,
};
}

View File

@@ -92,7 +92,7 @@ class CustomBottomBarState extends State<CustomBottomBar> {
Navigator.pushNamed(context, AppRoutes.diaryEdit);
break;
case 3:
Navigator.pushNamed(context, '/chat');
Navigator.pushNamed(context, AppRoutes.chatSelectScreen);
break;
}
}