import 'package:anyway/constants.dart';
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

    Widget? positionIndicator;
    if (landmark.type != typeStart && landmark.type != typeFinish) {
      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: APP_GRADIENT,
              shape: BoxShape.circle,
              border: Border.all(color: Colors.black, width: 5),
            ),
            width: 70,
            height: 70,
            padding: const EdgeInsets.all(5),
            child: Icon(landmark.type.icon.icon, size: 50),
          ),
          if (positionIndicator != null) positionIndicator,
        ],
      ),
    );
  }
}