2023-02-26 08:27:17 +00:00
|
|
|
import 'dart:collection';
|
|
|
|
|
|
2024-01-24 15:59:45 +00:00
|
|
|
// TODO(RS): remove dependency on presentation code
|
|
|
|
|
import 'package:appflowy/plugins/database/grid/presentation/widgets/filter/filter_info.dart';
|
2024-01-05 09:30:54 +00:00
|
|
|
import 'package:appflowy/plugins/database/grid/presentation/widgets/sort/sort_info.dart';
|
2023-04-28 06:08:53 +00:00
|
|
|
import 'package:appflowy_backend/protobuf/flowy-database2/database_entities.pb.dart';
|
2023-02-26 08:27:17 +00:00
|
|
|
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
2023-08-05 07:02:05 +00:00
|
|
|
import 'package:dartz/dartz.dart';
|
|
|
|
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
2023-02-26 08:27:17 +00:00
|
|
|
|
2023-08-10 07:46:16 +00:00
|
|
|
import 'field/field_info.dart';
|
2023-02-26 08:27:17 +00:00
|
|
|
import 'row/row_cache.dart';
|
2023-04-28 12:47:40 +00:00
|
|
|
import 'row/row_service.dart';
|
2023-02-26 08:27:17 +00:00
|
|
|
|
2023-08-05 07:02:05 +00:00
|
|
|
part 'defines.freezed.dart';
|
|
|
|
|
|
2023-02-26 08:27:17 +00:00
|
|
|
typedef OnFieldsChanged = void Function(UnmodifiableListView<FieldInfo>);
|
|
|
|
|
typedef OnFiltersChanged = void Function(List<FilterInfo>);
|
2023-06-20 15:48:34 +00:00
|
|
|
typedef OnSortsChanged = void Function(List<SortInfo>);
|
2023-02-26 08:27:17 +00:00
|
|
|
typedef OnDatabaseChanged = void Function(DatabasePB);
|
2023-03-20 13:16:37 +00:00
|
|
|
|
2024-01-24 15:59:45 +00:00
|
|
|
typedef OnRowsCreated = void Function(List<RowId> rowIds);
|
2023-06-14 14:16:33 +00:00
|
|
|
typedef OnRowsUpdated = void Function(
|
2024-01-24 15:59:45 +00:00
|
|
|
List<RowId> rowIds,
|
2023-07-14 05:37:13 +00:00
|
|
|
ChangedReason reason,
|
2023-06-14 14:16:33 +00:00
|
|
|
);
|
2024-01-24 15:59:45 +00:00
|
|
|
typedef OnRowsDeleted = void Function(List<RowId> rowIds);
|
2023-06-01 12:23:27 +00:00
|
|
|
typedef OnNumOfRowsChanged = void Function(
|
2023-03-20 13:16:37 +00:00
|
|
|
UnmodifiableListView<RowInfo> rows,
|
2024-01-24 15:59:45 +00:00
|
|
|
UnmodifiableMapView<RowId, RowInfo> rowById,
|
2023-07-14 05:37:13 +00:00
|
|
|
ChangedReason reason,
|
2023-02-26 08:27:17 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
typedef OnError = void Function(FlowyError);
|
2023-08-05 07:02:05 +00:00
|
|
|
|
|
|
|
|
@freezed
|
|
|
|
|
class LoadingState with _$LoadingState {
|
2024-01-11 01:44:33 +00:00
|
|
|
const factory LoadingState.idle() = _Idle;
|
2023-08-05 07:02:05 +00:00
|
|
|
const factory LoadingState.loading() = _Loading;
|
|
|
|
|
const factory LoadingState.finish(
|
|
|
|
|
Either<Unit, FlowyError> successOrFail,
|
|
|
|
|
) = _Finish;
|
2023-08-21 16:19:15 +00:00
|
|
|
|
|
|
|
|
const LoadingState._();
|
2023-12-08 13:01:54 +00:00
|
|
|
bool isLoading() => this is _Loading;
|
2023-08-05 07:02:05 +00:00
|
|
|
}
|