import 'package:elektronika/app/core/themes/colors.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_svg/svg.dart';

class ListTileItem extends StatelessWidget {
  final double topRightBorder;
  final double topLeftBorder;
  final double bottomRightBorder;
  final double bottomLeftBorder;
  final String leading;
  final String text;
  final String? path;
  final bool hasTrailing;

  final Function(String)? callback;

  const ListTileItem({
    this.topRightBorder = 0.0,
    this.topLeftBorder = 0.0,
    this.bottomRightBorder = 0.0,
    this.bottomLeftBorder = 0.0,
    this.hasTrailing = true,
    this.path,
    this.callback,
    required this.leading,
    required this.text,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(left: 16.w, right: 16.w),
      decoration: new BoxDecoration(
        // border: Border(bottom: BorderSide(color: ThemeColor.scaffoldBckColor)),
        color: ThemeColor.white,
        borderRadius: BorderRadius.only(
          topLeft: Radius.circular(topLeftBorder),
          topRight: Radius.circular(topRightBorder),
          bottomLeft: Radius.circular(bottomLeftBorder),
          bottomRight: Radius.circular(bottomRightBorder),
        ),
      ),
      child: ListTile(
        // contentPadding: EdgeInsets.zero,
        // tileColor: ThemeColor.white,
        onTap: () => callback != null ? callback!(path!) : () {},
        leading: SvgPicture.asset(leading, height: 16.h),
        title: Transform.translate(
          offset: Offset(-20, 0),
          child: Text(
            text,
            style: new TextStyle(
              fontSize: 12.sp,
            ),
          ),
        ),
        trailing: hasTrailing
            ? Container(
                padding: const EdgeInsets.all(4),
                decoration: new BoxDecoration(
                  color: ThemeColor.mainColor.withOpacity(0.10),
                  borderRadius: BorderRadius.all(Radius.circular(8)),
                ),
                child: Icon(
                  Icons.arrow_forward_ios_outlined,
                  size: 12.sp,
                  color: ThemeColor.mainColor,
                ),
              )
            : null,
      ),
    );
  }
}

class ListTileDivider extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Divider(
      color: ThemeColor.scaffoldBckColor,
      thickness: 1,
      height: 0.5,
    );
  }
}
