import 'dart:convert';

import 'package:azlistview/azlistview.dart';
import 'package:prime_chat/basic/Method.dart';

import 'Global.dart';

/// 图片
class RemoteImageInfo {
  // String originalName;
  final String path;
  final String fileServer;

  RemoteImageInfo({required this.path, this.fileServer = "$server/file/"});

  const RemoteImageInfo.mock()
      : path = "",
        fileServer = "";

  RemoteImageInfo.fromJson(Map<String, dynamic> json)
      :
        // this.originalName = json["originalName"],
        path = json["path"],
        fileServer = json["fileServer"];
}

class FriendInfo extends ISuspensionBean {
  String? tagIndex;
  final Profile profile;

  FriendInfo({required this.profile, this.tagIndex});

  @override
  String getSuspensionTag() => tagIndex ?? name.substring(0, 1);

  String get name => profile.name;

  // toJson() => {"username": username, "uid": uid};

  // @override
  // String toString() => jsonEncode(this);
}

/// 用户自己的信息
class Profile {
  final String id;
  final String name;
  final RemoteImageInfo avatar;

  const Profile(
      {this.id = "",
      required this.name,
      this.avatar = const RemoteImageInfo.mock()});

  Profile.fromJson(Map<String, dynamic> json)
      : name = json["name"],
        id = json["userId"].toString(),
        avatar = RemoteImageInfo(path: json["avatar"]);
}
