You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cloudsolutions-atoms/lib/views/pages/user/requests/pending_requests_screen.dart

74 lines
3.7 KiB
Dart

import 'package:flutter/material.dart';
import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/service_request/pending_service_request_model.dart';
import 'package:test_sa/models/service_request/service_request.dart';
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
import 'package:test_sa/views/pages/user/requests/service_request_details.dart';
import 'package:test_sa/views/widgets/sound/sound_player.dart';
class PendingServiceRequestScreen extends StatelessWidget {
final PendingAssetServiceRequest pendingAssetServiceRequest;
const PendingServiceRequestScreen(this.pendingAssetServiceRequest, {Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: DefaultAppBar(title: "Pending Requests (${pendingAssetServiceRequest.details!.length})"),
body: ListView.separated(
itemCount: pendingAssetServiceRequest.details!.length,
padding: const EdgeInsets.all(16),
separatorBuilder: (cxt, index) => 12.height,
itemBuilder: (cxt, index) => Container(
padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 16),
decoration: BoxDecoration(
color: Colors.grey[200],
borderRadius: BorderRadius.circular(16),
),
child: Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
pendingAssetServiceRequest.details![index].message!.cleanupWhitespace.capitalizeFirstOfEach ?? "",
style: Theme.of(context).textTheme.bodyLarge,
),
if ((pendingAssetServiceRequest.details![index].callComments ?? "").isNotEmpty) ...[
4.height,
Text(
"${pendingAssetServiceRequest.details![index].callComments}",
style: Theme.of(context).textTheme.bodyMedium!.copyWith(color: const Color(0xff7D859A)),
),
],
if ((pendingAssetServiceRequest.details![index].voiceNote ?? "").isNotEmpty) ...[
4.height,
ASoundPlayer(
audio: URLs.getFileUrl(pendingAssetServiceRequest.details![index].voiceNote)!,
),
],
if ((pendingAssetServiceRequest.details![index].createdBy ?? "").isNotEmpty) ...[
4.height,
Text(
"Created By: ${pendingAssetServiceRequest.details![index].createdBy}",
style: Theme.of(context).textTheme.bodyMedium,
),
]
],
).expanded,
8.width,
const Icon(Icons.arrow_forward_ios, size: 16)
],
),
).onPress(() {
Navigator.of(context).push(MaterialPageRoute(
builder: (_) => ServiceRequestDetailsPage(
serviceRequest: ServiceRequest(id: pendingAssetServiceRequest.details![index].id.toString()),
)));
})));
}
}