forked from eatvio/eatvio_app
feat(chat): Layouts for chat select finished
This commit is contained in:
4
assets/images/img_glass.svg
Normal file
4
assets/images/img_glass.svg
Normal file
@@ -0,0 +1,4 @@
|
||||
<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M18 27C22.4183 27 26 23.4183 26 19C26 14.5817 22.4183 11 18 11C13.5817 11 10 14.5817 10 19C10 23.4183 13.5817 27 18 27Z" stroke="#7B8794" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M28.0004 28.9999L23.6504 24.6499" stroke="#7B8794" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 442 B |
@@ -14,6 +14,7 @@ class ImageConstant {
|
||||
|
||||
static String imageNotFound = 'assets/images/image_not_found.png';
|
||||
|
||||
static String imaGlass = 'assets/images/image_glass.svg';
|
||||
// Настройки images
|
||||
|
||||
static String imgClose = '$imagePath/img_close.svg';
|
||||
|
||||
@@ -2,6 +2,7 @@ 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';
|
||||
import 'package:eatvio_app/presentation/chat/chat_select_screen/models/chat_entry.dart'; // ignore: must_be_immutable
|
||||
part 'chat_select_event.dart';
|
||||
part 'chat_select_state.dart';
|
||||
|
||||
@@ -11,11 +12,38 @@ class ChatSelectBloc extends Bloc<ChatSelectEvent, ChatSelectState> {
|
||||
on<ChatSelectInitialEvent>(_onInitialize);
|
||||
}
|
||||
|
||||
List<ChatItemModel> fillChatEntryList() {
|
||||
return [
|
||||
ChatItemModel(
|
||||
userImage: ImageConstant.imgLogo,
|
||||
username: "Ксения Обрамова",
|
||||
dateText: "9/29",
|
||||
greetingText: "Привет, хорошая статья"),
|
||||
ChatItemModel(
|
||||
userImage: ImageConstant.imgLogo,
|
||||
username: "Ксения Обрамова",
|
||||
dateText: "9/29",
|
||||
greetingText: "Привет, хорошая статья"),
|
||||
ChatItemModel(
|
||||
userImage: ImageConstant.imgLogo,
|
||||
username: "Данил Иванов",
|
||||
dateText: "9/29",
|
||||
greetingText: "Посоветуй пожалуйста рецепт..."),
|
||||
ChatItemModel(
|
||||
userImage: ImageConstant.imgLogo,
|
||||
username: "Данил Иванов",
|
||||
dateText: "9/29",
|
||||
greetingText: "Посоветуй пожалуйста рецепт...")
|
||||
];
|
||||
}
|
||||
|
||||
_onInitialize(
|
||||
ChatSelectInitialEvent event,
|
||||
Emitter<ChatSelectState> emit,
|
||||
) async {
|
||||
emit(state.copyWith(
|
||||
chatSelectModelObj: state.chatSelectModelObj?.copyWith()));
|
||||
chatSelectModelObj: state.chatSelectModelObj?.copyWith(
|
||||
userprofileItemList: fillChatEntryList(),
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
164
lib/presentation/chat/chat_select_screen/chat_search_view.dart
Normal file
164
lib/presentation/chat/chat_select_screen/chat_search_view.dart
Normal file
@@ -0,0 +1,164 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
|
||||
class CustomSearchView extends StatelessWidget {
|
||||
CustomSearchView(
|
||||
{Key? key,
|
||||
this.alignment,
|
||||
this.width,
|
||||
this.scrollPadding,
|
||||
this.controller,
|
||||
this.focusNode,
|
||||
this.autofocus = false,
|
||||
this.textStyle,
|
||||
this.textInputType = TextInputType.text,
|
||||
this.maxLines,
|
||||
this.hintText,
|
||||
this.hintStyle,
|
||||
this.prefix,
|
||||
this.prefixConstraints,
|
||||
this.suffix,
|
||||
this.suffixConstraints,
|
||||
this.contentPadding,
|
||||
this.borderDecoration,
|
||||
this.fillColor,
|
||||
this.filled = true,
|
||||
this.validator,
|
||||
this.onChanged})
|
||||
: super(
|
||||
key: key,
|
||||
);
|
||||
|
||||
final Alignment? alignment;
|
||||
|
||||
final double? width;
|
||||
|
||||
final TextEditingController? scrollPadding;
|
||||
|
||||
final TextEditingController? controller;
|
||||
|
||||
final FocusNode? focusNode;
|
||||
|
||||
final bool? autofocus;
|
||||
|
||||
final TextStyle? textStyle;
|
||||
|
||||
final TextInputType? textInputType;
|
||||
|
||||
final int? maxLines;
|
||||
|
||||
final String? hintText;
|
||||
|
||||
final TextStyle? hintStyle;
|
||||
|
||||
final Widget? prefix;
|
||||
|
||||
final BoxConstraints? prefixConstraints;
|
||||
|
||||
final Widget? suffix;
|
||||
|
||||
final BoxConstraints? suffixConstraints;
|
||||
|
||||
final EdgeInsets? contentPadding;
|
||||
|
||||
final InputBorder? borderDecoration;
|
||||
|
||||
final Color? fillColor;
|
||||
|
||||
final bool? filled;
|
||||
|
||||
final FormFieldValidator<String>? validator;
|
||||
|
||||
final Function(String)? onChanged;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return alignment != null
|
||||
? Align(
|
||||
alignment: alignment ?? Alignment.center,
|
||||
child: searchViewWidget(context))
|
||||
: searchViewWidget(context);
|
||||
}
|
||||
|
||||
searchViewWidget(BuildContext context) => SizedBox(
|
||||
width: width ?? double.maxFinite,
|
||||
child: TextFormField(
|
||||
scrollPadding:
|
||||
EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
|
||||
controller: controller,
|
||||
focusNode: focusNode,
|
||||
onTapOutside: (event) => onTapOutside(),
|
||||
autofocus: autofocus!,
|
||||
style: textStyle ?? CustomTextStyles.bodySmallMulishBluegray800,
|
||||
keyboardType: textInputType,
|
||||
maxLines: maxLines ?? 1,
|
||||
decoration: decoration,
|
||||
validator: validator,
|
||||
onChanged: (String value) => onChanged?.call(value),
|
||||
),
|
||||
);
|
||||
|
||||
void onTapOutside() {
|
||||
if (focusNode != null) {
|
||||
focusNode?.unfocus();
|
||||
} else {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
}
|
||||
}
|
||||
|
||||
InputDecoration get decoration => InputDecoration(
|
||||
hintText: hintText ?? "",
|
||||
hintStyle: hintStyle ?? CustomTextStyles.bodySmallMulishBluegray800,
|
||||
prefixIcon: prefix ??
|
||||
SizedBox(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(left: 10),
|
||||
child: Icon(Icons.search)),
|
||||
),
|
||||
prefixIconConstraints: prefixConstraints ??
|
||||
BoxConstraints(
|
||||
maxHeight: 40.v,
|
||||
),
|
||||
suffixIcon: suffix ??
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
right: 15.h,
|
||||
),
|
||||
child: IconButton(
|
||||
onPressed: () => controller!.clear(),
|
||||
icon: Icon(
|
||||
Icons.clear,
|
||||
color: Colors.grey.shade600,
|
||||
),
|
||||
),
|
||||
),
|
||||
suffixIconConstraints: suffixConstraints ??
|
||||
BoxConstraints(
|
||||
maxHeight: 40.v,
|
||||
),
|
||||
isDense: true,
|
||||
contentPadding: contentPadding ??
|
||||
EdgeInsets.only(
|
||||
top: 11.v,
|
||||
right: 11.h,
|
||||
bottom: 11.v,
|
||||
),
|
||||
fillColor: fillColor ?? appTheme.gray100,
|
||||
filled: filled,
|
||||
border: borderDecoration ??
|
||||
OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8.h),
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
enabledBorder: borderDecoration ??
|
||||
OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8.h),
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
focusedBorder: borderDecoration ??
|
||||
OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8.h),
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
import 'bloc/chat_select_bloc.dart';
|
||||
import 'models/chat_select_model.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import '../chat_select_screen/chat_search_view.dart';
|
||||
import 'package:eatvio_app/widgets/custom_bottom_bar.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
|
||||
@@ -20,41 +22,53 @@ class ChatSelectScreen extends StatelessWidget {
|
||||
mediaQueryData = MediaQuery.of(context);
|
||||
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)
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
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: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
BlocSelector<ChatSelectBloc, ChatSelectState,
|
||||
TextEditingController?>(
|
||||
selector: (state) => TextEditingController(),
|
||||
builder: (context, searchController) {
|
||||
return CustomSearchView(
|
||||
controller: searchController,
|
||||
hintText: "Поиск",
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(height: 20.v),
|
||||
_buildUserprofile(context)
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: _buildBottomBar(context)),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -63,7 +77,6 @@ class ChatSelectScreen extends StatelessWidget {
|
||||
selector: (state) => state.chatSelectModelObj,
|
||||
builder: (context, chatSelectModelObj) {
|
||||
return ListView.separated(
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
separatorBuilder: (context, index) {
|
||||
return SizedBox(
|
||||
@@ -72,9 +85,9 @@ class ChatSelectScreen extends StatelessWidget {
|
||||
},
|
||||
itemCount: chatSelectModelObj?.userprofileItemList.length ?? 0,
|
||||
itemBuilder: (context, index) {
|
||||
UserprofileItemModel model =
|
||||
ChatItemModel model =
|
||||
chatSelectModelObj?.userprofileItemList[index] ??
|
||||
UserprofileItemModel();
|
||||
ChatItemModel();
|
||||
return UserprofileItemWidget(
|
||||
model,
|
||||
);
|
||||
@@ -83,4 +96,8 @@ class ChatSelectScreen extends StatelessWidget {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
_buildBottomBar(BuildContext context) {
|
||||
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ 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(
|
||||
class ChatItemModel {
|
||||
ChatItemModel(
|
||||
{this.userImage,
|
||||
this.username,
|
||||
this.dateText,
|
||||
|
||||
@@ -8,8 +8,8 @@ import 'package:eatvio_app/presentation/chat/chat_select_screen/models/chat_entr
|
||||
class ChatSelectModel extends Equatable {
|
||||
ChatSelectModel({this.userprofileItemList = const []});
|
||||
|
||||
List<UserprofileItemModel> userprofileItemList;
|
||||
ChatSelectModel copyWith({List<UserprofileItemModel>? userprofileItemList}) {
|
||||
List<ChatItemModel> userprofileItemList;
|
||||
ChatSelectModel copyWith({List<ChatItemModel>? userprofileItemList}) {
|
||||
return ChatSelectModel(
|
||||
userprofileItemList: userprofileItemList ?? this.userprofileItemList,
|
||||
);
|
||||
|
||||
@@ -10,7 +10,7 @@ class UserprofileItemWidget extends StatelessWidget {
|
||||
key: key,
|
||||
);
|
||||
|
||||
UserprofileItemModel userprofileItemModelObj;
|
||||
ChatItemModel userprofileItemModelObj;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
Reference in New Issue
Block a user