horario pro
This commit is contained in:
@@ -0,0 +1,161 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:professional_repository/professional_repository.dart';
|
||||
|
||||
class ScheduleItem extends StatelessWidget {
|
||||
ScheduleEntity schedule;
|
||||
String label;
|
||||
final ValueChanged<ScheduleEntity> onChanged;
|
||||
|
||||
ScheduleItem(
|
||||
{super.key,
|
||||
required this.label,
|
||||
required this.schedule,
|
||||
required this.onChanged});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
Switch(
|
||||
value: schedule.enabled,
|
||||
onChanged: (value) {
|
||||
onChanged.call(schedule.copyWith(enabled: value));
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
Visibility(
|
||||
visible: schedule.enabled,
|
||||
child: Row(
|
||||
children: [
|
||||
const Expanded(
|
||||
child: Text(
|
||||
'Jornada continua',
|
||||
style: TextStyle(
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
Switch(
|
||||
value: schedule.continuousDay,
|
||||
onChanged: (value) {
|
||||
onChanged.call(schedule.copyWith(continuousDay: value));
|
||||
},
|
||||
),
|
||||
],
|
||||
)),
|
||||
Visibility(
|
||||
visible: schedule.enabled,
|
||||
child: hoursRangesBody(context),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
hoursRangesBody(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
timePickerField(
|
||||
context: context,
|
||||
text: schedule.getFormatTime(schedule.range1Hour1),
|
||||
onPick: (pickedTime) {
|
||||
onChanged.call(schedule.copyWith(range1Hour1: pickedTime));
|
||||
},
|
||||
),
|
||||
Center(
|
||||
child: Container(
|
||||
width: 10,
|
||||
height: 1,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: !schedule.continuousDay,
|
||||
child: timePickerField(
|
||||
context: context,
|
||||
text: schedule.getFormatTime(schedule.range1Hour2),
|
||||
onPick: (pickedTime) {
|
||||
onChanged.call(schedule.copyWith(range1Hour2: pickedTime));
|
||||
},
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: !schedule.continuousDay,
|
||||
child: const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: !schedule.continuousDay,
|
||||
child: timePickerField(
|
||||
context: context,
|
||||
text: schedule.getFormatTime(schedule.range2Hour1),
|
||||
onPick: (pickedTime) {
|
||||
onChanged.call(schedule.copyWith(range2Hour1: pickedTime));
|
||||
},
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: !schedule.continuousDay,
|
||||
child: Center(
|
||||
child: Container(
|
||||
width: 10,
|
||||
height: 1,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
timePickerField(
|
||||
context: context,
|
||||
text: schedule.getFormatTime(schedule.range2Hour2),
|
||||
onPick: (pickedTime) {
|
||||
onChanged.call(schedule.copyWith(range2Hour2: pickedTime));
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
timePickerField(
|
||||
{required BuildContext context,
|
||||
required String? text,
|
||||
required Function(TimeOfDay) onPick}) {
|
||||
return Expanded(
|
||||
child: TextField(
|
||||
readOnly: true,
|
||||
controller: TextEditingController(
|
||||
text: text,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
onTap: () async {
|
||||
final TimeOfDay? pickedTime = await showTimePicker(
|
||||
context: context,
|
||||
initialTime: TimeOfDay.now(),
|
||||
);
|
||||
if (pickedTime != null) {
|
||||
onPick.call(pickedTime);
|
||||
}
|
||||
},
|
||||
decoration: const InputDecoration(
|
||||
hintText: 'Hora',
|
||||
border: UnderlineInputBorder(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user