import 'package:agrilink_vocpro/core/constant/app_theme.dart';
import 'package:agrilink_vocpro/core/extension/extention.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import '../../../core/constant/app_color.dart';

class RelayStatusHistoryWidget extends StatelessWidget {
  const RelayStatusHistoryWidget({
    super.key,
    required this.disabledAt,
    required this.enabledAt,
    required this.name,
    required this.imageUrl,
  });

  final String? disabledAt;
  final String? enabledAt;
  final String name;
  final String imageUrl;

  @override
  Widget build(BuildContext context) {
    return ListTile(
      leading: CircleAvatar(
        radius: 26.r,
        backgroundColor: AppColor.ternary,
        child: Image.asset(
          imageUrl,
          width: 24.r,
          color: Colors.white,
        ),
      ),
      title: Text(
        name,
        style: AppTheme.labelMedium,
      ),
      subtitle: Column(
        children: [
          Row(
            children: [
              CircleAvatar(
                backgroundColor: Colors.greenAccent,
                radius: 4.r,
              ),
              Text(
                ' Aktif               ${timeAgo(enabledAt)}',
                style: AppTheme.labelSmall,
              ),
            ],
          ),
          Row(
            children: [
              CircleAvatar(
                backgroundColor: Colors.grey.shade300,
                radius: 4.r,
              ),
              Text(
                ' Nonaktif        ${timeAgo(disabledAt)}',
                style: AppTheme.labelSmall,
              ),
            ],
          )
        ],
      ),
    );
  }
}
