refactor: rename some class names

This commit is contained in:
appflowy 2022-02-23 22:17:47 +08:00
parent b8a4897056
commit c1237452ab
14 changed files with 218 additions and 230 deletions

View File

@ -1,11 +1,11 @@
import 'dart:convert'; import 'dart:convert';
import 'package:app_flowy/workspace/infrastructure/repos/doc_repo.dart'; import 'package:app_flowy/workspace/infrastructure/repos/document_repo.dart';
import 'package:app_flowy/workspace/infrastructure/repos/trash_repo.dart'; import 'package:app_flowy/workspace/infrastructure/repos/trash_repo.dart';
import 'package:app_flowy/workspace/infrastructure/repos/view_repo.dart'; import 'package:app_flowy/workspace/infrastructure/repos/view_repo.dart';
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/trash.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-folder-data-model/trash.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
import 'package:flutter_quill/flutter_quill.dart'; import 'package:flutter_quill/flutter_quill.dart' show Document, Delta;
import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/log.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:freezed_annotation/freezed_annotation.dart';
@ -13,21 +13,23 @@ import 'package:dartz/dartz.dart';
import 'dart:async'; import 'dart:async';
part 'doc_bloc.freezed.dart'; part 'doc_bloc.freezed.dart';
class DocBloc extends Bloc<DocEvent, DocState> { typedef FlutterQuillDocument = Document;
class DocumentBloc extends Bloc<DocumentEvent, DocumentState> {
final View view; final View view;
final DocRepository repo; final DocumentRepository repo;
final ViewListener listener; final ViewListener listener;
final TrashRepo trashRepo; final TrashRepo trashRepo;
late Document document; late FlutterQuillDocument document;
StreamSubscription? _subscription; StreamSubscription? _subscription;
DocBloc({ DocumentBloc({
required this.view, required this.view,
required this.repo, required this.repo,
required this.listener, required this.listener,
required this.trashRepo, required this.trashRepo,
}) : super(DocState.initial()) { }) : super(DocumentState.initial()) {
on<DocEvent>((event, emit) async { on<DocumentEvent>((event, emit) async {
await event.map( await event.map(
initial: (Initial value) async { initial: (Initial value) async {
await _initial(value, emit); await _initial(value, emit);
@ -60,27 +62,27 @@ class DocBloc extends Bloc<DocEvent, DocState> {
await _subscription?.cancel(); await _subscription?.cancel();
} }
repo.closeDoc(); repo.closeDocument();
return super.close(); return super.close();
} }
Future<void> _initial(Initial value, Emitter<DocState> emit) async { Future<void> _initial(Initial value, Emitter<DocumentState> emit) async {
listener.deletedNotifier.addPublishListener((result) { listener.deletedNotifier.addPublishListener((result) {
result.fold( result.fold(
(view) => add(const DocEvent.deleted()), (view) => add(const DocumentEvent.deleted()),
(error) {}, (error) {},
); );
}); });
listener.restoredNotifier.addPublishListener((result) { listener.restoredNotifier.addPublishListener((result) {
result.fold( result.fold(
(view) => add(const DocEvent.restore()), (view) => add(const DocumentEvent.restore()),
(error) {}, (error) {},
); );
}); });
listener.start(); listener.start();
final result = await repo.readDoc(); final result = await repo.openDocument();
result.fold( result.fold(
(doc) { (doc) {
document = _decodeJsonToDocument(doc.deltaJson); document = _decodeJsonToDocument(doc.deltaJson);
@ -89,10 +91,10 @@ class DocBloc extends Bloc<DocEvent, DocState> {
final documentDelta = document.toDelta(); final documentDelta = document.toDelta();
_composeDelta(delta, documentDelta); _composeDelta(delta, documentDelta);
}); });
emit(state.copyWith(loadState: DocLoadState.finish(left(unit)))); emit(state.copyWith(loadingState: DocumentLoadingState.finish(left(unit))));
}, },
(err) { (err) {
emit(state.copyWith(loadState: DocLoadState.finish(right(err)))); emit(state.copyWith(loadingState: DocumentLoadingState.finish(right(err))));
}, },
); );
} }
@ -126,31 +128,31 @@ class DocBloc extends Bloc<DocEvent, DocState> {
} }
@freezed @freezed
class DocEvent with _$DocEvent { class DocumentEvent with _$DocumentEvent {
const factory DocEvent.initial() = Initial; const factory DocumentEvent.initial() = Initial;
const factory DocEvent.deleted() = Deleted; const factory DocumentEvent.deleted() = Deleted;
const factory DocEvent.restore() = Restore; const factory DocumentEvent.restore() = Restore;
const factory DocEvent.restorePage() = RestorePage; const factory DocumentEvent.restorePage() = RestorePage;
const factory DocEvent.deletePermanently() = DeletePermanently; const factory DocumentEvent.deletePermanently() = DeletePermanently;
} }
@freezed @freezed
class DocState with _$DocState { class DocumentState with _$DocumentState {
const factory DocState({ const factory DocumentState({
required DocLoadState loadState, required DocumentLoadingState loadingState,
required bool isDeleted, required bool isDeleted,
required bool forceClose, required bool forceClose,
}) = _DocState; }) = _DocumentState;
factory DocState.initial() => const DocState( factory DocumentState.initial() => const DocumentState(
loadState: _Loading(), loadingState: _Loading(),
isDeleted: false, isDeleted: false,
forceClose: false, forceClose: false,
); );
} }
@freezed @freezed
class DocLoadState with _$DocLoadState { class DocumentLoadingState with _$DocumentLoadingState {
const factory DocLoadState.loading() = _Loading; const factory DocumentLoadingState.loading() = _Loading;
const factory DocLoadState.finish(Either<Unit, FlowyError> successOrFail) = _Finish; const factory DocumentLoadingState.finish(Either<Unit, FlowyError> successOrFail) = _Finish;
} }

View File

@ -14,8 +14,8 @@ 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 informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); '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 informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
/// @nodoc /// @nodoc
class _$DocEventTearOff { class _$DocumentEventTearOff {
const _$DocEventTearOff(); const _$DocumentEventTearOff();
Initial initial() { Initial initial() {
return const Initial(); return const Initial();
@ -39,10 +39,10 @@ class _$DocEventTearOff {
} }
/// @nodoc /// @nodoc
const $DocEvent = _$DocEventTearOff(); const $DocumentEvent = _$DocumentEventTearOff();
/// @nodoc /// @nodoc
mixin _$DocEvent { mixin _$DocumentEvent {
@optionalTypeArgs @optionalTypeArgs
TResult when<TResult extends Object?>({ TResult when<TResult extends Object?>({
required TResult Function() initial, required TResult Function() initial,
@ -102,18 +102,20 @@ mixin _$DocEvent {
} }
/// @nodoc /// @nodoc
abstract class $DocEventCopyWith<$Res> { abstract class $DocumentEventCopyWith<$Res> {
factory $DocEventCopyWith(DocEvent value, $Res Function(DocEvent) then) = factory $DocumentEventCopyWith(
_$DocEventCopyWithImpl<$Res>; DocumentEvent value, $Res Function(DocumentEvent) then) =
_$DocumentEventCopyWithImpl<$Res>;
} }
/// @nodoc /// @nodoc
class _$DocEventCopyWithImpl<$Res> implements $DocEventCopyWith<$Res> { class _$DocumentEventCopyWithImpl<$Res>
_$DocEventCopyWithImpl(this._value, this._then); implements $DocumentEventCopyWith<$Res> {
_$DocumentEventCopyWithImpl(this._value, this._then);
final DocEvent _value; final DocumentEvent _value;
// ignore: unused_field // ignore: unused_field
final $Res Function(DocEvent) _then; final $Res Function(DocumentEvent) _then;
} }
/// @nodoc /// @nodoc
@ -123,7 +125,7 @@ abstract class $InitialCopyWith<$Res> {
} }
/// @nodoc /// @nodoc
class _$InitialCopyWithImpl<$Res> extends _$DocEventCopyWithImpl<$Res> class _$InitialCopyWithImpl<$Res> extends _$DocumentEventCopyWithImpl<$Res>
implements $InitialCopyWith<$Res> { implements $InitialCopyWith<$Res> {
_$InitialCopyWithImpl(Initial _value, $Res Function(Initial) _then) _$InitialCopyWithImpl(Initial _value, $Res Function(Initial) _then)
: super(_value, (v) => _then(v as Initial)); : super(_value, (v) => _then(v as Initial));
@ -139,7 +141,7 @@ class _$Initial implements Initial {
@override @override
String toString() { String toString() {
return 'DocEvent.initial()'; return 'DocumentEvent.initial()';
} }
@override @override
@ -231,7 +233,7 @@ class _$Initial implements Initial {
} }
} }
abstract class Initial implements DocEvent { abstract class Initial implements DocumentEvent {
const factory Initial() = _$Initial; const factory Initial() = _$Initial;
} }
@ -242,7 +244,7 @@ abstract class $DeletedCopyWith<$Res> {
} }
/// @nodoc /// @nodoc
class _$DeletedCopyWithImpl<$Res> extends _$DocEventCopyWithImpl<$Res> class _$DeletedCopyWithImpl<$Res> extends _$DocumentEventCopyWithImpl<$Res>
implements $DeletedCopyWith<$Res> { implements $DeletedCopyWith<$Res> {
_$DeletedCopyWithImpl(Deleted _value, $Res Function(Deleted) _then) _$DeletedCopyWithImpl(Deleted _value, $Res Function(Deleted) _then)
: super(_value, (v) => _then(v as Deleted)); : super(_value, (v) => _then(v as Deleted));
@ -258,7 +260,7 @@ class _$Deleted implements Deleted {
@override @override
String toString() { String toString() {
return 'DocEvent.deleted()'; return 'DocumentEvent.deleted()';
} }
@override @override
@ -350,7 +352,7 @@ class _$Deleted implements Deleted {
} }
} }
abstract class Deleted implements DocEvent { abstract class Deleted implements DocumentEvent {
const factory Deleted() = _$Deleted; const factory Deleted() = _$Deleted;
} }
@ -361,7 +363,7 @@ abstract class $RestoreCopyWith<$Res> {
} }
/// @nodoc /// @nodoc
class _$RestoreCopyWithImpl<$Res> extends _$DocEventCopyWithImpl<$Res> class _$RestoreCopyWithImpl<$Res> extends _$DocumentEventCopyWithImpl<$Res>
implements $RestoreCopyWith<$Res> { implements $RestoreCopyWith<$Res> {
_$RestoreCopyWithImpl(Restore _value, $Res Function(Restore) _then) _$RestoreCopyWithImpl(Restore _value, $Res Function(Restore) _then)
: super(_value, (v) => _then(v as Restore)); : super(_value, (v) => _then(v as Restore));
@ -377,7 +379,7 @@ class _$Restore implements Restore {
@override @override
String toString() { String toString() {
return 'DocEvent.restore()'; return 'DocumentEvent.restore()';
} }
@override @override
@ -469,7 +471,7 @@ class _$Restore implements Restore {
} }
} }
abstract class Restore implements DocEvent { abstract class Restore implements DocumentEvent {
const factory Restore() = _$Restore; const factory Restore() = _$Restore;
} }
@ -481,7 +483,7 @@ abstract class $RestorePageCopyWith<$Res> {
} }
/// @nodoc /// @nodoc
class _$RestorePageCopyWithImpl<$Res> extends _$DocEventCopyWithImpl<$Res> class _$RestorePageCopyWithImpl<$Res> extends _$DocumentEventCopyWithImpl<$Res>
implements $RestorePageCopyWith<$Res> { implements $RestorePageCopyWith<$Res> {
_$RestorePageCopyWithImpl( _$RestorePageCopyWithImpl(
RestorePage _value, $Res Function(RestorePage) _then) RestorePage _value, $Res Function(RestorePage) _then)
@ -498,7 +500,7 @@ class _$RestorePage implements RestorePage {
@override @override
String toString() { String toString() {
return 'DocEvent.restorePage()'; return 'DocumentEvent.restorePage()';
} }
@override @override
@ -590,7 +592,7 @@ class _$RestorePage implements RestorePage {
} }
} }
abstract class RestorePage implements DocEvent { abstract class RestorePage implements DocumentEvent {
const factory RestorePage() = _$RestorePage; const factory RestorePage() = _$RestorePage;
} }
@ -602,7 +604,8 @@ abstract class $DeletePermanentlyCopyWith<$Res> {
} }
/// @nodoc /// @nodoc
class _$DeletePermanentlyCopyWithImpl<$Res> extends _$DocEventCopyWithImpl<$Res> class _$DeletePermanentlyCopyWithImpl<$Res>
extends _$DocumentEventCopyWithImpl<$Res>
implements $DeletePermanentlyCopyWith<$Res> { implements $DeletePermanentlyCopyWith<$Res> {
_$DeletePermanentlyCopyWithImpl( _$DeletePermanentlyCopyWithImpl(
DeletePermanently _value, $Res Function(DeletePermanently) _then) DeletePermanently _value, $Res Function(DeletePermanently) _then)
@ -619,7 +622,7 @@ class _$DeletePermanently implements DeletePermanently {
@override @override
String toString() { String toString() {
return 'DocEvent.deletePermanently()'; return 'DocumentEvent.deletePermanently()';
} }
@override @override
@ -711,20 +714,20 @@ class _$DeletePermanently implements DeletePermanently {
} }
} }
abstract class DeletePermanently implements DocEvent { abstract class DeletePermanently implements DocumentEvent {
const factory DeletePermanently() = _$DeletePermanently; const factory DeletePermanently() = _$DeletePermanently;
} }
/// @nodoc /// @nodoc
class _$DocStateTearOff { class _$DocumentStateTearOff {
const _$DocStateTearOff(); const _$DocumentStateTearOff();
_DocState call( _DocumentState call(
{required DocLoadState loadState, {required DocumentLoadingState loadingState,
required bool isDeleted, required bool isDeleted,
required bool forceClose}) { required bool forceClose}) {
return _DocState( return _DocumentState(
loadState: loadState, loadingState: loadingState,
isDeleted: isDeleted, isDeleted: isDeleted,
forceClose: forceClose, forceClose: forceClose,
); );
@ -732,47 +735,50 @@ class _$DocStateTearOff {
} }
/// @nodoc /// @nodoc
const $DocState = _$DocStateTearOff(); const $DocumentState = _$DocumentStateTearOff();
/// @nodoc /// @nodoc
mixin _$DocState { mixin _$DocumentState {
DocLoadState get loadState => throw _privateConstructorUsedError; DocumentLoadingState get loadingState => throw _privateConstructorUsedError;
bool get isDeleted => throw _privateConstructorUsedError; bool get isDeleted => throw _privateConstructorUsedError;
bool get forceClose => throw _privateConstructorUsedError; bool get forceClose => throw _privateConstructorUsedError;
@JsonKey(ignore: true) @JsonKey(ignore: true)
$DocStateCopyWith<DocState> get copyWith => $DocumentStateCopyWith<DocumentState> get copyWith =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
} }
/// @nodoc /// @nodoc
abstract class $DocStateCopyWith<$Res> { abstract class $DocumentStateCopyWith<$Res> {
factory $DocStateCopyWith(DocState value, $Res Function(DocState) then) = factory $DocumentStateCopyWith(
_$DocStateCopyWithImpl<$Res>; DocumentState value, $Res Function(DocumentState) then) =
$Res call({DocLoadState loadState, bool isDeleted, bool forceClose}); _$DocumentStateCopyWithImpl<$Res>;
$Res call(
{DocumentLoadingState loadingState, bool isDeleted, bool forceClose});
$DocLoadStateCopyWith<$Res> get loadState; $DocumentLoadingStateCopyWith<$Res> get loadingState;
} }
/// @nodoc /// @nodoc
class _$DocStateCopyWithImpl<$Res> implements $DocStateCopyWith<$Res> { class _$DocumentStateCopyWithImpl<$Res>
_$DocStateCopyWithImpl(this._value, this._then); implements $DocumentStateCopyWith<$Res> {
_$DocumentStateCopyWithImpl(this._value, this._then);
final DocState _value; final DocumentState _value;
// ignore: unused_field // ignore: unused_field
final $Res Function(DocState) _then; final $Res Function(DocumentState) _then;
@override @override
$Res call({ $Res call({
Object? loadState = freezed, Object? loadingState = freezed,
Object? isDeleted = freezed, Object? isDeleted = freezed,
Object? forceClose = freezed, Object? forceClose = freezed,
}) { }) {
return _then(_value.copyWith( return _then(_value.copyWith(
loadState: loadState == freezed loadingState: loadingState == freezed
? _value.loadState ? _value.loadingState
: loadState // ignore: cast_nullable_to_non_nullable : loadingState // ignore: cast_nullable_to_non_nullable
as DocLoadState, as DocumentLoadingState,
isDeleted: isDeleted == freezed isDeleted: isDeleted == freezed
? _value.isDeleted ? _value.isDeleted
: isDeleted // ignore: cast_nullable_to_non_nullable : isDeleted // ignore: cast_nullable_to_non_nullable
@ -785,44 +791,49 @@ class _$DocStateCopyWithImpl<$Res> implements $DocStateCopyWith<$Res> {
} }
@override @override
$DocLoadStateCopyWith<$Res> get loadState { $DocumentLoadingStateCopyWith<$Res> get loadingState {
return $DocLoadStateCopyWith<$Res>(_value.loadState, (value) { return $DocumentLoadingStateCopyWith<$Res>(_value.loadingState, (value) {
return _then(_value.copyWith(loadState: value)); return _then(_value.copyWith(loadingState: value));
}); });
} }
} }
/// @nodoc /// @nodoc
abstract class _$DocStateCopyWith<$Res> implements $DocStateCopyWith<$Res> { abstract class _$DocumentStateCopyWith<$Res>
factory _$DocStateCopyWith(_DocState value, $Res Function(_DocState) then) = implements $DocumentStateCopyWith<$Res> {
__$DocStateCopyWithImpl<$Res>; factory _$DocumentStateCopyWith(
_DocumentState value, $Res Function(_DocumentState) then) =
__$DocumentStateCopyWithImpl<$Res>;
@override @override
$Res call({DocLoadState loadState, bool isDeleted, bool forceClose}); $Res call(
{DocumentLoadingState loadingState, bool isDeleted, bool forceClose});
@override @override
$DocLoadStateCopyWith<$Res> get loadState; $DocumentLoadingStateCopyWith<$Res> get loadingState;
} }
/// @nodoc /// @nodoc
class __$DocStateCopyWithImpl<$Res> extends _$DocStateCopyWithImpl<$Res> class __$DocumentStateCopyWithImpl<$Res>
implements _$DocStateCopyWith<$Res> { extends _$DocumentStateCopyWithImpl<$Res>
__$DocStateCopyWithImpl(_DocState _value, $Res Function(_DocState) _then) implements _$DocumentStateCopyWith<$Res> {
: super(_value, (v) => _then(v as _DocState)); __$DocumentStateCopyWithImpl(
_DocumentState _value, $Res Function(_DocumentState) _then)
: super(_value, (v) => _then(v as _DocumentState));
@override @override
_DocState get _value => super._value as _DocState; _DocumentState get _value => super._value as _DocumentState;
@override @override
$Res call({ $Res call({
Object? loadState = freezed, Object? loadingState = freezed,
Object? isDeleted = freezed, Object? isDeleted = freezed,
Object? forceClose = freezed, Object? forceClose = freezed,
}) { }) {
return _then(_DocState( return _then(_DocumentState(
loadState: loadState == freezed loadingState: loadingState == freezed
? _value.loadState ? _value.loadingState
: loadState // ignore: cast_nullable_to_non_nullable : loadingState // ignore: cast_nullable_to_non_nullable
as DocLoadState, as DocumentLoadingState,
isDeleted: isDeleted == freezed isDeleted: isDeleted == freezed
? _value.isDeleted ? _value.isDeleted
: isDeleted // ignore: cast_nullable_to_non_nullable : isDeleted // ignore: cast_nullable_to_non_nullable
@ -837,14 +848,14 @@ class __$DocStateCopyWithImpl<$Res> extends _$DocStateCopyWithImpl<$Res>
/// @nodoc /// @nodoc
class _$_DocState implements _DocState { class _$_DocumentState implements _DocumentState {
const _$_DocState( const _$_DocumentState(
{required this.loadState, {required this.loadingState,
required this.isDeleted, required this.isDeleted,
required this.forceClose}); required this.forceClose});
@override @override
final DocLoadState loadState; final DocumentLoadingState loadingState;
@override @override
final bool isDeleted; final bool isDeleted;
@override @override
@ -852,16 +863,16 @@ class _$_DocState implements _DocState {
@override @override
String toString() { String toString() {
return 'DocState(loadState: $loadState, isDeleted: $isDeleted, forceClose: $forceClose)'; return 'DocumentState(loadingState: $loadingState, isDeleted: $isDeleted, forceClose: $forceClose)';
} }
@override @override
bool operator ==(dynamic other) { bool operator ==(dynamic other) {
return identical(this, other) || return identical(this, other) ||
(other is _DocState && (other is _DocumentState &&
(identical(other.loadState, loadState) || (identical(other.loadingState, loadingState) ||
const DeepCollectionEquality() const DeepCollectionEquality()
.equals(other.loadState, loadState)) && .equals(other.loadingState, loadingState)) &&
(identical(other.isDeleted, isDeleted) || (identical(other.isDeleted, isDeleted) ||
const DeepCollectionEquality() const DeepCollectionEquality()
.equals(other.isDeleted, isDeleted)) && .equals(other.isDeleted, isDeleted)) &&
@ -873,37 +884,37 @@ class _$_DocState implements _DocState {
@override @override
int get hashCode => int get hashCode =>
runtimeType.hashCode ^ runtimeType.hashCode ^
const DeepCollectionEquality().hash(loadState) ^ const DeepCollectionEquality().hash(loadingState) ^
const DeepCollectionEquality().hash(isDeleted) ^ const DeepCollectionEquality().hash(isDeleted) ^
const DeepCollectionEquality().hash(forceClose); const DeepCollectionEquality().hash(forceClose);
@JsonKey(ignore: true) @JsonKey(ignore: true)
@override @override
_$DocStateCopyWith<_DocState> get copyWith => _$DocumentStateCopyWith<_DocumentState> get copyWith =>
__$DocStateCopyWithImpl<_DocState>(this, _$identity); __$DocumentStateCopyWithImpl<_DocumentState>(this, _$identity);
} }
abstract class _DocState implements DocState { abstract class _DocumentState implements DocumentState {
const factory _DocState( const factory _DocumentState(
{required DocLoadState loadState, {required DocumentLoadingState loadingState,
required bool isDeleted, required bool isDeleted,
required bool forceClose}) = _$_DocState; required bool forceClose}) = _$_DocumentState;
@override @override
DocLoadState get loadState => throw _privateConstructorUsedError; DocumentLoadingState get loadingState => throw _privateConstructorUsedError;
@override @override
bool get isDeleted => throw _privateConstructorUsedError; bool get isDeleted => throw _privateConstructorUsedError;
@override @override
bool get forceClose => throw _privateConstructorUsedError; bool get forceClose => throw _privateConstructorUsedError;
@override @override
@JsonKey(ignore: true) @JsonKey(ignore: true)
_$DocStateCopyWith<_DocState> get copyWith => _$DocumentStateCopyWith<_DocumentState> get copyWith =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
} }
/// @nodoc /// @nodoc
class _$DocLoadStateTearOff { class _$DocumentLoadingStateTearOff {
const _$DocLoadStateTearOff(); const _$DocumentLoadingStateTearOff();
_Loading loading() { _Loading loading() {
return const _Loading(); return const _Loading();
@ -917,15 +928,14 @@ class _$DocLoadStateTearOff {
} }
/// @nodoc /// @nodoc
const $DocLoadState = _$DocLoadStateTearOff(); const $DocumentLoadingState = _$DocumentLoadingStateTearOff();
/// @nodoc /// @nodoc
mixin _$DocLoadState { mixin _$DocumentLoadingState {
@optionalTypeArgs @optionalTypeArgs
TResult when<TResult extends Object?>({ TResult when<TResult extends Object?>({
required TResult Function() loading, required TResult Function() loading,
required TResult Function(Either<Unit, FlowyError> successOrFail) required TResult Function(Either<Unit, FlowyError> successOrFail) finish,
finish,
}) => }) =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
@optionalTypeArgs @optionalTypeArgs
@ -963,19 +973,20 @@ mixin _$DocLoadState {
} }
/// @nodoc /// @nodoc
abstract class $DocLoadStateCopyWith<$Res> { abstract class $DocumentLoadingStateCopyWith<$Res> {
factory $DocLoadStateCopyWith( factory $DocumentLoadingStateCopyWith(DocumentLoadingState value,
DocLoadState value, $Res Function(DocLoadState) then) = $Res Function(DocumentLoadingState) then) =
_$DocLoadStateCopyWithImpl<$Res>; _$DocumentLoadingStateCopyWithImpl<$Res>;
} }
/// @nodoc /// @nodoc
class _$DocLoadStateCopyWithImpl<$Res> implements $DocLoadStateCopyWith<$Res> { class _$DocumentLoadingStateCopyWithImpl<$Res>
_$DocLoadStateCopyWithImpl(this._value, this._then); implements $DocumentLoadingStateCopyWith<$Res> {
_$DocumentLoadingStateCopyWithImpl(this._value, this._then);
final DocLoadState _value; final DocumentLoadingState _value;
// ignore: unused_field // ignore: unused_field
final $Res Function(DocLoadState) _then; final $Res Function(DocumentLoadingState) _then;
} }
/// @nodoc /// @nodoc
@ -985,7 +996,8 @@ abstract class _$LoadingCopyWith<$Res> {
} }
/// @nodoc /// @nodoc
class __$LoadingCopyWithImpl<$Res> extends _$DocLoadStateCopyWithImpl<$Res> class __$LoadingCopyWithImpl<$Res>
extends _$DocumentLoadingStateCopyWithImpl<$Res>
implements _$LoadingCopyWith<$Res> { implements _$LoadingCopyWith<$Res> {
__$LoadingCopyWithImpl(_Loading _value, $Res Function(_Loading) _then) __$LoadingCopyWithImpl(_Loading _value, $Res Function(_Loading) _then)
: super(_value, (v) => _then(v as _Loading)); : super(_value, (v) => _then(v as _Loading));
@ -1001,7 +1013,7 @@ class _$_Loading implements _Loading {
@override @override
String toString() { String toString() {
return 'DocLoadState.loading()'; return 'DocumentLoadingState.loading()';
} }
@override @override
@ -1016,8 +1028,7 @@ class _$_Loading implements _Loading {
@optionalTypeArgs @optionalTypeArgs
TResult when<TResult extends Object?>({ TResult when<TResult extends Object?>({
required TResult Function() loading, required TResult Function() loading,
required TResult Function(Either<Unit, FlowyError> successOrFail) required TResult Function(Either<Unit, FlowyError> successOrFail) finish,
finish,
}) { }) {
return loading(); return loading();
} }
@ -1076,7 +1087,7 @@ class _$_Loading implements _Loading {
} }
} }
abstract class _Loading implements DocLoadState { abstract class _Loading implements DocumentLoadingState {
const factory _Loading() = _$_Loading; const factory _Loading() = _$_Loading;
} }
@ -1088,7 +1099,8 @@ abstract class _$FinishCopyWith<$Res> {
} }
/// @nodoc /// @nodoc
class __$FinishCopyWithImpl<$Res> extends _$DocLoadStateCopyWithImpl<$Res> class __$FinishCopyWithImpl<$Res>
extends _$DocumentLoadingStateCopyWithImpl<$Res>
implements _$FinishCopyWith<$Res> { implements _$FinishCopyWith<$Res> {
__$FinishCopyWithImpl(_Finish _value, $Res Function(_Finish) _then) __$FinishCopyWithImpl(_Finish _value, $Res Function(_Finish) _then)
: super(_value, (v) => _then(v as _Finish)); : super(_value, (v) => _then(v as _Finish));
@ -1119,7 +1131,7 @@ class _$_Finish implements _Finish {
@override @override
String toString() { String toString() {
return 'DocLoadState.finish(successOrFail: $successOrFail)'; return 'DocumentLoadingState.finish(successOrFail: $successOrFail)';
} }
@override @override
@ -1144,8 +1156,7 @@ class _$_Finish implements _Finish {
@optionalTypeArgs @optionalTypeArgs
TResult when<TResult extends Object?>({ TResult when<TResult extends Object?>({
required TResult Function() loading, required TResult Function() loading,
required TResult Function(Either<Unit, FlowyError> successOrFail) required TResult Function(Either<Unit, FlowyError> successOrFail) finish,
finish,
}) { }) {
return finish(successOrFail); return finish(successOrFail);
} }
@ -1204,7 +1215,7 @@ class _$_Finish implements _Finish {
} }
} }
abstract class _Finish implements DocLoadState { abstract class _Finish implements DocumentLoadingState {
const factory _Finish(Either<Unit, FlowyError> successOrFail) = _$_Finish; const factory _Finish(Either<Unit, FlowyError> successOrFail) = _$_Finish;
Either<Unit, FlowyError> get successOrFail => Either<Unit, FlowyError> get successOrFail =>

View File

@ -67,8 +67,7 @@ mixin _$MenuEvent {
TResult Function()? collapse, TResult Function()? collapse,
TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage, TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage,
TResult Function(String name, String? desc)? createApp, TResult Function(String name, String? desc)? createApp,
TResult Function(Either<List<App>, FlowyError> appsOrFail)? TResult Function(Either<List<App>, FlowyError> appsOrFail)? didReceiveApps,
didReceiveApps,
}) => }) =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
@optionalTypeArgs @optionalTypeArgs
@ -77,8 +76,7 @@ mixin _$MenuEvent {
TResult Function()? collapse, TResult Function()? collapse,
TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage, TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage,
TResult Function(String name, String? desc)? createApp, TResult Function(String name, String? desc)? createApp,
TResult Function(Either<List<App>, FlowyError> appsOrFail)? TResult Function(Either<List<App>, FlowyError> appsOrFail)? didReceiveApps,
didReceiveApps,
required TResult orElse(), required TResult orElse(),
}) => }) =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
@ -182,8 +180,7 @@ class _$_Initial implements _Initial {
TResult Function()? collapse, TResult Function()? collapse,
TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage, TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage,
TResult Function(String name, String? desc)? createApp, TResult Function(String name, String? desc)? createApp,
TResult Function(Either<List<App>, FlowyError> appsOrFail)? TResult Function(Either<List<App>, FlowyError> appsOrFail)? didReceiveApps,
didReceiveApps,
}) { }) {
return initial?.call(); return initial?.call();
} }
@ -195,8 +192,7 @@ class _$_Initial implements _Initial {
TResult Function()? collapse, TResult Function()? collapse,
TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage, TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage,
TResult Function(String name, String? desc)? createApp, TResult Function(String name, String? desc)? createApp,
TResult Function(Either<List<App>, FlowyError> appsOrFail)? TResult Function(Either<List<App>, FlowyError> appsOrFail)? didReceiveApps,
didReceiveApps,
required TResult orElse(), required TResult orElse(),
}) { }) {
if (initial != null) { if (initial != null) {
@ -305,8 +301,7 @@ class _$Collapse implements Collapse {
TResult Function()? collapse, TResult Function()? collapse,
TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage, TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage,
TResult Function(String name, String? desc)? createApp, TResult Function(String name, String? desc)? createApp,
TResult Function(Either<List<App>, FlowyError> appsOrFail)? TResult Function(Either<List<App>, FlowyError> appsOrFail)? didReceiveApps,
didReceiveApps,
}) { }) {
return collapse?.call(); return collapse?.call();
} }
@ -318,8 +313,7 @@ class _$Collapse implements Collapse {
TResult Function()? collapse, TResult Function()? collapse,
TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage, TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage,
TResult Function(String name, String? desc)? createApp, TResult Function(String name, String? desc)? createApp,
TResult Function(Either<List<App>, FlowyError> appsOrFail)? TResult Function(Either<List<App>, FlowyError> appsOrFail)? didReceiveApps,
didReceiveApps,
required TResult orElse(), required TResult orElse(),
}) { }) {
if (collapse != null) { if (collapse != null) {
@ -453,8 +447,7 @@ class _$OpenPage implements OpenPage {
TResult Function()? collapse, TResult Function()? collapse,
TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage, TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage,
TResult Function(String name, String? desc)? createApp, TResult Function(String name, String? desc)? createApp,
TResult Function(Either<List<App>, FlowyError> appsOrFail)? TResult Function(Either<List<App>, FlowyError> appsOrFail)? didReceiveApps,
didReceiveApps,
}) { }) {
return openPage?.call(context); return openPage?.call(context);
} }
@ -466,8 +459,7 @@ class _$OpenPage implements OpenPage {
TResult Function()? collapse, TResult Function()? collapse,
TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage, TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage,
TResult Function(String name, String? desc)? createApp, TResult Function(String name, String? desc)? createApp,
TResult Function(Either<List<App>, FlowyError> appsOrFail)? TResult Function(Either<List<App>, FlowyError> appsOrFail)? didReceiveApps,
didReceiveApps,
required TResult orElse(), required TResult orElse(),
}) { }) {
if (openPage != null) { if (openPage != null) {
@ -619,8 +611,7 @@ class _$CreateApp implements CreateApp {
TResult Function()? collapse, TResult Function()? collapse,
TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage, TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage,
TResult Function(String name, String? desc)? createApp, TResult Function(String name, String? desc)? createApp,
TResult Function(Either<List<App>, FlowyError> appsOrFail)? TResult Function(Either<List<App>, FlowyError> appsOrFail)? didReceiveApps,
didReceiveApps,
}) { }) {
return createApp?.call(name, desc); return createApp?.call(name, desc);
} }
@ -632,8 +623,7 @@ class _$CreateApp implements CreateApp {
TResult Function()? collapse, TResult Function()? collapse,
TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage, TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage,
TResult Function(String name, String? desc)? createApp, TResult Function(String name, String? desc)? createApp,
TResult Function(Either<List<App>, FlowyError> appsOrFail)? TResult Function(Either<List<App>, FlowyError> appsOrFail)? didReceiveApps,
didReceiveApps,
required TResult orElse(), required TResult orElse(),
}) { }) {
if (createApp != null) { if (createApp != null) {
@ -776,8 +766,7 @@ class _$ReceiveApps implements ReceiveApps {
TResult Function()? collapse, TResult Function()? collapse,
TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage, TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage,
TResult Function(String name, String? desc)? createApp, TResult Function(String name, String? desc)? createApp,
TResult Function(Either<List<App>, FlowyError> appsOrFail)? TResult Function(Either<List<App>, FlowyError> appsOrFail)? didReceiveApps,
didReceiveApps,
}) { }) {
return didReceiveApps?.call(appsOrFail); return didReceiveApps?.call(appsOrFail);
} }
@ -789,8 +778,7 @@ class _$ReceiveApps implements ReceiveApps {
TResult Function()? collapse, TResult Function()? collapse,
TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage, TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage,
TResult Function(String name, String? desc)? createApp, TResult Function(String name, String? desc)? createApp,
TResult Function(Either<List<App>, FlowyError> appsOrFail)? TResult Function(Either<List<App>, FlowyError> appsOrFail)? didReceiveApps,
didReceiveApps,
required TResult orElse(), required TResult orElse(),
}) { }) {
if (didReceiveApps != null) { if (didReceiveApps != null) {

View File

@ -1007,8 +1007,7 @@ abstract class $TrashStateCopyWith<$Res> {
factory $TrashStateCopyWith( factory $TrashStateCopyWith(
TrashState value, $Res Function(TrashState) then) = TrashState value, $Res Function(TrashState) then) =
_$TrashStateCopyWithImpl<$Res>; _$TrashStateCopyWithImpl<$Res>;
$Res call( $Res call({List<Trash> objects, Either<Unit, FlowyError> successOrFailure});
{List<Trash> objects, Either<Unit, FlowyError> successOrFailure});
} }
/// @nodoc /// @nodoc
@ -1043,8 +1042,7 @@ abstract class _$TrashStateCopyWith<$Res> implements $TrashStateCopyWith<$Res> {
_TrashState value, $Res Function(_TrashState) then) = _TrashState value, $Res Function(_TrashState) then) =
__$TrashStateCopyWithImpl<$Res>; __$TrashStateCopyWithImpl<$Res>;
@override @override
$Res call( $Res call({List<Trash> objects, Either<Unit, FlowyError> successOrFailure});
{List<Trash> objects, Either<Unit, FlowyError> successOrFailure});
} }
/// @nodoc /// @nodoc

View File

@ -60,8 +60,7 @@ mixin _$ViewEvent {
required TResult Function(String newName) rename, required TResult Function(String newName) rename,
required TResult Function() delete, required TResult Function() delete,
required TResult Function() duplicate, required TResult Function() duplicate,
required TResult Function(Either<View, FlowyError> result) required TResult Function(Either<View, FlowyError> result) viewDidUpdate,
viewDidUpdate,
}) => }) =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
@optionalTypeArgs @optionalTypeArgs
@ -175,8 +174,7 @@ class _$Initial implements Initial {
required TResult Function(String newName) rename, required TResult Function(String newName) rename,
required TResult Function() delete, required TResult Function() delete,
required TResult Function() duplicate, required TResult Function() duplicate,
required TResult Function(Either<View, FlowyError> result) required TResult Function(Either<View, FlowyError> result) viewDidUpdate,
viewDidUpdate,
}) { }) {
return initial(); return initial();
} }
@ -328,8 +326,7 @@ class _$SetEditing implements SetEditing {
required TResult Function(String newName) rename, required TResult Function(String newName) rename,
required TResult Function() delete, required TResult Function() delete,
required TResult Function() duplicate, required TResult Function() duplicate,
required TResult Function(Either<View, FlowyError> result) required TResult Function(Either<View, FlowyError> result) viewDidUpdate,
viewDidUpdate,
}) { }) {
return setIsEditing(isEditing); return setIsEditing(isEditing);
} }
@ -484,8 +481,7 @@ class _$Rename implements Rename {
required TResult Function(String newName) rename, required TResult Function(String newName) rename,
required TResult Function() delete, required TResult Function() delete,
required TResult Function() duplicate, required TResult Function() duplicate,
required TResult Function(Either<View, FlowyError> result) required TResult Function(Either<View, FlowyError> result) viewDidUpdate,
viewDidUpdate,
}) { }) {
return rename(newName); return rename(newName);
} }
@ -614,8 +610,7 @@ class _$Delete implements Delete {
required TResult Function(String newName) rename, required TResult Function(String newName) rename,
required TResult Function() delete, required TResult Function() delete,
required TResult Function() duplicate, required TResult Function() duplicate,
required TResult Function(Either<View, FlowyError> result) required TResult Function(Either<View, FlowyError> result) viewDidUpdate,
viewDidUpdate,
}) { }) {
return delete(); return delete();
} }
@ -740,8 +735,7 @@ class _$Duplicate implements Duplicate {
required TResult Function(String newName) rename, required TResult Function(String newName) rename,
required TResult Function() delete, required TResult Function() delete,
required TResult Function() duplicate, required TResult Function() duplicate,
required TResult Function(Either<View, FlowyError> result) required TResult Function(Either<View, FlowyError> result) viewDidUpdate,
viewDidUpdate,
}) { }) {
return duplicate(); return duplicate();
} }
@ -893,8 +887,7 @@ class _$ViewDidUpdate implements ViewDidUpdate {
required TResult Function(String newName) rename, required TResult Function(String newName) rename,
required TResult Function() delete, required TResult Function() delete,
required TResult Function() duplicate, required TResult Function() duplicate,
required TResult Function(Either<View, FlowyError> result) required TResult Function(Either<View, FlowyError> result) viewDidUpdate,
viewDidUpdate,
}) { }) {
return viewDidUpdate(result); return viewDidUpdate(result);
} }
@ -1019,9 +1012,7 @@ abstract class $ViewStateCopyWith<$Res> {
factory $ViewStateCopyWith(ViewState value, $Res Function(ViewState) then) = factory $ViewStateCopyWith(ViewState value, $Res Function(ViewState) then) =
_$ViewStateCopyWithImpl<$Res>; _$ViewStateCopyWithImpl<$Res>;
$Res call( $Res call(
{View view, {View view, bool isEditing, Either<Unit, FlowyError> successOrFailure});
bool isEditing,
Either<Unit, FlowyError> successOrFailure});
} }
/// @nodoc /// @nodoc
@ -1062,9 +1053,7 @@ abstract class _$ViewStateCopyWith<$Res> implements $ViewStateCopyWith<$Res> {
__$ViewStateCopyWithImpl<$Res>; __$ViewStateCopyWithImpl<$Res>;
@override @override
$Res call( $Res call(
{View view, {View view, bool isEditing, Either<Unit, FlowyError> successOrFailure});
bool isEditing,
Either<Unit, FlowyError> successOrFailure});
} }
/// @nodoc /// @nodoc

