import 'package:get/get.dart';
import 'package:json_annotation/json_annotation.dart';

part 'talk_original.g.dart';

@JsonSerializable()
class TalkOriginal {
  @JsonKey(name: 'endMs')
  int? endMs;

  @JsonKey(name: 'startMs')
  int? startMs;

  @JsonKey(name: 'duration')
  double? duration;

  @JsonKey(name: 'speakerId')
  int? speakerId;

  @JsonKey(name: 'speaker')
  String? speaker;

  @JsonKey(name: 'sentence')
  String? sentence;

  @JsonKey(includeFromJson: false, includeToJson: false)
  final Rxn<bool> _isSelected = Rxn<bool>();

  bool isSelected() => _isSelected.value ?? false;

  setSelected(bool value) => _isSelected.value = value;

  @JsonKey(includeFromJson: false, includeToJson: false)
  final Rx<TalkTranslate> _translateStatus = TalkTranslate.normal.obs;

  TalkTranslate getTranslateStatus() => _translateStatus.value;

  setTranslateStatus(TalkTranslate value) => _translateStatus.value = value;

  @JsonKey(includeFromJson: false, includeToJson: false)
  final Rxn<String> _translatedSentence = Rxn<String>();

  String? getTranslatedSentence() => _translatedSentence.value;

  setTranslatedSentence(String value) => _translatedSentence.value = value;

  TalkOriginal({
    this.endMs,
    this.startMs,
    this.duration,
    this.speakerId,
    this.speaker,
    this.sentence,
  });

  factory TalkOriginal.fromJson(Map<String, dynamic> json) =>
      _$TalkOriginalFromJson(json);
}

enum TalkTranslate {
  normal,
  translating,
  translated,
  translateFail,
}
