import 'package:json_annotation/json_annotation.dart';
import 'package:marking_app/common/model/job/job_page_tab.dart';

part 'job_do_synchro_tab.g.dart';

@JsonSerializable()
class JobDoSynchroTab extends Object {
  List<JobPageTab> tabs;

  JobDoSynchroTab(this.tabs);

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

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

  /// 当前tab下一个tab的pageIndex
  int? getNextPageIndex([int? indexLocated]) {
    if (indexLocated == null) return null;
    return indexLocated == tabs.length - 1 ? null : tabs[indexLocated + 1].pageIndex;
  }

  /// 当前tab上一个tab的pageIndex
  int? getPreviousPageIndex([int? indexLocated]) {
    if (indexLocated == null) return null;
    return indexLocated == 0 ? null : tabs[indexLocated - 1].pageIndex;
  }
}
