132 lines
4.6 KiB
Dart
132 lines
4.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import '../providers/realtime_controller.dart';
|
|
|
|
class ReconnectOverlay extends ConsumerWidget {
|
|
const ReconnectOverlay({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final ctrl = ref.watch(realtimeControllerProvider);
|
|
if (!ctrl.isConnecting && !ctrl.isFailed) return const SizedBox.shrink();
|
|
|
|
if (ctrl.isFailed) {
|
|
return Positioned.fill(
|
|
child: AbsorbPointer(
|
|
absorbing: true,
|
|
child: Center(
|
|
child: SizedBox(
|
|
width: 420,
|
|
child: Card(
|
|
elevation: 6,
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(16.0),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Text(
|
|
'Realtime connection failed',
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
),
|
|
const SizedBox(height: 8),
|
|
Text(
|
|
ctrl.lastError ??
|
|
'Unable to reconnect after multiple attempts.',
|
|
style: Theme.of(context).textTheme.bodyMedium,
|
|
),
|
|
const SizedBox(height: 12),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
children: [
|
|
TextButton(
|
|
onPressed: () => ctrl.retry(),
|
|
child: const Text('Retry'),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
// isConnecting: show richer skeleton-like placeholders
|
|
return Positioned.fill(
|
|
child: AbsorbPointer(
|
|
absorbing: true,
|
|
child: Container(
|
|
color: Theme.of(
|
|
context,
|
|
).colorScheme.surface.withAlpha((0.35 * 255).round()),
|
|
child: Center(
|
|
child: SizedBox(
|
|
width: 640,
|
|
child: Card(
|
|
elevation: 4,
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(16.0),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
// Header
|
|
Container(
|
|
height: 20,
|
|
decoration: BoxDecoration(
|
|
color: Theme.of(
|
|
context,
|
|
).colorScheme.surfaceContainerHighest,
|
|
borderRadius: BorderRadius.circular(6),
|
|
),
|
|
),
|
|
const SizedBox(height: 12),
|
|
// chips row
|
|
Row(
|
|
children: [
|
|
for (var i = 0; i < 3; i++)
|
|
Padding(
|
|
padding: const EdgeInsets.only(right: 8.0),
|
|
child: Container(
|
|
width: 100,
|
|
height: 14,
|
|
decoration: BoxDecoration(
|
|
color: Theme.of(
|
|
context,
|
|
).colorScheme.surfaceContainerHighest,
|
|
borderRadius: BorderRadius.circular(6),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 16),
|
|
// lines representing content
|
|
for (var i = 0; i < 4; i++) ...[
|
|
Container(
|
|
height: 12,
|
|
margin: const EdgeInsets.only(bottom: 8),
|
|
decoration: BoxDecoration(
|
|
color: Theme.of(
|
|
context,
|
|
).colorScheme.surfaceContainerHighest,
|
|
borderRadius: BorderRadius.circular(6),
|
|
),
|
|
),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|