|
|
|
|
@ -37,7 +37,7 @@ class _CommentsBottomSheetState extends State<CommentsBottomSheet> {
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final commentsProvider = Provider.of<CommentsProvider>(context);
|
|
|
|
|
final commentsProvider = Provider.of<CommentsProvider>(context, listen: false);
|
|
|
|
|
final userProvider = Provider.of<UserProvider>(context, listen: false);
|
|
|
|
|
return Container(
|
|
|
|
|
height: MediaQuery.of(context).size.height * 0.55,
|
|
|
|
|
@ -50,78 +50,82 @@ class _CommentsBottomSheetState extends State<CommentsBottomSheet> {
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth, vertical: 8.toScreenHeight),
|
|
|
|
|
child: Form(
|
|
|
|
|
key: _formKey,
|
|
|
|
|
child: LoadingManager(
|
|
|
|
|
isLoading: commentsProvider.isLoading,
|
|
|
|
|
isFailedLoading: commentsProvider.comments == null,
|
|
|
|
|
stateCode: commentsProvider.stateCode,
|
|
|
|
|
onRefresh: () async {
|
|
|
|
|
commentsProvider.reset();
|
|
|
|
|
await commentsProvider.getComments(callId: widget.requestId);
|
|
|
|
|
},
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
width: 40.toScreenWidth,
|
|
|
|
|
height: 5.toScreenHeight,
|
|
|
|
|
decoration: BoxDecoration(color: AppColor.neutral40, borderRadius: BorderRadius.circular(30)),
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
LoadingManager(
|
|
|
|
|
isLoading: commentsProvider.isLoading,
|
|
|
|
|
isFailedLoading: commentsProvider.comments == null,
|
|
|
|
|
stateCode: commentsProvider.stateCode,
|
|
|
|
|
onRefresh: () async {
|
|
|
|
|
commentsProvider.reset();
|
|
|
|
|
await commentsProvider.getComments(callId: widget.requestId);
|
|
|
|
|
},
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
width: 40.toScreenWidth,
|
|
|
|
|
height: 5.toScreenHeight,
|
|
|
|
|
decoration: BoxDecoration(color: AppColor.neutral40, borderRadius: BorderRadius.circular(30)),
|
|
|
|
|
),
|
|
|
|
|
16.height,
|
|
|
|
|
Align(
|
|
|
|
|
alignment: AlignmentDirectional.centerStart,
|
|
|
|
|
child: context.translation.comments.heading3(context).custom(fontWeight: FontWeight.w600),
|
|
|
|
|
),
|
|
|
|
|
commentsProvider.comments.isEmpty
|
|
|
|
|
? NoItemFound(message: context.translation.noDataFound).expanded
|
|
|
|
|
: LazyLoading(
|
|
|
|
|
nextPage: commentsProvider.nextPage,
|
|
|
|
|
onLazyLoad: () async => await commentsProvider.getComments(callId: widget.requestId),
|
|
|
|
|
child: ListView.separated(
|
|
|
|
|
itemCount: commentsProvider.comments.length,
|
|
|
|
|
padding: const EdgeInsets.only(top: 16, bottom: 8),
|
|
|
|
|
separatorBuilder: (cxt, index) => 8.height,
|
|
|
|
|
itemBuilder: (context, itemIndex) {
|
|
|
|
|
final model = commentsProvider.comments[itemIndex];
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
(model?.createdBy?.userName ?? "Nurse").heading6(context),
|
|
|
|
|
8.height,
|
|
|
|
|
(model?.comment ?? "").bodyText(context),
|
|
|
|
|
8.height,
|
|
|
|
|
Align(
|
|
|
|
|
alignment: AlignmentDirectional.bottomEnd,
|
|
|
|
|
child: Text(DateTime.tryParse(model.createdOn).toIso8601String().toServiceRequestDetailsFormat,
|
|
|
|
|
style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50)),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
).toShadowContainer(context);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
).expanded,
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
16.height,
|
|
|
|
|
Align(
|
|
|
|
|
alignment: AlignmentDirectional.centerStart,
|
|
|
|
|
child: context.translation.comments.heading3(context).custom(fontWeight: FontWeight.w600),
|
|
|
|
|
).expanded,
|
|
|
|
|
if (userProvider.user.type == UsersTypes.normal_user) 8.height,
|
|
|
|
|
if (userProvider.user.type == UsersTypes.normal_user) // todo its keeps loading when open keyboard or dismiss
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
labelText: "Type any comment",
|
|
|
|
|
backgroundColor: AppColor.neutral30,
|
|
|
|
|
alignLabelWithHint: true,
|
|
|
|
|
showShadow: false,
|
|
|
|
|
validator: (value) => Validator.hasValue(value) ? null : context.translation.requiredField,
|
|
|
|
|
textInputType: TextInputType.multiline,
|
|
|
|
|
suffixIcon: "comment_send".toSvgAsset().paddingOnly(end: 16).onPress(() {
|
|
|
|
|
if (_formKey.currentState.validate()) {
|
|
|
|
|
_formKey.currentState.save();
|
|
|
|
|
final comment = Comment(id: 0, callRequestId: num.tryParse(widget.requestId ?? ""), comment: text);
|
|
|
|
|
commentsProvider.addComment(context, comment: comment);
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
onSaved: (value) {
|
|
|
|
|
text = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
commentsProvider.comments.isEmpty
|
|
|
|
|
? NoItemFound(message: context.translation.noDataFound).expanded
|
|
|
|
|
: LazyLoading(
|
|
|
|
|
nextPage: commentsProvider.nextPage,
|
|
|
|
|
onLazyLoad: () async => await commentsProvider.getComments(callId: widget.requestId),
|
|
|
|
|
child: ListView.separated(
|
|
|
|
|
itemCount: commentsProvider.comments.length,
|
|
|
|
|
padding: const EdgeInsets.only(top: 16, bottom: 8),
|
|
|
|
|
separatorBuilder: (cxt, index) => 8.height,
|
|
|
|
|
itemBuilder: (context, itemIndex) {
|
|
|
|
|
final model = commentsProvider.comments[itemIndex];
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
(model?.createdBy?.userName ?? "Nurse").heading6(context),
|
|
|
|
|
8.height,
|
|
|
|
|
(model?.comment ?? "").bodyText(context),
|
|
|
|
|
8.height,
|
|
|
|
|
Align(
|
|
|
|
|
alignment: AlignmentDirectional.bottomEnd,
|
|
|
|
|
child: Text(DateTime.tryParse(model.createdOn).toIso8601String().toServiceRequestDetailsFormat,
|
|
|
|
|
style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50)),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
).toShadowContainer(context);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
).expanded,
|
|
|
|
|
if (userProvider.user.type == UsersTypes.normal_user) 8.height,
|
|
|
|
|
if (userProvider.user.type == UsersTypes.normal_user)
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
labelText: "Type any comment",
|
|
|
|
|
backgroundColor: AppColor.neutral30,
|
|
|
|
|
alignLabelWithHint: true,
|
|
|
|
|
showShadow: false,
|
|
|
|
|
validator: (value) => Validator.hasValue(value) ? null : context.translation.requiredField,
|
|
|
|
|
textInputType: TextInputType.multiline,
|
|
|
|
|
suffixIcon: "comment_send".toSvgAsset().paddingOnly(end: 16).onPress(() {
|
|
|
|
|
if (_formKey.currentState.validate()) {
|
|
|
|
|
_formKey.currentState.save();
|
|
|
|
|
final comment = Comment(id: 0, callRequestId: num.tryParse(widget.requestId ?? ""), comment: text);
|
|
|
|
|
commentsProvider.addComment(context, comment: comment);
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
onSaved: (value) {
|
|
|
|
|
text = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
16.height,
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
16.height,
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|