// 实体文件

import 'dart:ui';

import 'package:get/get.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:making_school_asignment_app/page/home_page/children/homework_review/components/job_handwriting.dart';

part 'states.g.dart';

@JsonSerializable()
class HandwritingInfo extends Object {
  int pauseCount; // 停顿次数
  List<PauseIntervalTime> pauseInterval;
  int timeConsuming; // 耗时（毫秒）
  Map<int, List<Lattices>> strokeMap; // 笔画数据

  HandwritingInfo(this.pauseCount, this.timeConsuming, this.strokeMap, this.pauseInterval);

  factory HandwritingInfo.fromJson(Map<String, dynamic> srcJson) => _$HandwritingInfoFromJson(srcJson);

  Map<String, dynamic> toJson() => _$HandwritingInfoToJson(this);
}

class ToolbarControl {
  Rx<bool> showManuscript; // 查看原稿
  Rx<bool> initialization;
  Rx<List<GestureHandwritingRecording>> executionData;

  ToolbarControl({
    required this.executionData,
    required this.showManuscript,
    required this.initialization,
  });
}

// 播放倍速
enum PlaybackSpeed {
  ORIGINAL_SPEED(name: '原速播放', speed: 1),
  ONE_POINT_FIVE_SPEED(name: '1.5x播放', speed: 1.5),
  DOUBLE_SPEED(name: '2.0x播放', speed: 2),
  TRIPLE_SPEED(name: '3.0x播放', speed: 3),
  FOUR_SPEED(name: '4.0x播放', speed: 4),
  FIVE_SPEED(name: '5.0x播放', speed: 5),
  SIX_SPEED(name: '6.0x播放', speed: 6);

  const PlaybackSpeed({required this.name, required this.speed});
  final double speed;
  final String name;
}

@JsonSerializable()
class PauseIntervalTime extends Object {
  int? apart;
  int startTime;
  int endTime;
  PauseIntervalTime({required this.startTime, required this.endTime}) {
    apart = endTime - startTime;
  }

  factory PauseIntervalTime.fromJson(Map<String, dynamic> srcJson) => _$PauseIntervalTimeFromJson(srcJson);

  Map<String, dynamic> toJson() => _$PauseIntervalTimeToJson(this);
}

// 播放按钮
class JobHandwritingPlaybarBus {
  bool play;
  bool recalculate;
  JobHandwritingPlaybarBus(this.play, [this.recalculate = true]);
}

// 笔迹是否已经准备好(笔迹计算好坐标后通知通知栏可以开始播放)
class JobHandwritingGetReadyBus {
  JobHandwritingGetReadyBus();
}

// 笔记运行时间
class JobHandwritingRunTimeBus {
  int runTimeVal;
  int totalVal;
  JobHandwritingRunTimeBus(this.runTimeVal, this.totalVal);
}

// 拖动进度条
class JobHandwritingDragProgressBarBus {
  int changeVal;
  int totalVal;
  JobHandwritingDragProgressBarBus(this.changeVal, this.totalVal);
}

// 播放速度 （原速播放/快速播放）
class PlaybackSpeedBus {
  double speed;
  PlaybackSpeedBus(this.speed);
}

// 手势记录(原稿笔记还原)
class GestureHandwritingRecording {
  int stroke;
  int usageTime; // 用时
  Offset data;
  int intervalTime; // 间隔时间
  GestureHandwritingRecording({
    required this.stroke,
    required this.data,
    required this.usageTime,
    required this.intervalTime,
  });
}
