109 lines
4.0 KiB
Dart
109 lines
4.0 KiB
Dart
|
|
import 'package:flutter/material.dart';
|
||
|
|
import 'package:provider/provider.dart';
|
||
|
|
import 'package:sf_app_platform/payments/view/screens/core/wallet_management_layout.dart';
|
||
|
|
|
||
|
|
import '../../domain/entities/kid.dart';
|
||
|
|
import '../../domain/ports/theme_port.dart';
|
||
|
|
|
||
|
|
class LimitsScreen extends StatefulWidget{
|
||
|
|
final Kid kid;
|
||
|
|
|
||
|
|
const LimitsScreen({super.key, required this.kid});
|
||
|
|
|
||
|
|
@override
|
||
|
|
State<LimitsScreen> createState() => LimitsScreenState();
|
||
|
|
}
|
||
|
|
|
||
|
|
class LimitsScreenState extends State<LimitsScreen>{
|
||
|
|
late List dailyLimits;
|
||
|
|
late List timeLimits;
|
||
|
|
late List conditions;
|
||
|
|
late List blocks;
|
||
|
|
|
||
|
|
@override
|
||
|
|
void initState() {
|
||
|
|
super.initState();
|
||
|
|
dailyLimits = [{"title": "Diario L-V", "limit": "5", "edit": false},
|
||
|
|
{"title": "Fines de semana", "limit": "8", "edit": false},
|
||
|
|
{"title": "Semanal", "limit": "30", "edit": false},
|
||
|
|
{"title": "Mensual", "limit": "1200", "edit": false},];
|
||
|
|
timeLimits = [{"title": "Lunes a Viernes", "start": "08:00", "end": "20:00", "edit": false},
|
||
|
|
{"title": "Fines de semana", "start": "10:00", "end": "21:00", "edit": false},
|
||
|
|
{"title": "Vacaciones", "start": "09:00", "end": "22:00", "edit": false}];
|
||
|
|
conditions = [{"title": "Alimentación", "limit": "10", "edit": false},
|
||
|
|
{"title": "Transporte", "limit": "10", "edit": false},
|
||
|
|
{"title": "Alimentación", "limit": "10", "edit": false},];
|
||
|
|
blocks = [];
|
||
|
|
}
|
||
|
|
|
||
|
|
@override
|
||
|
|
Widget build(BuildContext context) {
|
||
|
|
ThemePort theme = context.read<ThemePort>();
|
||
|
|
|
||
|
|
return WalletManagementLayout(
|
||
|
|
kid: widget.kid,
|
||
|
|
children: [
|
||
|
|
Container(
|
||
|
|
padding: EdgeInsets.all(20),
|
||
|
|
decoration: BoxDecoration(
|
||
|
|
borderRadius: BorderRadius.all(Radius.circular(20)),
|
||
|
|
color: theme.getColorFor(ThemeCode.background_primary),
|
||
|
|
),
|
||
|
|
child: Column(
|
||
|
|
spacing: 10,
|
||
|
|
children: [
|
||
|
|
Text("Pon límite de gastos", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20)),
|
||
|
|
Text("Libertad para ellos, tranquilidad para ti"),
|
||
|
|
...List<Widget>.generate(dailyLimits.length, (int index) {
|
||
|
|
return Column(children: [
|
||
|
|
Row(children: [
|
||
|
|
Text("${dailyLimits[index]["title"]}: ${dailyLimits[index]["limit"]} €"),
|
||
|
|
Spacer(),
|
||
|
|
TextButton(onPressed: ()=>{setState(() {
|
||
|
|
dailyLimits[index]["edit"] = !dailyLimits[index]["edit"];
|
||
|
|
})}, child: Text("Editar"))
|
||
|
|
]),
|
||
|
|
if (dailyLimits[index]["edit"]) TextField()
|
||
|
|
]);
|
||
|
|
}),
|
||
|
|
|
||
|
|
],
|
||
|
|
),
|
||
|
|
),
|
||
|
|
Container(
|
||
|
|
padding: EdgeInsets.all(20),
|
||
|
|
decoration: BoxDecoration(
|
||
|
|
borderRadius: BorderRadius.all(Radius.circular(20)),
|
||
|
|
color: theme.getColorFor(ThemeCode.background_primary),
|
||
|
|
),
|
||
|
|
child: Column(
|
||
|
|
spacing: 10,
|
||
|
|
children: [
|
||
|
|
Text("Horarios permitidos", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20)),
|
||
|
|
Text("Controla cuándo pueden comprar"),
|
||
|
|
...List<Widget>.generate(timeLimits.length, (int index) {
|
||
|
|
return Column(children: [
|
||
|
|
Row(children: [
|
||
|
|
Text("${timeLimits[index]["title"]}: ${timeLimits[index]["start"]} - ${timeLimits[index]["end"]}"),
|
||
|
|
Spacer(),
|
||
|
|
TextButton(onPressed: ()=>{setState(() {
|
||
|
|
timeLimits[index]["edit"] = !timeLimits[index]["edit"];
|
||
|
|
})}, child: Text("Editar"))
|
||
|
|
]),
|
||
|
|
if (timeLimits[index]["edit"]) TextField()
|
||
|
|
]);
|
||
|
|
}),
|
||
|
|
],
|
||
|
|
),
|
||
|
|
)
|
||
|
|
],
|
||
|
|
footer: Column(children: [
|
||
|
|
FilledButton(onPressed: ()=>{}, child: SizedBox(
|
||
|
|
width: double.infinity,
|
||
|
|
child: Center(child: Text("Guardar límites")),
|
||
|
|
))
|
||
|
|
]),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|