View File

@ -874,8 +874,7 @@ abstract class _WelcomeState implements WelcomeState {
const factory _WelcomeState( const factory _WelcomeState(
{required bool isLoading, {required bool isLoading,
required List<Workspace> workspaces, required List<Workspace> workspaces,
required Either<Unit, FlowyError> successOrFailure}) = required Either<Unit, FlowyError> successOrFailure}) = _$_WelcomeState;
_$_WelcomeState;
@override @override
bool get isLoading => throw _privateConstructorUsedError; bool get isLoading => throw _privateConstructorUsedError;

View File

@ -9,7 +9,7 @@ import 'package:app_flowy/workspace/application/view/view_bloc.dart';
import 'package:app_flowy/workspace/application/workspace/welcome_bloc.dart'; import 'package:app_flowy/workspace/application/workspace/welcome_bloc.dart';
import 'package:app_flowy/workspace/domain/page_stack/page_stack.dart'; import 'package:app_flowy/workspace/domain/page_stack/page_stack.dart';
import 'package:app_flowy/workspace/infrastructure/repos/app_repo.dart'; import 'package:app_flowy/workspace/infrastructure/repos/app_repo.dart';
import 'package:app_flowy/workspace/infrastructure/repos/doc_repo.dart'; import 'package:app_flowy/workspace/infrastructure/repos/document_repo.dart';
import 'package:app_flowy/workspace/infrastructure/repos/trash_repo.dart'; import 'package:app_flowy/workspace/infrastructure/repos/trash_repo.dart';
import 'package:app_flowy/workspace/infrastructure/repos/user_repo.dart'; import 'package:app_flowy/workspace/infrastructure/repos/user_repo.dart';
import 'package:app_flowy/workspace/infrastructure/repos/view_repo.dart'; import 'package:app_flowy/workspace/infrastructure/repos/view_repo.dart';
@ -80,10 +80,10 @@ class HomeDepsResolver {
); );
// Doc // Doc
getIt.registerFactoryParam<DocBloc, View, void>( getIt.registerFactoryParam<DocumentBloc, View, void>(
(view, _) => DocBloc( (view, _) => DocumentBloc(
view: view, view: view,
repo: DocRepository(docId: view.id), repo: DocumentRepository(docId: view.id),
listener: getIt<ViewListener>(param1: view), listener: getIt<ViewListener>(param1: view),
trashRepo: getIt<TrashRepo>(), trashRepo: getIt<TrashRepo>(),
), ),

View File

@ -4,13 +4,13 @@ import 'package:flowy_sdk/protobuf/flowy-collaboration/document_info.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
class DocRepository { class DocumentRepository {
final String docId; final String docId;
DocRepository({ DocumentRepository({
required this.docId, required this.docId,
}); });
Future<Either<DocumentDelta, FlowyError>> readDoc() { Future<Either<DocumentDelta, FlowyError>> openDocument() {
final request = QueryViewRequest(viewIds: [docId]); final request = QueryViewRequest(viewIds: [docId]);
return FolderEventOpenDocument(request).send(); return FolderEventOpenDocument(request).send();
} }
@ -22,7 +22,7 @@ class DocRepository {
return FolderEventApplyDocDelta(request).send(); return FolderEventApplyDocDelta(request).send();
} }
Future<Either<Unit, FlowyError>> closeDoc() { Future<Either<Unit, FlowyError>> closeDocument() {
final request = QueryViewRequest(viewIds: [docId]); final request = QueryViewRequest(viewIds: [docId]);
return FolderEventCloseView(request).send(); return FolderEventCloseView(request).send();
} }

View File

@ -22,7 +22,7 @@ import 'package:clipboard/clipboard.dart';
import 'package:app_flowy/generated/locale_keys.g.dart'; import 'package:app_flowy/generated/locale_keys.g.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'doc_page.dart'; import 'document_page.dart';
class DocStackContext extends HomeStackContext<int, ShareActionWrapper> { class DocStackContext extends HomeStackContext<int, ShareActionWrapper> {
View _view; View _view;
@ -56,7 +56,7 @@ class DocStackContext extends HomeStackContext<int, ShareActionWrapper> {
HomeStackType get type => _view.stackType(); HomeStackType get type => _view.stackType();
@override @override
Widget buildWidget() => DocPage(view: _view, key: ValueKey(_view.id)); Widget buildWidget() => DocumentPage(view: _view, key: ValueKey(_view.id));
@override @override
List<NavigationItem> get navigationItems => _makeNavigationItems(); List<NavigationItem> get navigationItems => _makeNavigationItems();

View File

@ -14,23 +14,23 @@ import 'styles.dart';
import 'widget/banner.dart'; import 'widget/banner.dart';
import 'widget/toolbar/tool_bar.dart'; import 'widget/toolbar/tool_bar.dart';
class DocPage extends StatefulWidget { class DocumentPage extends StatefulWidget {
final View view; final View view;
DocPage({Key? key, required this.view}) : super(key: ValueKey(view.id)); DocumentPage({Key? key, required this.view}) : super(key: ValueKey(view.id));
@override @override
State<DocPage> createState() => _DocPageState(); State<DocumentPage> createState() => _DocumentPageState();
} }
class _DocPageState extends State<DocPage> { class _DocumentPageState extends State<DocumentPage> {
late DocBloc docBloc; late DocumentBloc documentBloc;
final scrollController = ScrollController(); final scrollController = ScrollController();
final FocusNode _focusNode = FocusNode(); final FocusNode _focusNode = FocusNode();
@override @override
void initState() { void initState() {
docBloc = getIt<DocBloc>(param1: super.widget.view)..add(const DocEvent.initial()); documentBloc = getIt<DocumentBloc>(param1: super.widget.view)..add(const DocumentEvent.initial());
super.initState(); super.initState();
} }
@ -38,10 +38,10 @@ class _DocPageState extends State<DocPage> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MultiBlocProvider( return MultiBlocProvider(
providers: [ providers: [
BlocProvider<DocBloc>.value(value: docBloc), BlocProvider<DocumentBloc>.value(value: documentBloc),
], ],
child: BlocBuilder<DocBloc, DocState>(builder: (context, state) { child: BlocBuilder<DocumentBloc, DocumentState>(builder: (context, state) {
return state.loadState.map( return state.loadingState.map(
// loading: (_) => const FlowyProgressIndicator(), // loading: (_) => const FlowyProgressIndicator(),
loading: (_) => SizedBox.expand(child: Container(color: Colors.transparent)), loading: (_) => SizedBox.expand(child: Container(color: Colors.transparent)),
finish: (result) => result.successOrFail.fold( finish: (result) => result.successOrFail.fold(
@ -49,7 +49,7 @@ class _DocPageState extends State<DocPage> {
if (state.forceClose) { if (state.forceClose) {
return _renderAppPage(); return _renderAppPage();
} else { } else {
return _renderDoc(context, state); return _renderDocument(context, state);
} }
}, },
(err) => FlowyErrorPage(err.toString()), (err) => FlowyErrorPage(err.toString()),
@ -61,13 +61,13 @@ class _DocPageState extends State<DocPage> {
@override @override
Future<void> dispose() async { Future<void> dispose() async {
docBloc.close(); documentBloc.close();
super.dispose(); super.dispose();
} }
Widget _renderDoc(BuildContext context, DocState state) { Widget _renderDocument(BuildContext context, DocumentState state) {
quill.QuillController controller = quill.QuillController( quill.QuillController controller = quill.QuillController(
document: context.read<DocBloc>().document, document: context.read<DocumentBloc>().document,
selection: const TextSelection.collapsed(offset: 0), selection: const TextSelection.collapsed(offset: 0),
); );
return Column( return Column(
@ -89,9 +89,9 @@ class _DocPageState extends State<DocPage> {
} }
Widget _renderBanner(BuildContext context) { Widget _renderBanner(BuildContext context) {
return DocBanner( return DocumentBanner(
onRestore: () => context.read<DocBloc>().add(const DocEvent.restorePage()), onRestore: () => context.read<DocumentBloc>().add(const DocumentEvent.restorePage()),
onDelete: () => context.read<DocBloc>().add(const DocEvent.deletePermanently()), onDelete: () => context.read<DocumentBloc>().add(const DocumentEvent.deletePermanently()),
); );
} }

View File

@ -8,10 +8,10 @@ import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:app_flowy/generated/locale_keys.g.dart'; import 'package:app_flowy/generated/locale_keys.g.dart';
class DocBanner extends StatelessWidget { class DocumentBanner extends StatelessWidget {
final void Function() onRestore; final void Function() onRestore;
final void Function() onDelete; final void Function() onDelete;
const DocBanner({required this.onRestore, required this.onDelete, Key? key}) : super(key: key); const DocumentBanner({required this.onRestore, required this.onDelete, Key? key}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View File

@ -15,13 +15,14 @@ dependencies:
isolates: ^3.0.3+8 isolates: ^3.0.3+8
protobuf: "2.0.0" protobuf: "2.0.0"
dartz: "0.10.0-nullsafety.2" dartz: "0.10.0-nullsafety.2"
freezed_annotation: ^0.14.1 freezed_annotation:
logger: ^1.0.0 logger: ^1.0.0
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
build_runner: "1.12.2" build_runner:
freezed:
flutter_lints: ^1.0.0 flutter_lints: ^1.0.0
# For information on the generic Dart part of this file, see the # For information on the generic Dart part of this file, see the

View File

@ -329,7 +329,7 @@ packages:
name: easy_localization name: easy_localization
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.0.0" version: "3.0.1-dev"
easy_logger: easy_logger:
dependency: transitive dependency: transitive
description: description:
@ -645,7 +645,7 @@ packages:
name: js name: js
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.6.3" version: "0.6.4"
json_annotation: json_annotation:
dependency: transitive dependency: transitive
description: description:
@ -799,7 +799,7 @@ packages:
name: path name: path
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.0" version: "1.8.1"
path_drawing: path_drawing:
dependency: transitive dependency: transitive
description: description:
@ -1133,21 +1133,21 @@ packages:
name: test name: test
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.19.5" version: "1.20.1"
test_api: test_api:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.4.8" version: "0.4.9"
test_core: test_core:
dependency: transitive dependency: transitive
description: description:
name: test_core name: test_core
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.4.9" version: "0.4.11"
textstyle_extensions: textstyle_extensions:
dependency: transitive dependency: transitive
description: description:
@ -1354,5 +1354,5 @@ packages:
source: hosted source: hosted
version: "8.0.0" version: "8.0.0"
sdks: sdks:
dart: ">=2.15.0-116.0.dev <3.0.0" dart: ">=2.16.0-100.0.dev <3.0.0"
flutter: ">=2.5.0" flutter: ">=2.5.0"

View File

@ -79,7 +79,7 @@ dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
build_runner: build_runner:
freezed: "^0.14.2" freezed:
bloc_test: ^9.0.2 bloc_test: ^9.0.2
# The "flutter_lints" package below contains a set of recommended lints to # The "flutter_lints" package below contains a set of recommended lints to