import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:hl_lieferservice/feature/delivery/detail/bloc/note_bloc.dart';
import 'package:hl_lieferservice/feature/delivery/detail/bloc/note_event.dart';
import 'package:hl_lieferservice/model/delivery.dart';

class NoteLoadingFailPage extends StatelessWidget {
  const NoteLoadingFailPage({super.key, required this.delivery});

  final Delivery delivery;

  void _onRetry(BuildContext context) {
    context.read<NoteBloc>().add(LoadNote(delivery: delivery));
  }

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Padding(
        padding: const EdgeInsets.all(50),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Icon(Icons.error_outline, size: 72, color: Theme.of(context).colorScheme.error,),
            Padding(
              padding: const EdgeInsets.only(top: 30),
              child: Text(
                "Leider ist es beim Laden der Notizen zu einem Fehler gekommen.",
              ),
            ),
            Padding(
              padding: const EdgeInsets.only(top: 30),
              child: FilledButton(
                onPressed: () => _onRetry(context),
                child: Text("Erneut versuchen"),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
