import 'package:flutter/material.dart';

import '../model/flood_station.dart';
import '../services/date_utility.dart';

class MapPopup extends StatelessWidget {
  const MapPopup(
      {super.key,
      required FloodStation station,
      required dynamic Function() onShowTapped})
      : _onShowTapped = onShowTapped,
        _station = station;

  final FloodStation _station;
  final Function() _onShowTapped;

  @override
  Widget build(BuildContext context) {
    return AlertDialog(
      title: Text(_station.label),
      content: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        mainAxisSize: MainAxisSize.min,
        children: [
          Row(
            mainAxisSize: MainAxisSize.min,
            children: [
              Icon(Icons.home_outlined),
              Padding(padding: EdgeInsets.only(left: 8)),
              Text(_station.town.isEmpty ? '-' : _station.town),
            ],
          ),
          Row(
            children: [
              Icon(Icons.water),
              Padding(padding: EdgeInsets.only(left: 8)),
              Text(_station.riverName.isEmpty ? '-' : _station.riverName),
            ],
          ),
          Row(
            children: [
              Icon(Icons.calendar_month_outlined),
              Padding(padding: EdgeInsets.only(left: 8)),
              Text(
                _station.dateOpened != null
                    ? DateUtility.formatDateToYmd(_station.dateOpened!)
                    : '-',
              ),
            ],
          )
        ],
      ),
      actions: [
        TextButton(
          onPressed: () => Navigator.of(context).pop(),
          child: Text('dismiss'),
        ),
        TextButton(
          onPressed: _onShowTapped,
          child: Text('show'),
        ),
      ],
    );
  }
}
