Enhancements on comments bottom sheet

design_3.0_demo_module
zaid_daoud 2 years ago
parent 5b9a33c519
commit c2eb7b0dad

@ -37,10 +37,12 @@ class _CommentsBottomSheetState extends State<CommentsBottomSheet> {
@override
Widget build(BuildContext context) {
final commentsProvider = Provider.of<CommentsProvider>(context, listen: false);
final commentsProvider = Provider.of<CommentsProvider>(context);
final userProvider = Provider.of<UserProvider>(context, listen: false);
return Container(
height: MediaQuery.of(context).size.height * 0.55,
return SingleChildScrollView(
child: Wrap(
children: [
Container(
clipBehavior: Clip.antiAlias,
margin: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
decoration: BoxDecoration(
@ -74,13 +76,18 @@ class _CommentsBottomSheetState extends State<CommentsBottomSheet> {
child: context.translation.comments.heading3(context).custom(fontWeight: FontWeight.w600),
),
commentsProvider.comments.isEmpty
? NoItemFound(message: context.translation.noDataFound).expanded
? SizedBox(
height: MediaQuery.of(context).size.height * 0.25,
child: NoItemFound(message: context.translation.noDataFound),
)
: 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),
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
separatorBuilder: (cxt, index) => 8.height,
itemBuilder: (context, itemIndex) {
final model = commentsProvider.comments[itemIndex];
@ -100,10 +107,10 @@ class _CommentsBottomSheetState extends State<CommentsBottomSheet> {
).toShadowContainer(context);
},
),
).expanded,
),
],
),
).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(
@ -128,6 +135,9 @@ class _CommentsBottomSheetState extends State<CommentsBottomSheet> {
],
),
),
),
],
),
);
}
}

@ -37,17 +37,24 @@ class ServiceRequestDetailsPage extends StatefulWidget {
}
class _ServiceRequestDetailsPageState extends State<ServiceRequestDetailsPage> {
bool loading = false;
ServiceRequest serviceRequest;
@override
void didChangeDependencies() {
void initState() {
super.initState();
loading = true;
setState(() {});
WidgetsFlutterBinding.ensureInitialized().addPostFrameCallback((timeStamp) async {
Provider.of<CommentsProvider>(context, listen: false).reset();
super.didChangeDependencies();
serviceRequest = await Provider.of<ServiceRequestsProvider>(context, listen: false).getServiceRequestObjectById(requestId: widget.serviceRequest.id);
loading = false;
setState(() {});
});
}
@override
Widget build(BuildContext context) {
UserProvider _userProvider = Provider.of<UserProvider>(context);
ServiceRequestsProvider _serviceRequestsProvider = Provider.of<ServiceRequestsProvider>(context);
// _serviceRequestsProvider.getServiceRequestObjectById(requestId: serviceRequest.id);
UserProvider _userProvider = Provider.of<UserProvider>(context, listen: false);
Widget informationCard(ServiceRequest serviceRequest) {
return Column(
@ -210,14 +217,9 @@ class _ServiceRequestDetailsPageState extends State<ServiceRequestDetailsPage> {
appBar: DefaultAppBar(title: context.translation.serviceDetails),
//backgroundColor: const Color(0xfff8f9fb),
body: SafeArea(
child: FutureBuilder(
future: _serviceRequestsProvider.getServiceRequestObjectById(requestId: widget.serviceRequest.id),
builder: (context, snap) {
if (snap.connectionState == ConnectionState.waiting) {
return const ALoading();
} else if (snap.hasData) {
ServiceRequest serviceRequest = snap.data;
return Column(
child: loading
? const ALoading().center
: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SingleChildScrollView(
@ -255,10 +257,6 @@ class _ServiceRequestDetailsPageState extends State<ServiceRequestDetailsPage> {
))
.paddingOnly(start: 16, end: 16, bottom: 24),
],
);
}
return const SizedBox();
},
),
),
);

Loading…
Cancel
Save