2023-02-26 16:27:17 +08:00
|
|
|
import 'dart:collection';
|
|
|
|
|
2024-01-24 23:59:45 +08:00
|
|
|
// TODO(RS): remove dependency on presentation code
|
|
|
|
import 'package:appflowy/plugins/database/grid/presentation/widgets/filter/filter_info.dart';
|
2024-01-05 17:30:54 +08:00
|
|
|
import 'package:appflowy/plugins/database/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
|
|
|
|
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
|
|
|
|
2024-01-24 23:59:45 +08:00
|
|
|
typedef OnRowsCreated = void Function(List<RowId> rowIds);
|
2023-06-14 22:16:33 +08:00
|
|
|
typedef OnRowsUpdated = void Function(
|
2024-01-24 23:59:45 +08:00
|
|
|
List<RowId> rowIds,
|
2023-07-14 13:37:13 +08:00
|
|
|
ChangedReason reason,
|
2023-06-14 22:16:33 +08:00
|
|
|
);
|
2024-01-24 23:59:45 +08:00
|
|
|
typedef OnRowsDeleted = void Function(List<RowId> rowIds);
|
2023-06-01 20:23:27 +08:00
|
|
|
typedef OnNumOfRowsChanged = void Function(
|
2023-03-20 21:16:37 +08:00
|
|
|
UnmodifiableListView<RowInfo> rows,
|
2024-01-24 23:59:45 +08:00
|
|
|
UnmodifiableMapView<RowId, RowInfo> rowById,
|
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 {
|
2024-01-11 09:44:33 +08:00
|
|
|
const factory LoadingState.idle() = _Idle;
|
2023-08-05 15:02:05 +08:00
|
|
|
const factory LoadingState.loading() = _Loading;
|
|
|
|
const factory LoadingState.finish(
|
|
|
|
Either<Unit, FlowyError> successOrFail,
|
|
|
|
) = _Finish;
|
2023-08-22 00:19:15 +08:00
|
|
|
|
|
|
|
const LoadingState._();
|
2023-12-08 20:01:54 +07:00
|
|
|
bool isLoading() => this is _Loading;
|
2023-08-05 15:02:05 +08:00
|
|
|
}
|