|
|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:test_sa/controllers/providers/api/regular_visits_provider.dart';
|
|
|
|
|
import 'package:test_sa/extensions/context_extension.dart';
|
|
|
|
|
import 'package:test_sa/extensions/int_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/string_extensions.dart';
|
|
|
|
|
@ -8,6 +9,8 @@ import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:test_sa/models/visits/visit.dart';
|
|
|
|
|
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
|
|
|
|
|
import 'package:test_sa/views/pages/user/visits/pantry/edit_pentry.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/loaders/app_loading.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/loaders/no_item_found.dart';
|
|
|
|
|
|
|
|
|
|
import '../../../../controllers/providers/api/user_provider.dart';
|
|
|
|
|
import '../../../../models/enums/user_types.dart';
|
|
|
|
|
@ -25,58 +28,69 @@ class VisitDetailsPage extends StatelessWidget {
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
UserProvider userProvider = Provider.of<UserProvider>(context);
|
|
|
|
|
|
|
|
|
|
RegularVisitsProvider _visitsProvider = Provider.of<RegularVisitsProvider>(context);
|
|
|
|
|
|
|
|
|
|
return Scaffold(
|
|
|
|
|
appBar: DefaultAppBar(title: context.translation.preventiveMaintenance),
|
|
|
|
|
body: SafeArea(
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
SingleChildScrollView(
|
|
|
|
|
child: Column(
|
|
|
|
|
//mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
// StatusLabel(
|
|
|
|
|
// label: visit.priority.name,
|
|
|
|
|
// id: visit.priority.id,
|
|
|
|
|
// textColor: AColors.getPriorityStatusTextColor(visit.priority.id),
|
|
|
|
|
// backgroundColor: AColors.getPriorityStatusColor(visit.priority.id)),
|
|
|
|
|
// 8.width,
|
|
|
|
|
StatusLabel(
|
|
|
|
|
label: visit.status.name,
|
|
|
|
|
id: visit.status.id,
|
|
|
|
|
textColor: AColors.getRequestStatusTextColorByName(visit.status.name),
|
|
|
|
|
backgroundColor: AColors.getRequestStatusColorByName(visit.status.name),
|
|
|
|
|
),
|
|
|
|
|
1.width.expanded,
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
visit.deviceEnglishName.heading5(context),
|
|
|
|
|
8.height,
|
|
|
|
|
'${context.translation.assetNumber}: ${visit.deviceNumber}'.bodyText(context),
|
|
|
|
|
'${context.translation.assetSN}: ${visit.deviceSerialNumber}'.bodyText(context),
|
|
|
|
|
'${context.translation.code}: ${visit.serialNumber}'.bodyText(context),
|
|
|
|
|
const Divider().defaultStyle(context),
|
|
|
|
|
'${context.translation.expectDate}: ${visit.expectDate?.toServiceRequestDetailsFormat}'.bodyText(context),
|
|
|
|
|
'${context.translation.actualDate}: ${visit.actualDate?.toServiceRequestDetailsFormat}'.bodyText(context),
|
|
|
|
|
const Divider().defaultStyle(context),
|
|
|
|
|
'${context.translation.assignedTo}: ${visit.assignTo}'.bodyText(context),
|
|
|
|
|
'${context.translation.engineerName}: ${visit.employName}'.bodyText(context),
|
|
|
|
|
'${context.translation.site}: ${visit.hospitalName}'.bodyText(context),
|
|
|
|
|
],
|
|
|
|
|
).toShadowContainer(context).paddingAll(16),
|
|
|
|
|
).expanded,
|
|
|
|
|
if (userProvider.user.type == UsersTypes.engineer && visit.status.id != 270)
|
|
|
|
|
AppFilledButton(
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.of(context).push(MaterialPageRoute(builder: (_) => EditPentry(visit: visit, pentry: visit.pentry)));
|
|
|
|
|
},
|
|
|
|
|
label: context.translation.updateRequest,
|
|
|
|
|
).paddingAll(16),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
child: FutureBuilder(
|
|
|
|
|
future: _visitsProvider.getVisitObjectById(visit.id),
|
|
|
|
|
builder: (context, snap) {
|
|
|
|
|
if (snap.connectionState == ConnectionState.waiting) {
|
|
|
|
|
return const ALoading();
|
|
|
|
|
} else if (snap.hasData) {
|
|
|
|
|
Visit visit = snap.data;
|
|
|
|
|
|
|
|
|
|
return Column(children: [
|
|
|
|
|
SingleChildScrollView(
|
|
|
|
|
child: Column(
|
|
|
|
|
//mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
// StatusLabel(
|
|
|
|
|
// label: visit.priority.name,
|
|
|
|
|
// id: visit.priority.id,
|
|
|
|
|
// textColor: AColors.getPriorityStatusTextColor(visit.priority.id),
|
|
|
|
|
// backgroundColor: AColors.getPriorityStatusColor(visit.priority.id)),
|
|
|
|
|
// 8.width,
|
|
|
|
|
StatusLabel(
|
|
|
|
|
label: visit.status.name,
|
|
|
|
|
id: visit.status.id,
|
|
|
|
|
textColor: AColors.getRequestStatusTextColorByName(visit.status.name),
|
|
|
|
|
backgroundColor: AColors.getRequestStatusColorByName(visit.status.name),
|
|
|
|
|
),
|
|
|
|
|
1.width.expanded,
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
visit.deviceEnglishName.heading5(context),
|
|
|
|
|
8.height,
|
|
|
|
|
'${context.translation.assetNumber}: ${visit.deviceNumber}'.bodyText(context),
|
|
|
|
|
'${context.translation.assetSN}: ${visit.deviceSerialNumber}'.bodyText(context),
|
|
|
|
|
'${context.translation.code}: ${visit.serialNumber}'.bodyText(context),
|
|
|
|
|
const Divider().defaultStyle(context),
|
|
|
|
|
'${context.translation.expectDate}: ${visit.expectDate?.toServiceRequestDetailsFormat}'.bodyText(context),
|
|
|
|
|
'${context.translation.actualDate}: ${visit.actualDate?.toServiceRequestDetailsFormat}'.bodyText(context),
|
|
|
|
|
const Divider().defaultStyle(context),
|
|
|
|
|
'${context.translation.assignedTo}: ${visit.assignTo}'.bodyText(context),
|
|
|
|
|
'${context.translation.engineerName}: ${visit.employName}'.bodyText(context),
|
|
|
|
|
'${context.translation.site}: ${visit.hospitalName}'.bodyText(context),
|
|
|
|
|
],
|
|
|
|
|
).toShadowContainer(context).paddingAll(16),
|
|
|
|
|
).expanded,
|
|
|
|
|
if (userProvider.user.type == UsersTypes.engineer && visit.status.id != 270)
|
|
|
|
|
AppFilledButton(
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.of(context).push(MaterialPageRoute(builder: (_) => EditPentry(visit: visit, pentry: visit.pentry)));
|
|
|
|
|
},
|
|
|
|
|
label: context.translation.updateRequest,
|
|
|
|
|
).paddingAll(16)
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
return NoItemFound(message: context.translation.noDataFound);
|
|
|
|
|
}),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|