import 'package:ef/ef.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:vbvs_app/common/util/FitTool.dart';
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
import 'package:vbvs_app/controller/mh_controller/issue_controller.dart';
import 'package:vbvs_app/controller/mh_controller/issue_preview_controller.dart';

import '../../common/color/appFontsize.dart';

class IssuePreviewWidget extends GetView<IssuePreviewInfoController> {
  final int index;
  final IssueListController issueListController;

  IssuePreviewWidget({
    required this.index,
    required this.issueListController,
  });

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: () async {
        // issueListController.model.selectedIndex = index;
        // issueListController.updateAll();
        // await Future.delayed(Duration(milliseconds: 100));
        // issueListController.model.selectedIndex = -1;
        // issueListController.updateAll();
        var article = issueListController.model.issueList![index];
        Get.toNamed("/helpArticle", arguments: article);
        // TopSlideNotification.show(
        //   context,
        //   text: "功能开发中...",
        // );
      },
      child: Obx(() {
        return Container(
          margin: EdgeInsets.only(left: 30.rpx, right: 30.rpx),
          alignment: Alignment.center,
          width: double.infinity,
          constraints: BoxConstraints(
            // minWidth: 100,
            minHeight: 119.rpx,
          ),
          decoration: BoxDecoration(
            // borderRadius: BorderRadius.circular(0),
            // 整行的背景颜色
            color: index == issueListController.model.selectedIndex
                ? Colors.grey[300]
                : Colors.transparent,
            border: Border(
              bottom: BorderSide(color: const Color(0xFF929699), width: 0.rpx),
            ),
          ),
          child: Padding(
            padding: EdgeInsetsDirectional.fromSTEB(16.rpx, 0, 41.rpx, 0),
            child: Row(
              mainAxisSize: MainAxisSize.max,
              mainAxisAlignment: MainAxisAlignment.start,
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Flexible(
                  flex: 9,
                  child: Align(
                    alignment: AlignmentDirectional(-1, -1),
                    child: Text(
                      issueListController.model.issueList![index]['title'] ??
                          '',
                      style: TextStyle(
                        fontFamily: 'Readex Pro',
                        color: Color(0xFFFFFFFF),
                        fontSize: AppFontsize.title_size,
                        letterSpacing: 0,
                        // height: 1,
                      ),
                    ),
                  ),
                ),
                Expanded(
                  flex: 1,
                  child: Align(
                    alignment: Alignment.centerRight,
                    child: ClickableContainer(
                        backgroundColor: Colors.transparent,
                        highlightColor: Colors.transparent,
                        padding: EdgeInsets.only(right: 0),
                        onTap: () {},
                        child: Container(
                            height: 30.rpx,
                            width: 30.rpx,
                            child: SvgPicture.asset(
                              'assets/img/icon/expand.svg',
                              color: Colors.white,
                            )
                            //  Icon(
                            //   Icons.arrow_forward_ios,
                            //   color: Colors.white,
                            //   // size: 14.rpx,
                            // ),
                            )),
                  ),
                ),
              ],
            ),
          ),
        );
      }),
    );
  }
}
