import 'package:flutter/material.dart';

import '../../../../themes/app_colors.dart';
import '../../../../themes/styles_text.dart';

class ItemCodeTimeline extends StatelessWidget {
  final Function onPressed;
  const ItemCodeTimeline({
    super.key,
    required this.onPressed,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Stack(
        children: [
          Row(
            children: [
              const SizedBox(
                width: 16,
                height: 20,
              ),
              Expanded(child: _widgetTimeLine()),
            ],
          ),
          Positioned(
            top: 0,
            left: 8,
            child: Container(
              color: Colors.white,
              width: 16,
              height: 24,
              child: Column(
                children: [
                  Container(
                    width: 16,
                    height: 16,
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(
                        16,
                      ),
                      color: Colors.green,
                    ),
                  ),
                ],
              ),
            ),
          ),
        ],
      ),
    );
  }

  Widget _widgetTimeLine() {
    return Container(
      width: double.infinity,
      padding: const EdgeInsets.only(
        left: 12,
        right: 8,
      ),
      margin: const EdgeInsets.only(
        bottom: 8,
      ),
      decoration: BoxDecoration(
        border: Border(
          left: BorderSide(color: Colors.blue),
        ),
      ),
      child: Column(
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.start,
            children: [
              Text(
                'ss - ',
                style: StylesText.body5,
              ),
              Text(
                '20/22/2202',
                style: StylesText.caption3.copyWith(),
              )
            ],
          ),
          const SizedBox(
            height: 8,
          ),
          _widgetItemInfoCompleted(
            title: 'title',
            actionDate: '2/2/2023',
            nguoiThucHiens: 'nguoi thuc hien',
          ),
        ],
      ),
    );
  }

  Widget _widgetItemInfoCompleted({
    required String title,
    required String actionDate,
    String? nguoiThucHiens,
  }) {
    return Container(
      padding: const EdgeInsets.all(8),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(8),
        color: AppColors.background1,
      ),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.start,
        children: [
          Row(
            children: [
              Expanded(
                child: Text(
                  title,
                  style: StylesText.caption2.copyWith(
                    color: AppColors.neutral1,
                  ),
                ),
              ),
              Text(
                actionDate,
                style: StylesText.caption3.copyWith(
                  color: AppColors.neutral1,
                ),
              ),
            ],
          ),
          Padding(
            padding: const EdgeInsets.symmetric(vertical: 8.0),
            child: Row(
              children: [
                Expanded(
                  child: Text(
                    'Người thực hiện',
                    style: StylesText.caption2.copyWith(
                      color: AppColors.neutral1,
                    ),
                  ),
                ),
                Text(
                  nguoiThucHiens ?? '',
                  style: StylesText.caption3.copyWith(
                    color: AppColors.neutral1,
                  ),
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}
