feat: Add refresh token mechanism and sync request handling in home screen
This commit is contained in:
@@ -11,57 +11,82 @@ class SyncStatusIndicator extends StatelessWidget {
|
||||
const SyncStatusIndicator({
|
||||
required this.status,
|
||||
this.errorMessage,
|
||||
this.onTap,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final SyncStatus status;
|
||||
final String? errorMessage;
|
||||
final VoidCallback? onTap;
|
||||
|
||||
Widget _buildIndicator(Widget child) {
|
||||
if (onTap == null) {
|
||||
return child;
|
||||
}
|
||||
|
||||
return MouseRegion(
|
||||
cursor: SystemMouseCursors.click,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: onTap,
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
switch (status) {
|
||||
case SyncStatus.idle:
|
||||
return const Tooltip(
|
||||
return Tooltip(
|
||||
message: 'Sincronización en espera',
|
||||
child: Icon(
|
||||
Icons.cloud_outlined,
|
||||
size: 16,
|
||||
color: Colors.white38,
|
||||
child: _buildIndicator(
|
||||
const Icon(
|
||||
Icons.cloud_outlined,
|
||||
size: 16,
|
||||
color: Colors.white38,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
case SyncStatus.syncing:
|
||||
return const Tooltip(
|
||||
return Tooltip(
|
||||
message: 'Sincronizando...',
|
||||
child: SizedBox(
|
||||
width: 16,
|
||||
height: 16,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
Color.fromARGB(255, 150, 150, 150),
|
||||
child: _buildIndicator(
|
||||
const SizedBox(
|
||||
width: 16,
|
||||
height: 16,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
Color.fromARGB(255, 150, 150, 150),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
case SyncStatus.synced:
|
||||
return const Tooltip(
|
||||
return Tooltip(
|
||||
message: 'Sincronizado',
|
||||
child: Icon(
|
||||
Icons.check_circle,
|
||||
size: 16,
|
||||
color: Colors.green,
|
||||
child: _buildIndicator(
|
||||
const Icon(
|
||||
Icons.check_circle,
|
||||
size: 16,
|
||||
color: Colors.green,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
case SyncStatus.error:
|
||||
return Tooltip(
|
||||
message: errorMessage ?? 'Error al sincronizar',
|
||||
child: const Icon(
|
||||
Icons.error,
|
||||
size: 16,
|
||||
color: Colors.red,
|
||||
child: _buildIndicator(
|
||||
const Icon(
|
||||
Icons.error,
|
||||
size: 16,
|
||||
color: Colors.red,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user