Some checks failed
CI / Windows build (push) Has been cancelled
Add a bookmark tool to the PDF editor. A bookmark anchors to a precise location: when text is selected it captures the selection's normalized rect + the start char index in the page text (the true paragraph anchor); with no selection it falls back to the tapped page + point. - Bookmark model gains optional normalized anchor rect + charIndex + label (all absent from JSON when null, so old sidecars still load). - Bookmarks persist in the sidecar (scheduleBookmarkUpsert) and load on open; a bookmarks panel lists them and tapping one jumps to its page. Delete is persisted. Scoped to the PDF editor (note bookmarks later); scroll-to-anchor is page-level for now. analyze clean, 391 tests green.
434 lines
14 KiB
Dart
434 lines
14 KiB
Dart
// coverage:ignore-file
|
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
// ignore_for_file: type=lint
|
|
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
|
|
|
part of 'bookmark.dart';
|
|
|
|
// **************************************************************************
|
|
// FreezedGenerator
|
|
// **************************************************************************
|
|
|
|
T _$identity<T>(T value) => value;
|
|
|
|
final _privateConstructorUsedError = UnsupportedError(
|
|
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
|
|
);
|
|
|
|
Bookmark _$BookmarkFromJson(Map<String, dynamic> json) {
|
|
return _Bookmark.fromJson(json);
|
|
}
|
|
|
|
/// @nodoc
|
|
mixin _$Bookmark {
|
|
String get id => throw _privateConstructorUsedError;
|
|
String get documentId => throw _privateConstructorUsedError;
|
|
|
|
/// 1-based page number this bookmark lives on.
|
|
int get pageNumber => throw _privateConstructorUsedError;
|
|
String get label => throw _privateConstructorUsedError;
|
|
int get color => throw _privateConstructorUsedError;
|
|
DateTime get createdAt => throw _privateConstructorUsedError;
|
|
|
|
/// Normalized in-page anchor rect (top-left origin, [0,1]). Null for legacy
|
|
/// page-only bookmarks (and tap-fallback bookmarks set only top/left). Old
|
|
/// page-only bookmark JSON omits these keys; they decode to null and the
|
|
/// data round-trips (back-compat). A re-encoded legacy bookmark gains
|
|
/// explicit null keys, which readers tolerate.
|
|
double? get anchorLeft => throw _privateConstructorUsedError;
|
|
double? get anchorTop => throw _privateConstructorUsedError;
|
|
double? get anchorRight => throw _privateConstructorUsedError;
|
|
double? get anchorBottom => throw _privateConstructorUsedError;
|
|
|
|
/// Character index of the selection start in the page's `fullText`, or null
|
|
/// (tap-fallback / legacy bookmarks).
|
|
int? get charIndex => throw _privateConstructorUsedError;
|
|
|
|
/// Serializes this Bookmark to a JSON map.
|
|
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
|
|
|
/// Create a copy of Bookmark
|
|
/// with the given fields replaced by the non-null parameter values.
|
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
$BookmarkCopyWith<Bookmark> get copyWith =>
|
|
throw _privateConstructorUsedError;
|
|
}
|
|
|
|
/// @nodoc
|
|
abstract class $BookmarkCopyWith<$Res> {
|
|
factory $BookmarkCopyWith(Bookmark value, $Res Function(Bookmark) then) =
|
|
_$BookmarkCopyWithImpl<$Res, Bookmark>;
|
|
@useResult
|
|
$Res call({
|
|
String id,
|
|
String documentId,
|
|
int pageNumber,
|
|
String label,
|
|
int color,
|
|
DateTime createdAt,
|
|
double? anchorLeft,
|
|
double? anchorTop,
|
|
double? anchorRight,
|
|
double? anchorBottom,
|
|
int? charIndex,
|
|
});
|
|
}
|
|
|
|
/// @nodoc
|
|
class _$BookmarkCopyWithImpl<$Res, $Val extends Bookmark>
|
|
implements $BookmarkCopyWith<$Res> {
|
|
_$BookmarkCopyWithImpl(this._value, this._then);
|
|
|
|
// ignore: unused_field
|
|
final $Val _value;
|
|
// ignore: unused_field
|
|
final $Res Function($Val) _then;
|
|
|
|
/// Create a copy of Bookmark
|
|
/// with the given fields replaced by the non-null parameter values.
|
|
@pragma('vm:prefer-inline')
|
|
@override
|
|
$Res call({
|
|
Object? id = null,
|
|
Object? documentId = null,
|
|
Object? pageNumber = null,
|
|
Object? label = null,
|
|
Object? color = null,
|
|
Object? createdAt = null,
|
|
Object? anchorLeft = freezed,
|
|
Object? anchorTop = freezed,
|
|
Object? anchorRight = freezed,
|
|
Object? anchorBottom = freezed,
|
|
Object? charIndex = freezed,
|
|
}) {
|
|
return _then(
|
|
_value.copyWith(
|
|
id: null == id
|
|
? _value.id
|
|
: id // ignore: cast_nullable_to_non_nullable
|
|
as String,
|
|
documentId: null == documentId
|
|
? _value.documentId
|
|
: documentId // ignore: cast_nullable_to_non_nullable
|
|
as String,
|
|
pageNumber: null == pageNumber
|
|
? _value.pageNumber
|
|
: pageNumber // ignore: cast_nullable_to_non_nullable
|
|
as int,
|
|
label: null == label
|
|
? _value.label
|
|
: label // ignore: cast_nullable_to_non_nullable
|
|
as String,
|
|
color: null == color
|
|
? _value.color
|
|
: color // ignore: cast_nullable_to_non_nullable
|
|
as int,
|
|
createdAt: null == createdAt
|
|
? _value.createdAt
|
|
: createdAt // ignore: cast_nullable_to_non_nullable
|
|
as DateTime,
|
|
anchorLeft: freezed == anchorLeft
|
|
? _value.anchorLeft
|
|
: anchorLeft // ignore: cast_nullable_to_non_nullable
|
|
as double?,
|
|
anchorTop: freezed == anchorTop
|
|
? _value.anchorTop
|
|
: anchorTop // ignore: cast_nullable_to_non_nullable
|
|
as double?,
|
|
anchorRight: freezed == anchorRight
|
|
? _value.anchorRight
|
|
: anchorRight // ignore: cast_nullable_to_non_nullable
|
|
as double?,
|
|
anchorBottom: freezed == anchorBottom
|
|
? _value.anchorBottom
|
|
: anchorBottom // ignore: cast_nullable_to_non_nullable
|
|
as double?,
|
|
charIndex: freezed == charIndex
|
|
? _value.charIndex
|
|
: charIndex // ignore: cast_nullable_to_non_nullable
|
|
as int?,
|
|
)
|
|
as $Val,
|
|
);
|
|
}
|
|
}
|
|
|
|
/// @nodoc
|
|
abstract class _$$BookmarkImplCopyWith<$Res>
|
|
implements $BookmarkCopyWith<$Res> {
|
|
factory _$$BookmarkImplCopyWith(
|
|
_$BookmarkImpl value,
|
|
$Res Function(_$BookmarkImpl) then,
|
|
) = __$$BookmarkImplCopyWithImpl<$Res>;
|
|
@override
|
|
@useResult
|
|
$Res call({
|
|
String id,
|
|
String documentId,
|
|
int pageNumber,
|
|
String label,
|
|
int color,
|
|
DateTime createdAt,
|
|
double? anchorLeft,
|
|
double? anchorTop,
|
|
double? anchorRight,
|
|
double? anchorBottom,
|
|
int? charIndex,
|
|
});
|
|
}
|
|
|
|
/// @nodoc
|
|
class __$$BookmarkImplCopyWithImpl<$Res>
|
|
extends _$BookmarkCopyWithImpl<$Res, _$BookmarkImpl>
|
|
implements _$$BookmarkImplCopyWith<$Res> {
|
|
__$$BookmarkImplCopyWithImpl(
|
|
_$BookmarkImpl _value,
|
|
$Res Function(_$BookmarkImpl) _then,
|
|
) : super(_value, _then);
|
|
|
|
/// Create a copy of Bookmark
|
|
/// with the given fields replaced by the non-null parameter values.
|
|
@pragma('vm:prefer-inline')
|
|
@override
|
|
$Res call({
|
|
Object? id = null,
|
|
Object? documentId = null,
|
|
Object? pageNumber = null,
|
|
Object? label = null,
|
|
Object? color = null,
|
|
Object? createdAt = null,
|
|
Object? anchorLeft = freezed,
|
|
Object? anchorTop = freezed,
|
|
Object? anchorRight = freezed,
|
|
Object? anchorBottom = freezed,
|
|
Object? charIndex = freezed,
|
|
}) {
|
|
return _then(
|
|
_$BookmarkImpl(
|
|
id: null == id
|
|
? _value.id
|
|
: id // ignore: cast_nullable_to_non_nullable
|
|
as String,
|
|
documentId: null == documentId
|
|
? _value.documentId
|
|
: documentId // ignore: cast_nullable_to_non_nullable
|
|
as String,
|
|
pageNumber: null == pageNumber
|
|
? _value.pageNumber
|
|
: pageNumber // ignore: cast_nullable_to_non_nullable
|
|
as int,
|
|
label: null == label
|
|
? _value.label
|
|
: label // ignore: cast_nullable_to_non_nullable
|
|
as String,
|
|
color: null == color
|
|
? _value.color
|
|
: color // ignore: cast_nullable_to_non_nullable
|
|
as int,
|
|
createdAt: null == createdAt
|
|
? _value.createdAt
|
|
: createdAt // ignore: cast_nullable_to_non_nullable
|
|
as DateTime,
|
|
anchorLeft: freezed == anchorLeft
|
|
? _value.anchorLeft
|
|
: anchorLeft // ignore: cast_nullable_to_non_nullable
|
|
as double?,
|
|
anchorTop: freezed == anchorTop
|
|
? _value.anchorTop
|
|
: anchorTop // ignore: cast_nullable_to_non_nullable
|
|
as double?,
|
|
anchorRight: freezed == anchorRight
|
|
? _value.anchorRight
|
|
: anchorRight // ignore: cast_nullable_to_non_nullable
|
|
as double?,
|
|
anchorBottom: freezed == anchorBottom
|
|
? _value.anchorBottom
|
|
: anchorBottom // ignore: cast_nullable_to_non_nullable
|
|
as double?,
|
|
charIndex: freezed == charIndex
|
|
? _value.charIndex
|
|
: charIndex // ignore: cast_nullable_to_non_nullable
|
|
as int?,
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// @nodoc
|
|
@JsonSerializable()
|
|
class _$BookmarkImpl implements _Bookmark {
|
|
const _$BookmarkImpl({
|
|
required this.id,
|
|
required this.documentId,
|
|
required this.pageNumber,
|
|
this.label = '',
|
|
this.color = 0xFF2196F3,
|
|
required this.createdAt,
|
|
this.anchorLeft,
|
|
this.anchorTop,
|
|
this.anchorRight,
|
|
this.anchorBottom,
|
|
this.charIndex,
|
|
});
|
|
|
|
factory _$BookmarkImpl.fromJson(Map<String, dynamic> json) =>
|
|
_$$BookmarkImplFromJson(json);
|
|
|
|
@override
|
|
final String id;
|
|
@override
|
|
final String documentId;
|
|
|
|
/// 1-based page number this bookmark lives on.
|
|
@override
|
|
final int pageNumber;
|
|
@override
|
|
@JsonKey()
|
|
final String label;
|
|
@override
|
|
@JsonKey()
|
|
final int color;
|
|
@override
|
|
final DateTime createdAt;
|
|
|
|
/// Normalized in-page anchor rect (top-left origin, [0,1]). Null for legacy
|
|
/// page-only bookmarks (and tap-fallback bookmarks set only top/left). Old
|
|
/// page-only bookmark JSON omits these keys; they decode to null and the
|
|
/// data round-trips (back-compat). A re-encoded legacy bookmark gains
|
|
/// explicit null keys, which readers tolerate.
|
|
@override
|
|
final double? anchorLeft;
|
|
@override
|
|
final double? anchorTop;
|
|
@override
|
|
final double? anchorRight;
|
|
@override
|
|
final double? anchorBottom;
|
|
|
|
/// Character index of the selection start in the page's `fullText`, or null
|
|
/// (tap-fallback / legacy bookmarks).
|
|
@override
|
|
final int? charIndex;
|
|
|
|
@override
|
|
String toString() {
|
|
return 'Bookmark(id: $id, documentId: $documentId, pageNumber: $pageNumber, label: $label, color: $color, createdAt: $createdAt, anchorLeft: $anchorLeft, anchorTop: $anchorTop, anchorRight: $anchorRight, anchorBottom: $anchorBottom, charIndex: $charIndex)';
|
|
}
|
|
|
|
@override
|
|
bool operator ==(Object other) {
|
|
return identical(this, other) ||
|
|
(other.runtimeType == runtimeType &&
|
|
other is _$BookmarkImpl &&
|
|
(identical(other.id, id) || other.id == id) &&
|
|
(identical(other.documentId, documentId) ||
|
|
other.documentId == documentId) &&
|
|
(identical(other.pageNumber, pageNumber) ||
|
|
other.pageNumber == pageNumber) &&
|
|
(identical(other.label, label) || other.label == label) &&
|
|
(identical(other.color, color) || other.color == color) &&
|
|
(identical(other.createdAt, createdAt) ||
|
|
other.createdAt == createdAt) &&
|
|
(identical(other.anchorLeft, anchorLeft) ||
|
|
other.anchorLeft == anchorLeft) &&
|
|
(identical(other.anchorTop, anchorTop) ||
|
|
other.anchorTop == anchorTop) &&
|
|
(identical(other.anchorRight, anchorRight) ||
|
|
other.anchorRight == anchorRight) &&
|
|
(identical(other.anchorBottom, anchorBottom) ||
|
|
other.anchorBottom == anchorBottom) &&
|
|
(identical(other.charIndex, charIndex) ||
|
|
other.charIndex == charIndex));
|
|
}
|
|
|
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
@override
|
|
int get hashCode => Object.hash(
|
|
runtimeType,
|
|
id,
|
|
documentId,
|
|
pageNumber,
|
|
label,
|
|
color,
|
|
createdAt,
|
|
anchorLeft,
|
|
anchorTop,
|
|
anchorRight,
|
|
anchorBottom,
|
|
charIndex,
|
|
);
|
|
|
|
/// Create a copy of Bookmark
|
|
/// with the given fields replaced by the non-null parameter values.
|
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
@override
|
|
@pragma('vm:prefer-inline')
|
|
_$$BookmarkImplCopyWith<_$BookmarkImpl> get copyWith =>
|
|
__$$BookmarkImplCopyWithImpl<_$BookmarkImpl>(this, _$identity);
|
|
|
|
@override
|
|
Map<String, dynamic> toJson() {
|
|
return _$$BookmarkImplToJson(this);
|
|
}
|
|
}
|
|
|
|
abstract class _Bookmark implements Bookmark {
|
|
const factory _Bookmark({
|
|
required final String id,
|
|
required final String documentId,
|
|
required final int pageNumber,
|
|
final String label,
|
|
final int color,
|
|
required final DateTime createdAt,
|
|
final double? anchorLeft,
|
|
final double? anchorTop,
|
|
final double? anchorRight,
|
|
final double? anchorBottom,
|
|
final int? charIndex,
|
|
}) = _$BookmarkImpl;
|
|
|
|
factory _Bookmark.fromJson(Map<String, dynamic> json) =
|
|
_$BookmarkImpl.fromJson;
|
|
|
|
@override
|
|
String get id;
|
|
@override
|
|
String get documentId;
|
|
|
|
/// 1-based page number this bookmark lives on.
|
|
@override
|
|
int get pageNumber;
|
|
@override
|
|
String get label;
|
|
@override
|
|
int get color;
|
|
@override
|
|
DateTime get createdAt;
|
|
|
|
/// Normalized in-page anchor rect (top-left origin, [0,1]). Null for legacy
|
|
/// page-only bookmarks (and tap-fallback bookmarks set only top/left). Old
|
|
/// page-only bookmark JSON omits these keys; they decode to null and the
|
|
/// data round-trips (back-compat). A re-encoded legacy bookmark gains
|
|
/// explicit null keys, which readers tolerate.
|
|
@override
|
|
double? get anchorLeft;
|
|
@override
|
|
double? get anchorTop;
|
|
@override
|
|
double? get anchorRight;
|
|
@override
|
|
double? get anchorBottom;
|
|
|
|
/// Character index of the selection start in the page's `fullText`, or null
|
|
/// (tap-fallback / legacy bookmarks).
|
|
@override
|
|
int? get charIndex;
|
|
|
|
/// Create a copy of Bookmark
|
|
/// with the given fields replaced by the non-null parameter values.
|
|
@override
|
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
_$$BookmarkImplCopyWith<_$BookmarkImpl> get copyWith =>
|
|
throw _privateConstructorUsedError;
|
|
}
|