import 'package:boilerplate/core/styles/my_dimensions.dart';
import 'package:boilerplate/core/utils/navigator_util.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';

class IPMBackButton extends StatelessWidget {
  final Color color;

  const IPMBackButton({
    Key? key,
    this.color = Colors.white,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        if (ModalRoute.of(context)?.canPop ?? false) {
          NavigatorUtil.pop();
        }
      },
      child: Container(
        width: MyDimens.dimen24 - 10,
        height: MyDimens.dimen24 - 10,
        color: Colors.transparent,
        child: SvgPicture.asset(
          'assets/icons/ic_back_button.svg',
          width: MyDimens.dimen24 - 5,
          height: MyDimens.dimen24 - 5,
          color: this.color,
        ),
      ),
    );
  }
}
