import 'package:hmg_patient_app/core/viewModels/project_view_model.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

class IconWithBg extends StatelessWidget {
  final IconData? icon;
  final Color? color;
  final VoidCallback? onPress;
  final bool hasPadding;

  IconWithBg(
      {Key? key, this.icon, this.color, this.onPress, this.hasPadding = false})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    ProjectViewModel projectViewModel = Provider.of(context);
    return Container(
        width: 40,
        height: 40,
        decoration: BoxDecoration(
          color: Colors.grey[200],
          borderRadius: BorderRadius.circular(30),
        ),
        child: Center(
          child: Padding(
            padding: EdgeInsets.only(
                left: !projectViewModel.isArabic ? (hasPadding ? 4 : 0) : 0,
              right: projectViewModel.isArabic ? (hasPadding ? 4 : 0) : 0
            ),
            child: IconButton(
              icon: Icon(
                icon,
                size: 20,
              ),
              color: color,
              onPressed: () async {
                onPress!();
              },
            ),
          ),
        ));
  }
}
