|
|
|
|
@ -5,6 +5,11 @@ import 'package:test_sa/controllers/localization/localization.dart';
|
|
|
|
|
import 'package:test_sa/controllers/providers/api/service_requests_provider.dart';
|
|
|
|
|
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
|
|
|
|
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
|
|
|
|
import 'package:test_sa/extensions/context_extension.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/enums/translation_keys.dart';
|
|
|
|
|
import 'package:test_sa/models/enums/user_types.dart';
|
|
|
|
|
import 'package:test_sa/models/service_request/service_request.dart';
|
|
|
|
|
import 'package:test_sa/models/subtitle.dart';
|
|
|
|
|
@ -31,219 +36,269 @@ class ServiceRequestItem extends StatelessWidget {
|
|
|
|
|
Color itemColor = index % 2 == 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onPrimary;
|
|
|
|
|
Color onItemColor = index % 2 != 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onPrimary;
|
|
|
|
|
|
|
|
|
|
return Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 4),
|
|
|
|
|
child: ElevatedButton(
|
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 8),
|
|
|
|
|
primary: itemColor,
|
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
|
borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
//padding: EdgeInsets.symmetric(vertical: 8,horizontal: 8),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
onPressed(request);
|
|
|
|
|
},
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
//Placeholder(color: onItemColor,fallbackWidth: 80,fallbackHeight: 80,),
|
|
|
|
|
_user.type == UsersTypes.normal_user && request.devicePhotos.isEmpty
|
|
|
|
|
? SizedBox.shrink()
|
|
|
|
|
: SizedBox(
|
|
|
|
|
width: 80,
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
return index % 2 == 0
|
|
|
|
|
? Container(
|
|
|
|
|
decoration: ShapeDecoration(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
|
borderRadius: BorderRadius.circular(20),
|
|
|
|
|
),
|
|
|
|
|
shadows: const [BoxShadow(color: Color(0x07000000), blurRadius: 14, offset: Offset(0, 0), spreadRadius: 0)],
|
|
|
|
|
),
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
request.devicePhotos?.isEmpty != false
|
|
|
|
|
? SizedBox.shrink()
|
|
|
|
|
: Column(
|
|
|
|
|
children: [
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 80,
|
|
|
|
|
width: 80,
|
|
|
|
|
child: ImageLoader(
|
|
|
|
|
url: request.devicePhotos.first,
|
|
|
|
|
boxFit: BoxFit.cover,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 24,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
_user.type == UsersTypes.engineer
|
|
|
|
|
? Material(
|
|
|
|
|
color: onItemColor,
|
|
|
|
|
elevation: 6,
|
|
|
|
|
shape: CircleBorder(),
|
|
|
|
|
child: IconButton(
|
|
|
|
|
icon: Icon(
|
|
|
|
|
Icons.description,
|
|
|
|
|
color: itemColor,
|
|
|
|
|
size: 32,
|
|
|
|
|
),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.of(context).push(
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
builder: (_) => CreateServiceReport(
|
|
|
|
|
request: request,
|
|
|
|
|
)),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
: SizedBox.shrink(),
|
|
|
|
|
//SizedBox(height: 8,),
|
|
|
|
|
Container(
|
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 10),
|
|
|
|
|
decoration: ShapeDecoration(
|
|
|
|
|
color: const Color(0xFFFFDBDC),
|
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
|
borderRadius: BorderRadius.circular(50),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
child: Text('HIGH PRIORITY', style: AppTextStyles.overline.copyWith(color: const Color(0xFF8C0409))),
|
|
|
|
|
),
|
|
|
|
|
8.width,
|
|
|
|
|
Container(
|
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 10),
|
|
|
|
|
decoration: ShapeDecoration(
|
|
|
|
|
color: const Color(0xFFFFEDBC),
|
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
|
borderRadius: BorderRadius.circular(50),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
child: Text('IN PROGRESS', style: AppTextStyles.overline.copyWith(color: const Color(0xFF886300))),
|
|
|
|
|
),
|
|
|
|
|
1.width.expanded,
|
|
|
|
|
Text('05 Dec, 2022\n09:30 AM', textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: const Color(0xFF3B3D4A))),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 8,
|
|
|
|
|
8.height,
|
|
|
|
|
Text(context.translate(TranslationKeys.serviceRequest), style: AppTextStyles.heading5.copyWith(color: const Color(0xFF3B3D4A))),
|
|
|
|
|
],
|
|
|
|
|
).paddingAll(16),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
)
|
|
|
|
|
: Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 4),
|
|
|
|
|
child: ElevatedButton(
|
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 8),
|
|
|
|
|
primary: itemColor,
|
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
|
borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
//padding: EdgeInsets.symmetric(vertical: 8,horizontal: 8),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
onPressed(request);
|
|
|
|
|
},
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: request.requestCode == null
|
|
|
|
|
? SizedBox.shrink()
|
|
|
|
|
: Text(
|
|
|
|
|
request.requestCode ?? "-----",
|
|
|
|
|
style: Theme.of(context).textTheme.headline6.copyWith(color: onItemColor, fontSize: 16, fontWeight: FontWeight.bold),
|
|
|
|
|
//Placeholder(color: onItemColor,fallbackWidth: 80,fallbackHeight: 80,),
|
|
|
|
|
_user.type == UsersTypes.normal_user && request.devicePhotos.isEmpty
|
|
|
|
|
? SizedBox.shrink()
|
|
|
|
|
: SizedBox(
|
|
|
|
|
width: 80,
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
request.devicePhotos?.isEmpty != false
|
|
|
|
|
? SizedBox.shrink()
|
|
|
|
|
: Column(
|
|
|
|
|
children: [
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 80,
|
|
|
|
|
width: 80,
|
|
|
|
|
child: ImageLoader(
|
|
|
|
|
url: request.devicePhotos.first,
|
|
|
|
|
boxFit: BoxFit.cover,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
request.engineerName == null
|
|
|
|
|
? SizedBox.shrink()
|
|
|
|
|
: Text(
|
|
|
|
|
request.engineerName ?? "",
|
|
|
|
|
style: Theme.of(context).textTheme.subtitle2.copyWith(color: onItemColor, fontSize: 12, fontWeight: FontWeight.normal),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
Divider(
|
|
|
|
|
color: onItemColor,
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
request.deviceNumber,
|
|
|
|
|
style: Theme.of(context).textTheme.subtitle2.copyWith(color: onItemColor, fontSize: 12, fontWeight: FontWeight.normal),
|
|
|
|
|
),
|
|
|
|
|
Divider(
|
|
|
|
|
color: onItemColor,
|
|
|
|
|
),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: request.deviceModel == null
|
|
|
|
|
? SizedBox.shrink()
|
|
|
|
|
: Text(
|
|
|
|
|
request.deviceModel ?? "Model not available",
|
|
|
|
|
style: Theme.of(context).textTheme.subtitle2.copyWith(color: onItemColor, fontSize: 12, fontWeight: FontWeight.normal),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 24,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
request.engineerMobile == null
|
|
|
|
|
? SizedBox.shrink()
|
|
|
|
|
: Text(
|
|
|
|
|
request.engineerMobile,
|
|
|
|
|
style: Theme.of(context).textTheme.subtitle1.copyWith(color: onItemColor, fontSize: 12, fontWeight: FontWeight.normal),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
Divider(
|
|
|
|
|
color: onItemColor,
|
|
|
|
|
),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: request.deviceSerialNumber == null
|
|
|
|
|
? SizedBox.shrink()
|
|
|
|
|
: Text(
|
|
|
|
|
request.deviceSerialNumber,
|
|
|
|
|
style: Theme.of(context).textTheme.subtitle2.copyWith(color: onItemColor, fontSize: 12, fontWeight: FontWeight.normal),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
_user.type == UsersTypes.engineer
|
|
|
|
|
? Material(
|
|
|
|
|
color: onItemColor,
|
|
|
|
|
elevation: 6,
|
|
|
|
|
shape: CircleBorder(),
|
|
|
|
|
child: IconButton(
|
|
|
|
|
icon: Icon(
|
|
|
|
|
Icons.description,
|
|
|
|
|
color: itemColor,
|
|
|
|
|
size: 32,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
request.deviceEnName == null
|
|
|
|
|
? SizedBox.shrink()
|
|
|
|
|
: Row(
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.of(context).push(
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
builder: (_) => CreateServiceReport(
|
|
|
|
|
request: request,
|
|
|
|
|
)),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
: SizedBox.shrink(),
|
|
|
|
|
//SizedBox(height: 8,),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 8,
|
|
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Text(
|
|
|
|
|
request.deviceEnName,
|
|
|
|
|
style: Theme.of(context).textTheme.subtitle1.copyWith(color: onItemColor, fontSize: 12, fontWeight: FontWeight.normal),
|
|
|
|
|
),
|
|
|
|
|
child: request.requestCode == null
|
|
|
|
|
? SizedBox.shrink()
|
|
|
|
|
: Text(
|
|
|
|
|
request.requestCode ?? "-----",
|
|
|
|
|
style: Theme.of(context).textTheme.headline6.copyWith(color: onItemColor, fontSize: 16, fontWeight: FontWeight.bold),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
request.engineerName == null
|
|
|
|
|
? SizedBox.shrink()
|
|
|
|
|
: Text(
|
|
|
|
|
request.engineerName ?? "",
|
|
|
|
|
style: Theme.of(context).textTheme.subtitle2.copyWith(color: onItemColor, fontSize: 12, fontWeight: FontWeight.normal),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
Divider(
|
|
|
|
|
color: onItemColor,
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
request.deviceNumber,
|
|
|
|
|
style: Theme.of(context).textTheme.subtitle2.copyWith(color: onItemColor, fontSize: 12, fontWeight: FontWeight.normal),
|
|
|
|
|
),
|
|
|
|
|
Divider(
|
|
|
|
|
color: onItemColor,
|
|
|
|
|
),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: request.deviceModel == null
|
|
|
|
|
? SizedBox.shrink()
|
|
|
|
|
: Text(
|
|
|
|
|
request.deviceModel ?? "Model not available",
|
|
|
|
|
style: Theme.of(context).textTheme.subtitle2.copyWith(color: onItemColor, fontSize: 12, fontWeight: FontWeight.normal),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
request.engineerMobile == null
|
|
|
|
|
? SizedBox.shrink()
|
|
|
|
|
: Text(
|
|
|
|
|
request.engineerMobile,
|
|
|
|
|
style: Theme.of(context).textTheme.subtitle1.copyWith(color: onItemColor, fontSize: 12, fontWeight: FontWeight.normal),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
Divider(
|
|
|
|
|
color: onItemColor,
|
|
|
|
|
),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: request.deviceSerialNumber == null
|
|
|
|
|
? SizedBox.shrink()
|
|
|
|
|
: Text(
|
|
|
|
|
request.deviceSerialNumber,
|
|
|
|
|
style: Theme.of(context).textTheme.subtitle2.copyWith(color: onItemColor, fontSize: 12, fontWeight: FontWeight.normal),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
request.deviceEnName == null
|
|
|
|
|
? SizedBox.shrink()
|
|
|
|
|
: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Text(
|
|
|
|
|
request.deviceEnName,
|
|
|
|
|
style: Theme.of(context).textTheme.subtitle1.copyWith(color: onItemColor, fontSize: 12, fontWeight: FontWeight.normal),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
Divider(
|
|
|
|
|
color: onItemColor,
|
|
|
|
|
),
|
|
|
|
|
Center(
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
|
|
|
|
child: Text(
|
|
|
|
|
request.callComments ?? "No maintenance issue found",
|
|
|
|
|
style: Theme.of(context).textTheme.subtitle1.copyWith(color: onItemColor),
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Divider(
|
|
|
|
|
color: onItemColor,
|
|
|
|
|
),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
request.date ?? "Date not available",
|
|
|
|
|
style: Theme.of(context).textTheme.subtitle2.copyWith(color: onItemColor),
|
|
|
|
|
),
|
|
|
|
|
Spacer(),
|
|
|
|
|
StatusLabel(label: request.statusLabel, color: AColors.getRequestStatusColor(request.statusValue)),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
request.nextVisitDate == null
|
|
|
|
|
? SizedBox.shrink()
|
|
|
|
|
: Column(
|
|
|
|
|
children: [
|
|
|
|
|
Divider(
|
|
|
|
|
color: onItemColor,
|
|
|
|
|
Divider(
|
|
|
|
|
color: onItemColor,
|
|
|
|
|
),
|
|
|
|
|
Center(
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
|
|
|
|
child: Text(
|
|
|
|
|
request.callComments ?? "No maintenance issue found",
|
|
|
|
|
style: Theme.of(context).textTheme.subtitle1.copyWith(color: onItemColor),
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
_subtitle.nextVisitDate,
|
|
|
|
|
style: Theme.of(context).textTheme.subtitle2.copyWith(color: onItemColor),
|
|
|
|
|
),
|
|
|
|
|
Spacer(),
|
|
|
|
|
Text(
|
|
|
|
|
DateFormat('EE dd/MM/yyyy').format(request.nextVisitDate),
|
|
|
|
|
style: Theme.of(context).textTheme.subtitle2.copyWith(color: onItemColor),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Divider(
|
|
|
|
|
color: onItemColor,
|
|
|
|
|
),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
request.date ?? "Date not available",
|
|
|
|
|
style: Theme.of(context).textTheme.subtitle2.copyWith(color: onItemColor),
|
|
|
|
|
),
|
|
|
|
|
Spacer(),
|
|
|
|
|
StatusLabel(label: request.statusLabel, color: AColors.getRequestStatusColor(request.statusValue)),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
request.nextVisitDate == null
|
|
|
|
|
? SizedBox.shrink()
|
|
|
|
|
: Column(
|
|
|
|
|
children: [
|
|
|
|
|
Divider(
|
|
|
|
|
color: onItemColor,
|
|
|
|
|
),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
_subtitle.nextVisitDate,
|
|
|
|
|
style: Theme.of(context).textTheme.subtitle2.copyWith(color: onItemColor),
|
|
|
|
|
),
|
|
|
|
|
Spacer(),
|
|
|
|
|
Text(
|
|
|
|
|
DateFormat('EE dd/MM/yyyy').format(request.nextVisitDate),
|
|
|
|
|
style: Theme.of(context).textTheme.subtitle2.copyWith(color: onItemColor),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|