|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:flutter/material.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/models/enums/user_types.dart';
|
|
|
|
|
import 'package:test_sa/models/subtitle.dart';
|
|
|
|
|
import 'package:test_sa/models/visits/visit.dart';
|
|
|
|
|
import 'package:test_sa/views/app_style/sizing.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/visits/visit_status.dart';
|
|
|
|
|
|
|
|
|
|
class VisitItem extends StatelessWidget {
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
UserProvider _userProvider = Provider.of<UserProvider>(context);
|
|
|
|
|
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;
|
|
|
|
|
Subtitle _subtitle = AppLocalization.of(context).subtitle;
|
|
|
|
|
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)),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
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,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Text(
|
|
|
|
|
"S.N: " + visit.deviceSerialNumber ?? "No serial number",
|
|
|
|
|
style: Theme.of(context).textTheme.headline6.copyWith(color: onItemColor, fontSize: 16, fontWeight: FontWeight.bold),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
AnimatedSwitcher(
|
|
|
|
|
duration: 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,
|
|
|
|
|
),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Text(
|
|
|
|
|
visit.hospitalName ?? "No client found",
|
|
|
|
|
style: Theme.of(context).textTheme.subtitle1.copyWith(
|
|
|
|
|
color: onItemColor,
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
visit.modelAndBrand ?? "",
|
|
|
|
|
style: Theme.of(context).textTheme.subtitle1.copyWith(
|
|
|
|
|
color: onItemColor,
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Divider(color: onItemColor),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Text(
|
|
|
|
|
visit.employName ?? "No employ found",
|
|
|
|
|
style: Theme.of(context).textTheme.headline6.copyWith(color: onItemColor, fontSize: 14, fontWeight: FontWeight.bold),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
// Text(
|
|
|
|
|
// visit.contactStatus ?? "",
|
|
|
|
|
// style: Theme.of(context).textTheme.subtitle1.copyWith(
|
|
|
|
|
// color: onItemColor,
|
|
|
|
|
// fontSize: 14,
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
Divider(
|
|
|
|
|
color: onItemColor,
|
|
|
|
|
),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
_subtitle.expectDate,
|
|
|
|
|
style: Theme.of(context).textTheme.headline6.copyWith(
|
|
|
|
|
color: onItemColor,
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
visit.expectDate ?? _subtitle.noDateFound,
|
|
|
|
|
style: Theme.of(context).textTheme.headline6.copyWith(
|
|
|
|
|
color: onItemColor,
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
_subtitle.actualDate,
|
|
|
|
|
style: Theme.of(context).textTheme.headline6.copyWith(
|
|
|
|
|
color: onItemColor,
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
visit.actualDate ?? _subtitle.noDateFound,
|
|
|
|
|
style: Theme.of(context).textTheme.headline6.copyWith(
|
|
|
|
|
color: onItemColor,
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
),
|
|
|
|
|
// Text(
|
|
|
|
|
// visit.contactStatus ?? "",
|
|
|
|
|
// style: Theme.of(context).textTheme.subtitle1.copyWith(
|
|
|
|
|
// color: onItemColor,
|
|
|
|
|
// fontSize: 14,
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|