import 'dart:convert';

import 'package:fluro/fluro.dart';
import 'package:flutter/cupertino.dart';
import 'package:yumi/modules/chat/noti/message_notifcation_page.dart';
import 'package:yumi/modules/chat/system/message_system_page.dart';
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart';
import 'package:yumi/app/routes/sc_router_init.dart';
import 'package:yumi/modules/chat/activity/message_activity_page.dart';

import 'message_chat_page.dart';

class SCChatRouter implements SCIRouterProvider {
  static String chat = '/chat';
  static String systemChat = '/systemChat';
  static String dynamicMsg = '/dynamicMsg';
  static String notifcation = '/chat/notifcation';
  static String activity = '/chat/activity';

  @override
  void initRouter(FluroRouter router) {
    router.define(
      chat,
      handler: Handler(
        handlerFunc:
            (_, params) => SCMessageChatPage(
              conversation: V2TimConversation.fromJson(
                jsonDecode(params['conversation']!.first),
              ),
            ),
      ),
    );

    router.define(
      systemChat,
      handler: Handler(
        handlerFunc:
            (_, params) => MessageSystemPage(
              conversation: V2TimConversation.fromJson(
                jsonDecode(params['conversation']!.first),
              ),
            ),
      ),
    );
    router.define(
      dynamicMsg,
      handler: Handler(handlerFunc: (_, params) => Container()),
    );

    router.define(
      notifcation,
      handler: Handler(handlerFunc: (_, params) => MessageNotifcationPage()),
    );
    router.define(
      activity,
      handler: Handler(handlerFunc: (_, params) => MessageActivityPage()),
    );
  }
}
