import 'package:ef/ef.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:flutterflow_ui/flutterflow_ui.dart';
import 'package:vbvs_app/common/util/FitTool.dart';
import 'package:vbvs_app/component/tool/ClickableContainer.dart';

import 'package:vbvs_app/controller/mh_controller/mhdevice_share_controller.dart';

class ShareUserWidget extends GetView {
  int index;
  MHDeviceShareController repairListController;

  ShareUserWidget({required this.index, required this.repairListController}) {}

  @override
  Widget build(BuildContext context) {
    var info = repairListController.model.shareUser![index];
    return InkWell(
      onTap: () {
        repairListController.model.mainShare =
            repairListController.model.shareUser![index];
        Get.toNamed('/shareDeviceDetail');
      },
      child: Container(
        width: MediaQuery.sizeOf(context).width,
        height: MediaQuery.sizeOf(context).height * 0.073,
        constraints: const BoxConstraints(
          minHeight: 71,
        ),
        decoration: const BoxDecoration(
          border: Border(
              bottom: BorderSide(
                color: Color(0xFF929699), // 设置底部线条颜色
                width: 0, // 设置线条宽度
              ),
              top: BorderSide(
                color: Color(0xFF929699), // 设置底部线条颜色
                width: 0, // 设置线条宽度
              )),
        ),
        child: Padding(
          padding:
              EdgeInsetsDirectional.fromSTEB(37.rpx, 29.rpx, 42.rpx, 30.rpx),
          child: Row(
            mainAxisSize: MainAxisSize.max,
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Container(
                width: 42.rpx,
                height: 42.rpx,
                child: SvgPicture.asset('assets/img/icon/default_head.svg'),
              ),
              Expanded(
                child: Container(
                  margin:
                      EdgeInsetsDirectional.only(start: 30.rpx, end: 30.rpx),
                  child: Column(
                    mainAxisSize: MainAxisSize.max,
                    children: [
                      Expanded(
                        child: Align(
                          alignment: const AlignmentDirectional(-1, 0),
                          child: Text(
                            '${info['userName']}',
                            style: TextStyle(
                              fontFamily: 'Readex Pro',
                              color: Colors.white,
                              fontSize: 30.rpx,
                              letterSpacing: 0.0,
                              height: 1,
                            ),
                          ),
                        ),
                      ),
                      Expanded(
                        child: Align(
                          alignment: const AlignmentDirectional(-1, 0),
                          child: Text(
                            info['op_type'] == 1
                                ? '允许对方控制该设备'.tr
                                : info['op_type'] == 2
                                    ? '仅允许对方查看该设备'.tr
                                    : '',
                            style: TextStyle(
                              fontFamily: 'Readex Pro',
                              color: const Color(0xFFC8CBD2),
                              fontSize: 20.rpx,
                              letterSpacing: 0.0,
                              height: 1,
                            ),
                          ),
                        ),
                      ),
                    ].divide(const SizedBox(height: 5)),
                  ),
                ),
              ),
              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,
                      ))),
            ],
          ),
        ),
      ),
    );
  }
}
