This commit is contained in:
Juan Felipe Duarte
2023-04-19 17:51:08 -05:00
parent 3b28febfec
commit 268af389bb
8 changed files with 690 additions and 55 deletions
+238
View File
@@ -0,0 +1,238 @@
import 'package:flutter/material.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:prosappco/src/components/pop_appbar.dart';
class HorarioScreen extends StatefulWidget {
const HorarioScreen({super.key});
@override
State<HorarioScreen> createState() => _HorarioScreenState();
}
class _HorarioScreenState extends State<HorarioScreen> {
bool lunesValue = false;
bool martesValue = false;
bool miercolesValue = false;
bool juevesValue = false;
bool viernesValue = false;
bool sabadoValue = false;
bool domingoValue = false;
bool jornadaContinuaLunes = false;
TimeOfDay? _selectedTime;
Future<void> _selectTime(BuildContext context) async {
final TimeOfDay? pickedTime = await showTimePicker(
context: context,
initialTime: TimeOfDay.now(),
// builder: (context, child) {
// return Theme(data: ThemeData.dark(), child: child!);
// },
);
if (pickedTime != null) {
setState(() {
_selectedTime = pickedTime;
});
}
}
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
appBar: PopAppbar(
onPressed: () {
Navigator.pop(context);
},
label: 'Horario'),
body: SingleChildScrollView(
child: Column(children: [
const Divider(color: Colors.white, height: 10),
customSwitch(
'Lunes',
lunesValue,
(value) {
lunesValue = value;
},
),
lunesValue
? Column(
children: [
customSwitch(
'Jornada continua',
jornadaContinuaLunes,
(value) {
jornadaContinuaLunes = value;
},
),
Padding(
padding: const EdgeInsets.only(left: 30, bottom: 15),
child: Column(
children: [
Row(
children: [
Expanded(
child: TextFormField(
onTap: () {
_selectTime(context);
},
readOnly: true,
decoration: const InputDecoration(
hintText: 'Hora',
),
controller: TextEditingController(
text: _selectedTime == null
? ''
: ' ${_selectedTime!.format(context)}',
),
style: const TextStyle(fontSize: 15),
),
),
const Text(' - '),
SizedBox(
width: 80,
child: TextFormField(
onTap: () {
_selectTime(context);
},
readOnly: true,
decoration: const InputDecoration(
hintText: 'Hora',
),
controller: TextEditingController(
text: _selectedTime == null
? ''
: ' ${_selectedTime!.format(context)}'),
),
),
const Text(' - '),
SizedBox(
width: 80,
child: TextFormField(
onTap: () {
_selectTime(context);
},
readOnly: true,
decoration: const InputDecoration(
hintText: 'Hora',
),
controller: TextEditingController(
text: _selectedTime == null
? ''
: ' ${_selectedTime!.format(context)}'),
),
),
const Text(' - '),
SizedBox(
width: 80,
child: TextFormField(
onTap: () {
_selectTime(context);
},
readOnly: true,
decoration: const InputDecoration(
hintText: 'Hora',
),
controller: TextEditingController(
text: _selectedTime == null
? ''
: ' ${_selectedTime!.format(context)}'),
),
),
],
).animate().moveY(
duration: const Duration(milliseconds: 100)),
],
)
.animate()
.moveY(duration: const Duration(milliseconds: 100)),
),
],
)
: const SizedBox(),
const Divider(height: 10),
customSwitch(
'Martes',
martesValue,
(value) {
martesValue = value;
},
),
const Divider(height: 10),
customSwitch(
'Miercoles',
miercolesValue,
(value) {
miercolesValue = value;
},
),
const Divider(height: 10),
customSwitch(
'Jueves',
juevesValue,
(value) {
juevesValue = value;
},
),
const Divider(height: 10),
customSwitch(
'Viernes',
viernesValue,
(value) {
viernesValue = value;
},
),
const Divider(height: 10),
customSwitch(
'Sabado',
sabadoValue,
(value) {
sabadoValue = value;
},
),
const Divider(height: 10),
customSwitch(
'Domingo',
domingoValue,
(value) {
domingoValue = value;
},
),
]),
),
),
);
}
customSwitch(String text, bool switchValue, ValueChanged<bool> onChanged) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 30),
child: SizedBox(
height: 40,
child: Row(
children: [
Expanded(
child: Text(
text,
style: const TextStyle(
fontSize: 15,
color: Colors.black,
),
)),
Transform.scale(
scale: 1.2,
child: Switch(
value: switchValue,
onChanged: (bool newValue) {
setState(() {
onChanged(newValue);
});
},
),
),
],
),
),
);
}
}