// Author: fengshengxiong
// Date: 2024/7/28
// Description: 搜索结果TabBar模型

import 'dart:convert';

import 'package:tone_snap/data/models/music_model.dart';

class SearchResultTabBarModel {
  String? title;
  String? params;
  String? uniqueId;
  List<MusicModel>? musicList;

  SearchResultTabBarModel({
    this.title,
    this.params,
    this.uniqueId,
    this.musicList,
  });

  SearchResultTabBarModel copyWith({
    String? title,
    String? params,
    String? uniqueId,
    List<MusicModel>? musicList,
  }) =>
      SearchResultTabBarModel(
        title: title ?? this.title,
        params: params ?? this.params,
        uniqueId: uniqueId ?? this.uniqueId,
        musicList: musicList ?? this.musicList,
      );

  factory SearchResultTabBarModel.fromJson(String str) => SearchResultTabBarModel.fromMap(json.decode(str));

  String toJson() => json.encode(toMap());

  factory SearchResultTabBarModel.fromMap(Map<String, dynamic> json) => SearchResultTabBarModel(
    title: json["title"],
    params: json["params"],
    uniqueId: json["uniqueId"],
    musicList: json["musicList"] == null ? <MusicModel>[] : List<MusicModel>.from(json["musicList"]!.map((x) => MusicModel.fromMap(x))),
  );

  Map<String, dynamic> toMap() => {
    "title": title,
    "params": params,
    "uniqueId": uniqueId,
    "musicList": musicList == null ? [] : List<dynamic>.from(musicList!.map((x) => x.toMap())),
  };
}
