import 'package:anyway/structs/landmark.dart';
import 'package:flutter/material.dart';


class ThemedMarker extends StatelessWidget {
  final Landmark landmark;
  final int position;

  ThemedMarker({
    super.key,
    required this.landmark,
    required this.position
    });

  @override
  Widget build(BuildContext context) {
    // This returns an outlined circle, with an icon corresponding to the landmark type
    // As a small dot, the number of the landmark is displayed in the top right
    Icon icon;
    if (landmark.type == sightseeing) {
      icon = Icon(Icons.church, color: Colors.black, size: 50);
    } else if (landmark.type == nature) {
      icon = Icon(Icons.park, color: Colors.black, size: 50);
    } else if (landmark.type == shopping) {
      icon = Icon(Icons.shopping_cart, color: Colors.black, size: 50);
    } else if (landmark.type == start || landmark.type == finish) {
      icon = Icon(Icons.flag, color: Colors.black, size: 50);
    } else {
      icon = Icon(Icons.location_on, color: Colors.black, size: 50);
    }

    Widget? positionIndicator;
    if (landmark.type != start && landmark.type != finish) {
      positionIndicator = Positioned(
        top: 0,
        right: 0,
        child: Container(
          padding: EdgeInsets.all(5),
          decoration: BoxDecoration(
            color: Colors.grey[100],
            shape: BoxShape.circle,
          ),
          child: Text('$position', style: TextStyle(color: Colors.black, fontSize: 25)),
        ),
      );
    }

    return RepaintBoundary(
      child: Stack(
        alignment: Alignment.topRight,
        children: [
          Container(
            decoration: BoxDecoration(
              gradient: LinearGradient(
                colors: [Colors.red, Colors.yellow]
              ),
              shape: BoxShape.circle,
              border: Border.all(color: Colors.black, width: 5),
            ),
            padding: EdgeInsets.all(5),
            child: icon
          ),
          if (positionIndicator != null) positionIndicator,
        ],
      ),
    );
  }
}