Root cause behind most "stuck loading" reports: the backend changed shape (schedules became an array, location_preferences a string) while the mobile parser still hard-cast to Map/int. The TypeError was swallowed by a silent catch that returned null, and screens only handled the success state, so a parse failure rendered as a permanent spinner. Same class of bug appeared across service lists via non-null map lookups and a total absence of request timeouts. Ported from prosappweb: - in-app suggestions (POST /suggestions) - policies/terms from GET /settings/policies - configurable appointment length (slot_duration_minutes) - block/unblock calendar slots (POST /services/block) - GPS city detection on the profile (Nominatim) - server-side professional search with haversine distance - retry cooldown after a rejected professional application Reliability: - parse schedules array (day_of_week 0=Mon) and string location_preferences - read times as wall clock, so 08:00 stays 08:00 across timezones - carry minutes into hours in TimeOfDay.add; a minute-based step used to loop forever and freeze the calendar (covered by test/time_slots_test.dart) - semver update check instead of string equality, which blocked every build that did not exactly match the configured version - request timeouts across all repositories - surface HTTP >= 400 instead of reporting failed writes as success - error states with retry instead of an indefinite shimmer Includes pre-existing uncommitted work from the UI redesign. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
108 lines
3.1 KiB
Dart
108 lines
3.1 KiB
Dart
import 'dart:developer';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:injector/injector.dart';
|
|
import 'package:prosappco/blocs/setting_bloc/setting_bloc.dart';
|
|
import 'package:prosappco/screens/configuration/configuration_about_screen.dart';
|
|
|
|
const _kPrimary = Color(0xFF1565C0);
|
|
|
|
class ConfigurationScreen extends StatelessWidget {
|
|
const ConfigurationScreen({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final settingBloc = Injector.appInstance.get<SettingBloc>();
|
|
|
|
return BlocProvider<SettingBloc>(
|
|
create: (context) => settingBloc,
|
|
child: BlocListener<SettingBloc, SettingState>(
|
|
listener: (context, state) {
|
|
if (state is SettingLogoutSuccess) {
|
|
Navigator.pop(context);
|
|
}
|
|
},
|
|
child: Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text('Configuración'),
|
|
backgroundColor: _kPrimary,
|
|
foregroundColor: Colors.white,
|
|
elevation: 0,
|
|
),
|
|
body: ListView(
|
|
children: [
|
|
const SizedBox(height: 8),
|
|
_ConfigItem(
|
|
icon: Icons.info_outline_rounded,
|
|
label: 'Acerca de la aplicación',
|
|
onTap: () => Navigator.push(
|
|
context,
|
|
CupertinoPageRoute(
|
|
builder: (_) => const ConfigurationAboutScreen(),
|
|
),
|
|
),
|
|
),
|
|
_ConfigItem(
|
|
icon: Icons.logout_rounded,
|
|
label: 'Cerrar sesión',
|
|
onTap: () {
|
|
try {
|
|
settingBloc.add(SettingLogoutRequest());
|
|
} catch (e) {
|
|
log('logout error: ${e.toString()}');
|
|
}
|
|
},
|
|
),
|
|
const Divider(height: 1),
|
|
_ConfigItem(
|
|
icon: Icons.delete_outline_rounded,
|
|
label: 'Eliminar cuenta',
|
|
color: Theme.of(context).colorScheme.error,
|
|
onTap: () {},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _ConfigItem extends StatelessWidget {
|
|
final IconData icon;
|
|
final String label;
|
|
final Color? color;
|
|
final VoidCallback onTap;
|
|
|
|
const _ConfigItem({
|
|
required this.icon,
|
|
required this.label,
|
|
required this.onTap,
|
|
this.color,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final onSurface = Theme.of(context).colorScheme.onSurface;
|
|
final c = color ?? onSurface;
|
|
return ListTile(
|
|
onTap: onTap,
|
|
leading: Container(
|
|
width: 36,
|
|
height: 36,
|
|
decoration: BoxDecoration(
|
|
color: c.withOpacity(0.08),
|
|
borderRadius: BorderRadius.circular(10),
|
|
),
|
|
child: Icon(icon, color: c, size: 20),
|
|
),
|
|
title: Text(label, style: TextStyle(color: c, fontWeight: FontWeight.w500)),
|
|
trailing: color == null
|
|
? Icon(Icons.keyboard_arrow_right, color: onSurface.withOpacity(0.35))
|
|
: null,
|
|
);
|
|
}
|
|
}
|