import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:making_school_asignment_app/common/utils/anti_shake_throttling.dart';
import 'package:making_school_asignment_app/page/home_page/children/homework_review/configuration_files/index.dart';

/// 自定义收藏组件
/// isFavorite  默认是否收藏
/// favoriteNum 默认收藏次数

class FavoriteWidget extends StatelessWidget {
  const FavoriteWidget({super.key});

  @override
  Widget build(BuildContext context) {
    final logic = Get.find<HomeworkReviewLogic>();
    final sateData = logic.state;

    return Container(
      padding: EdgeInsets.symmetric(horizontal: 4.r),
      child: InkWell(
        onTap: () => easyThrottle('homework_review_collect_btn', () => logic.toFavorite(),
            duration: const Duration(milliseconds: 500)),
        splashColor: Colors.transparent,
        highlightColor: Colors.transparent,
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Obx(() {
              return Icon(
                const IconData(0xe63c, fontFamily: "AlibabaIcon"),
                size: 24.r,
                color: sateData.favorite.value
                    ? const Color.fromRGBO(255, 172, 48, 1)
                    : const Color.fromRGBO(164, 164, 164, 1),
              );
            }),
            SizedBox(width: 6.w),
          ],
        ),
      ),
    );
  }
}

class JobQuestionsSwitch extends Object {
  final int taskId;
  final int studentId;
  final int paperId;

  JobQuestionsSwitch(this.taskId, this.studentId, this.paperId);
}
