import 'dart:convert';
import 'package:chat/configs/app_colors.dart';
import 'package:chat/configs/app_size.dart';
import 'package:chat/models/im/transfer_model.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:tencent_im_sdk_plugin_platform_interface/models/v2_tim_message.dart';

class ShowTransferMessage extends StatefulWidget {
  final V2TimMessage message;

  const ShowTransferMessage(this.message, {Key? key}) : super(key: key);

  @override
  State<ShowTransferMessage> createState() => _ShowTransferMessageState();
}

class _ShowTransferMessageState extends State<ShowTransferMessage> {
  @override
  Widget build(BuildContext context) {
    var model = TransferModel.fromJson(
      json.decode(widget.message.customElem!.data!),
    );

    return InkWell(
      onTap: () {
        // Get.toNamed(
        //   ConversationRoutes.conversationTransferDetail,
        //   arguments: {
        //     'order_id': model.orderId,
        //   },
        // );
      },
      child: Container(
        width: Get.width * 0.618,
        padding: const EdgeInsets.all(12),
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(4),
          color: widget.message.isSelf! ? AppColors.primary : AppColors.white,
        ),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Row(
              children: [
                Icon(
                  Icons.currency_exchange,
                  size: 44,
                  color: widget.message.isSelf!
                      ? AppColors.white
                      : AppColors.primary,
                ),
                const SizedBox(
                  width: 8,
                ),
                Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Row(
                      children: [
                        Text(
                          '￥',
                          style: TextStyle(
                            color: widget.message.isSelf!
                                ? AppColors.white
                                : AppColors.primary,
                          ),
                        ),
                        Text(
                          model.amount,
                          style: TextStyle(
                            color: widget.message.isSelf!
                                ? AppColors.white
                                : AppColors.primary,
                            fontSize: AppSize.titleFontSize,
                            fontWeight: FontWeight.bold,
                          ),
                        ),
                      ],
                    ),
                    Text(
                      '发起积分转账',
                      style: TextStyle(
                        color: widget.message.isSelf!
                            ? AppColors.white
                            : AppColors.primary,
                        fontSize: AppSize.fontSize,
                      ),
                    ),
                  ],
                )
              ],
            ),
            Divider(
              height: 16,
              color: widget.message.isSelf! ? AppColors.white : null,
            ),
            Text(
              'DT积分转账',
              style: TextStyle(
                color: widget.message.isSelf!
                    ? AppColors.white
                    : AppColors.primary,
                fontSize: AppSize.smallFontSize,
              ),
            ),
          ],
        ),
      ),
    );
  }
}
