import 'package:flutter/material.dart';
import 'package:get/get.dart';

class HomeAvatarWidget extends StatelessWidget {
  final double size;
  final String headImageToken;

  const HomeAvatarWidget({
    super.key,
    required this.size,
    required this.headImageToken,
  });

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      child: _buildAvatar(),
      onTap: () {
        Get.toNamed(
          '/home/personal_center',
        );
      },
    );
  }

  Widget _buildAvatar() {
    if (headImageToken.isNotEmpty) {
      return ClipRRect(
        borderRadius: BorderRadius.circular(50 / 2),
        child: Image.network(
          headImageToken,
          width: 50,
          height: 50,
          fit: BoxFit.cover,
        ),
      );
    }
    return ClipRRect(
      borderRadius: BorderRadius.circular(50 / 2),
      child: Image.asset(
        'assets/images/avatar.png',
        width: 50,
        height: 50,
        fit: BoxFit.cover,
      ),
    );
  }
}
