import 'package:json_annotation/json_annotation.dart';

import '../../module/talk/controller.dart';

part 'talk_tabs.g.dart';

@JsonSerializable()
class TalkTabs {
  @JsonKey(name: 'name')
  final String name;

  @JsonKey(
      name: 'type',
      fromJson: _talkTabsTypeFromJson,
      includeToJson: false,
      includeFromJson: true)
  final TalkBarType type;

  @JsonKey(name: 'select')
  final bool? select;

  TalkTabs(this.name, this.type, this.select);

  factory TalkTabs.fromJson(Map<String, dynamic> json) =>
      _$TalkTabsFromJson(json);

  static _talkTabsTypeFromJson(String? target) {
    if (target == 'summary') {
      return TalkBarType.summary;
    } else if (target == 'mind') {
      return TalkBarType.mindMap;
    } else if (target == 'agenda') {
      return TalkBarType.myTask;
    } else if (target == 'original') {
      return TalkBarType.original;
    }
    throw Exception('Unknown TalkTabs type: $target');
  }
}
