import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';

import '../../theme/theme_extension.dart';

class ConnectionErrorBanner extends StatelessWidget {
  const ConnectionErrorBanner({required this.onRetry, super.key});
  final VoidCallback onRetry;

  @override
  Widget build(BuildContext context) {
    final fs = Theme.of(context).extension<FabledSwordTheme>()!;
    return Container(
      color: fs.iron,
      padding: const EdgeInsets.all(12),
      child: Row(children: [
        Expanded(
          child: Text(
            "Couldn't reach the server.",
            style: TextStyle(color: fs.parchment),
          ),
        ),
        TextButton(onPressed: onRetry, child: const Text('Retry')),
        TextButton(
          onPressed: () => context.go('/server-url'),
          child: const Text('Change URL'),
        ),
      ]),
    );
  }
}
