Agrego frontend app
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
class Actividad {
|
||||
final int id;
|
||||
final String nombre;
|
||||
final int duracion; // minutos
|
||||
final int capacidadPorDefecto;
|
||||
final bool libre;
|
||||
final bool activo;
|
||||
|
||||
const Actividad({
|
||||
required this.id,
|
||||
required this.nombre,
|
||||
required this.duracion,
|
||||
required this.capacidadPorDefecto,
|
||||
this.libre = false,
|
||||
this.activo = true,
|
||||
});
|
||||
|
||||
factory Actividad.fromMap(Map<String, dynamic> map) {
|
||||
return Actividad(
|
||||
id: map['id'] as int,
|
||||
nombre: map['nombre'] as String? ?? '',
|
||||
duracion: (map['duracion'] as num?)?.toInt() ?? 0,
|
||||
capacidadPorDefecto: (map['capacidad_por_defecto'] as num?)?.toInt() ?? 0,
|
||||
libre: map['libre'] as bool? ?? false,
|
||||
activo: map['activo'] as bool? ?? true,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'nombre': nombre,
|
||||
'duracion': duracion,
|
||||
'capacidad_por_defecto': capacidadPorDefecto,
|
||||
'libre': libre,
|
||||
'activo': activo,
|
||||
};
|
||||
}
|
||||
|
||||
String get duracionDisplay {
|
||||
if (duracion >= 60) {
|
||||
final h = duracion ~/ 60;
|
||||
final m = duracion % 60;
|
||||
return m > 0 ? '${h}h ${m}min' : '${h}h';
|
||||
}
|
||||
return '${duracion}min';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user