2023-02-26 16:27:17 +08:00
|
|
|
import 'dart:collection';
|
|
|
|
|
2023-06-20 23:48:34 +08:00
|
|
|
import 'package:appflowy/plugins/database_view/grid/presentation/widgets/sort/sort_info.dart';
|
2023-04-28 14:08:53 +08:00
|
|
|
import 'package:appflowy_backend/protobuf/flowy-database2/database_entities.pb.dart';
|
2023-02-26 16:27:17 +08:00
|
|
|
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
2023-08-05 15:02:05 +08:00
|
|
|
import 'package:dartz/dartz.dart';
|
|
|
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
2023-02-26 16:27:17 +08:00
|
|
|
|
|
|
|
import '../grid/presentation/widgets/filter/filter_info.dart';
|
2023-08-10 15:46:16 +08:00
|
|
|
import 'field/field_info.dart';
|
2023-02-26 16:27:17 +08:00
|
|
|
import 'row/row_cache.dart';
|
2023-04-28 20:47:40 +08:00
|
|
|
import 'row/row_service.dart';
|
2023-02-26 16:27:17 +08:00
|
|
|
|
2023-08-05 15:02:05 +08:00
|
|
|
part 'defines.freezed.dart';
|
|
|
|
|
2023-02-26 16:27:17 +08:00
|
|
|
typedef OnFieldsChanged = void Function(UnmodifiableListView<FieldInfo>);
|
|
|
|
typedef OnFiltersChanged = void Function(List<FilterInfo>);
|
2023-06-20 23:48:34 +08:00
|
|
|
typedef OnSortsChanged = void Function(List<SortInfo>);
|
2023-02-26 16:27:17 +08:00
|
|
|
typedef OnDatabaseChanged = void Function(DatabasePB);
|
2023-03-20 21:16:37 +08:00
|
|
|
|
2023-04-28 20:47:40 +08:00
|
|
|
typedef OnRowsCreated = void Function(List<RowId> ids);
|
2023-06-14 22:16:33 +08:00
|
|
|
typedef OnRowsUpdated = void Function(
|
|
|
|
List<RowId> ids,
|
2023-07-14 13:37:13 +08:00
|
|
|
ChangedReason reason,
|
2023-06-14 22:16:33 +08:00
|
|
|
);
|
2023-04-28 20:47:40 +08:00
|
|
|
typedef OnRowsDeleted = void Function(List<RowId> ids);
|
2023-06-01 20:23:27 +08:00
|
|
|
typedef OnNumOfRowsChanged = void Function(
|
2023-03-20 21:16:37 +08:00
|
|
|
UnmodifiableListView<RowInfo> rows,
|
2023-04-28 20:47:40 +08:00
|
|
|
UnmodifiableMapView<RowId, RowInfo> rowByRowId,
|
2023-07-14 13:37:13 +08:00
|
|
|
ChangedReason reason,
|
2023-02-26 16:27:17 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
typedef OnError = void Function(FlowyError);
|
2023-08-05 15:02:05 +08:00
|
|
|
|
|
|
|
@freezed
|
|
|
|
class LoadingState with _$LoadingState {
|
|
|
|
const factory LoadingState.loading() = _Loading;
|
|
|
|
const factory LoadingState.finish(
|
|
|
|
Either<Unit, FlowyError> successOrFail,
|
|
|
|
) = _Finish;
|
|
|
|
}
|