import 'package:flutter/material.dart';

class SideBar extends StatelessWidget {
  final String title;
  final String value;
  final String unit;
  final Function? onTap;
  final bool? hasDevice;

  const SideBar({
    super.key,
    required this.title,
    required this.value,
    required this.unit,
    this.onTap,
    this.hasDevice = false,
  });

  @override
  Widget build(BuildContext context) {
    var padding = const EdgeInsets.only(
      right: 30,
      left: 40,
    );
    return Container(
      margin: hasDevice!
          ? const EdgeInsets.only(top: 60)
          : const EdgeInsets.only(top: 10),
      child: InkWell(
        onTap: () => onTap?.call(),
        child: Container(
          margin: const EdgeInsets.only(top: 10),
          padding: const EdgeInsets.symmetric(vertical: 20),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Container(
                height: 90,
                alignment: Alignment.center,
                padding: padding,
                child: Text(
                  title,
                  style: const TextStyle(
                    fontSize: 25,
                  ),
                ),
              ),
              Container(
                alignment: Alignment.bottomRight,
                padding: padding,
                child: FittedBox(
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.end,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      Text(
                        value,
                        style: const TextStyle(
                          fontSize: 60,
                          color: Colors.black,
                        ),
                      ),
                      Text(
                        "  $unit",
                        style: const TextStyle(fontSize: 25),
                      )
                    ],
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
