Working on ppm
parent
3c91abf47d
commit
3299c0c7a4
@ -1,172 +1,101 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:test_sa/controllers/localization/localization.dart';
|
|
||||||
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
|
||||||
import 'package:test_sa/extensions/context_extension.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';
|
||||||
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
||||||
import 'package:test_sa/models/enums/user_types.dart';
|
import 'package:test_sa/models/enums/user_types.dart';
|
||||||
import 'package:test_sa/models/subtitle.dart';
|
|
||||||
import 'package:test_sa/models/visits/visit.dart';
|
import 'package:test_sa/models/visits/visit.dart';
|
||||||
import 'package:test_sa/views/app_style/sizing.dart';
|
import 'package:test_sa/views/pages/user/visits/visit_details.dart';
|
||||||
import 'package:test_sa/views/widgets/visits/visit_status.dart';
|
|
||||||
|
import '../../../controllers/providers/api/user_provider.dart';
|
||||||
|
import '../../../extensions/text_extensions.dart';
|
||||||
|
import '../../app_style/colors.dart';
|
||||||
|
import '../../pages/user/visits/pantry/future_edit_pently.dart';
|
||||||
|
import '../requests/request_status.dart';
|
||||||
|
|
||||||
class VisitItem extends StatelessWidget {
|
class VisitItem extends StatelessWidget {
|
||||||
final Visit visit;
|
final Visit visit;
|
||||||
final int index;
|
|
||||||
final bool isSelected;
|
|
||||||
final bool activeSelectMod;
|
|
||||||
final Function(Visit) onPressed;
|
|
||||||
final Function(Visit) onLongPress;
|
|
||||||
final Function(Visit) onSelect;
|
|
||||||
|
|
||||||
const VisitItem({Key key, this.visit, this.onPressed, this.isSelected = false, this.activeSelectMod = false, this.onLongPress, this.onSelect, this.index}) : super(key: key);
|
const VisitItem({Key key, this.visit}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
UserProvider userProvider = Provider.of<UserProvider>(context);
|
UserProvider userProvider = Provider.of<UserProvider>(context);
|
||||||
Color itemColor = index % 2 == 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onPrimary;
|
return Container(
|
||||||
Color onItemColor = index % 2 != 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onPrimary;
|
decoration: ShapeDecoration(
|
||||||
|
color: Colors.white,
|
||||||
return Padding(
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
|
||||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
shadows: const [BoxShadow(color: Color(0x07000000), blurRadius: 14, offset: Offset(0, 0), spreadRadius: 0)],
|
||||||
child: ElevatedButton(
|
),
|
||||||
style: ElevatedButton.styleFrom(
|
padding: const EdgeInsets.all(16),
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 8),
|
margin: EdgeInsets.only(bottom: 8.toScreenHeight),
|
||||||
backgroundColor: itemColor,
|
child: Row(
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
if (activeSelectMod && userProvider.user.type == UsersTypes.engineer) {
|
|
||||||
onSelect(visit);
|
|
||||||
} else {
|
|
||||||
onPressed(visit);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onLongPress: userProvider.user.type == UsersTypes.engineer
|
|
||||||
? () {
|
|
||||||
onLongPress(visit);
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
"S.N: ${visit.deviceSerialNumber}" ?? "No serial number",
|
|
||||||
style: Theme.of(context).textTheme.titleLarge.copyWith(color: onItemColor, fontSize: 16, fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
AnimatedSwitcher(
|
|
||||||
duration: const Duration(milliseconds: 400),
|
|
||||||
child: Visibility(
|
|
||||||
key: ValueKey(activeSelectMod),
|
|
||||||
visible: activeSelectMod,
|
|
||||||
child: SizedBox(
|
|
||||||
height: 18,
|
|
||||||
child: Checkbox(
|
|
||||||
activeColor: Colors.black38,
|
|
||||||
value: isSelected,
|
|
||||||
onChanged: (value) {
|
|
||||||
onSelect(visit);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
VisitStatusLabel(
|
|
||||||
visit: visit,
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Divider(
|
|
||||||
color: onItemColor,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
visit.deviceNumber ?? "",
|
|
||||||
style: Theme.of(context).textTheme.titleMedium.copyWith(color: onItemColor, fontSize: 14),
|
|
||||||
),
|
|
||||||
Divider(
|
|
||||||
color: onItemColor,
|
|
||||||
),
|
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
// StatusLabel(
|
||||||
child: Text(
|
// label: visit.priority.name,
|
||||||
visit.hospitalName ?? "No client found",
|
// id: visit.priority.id,
|
||||||
style: Theme.of(context).textTheme.titleMedium.copyWith(
|
// textColor: AColors.getPriorityStatusTextColor(visit.priority.id),
|
||||||
color: onItemColor,
|
// backgroundColor: AColors.getPriorityStatusColor(visit.priority.id)),
|
||||||
fontSize: 14,
|
// 8.width,
|
||||||
),
|
StatusLabel(
|
||||||
),
|
label: visit.status.name,
|
||||||
),
|
id: visit.status.id,
|
||||||
|
textColor: AColors.getRequestStatusTextColor(visit.status.value),
|
||||||
|
backgroundColor: AColors.getRequestStatusColor(visit.status.value),
|
||||||
|
),
|
||||||
|
1.width.expanded,
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
8.height,
|
||||||
|
Text(visit.deviceEnglishName, style: AppTextStyles.heading5.copyWith(color: const Color(0xFF3B3D4A))),
|
||||||
|
8.height,
|
||||||
Text(
|
Text(
|
||||||
visit.modelAndBrand ?? "",
|
'${context.translation.assetNumber}: ${visit.deviceNumber}',
|
||||||
style: Theme.of(context).textTheme.titleMedium.copyWith(
|
style: AppTextStyles.bodyText.copyWith(color: const Color(0xFF757575)),
|
||||||
color: onItemColor,
|
|
||||||
fontSize: 14,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
if (visit.employName != null && visit.employName.isNotEmpty) Divider(color: onItemColor),
|
Text(
|
||||||
if (visit.employName != null && visit.employName.isNotEmpty)
|
'Asset Serial No.: ${visit.deviceSerialNumber}',
|
||||||
Row(
|
style: AppTextStyles.bodyText.copyWith(color: const Color(0xFF757575)),
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
visit.employName ?? "No employ found",
|
|
||||||
style: Theme.of(context).textTheme.titleLarge.copyWith(color: onItemColor, fontSize: 14, fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// Text(
|
|
||||||
// visit.contactStatus ?? "",
|
|
||||||
// style: Theme.of(context).textTheme.subtitle1.copyWith(
|
|
||||||
// color: onItemColor,
|
|
||||||
// fontSize: 14,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
Divider(
|
Text(
|
||||||
color: onItemColor,
|
'Code: ${visit.serialNumber}',
|
||||||
|
style: AppTextStyles.bodyText.copyWith(color: const Color(0xFF757575)),
|
||||||
),
|
),
|
||||||
|
16.height,
|
||||||
Row(
|
Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
context.translation.expectDate,
|
|
||||||
style: Theme.of(context).textTheme.titleLarge.copyWith(color: onItemColor, fontSize: 14),
|
|
||||||
),
|
|
||||||
Text(
|
Text(
|
||||||
visit.expectDate ?? context.translation.noDateFound,
|
'View Details',
|
||||||
style: Theme.of(context).textTheme.titleLarge.copyWith(color: onItemColor, fontSize: 14),
|
style: AppTextStyles.bodyText.copyWith(color: const Color(0xFF4A8DB7)),
|
||||||
),
|
),
|
||||||
|
4.width,
|
||||||
|
const Icon(Icons.arrow_forward, color: Color(0xFF4A8DB7), size: 14)
|
||||||
],
|
],
|
||||||
),
|
).onPress(() {
|
||||||
),
|
Navigator.of(context).push(MaterialPageRoute(builder: (_) => VisitDetailsPage(visit: visit)));
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
).expanded,
|
||||||
|
8.width,
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
children: [
|
||||||
Text(
|
if (userProvider.user.type == UsersTypes.engineer && visit.status.value != 5 && visit.status.value != 3)
|
||||||
context.translation.actualDate,
|
"edit".toSvgAsset(height: 48, width: 48).onPress(() {
|
||||||
style: Theme.of(context).textTheme.titleLarge.copyWith(color: onItemColor, fontSize: 14),
|
Navigator.of(context).push(MaterialPageRoute(builder: (_) => FutureEditPentry(visit: visit)));
|
||||||
),
|
}),
|
||||||
Text(
|
Text(visit.createdOn != null ? visit.createdOn.toServiceRequestCardFormat : "", textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: const Color(0xFF3B3D4A))),
|
||||||
visit.actualDate ?? context.translation.noDateFound,
|
|
||||||
style: Theme.of(context).textTheme.titleLarge.copyWith(color: onItemColor, fontSize: 14),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue