Some more layouts and state control

This commit is contained in:
2024-04-19 16:41:40 +03:00
parent 8c93d57492
commit 1b606d9fa6
4 changed files with 128 additions and 8 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);
@@ -56,10 +58,10 @@ class ChatSelectScreen extends StatelessWidget {
);
}
Widget _buildUserprofile(BuildContext context) {
_buildUserprofile(BuildContext context) {
return BlocSelector<ChatSelectBloc, ChatSelectState, ChatSelectModel?>(
selector: (state) => state.chatSelectModelObj,
builder: (context, k1ModelObj) {
builder: (context, chatSelectModelObj) {
return ListView.separated(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
@@ -68,10 +70,10 @@ class ChatSelectScreen extends StatelessWidget {
height: 10.v,
);
},
itemCount: k1ModelObj?.userprofileItemList.length ?? 0,
itemCount: chatSelectModelObj?.userprofileItemList.length ?? 0,
itemBuilder: (context, index) {
UserprofileItemModel model =
k1ModelObj?.userprofileItemList[index] ??
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'; // ignore: must_be_immutable
/// 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,
)
],
),
),
)
],
),
);
}
}