import 'dart:convert';

import 'package:chat/configs/app_colors.dart';
import 'package:chat/configs/app_size.dart';
import 'package:chat/models/im/group_card_model.dart';
import 'package:chat/views/home/widgets/group_avatar.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:tencent_im_sdk_plugin/models/v2_tim_message.dart';

class ShowGroupCardMessage extends StatelessWidget {
  final V2TimMessage message;
  const ShowGroupCardMessage(this.message, {Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    var model = GroupCardModel.fromJson(
      json.decode(message.customElem!.data!),
    );
    return Container(
      width: Get.width * 0.618,
      padding: const EdgeInsets.all(12),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(4),
        color: AppColors.white,
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Row(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              GroupAvatar(model.groupID),
              const SizedBox(
                width: 8,
              ),
              Text(
                model.groupName,
                style: const TextStyle(
                  color: AppColors.primary,
                  overflow: TextOverflow.ellipsis,
                ),
                maxLines: 1,
              )
            ],
          ),
          const Divider(height: 16),
          const Text(
            '个人名片',
            style: TextStyle(
              fontSize: AppSize.smallFontSize,
              color: AppColors.primary,
            ),
          ),
        ],
      ),
    );
  }
}
