mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
Refactor/database classes (#1913)
This commit is contained in:
parent
f1316acfcc
commit
59a1910b3c
1
frontend/.vscode/settings.json
vendored
1
frontend/.vscode/settings.json
vendored
@ -24,7 +24,6 @@
|
|||||||
"svgviewer.showzoominout": true,
|
"svgviewer.showzoominout": true,
|
||||||
"editor.wordWrapColumn": 80,
|
"editor.wordWrapColumn": 80,
|
||||||
"editor.minimap.maxColumn": 140,
|
"editor.minimap.maxColumn": 140,
|
||||||
"prettier.printWidth": 140,
|
|
||||||
"editor.wordWrap": "wordWrapColumn",
|
"editor.wordWrap": "wordWrapColumn",
|
||||||
"dart.lineLength": 80,
|
"dart.lineLength": 80,
|
||||||
"typescript.validate.enable": true,
|
"typescript.validate.enable": true,
|
||||||
|
@ -1,118 +1,16 @@
|
|||||||
part of 'cell_service.dart';
|
import 'dart:async';
|
||||||
|
import 'package:appflowy/plugins/database_view/application/field/field_listener.dart';
|
||||||
typedef TextCellController = CellController<String, String>;
|
import 'package:appflowy_backend/log.dart';
|
||||||
typedef CheckboxCellController = CellController<String, String>;
|
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pbenum.dart';
|
||||||
typedef NumberCellController = CellController<String, String>;
|
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
||||||
typedef SelectOptionCellController
|
import 'package:dartz/dartz.dart';
|
||||||
= CellController<SelectOptionCellDataPB, String>;
|
import 'package:equatable/equatable.dart';
|
||||||
typedef ChecklistCellController
|
import 'package:flutter/foundation.dart';
|
||||||
= CellController<SelectOptionCellDataPB, String>;
|
import '../field/field_controller.dart';
|
||||||
typedef DateCellController = CellController<DateCellDataPB, CalendarData>;
|
import '../field/field_service.dart';
|
||||||
typedef URLCellController = CellController<URLCellDataPB, String>;
|
import '../field/type_option/type_option_context.dart';
|
||||||
|
import 'cell_listener.dart';
|
||||||
abstract class CellControllerBuilderDelegate {
|
import 'cell_service.dart';
|
||||||
CellFieldNotifier buildFieldNotifier();
|
|
||||||
}
|
|
||||||
|
|
||||||
class CellControllerBuilder {
|
|
||||||
final CellIdentifier _cellId;
|
|
||||||
final CellCache _cellCache;
|
|
||||||
final CellControllerBuilderDelegate delegate;
|
|
||||||
|
|
||||||
CellControllerBuilder({
|
|
||||||
required this.delegate,
|
|
||||||
required CellIdentifier cellId,
|
|
||||||
required CellCache cellCache,
|
|
||||||
}) : _cellCache = cellCache,
|
|
||||||
_cellId = cellId;
|
|
||||||
|
|
||||||
CellController build() {
|
|
||||||
final cellFieldNotifier = delegate.buildFieldNotifier();
|
|
||||||
switch (_cellId.fieldType) {
|
|
||||||
case FieldType.Checkbox:
|
|
||||||
final cellDataLoader = CellDataLoader(
|
|
||||||
cellId: _cellId,
|
|
||||||
parser: StringCellDataParser(),
|
|
||||||
);
|
|
||||||
return TextCellController(
|
|
||||||
cellId: _cellId,
|
|
||||||
cellCache: _cellCache,
|
|
||||||
cellDataLoader: cellDataLoader,
|
|
||||||
fieldNotifier: cellFieldNotifier,
|
|
||||||
cellDataPersistence: TextCellDataPersistence(cellId: _cellId),
|
|
||||||
);
|
|
||||||
case FieldType.DateTime:
|
|
||||||
final cellDataLoader = CellDataLoader(
|
|
||||||
cellId: _cellId,
|
|
||||||
parser: DateCellDataParser(),
|
|
||||||
reloadOnFieldChanged: true,
|
|
||||||
);
|
|
||||||
|
|
||||||
return DateCellController(
|
|
||||||
cellId: _cellId,
|
|
||||||
cellCache: _cellCache,
|
|
||||||
cellDataLoader: cellDataLoader,
|
|
||||||
fieldNotifier: cellFieldNotifier,
|
|
||||||
cellDataPersistence: DateCellDataPersistence(cellId: _cellId),
|
|
||||||
);
|
|
||||||
case FieldType.Number:
|
|
||||||
final cellDataLoader = CellDataLoader(
|
|
||||||
cellId: _cellId,
|
|
||||||
parser: StringCellDataParser(),
|
|
||||||
reloadOnFieldChanged: true,
|
|
||||||
);
|
|
||||||
return NumberCellController(
|
|
||||||
cellId: _cellId,
|
|
||||||
cellCache: _cellCache,
|
|
||||||
cellDataLoader: cellDataLoader,
|
|
||||||
fieldNotifier: cellFieldNotifier,
|
|
||||||
cellDataPersistence: TextCellDataPersistence(cellId: _cellId),
|
|
||||||
);
|
|
||||||
case FieldType.RichText:
|
|
||||||
final cellDataLoader = CellDataLoader(
|
|
||||||
cellId: _cellId,
|
|
||||||
parser: StringCellDataParser(),
|
|
||||||
);
|
|
||||||
return TextCellController(
|
|
||||||
cellId: _cellId,
|
|
||||||
cellCache: _cellCache,
|
|
||||||
cellDataLoader: cellDataLoader,
|
|
||||||
fieldNotifier: cellFieldNotifier,
|
|
||||||
cellDataPersistence: TextCellDataPersistence(cellId: _cellId),
|
|
||||||
);
|
|
||||||
case FieldType.MultiSelect:
|
|
||||||
case FieldType.SingleSelect:
|
|
||||||
case FieldType.Checklist:
|
|
||||||
final cellDataLoader = CellDataLoader(
|
|
||||||
cellId: _cellId,
|
|
||||||
parser: SelectOptionCellDataParser(),
|
|
||||||
reloadOnFieldChanged: true,
|
|
||||||
);
|
|
||||||
|
|
||||||
return SelectOptionCellController(
|
|
||||||
cellId: _cellId,
|
|
||||||
cellCache: _cellCache,
|
|
||||||
cellDataLoader: cellDataLoader,
|
|
||||||
fieldNotifier: cellFieldNotifier,
|
|
||||||
cellDataPersistence: TextCellDataPersistence(cellId: _cellId),
|
|
||||||
);
|
|
||||||
|
|
||||||
case FieldType.URL:
|
|
||||||
final cellDataLoader = CellDataLoader(
|
|
||||||
cellId: _cellId,
|
|
||||||
parser: URLCellDataParser(),
|
|
||||||
);
|
|
||||||
return URLCellController(
|
|
||||||
cellId: _cellId,
|
|
||||||
cellCache: _cellCache,
|
|
||||||
cellDataLoader: cellDataLoader,
|
|
||||||
fieldNotifier: cellFieldNotifier,
|
|
||||||
cellDataPersistence: TextCellDataPersistence(cellId: _cellId),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
throw UnimplementedError;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// IGridCellController is used to manipulate the cell and receive notifications.
|
/// IGridCellController is used to manipulate the cell and receive notifications.
|
||||||
/// * Read/Write cell data
|
/// * Read/Write cell data
|
||||||
@ -124,40 +22,19 @@ class CellControllerBuilder {
|
|||||||
// ignore: must_be_immutable
|
// ignore: must_be_immutable
|
||||||
class CellController<T, D> extends Equatable {
|
class CellController<T, D> extends Equatable {
|
||||||
final CellIdentifier cellId;
|
final CellIdentifier cellId;
|
||||||
final CellCache _cellsCache;
|
final CellCache _cellCache;
|
||||||
final CellCacheKey _cacheKey;
|
final CellCacheKey _cacheKey;
|
||||||
final FieldBackendService _fieldBackendSvc;
|
final FieldBackendService _fieldBackendSvc;
|
||||||
final CellFieldNotifier _fieldNotifier;
|
final SingleFieldListener _fieldListener;
|
||||||
final CellDataLoader<T> _cellDataLoader;
|
final CellDataLoader<T> _cellDataLoader;
|
||||||
final CellDataPersistence<D> _cellDataPersistence;
|
final CellDataPersistence<D> _cellDataPersistence;
|
||||||
|
|
||||||
CellListener? _cellListener;
|
CellListener? _cellListener;
|
||||||
CellDataNotifier<T?>? _cellDataNotifier;
|
CellDataNotifier<T?>? _cellDataNotifier;
|
||||||
|
|
||||||
bool isListening = false;
|
VoidCallback? _onCellFieldChanged;
|
||||||
VoidCallback? _onFieldChangedFn;
|
|
||||||
Timer? _loadDataOperation;
|
Timer? _loadDataOperation;
|
||||||
Timer? _saveDataOperation;
|
Timer? _saveDataOperation;
|
||||||
bool _isDispose = false;
|
|
||||||
|
|
||||||
CellController({
|
|
||||||
required this.cellId,
|
|
||||||
required CellCache cellCache,
|
|
||||||
required CellFieldNotifier fieldNotifier,
|
|
||||||
required CellDataLoader<T> cellDataLoader,
|
|
||||||
required CellDataPersistence<D> cellDataPersistence,
|
|
||||||
}) : _cellsCache = cellCache,
|
|
||||||
_cellDataLoader = cellDataLoader,
|
|
||||||
_cellDataPersistence = cellDataPersistence,
|
|
||||||
_fieldNotifier = fieldNotifier,
|
|
||||||
_fieldBackendSvc = FieldBackendService(
|
|
||||||
viewId: cellId.viewId,
|
|
||||||
fieldId: cellId.fieldInfo.id,
|
|
||||||
),
|
|
||||||
_cacheKey = CellCacheKey(
|
|
||||||
rowId: cellId.rowId,
|
|
||||||
fieldId: cellId.fieldInfo.id,
|
|
||||||
);
|
|
||||||
|
|
||||||
String get viewId => cellId.viewId;
|
String get viewId => cellId.viewId;
|
||||||
|
|
||||||
@ -169,34 +46,28 @@ class CellController<T, D> extends Equatable {
|
|||||||
|
|
||||||
FieldType get fieldType => cellId.fieldInfo.fieldType;
|
FieldType get fieldType => cellId.fieldInfo.fieldType;
|
||||||
|
|
||||||
/// Listen on the cell content or field changes
|
CellController({
|
||||||
///
|
required this.cellId,
|
||||||
/// An optional [listenWhenOnCellChanged] can be implemented for more
|
required CellCache cellCache,
|
||||||
/// granular control over when [listener] is called.
|
required CellDataLoader<T> cellDataLoader,
|
||||||
/// [listenWhenOnCellChanged] will be invoked on each [onCellChanged]
|
required CellDataPersistence<D> cellDataPersistence,
|
||||||
/// get called.
|
}) : _cellCache = cellCache,
|
||||||
/// [listenWhenOnCellChanged] takes the previous `value` and current
|
_cellDataLoader = cellDataLoader,
|
||||||
/// `value` and must return a [bool] which determines whether or not
|
_cellDataPersistence = cellDataPersistence,
|
||||||
/// the [onCellChanged] function will be invoked.
|
_fieldListener = SingleFieldListener(fieldId: cellId.fieldId),
|
||||||
/// [onCellChanged] is optional and if omitted, it will default to `true`.
|
_fieldBackendSvc = FieldBackendService(
|
||||||
///
|
viewId: cellId.viewId,
|
||||||
VoidCallback? startListening({
|
fieldId: cellId.fieldInfo.id,
|
||||||
required void Function(T?) onCellChanged,
|
),
|
||||||
bool Function(T? oldValue, T? newValue)? listenWhenOnCellChanged,
|
_cacheKey = CellCacheKey(
|
||||||
VoidCallback? onCellFieldChanged,
|
rowId: cellId.rowId,
|
||||||
}) {
|
fieldId: cellId.fieldInfo.id,
|
||||||
if (isListening) {
|
) {
|
||||||
Log.error("Already started. It seems like you should call clone first");
|
_cellDataNotifier = CellDataNotifier(value: _cellCache.get(_cacheKey));
|
||||||
return null;
|
_cellListener = CellListener(
|
||||||
}
|
rowId: cellId.rowId,
|
||||||
isListening = true;
|
fieldId: cellId.fieldInfo.id,
|
||||||
|
|
||||||
_cellDataNotifier = CellDataNotifier(
|
|
||||||
value: _cellsCache.get(_cacheKey),
|
|
||||||
listenWhen: listenWhenOnCellChanged,
|
|
||||||
);
|
);
|
||||||
_cellListener =
|
|
||||||
CellListener(rowId: cellId.rowId, fieldId: cellId.fieldInfo.id);
|
|
||||||
|
|
||||||
/// 1.Listen on user edit event and load the new cell data if needed.
|
/// 1.Listen on user edit event and load the new cell data if needed.
|
||||||
/// For example:
|
/// For example:
|
||||||
@ -205,7 +76,7 @@ class CellController<T, D> extends Equatable {
|
|||||||
_cellListener?.start(onCellChanged: (result) {
|
_cellListener?.start(onCellChanged: (result) {
|
||||||
result.fold(
|
result.fold(
|
||||||
(_) {
|
(_) {
|
||||||
_cellsCache.remove(_cacheKey);
|
_cellCache.remove(_cacheKey);
|
||||||
_loadData();
|
_loadData();
|
||||||
},
|
},
|
||||||
(err) => Log.error(err),
|
(err) => Log.error(err),
|
||||||
@ -213,20 +84,25 @@ class CellController<T, D> extends Equatable {
|
|||||||
});
|
});
|
||||||
|
|
||||||
/// 2.Listen on the field event and load the cell data if needed.
|
/// 2.Listen on the field event and load the cell data if needed.
|
||||||
_onFieldChangedFn = () {
|
_fieldListener.start(onFieldChanged: (result) {
|
||||||
if (onCellFieldChanged != null) {
|
result.fold((fieldPB) {
|
||||||
onCellFieldChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// reloadOnFieldChanged should be true if you need to load the data when the corresponding field is changed
|
/// reloadOnFieldChanged should be true if you need to load the data when the corresponding field is changed
|
||||||
/// For example:
|
/// For example:
|
||||||
/// ¥12 -> $12
|
/// ¥12 -> $12
|
||||||
if (_cellDataLoader.reloadOnFieldChanged) {
|
if (_cellDataLoader.reloadOnFieldChanged) {
|
||||||
_loadData();
|
_loadData();
|
||||||
}
|
}
|
||||||
};
|
_onCellFieldChanged?.call();
|
||||||
|
}, (err) => Log.error(err));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
_fieldNotifier.register(_cacheKey, _onFieldChangedFn!);
|
/// Listen on the cell content or field changes
|
||||||
|
VoidCallback? startListening({
|
||||||
|
required void Function(T?) onCellChanged,
|
||||||
|
VoidCallback? onCellFieldChanged,
|
||||||
|
}) {
|
||||||
|
_onCellFieldChanged = onCellFieldChanged;
|
||||||
|
|
||||||
/// Notify the listener, the cell data was changed.
|
/// Notify the listener, the cell data was changed.
|
||||||
onCellChangedFn() => onCellChanged(_cellDataNotifier?.value);
|
onCellChangedFn() => onCellChanged(_cellDataNotifier?.value);
|
||||||
@ -244,7 +120,7 @@ class CellController<T, D> extends Equatable {
|
|||||||
/// The cell data will be read from the Cache first, and load from disk if it does not exist.
|
/// The cell data will be read from the Cache first, and load from disk if it does not exist.
|
||||||
/// You can set [loadIfNotExist] to false (default is true) to disable loading the cell data.
|
/// You can set [loadIfNotExist] to false (default is true) to disable loading the cell data.
|
||||||
T? getCellData({bool loadIfNotExist = true}) {
|
T? getCellData({bool loadIfNotExist = true}) {
|
||||||
final data = _cellsCache.get(_cacheKey);
|
final data = _cellCache.get(_cacheKey);
|
||||||
if (data == null && loadIfNotExist) {
|
if (data == null && loadIfNotExist) {
|
||||||
_loadData();
|
_loadData();
|
||||||
}
|
}
|
||||||
@ -294,9 +170,9 @@ class CellController<T, D> extends Equatable {
|
|||||||
_loadDataOperation = Timer(const Duration(milliseconds: 10), () {
|
_loadDataOperation = Timer(const Duration(milliseconds: 10), () {
|
||||||
_cellDataLoader.loadData().then((data) {
|
_cellDataLoader.loadData().then((data) {
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
_cellsCache.insert(_cacheKey, GridBaseCell(object: data));
|
_cellCache.insert(_cacheKey, GridBaseCell(object: data));
|
||||||
} else {
|
} else {
|
||||||
_cellsCache.remove(_cacheKey);
|
_cellCache.remove(_cacheKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
_cellDataNotifier?.value = data;
|
_cellDataNotifier?.value = data;
|
||||||
@ -305,54 +181,17 @@ class CellController<T, D> extends Equatable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> dispose() async {
|
Future<void> dispose() async {
|
||||||
if (_isDispose) {
|
|
||||||
Log.error("$this should only dispose once");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_isDispose = true;
|
|
||||||
await _cellListener?.stop();
|
await _cellListener?.stop();
|
||||||
_loadDataOperation?.cancel();
|
_loadDataOperation?.cancel();
|
||||||
_saveDataOperation?.cancel();
|
_saveDataOperation?.cancel();
|
||||||
_cellDataNotifier?.dispose();
|
_cellDataNotifier?.dispose();
|
||||||
|
await _fieldListener.stop();
|
||||||
_cellDataNotifier = null;
|
_cellDataNotifier = null;
|
||||||
|
|
||||||
if (_onFieldChangedFn != null) {
|
|
||||||
_fieldNotifier.unregister(_cacheKey, _onFieldChangedFn!);
|
|
||||||
await _fieldNotifier.dispose();
|
|
||||||
_onFieldChangedFn = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props =>
|
List<Object> get props =>
|
||||||
[_cellsCache.get(_cacheKey) ?? "", cellId.rowId + cellId.fieldInfo.id];
|
[_cellCache.get(_cacheKey) ?? "", cellId.rowId + cellId.fieldInfo.id];
|
||||||
}
|
|
||||||
|
|
||||||
class GridCellFieldNotifierImpl extends ICellFieldNotifier {
|
|
||||||
final FieldController _fieldController;
|
|
||||||
OnReceiveUpdateFields? _onChangesetFn;
|
|
||||||
|
|
||||||
GridCellFieldNotifierImpl(FieldController cache) : _fieldController = cache;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void onCellDispose() {
|
|
||||||
if (_onChangesetFn != null) {
|
|
||||||
_fieldController.removeListener(onChangesetListener: _onChangesetFn!);
|
|
||||||
_onChangesetFn = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void onCellFieldChanged(void Function(FieldInfo) callback) {
|
|
||||||
_onChangesetFn = (List<FieldInfo> filedInfos) {
|
|
||||||
for (final field in filedInfos) {
|
|
||||||
callback(field);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
_fieldController.addListener(
|
|
||||||
onReceiveFields: _onChangesetFn,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class CellDataNotifier<T> extends ChangeNotifier {
|
class CellDataNotifier<T> extends ChangeNotifier {
|
||||||
|
@ -0,0 +1,108 @@
|
|||||||
|
import 'package:appflowy_backend/protobuf/flowy-database/date_type_option_entities.pb.dart';
|
||||||
|
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pbenum.dart';
|
||||||
|
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.dart';
|
||||||
|
import 'package:appflowy_backend/protobuf/flowy-database/url_type_option_entities.pb.dart';
|
||||||
|
|
||||||
|
import 'cell_controller.dart';
|
||||||
|
import 'cell_service.dart';
|
||||||
|
|
||||||
|
typedef TextCellController = CellController<String, String>;
|
||||||
|
typedef CheckboxCellController = CellController<String, String>;
|
||||||
|
typedef NumberCellController = CellController<String, String>;
|
||||||
|
typedef SelectOptionCellController
|
||||||
|
= CellController<SelectOptionCellDataPB, String>;
|
||||||
|
typedef ChecklistCellController
|
||||||
|
= CellController<SelectOptionCellDataPB, String>;
|
||||||
|
typedef DateCellController = CellController<DateCellDataPB, CalendarData>;
|
||||||
|
typedef URLCellController = CellController<URLCellDataPB, String>;
|
||||||
|
|
||||||
|
class CellControllerBuilder {
|
||||||
|
final CellIdentifier _cellId;
|
||||||
|
final CellCache _cellCache;
|
||||||
|
|
||||||
|
CellControllerBuilder({
|
||||||
|
required CellIdentifier cellId,
|
||||||
|
required CellCache cellCache,
|
||||||
|
}) : _cellCache = cellCache,
|
||||||
|
_cellId = cellId;
|
||||||
|
|
||||||
|
CellController build() {
|
||||||
|
switch (_cellId.fieldType) {
|
||||||
|
case FieldType.Checkbox:
|
||||||
|
final cellDataLoader = CellDataLoader(
|
||||||
|
cellId: _cellId,
|
||||||
|
parser: StringCellDataParser(),
|
||||||
|
);
|
||||||
|
return TextCellController(
|
||||||
|
cellId: _cellId,
|
||||||
|
cellCache: _cellCache,
|
||||||
|
cellDataLoader: cellDataLoader,
|
||||||
|
cellDataPersistence: TextCellDataPersistence(cellId: _cellId),
|
||||||
|
);
|
||||||
|
case FieldType.DateTime:
|
||||||
|
final cellDataLoader = CellDataLoader(
|
||||||
|
cellId: _cellId,
|
||||||
|
parser: DateCellDataParser(),
|
||||||
|
reloadOnFieldChanged: true,
|
||||||
|
);
|
||||||
|
|
||||||
|
return DateCellController(
|
||||||
|
cellId: _cellId,
|
||||||
|
cellCache: _cellCache,
|
||||||
|
cellDataLoader: cellDataLoader,
|
||||||
|
cellDataPersistence: DateCellDataPersistence(cellId: _cellId),
|
||||||
|
);
|
||||||
|
case FieldType.Number:
|
||||||
|
final cellDataLoader = CellDataLoader(
|
||||||
|
cellId: _cellId,
|
||||||
|
parser: StringCellDataParser(),
|
||||||
|
reloadOnFieldChanged: true,
|
||||||
|
);
|
||||||
|
return NumberCellController(
|
||||||
|
cellId: _cellId,
|
||||||
|
cellCache: _cellCache,
|
||||||
|
cellDataLoader: cellDataLoader,
|
||||||
|
cellDataPersistence: TextCellDataPersistence(cellId: _cellId),
|
||||||
|
);
|
||||||
|
case FieldType.RichText:
|
||||||
|
final cellDataLoader = CellDataLoader(
|
||||||
|
cellId: _cellId,
|
||||||
|
parser: StringCellDataParser(),
|
||||||
|
);
|
||||||
|
return TextCellController(
|
||||||
|
cellId: _cellId,
|
||||||
|
cellCache: _cellCache,
|
||||||
|
cellDataLoader: cellDataLoader,
|
||||||
|
cellDataPersistence: TextCellDataPersistence(cellId: _cellId),
|
||||||
|
);
|
||||||
|
case FieldType.MultiSelect:
|
||||||
|
case FieldType.SingleSelect:
|
||||||
|
case FieldType.Checklist:
|
||||||
|
final cellDataLoader = CellDataLoader(
|
||||||
|
cellId: _cellId,
|
||||||
|
parser: SelectOptionCellDataParser(),
|
||||||
|
reloadOnFieldChanged: true,
|
||||||
|
);
|
||||||
|
|
||||||
|
return SelectOptionCellController(
|
||||||
|
cellId: _cellId,
|
||||||
|
cellCache: _cellCache,
|
||||||
|
cellDataLoader: cellDataLoader,
|
||||||
|
cellDataPersistence: TextCellDataPersistence(cellId: _cellId),
|
||||||
|
);
|
||||||
|
|
||||||
|
case FieldType.URL:
|
||||||
|
final cellDataLoader = CellDataLoader(
|
||||||
|
cellId: _cellId,
|
||||||
|
parser: URLCellDataParser(),
|
||||||
|
);
|
||||||
|
return URLCellController(
|
||||||
|
cellId: _cellId,
|
||||||
|
cellCache: _cellCache,
|
||||||
|
cellDataLoader: cellDataLoader,
|
||||||
|
cellDataPersistence: TextCellDataPersistence(cellId: _cellId),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
throw UnimplementedError;
|
||||||
|
}
|
||||||
|
}
|
@ -1,63 +0,0 @@
|
|||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import '../field/field_controller.dart';
|
|
||||||
import 'cell_service.dart';
|
|
||||||
|
|
||||||
abstract class ICellFieldNotifier {
|
|
||||||
void onCellFieldChanged(void Function(FieldInfo) callback);
|
|
||||||
void onCellDispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// DatabasePB's cell helper wrapper that enables each cell will get notified when the corresponding field was changed.
|
|
||||||
/// You Register an onFieldChanged callback to listen to the cell changes, and unregister if you don't want to listen.
|
|
||||||
class CellFieldNotifier {
|
|
||||||
final ICellFieldNotifier notifier;
|
|
||||||
|
|
||||||
/// fieldId: {objectId: callback}
|
|
||||||
final Map<String, Map<String, List<VoidCallback>>> _fieldListenerByFieldId =
|
|
||||||
{};
|
|
||||||
|
|
||||||
CellFieldNotifier({required this.notifier}) {
|
|
||||||
notifier.onCellFieldChanged(
|
|
||||||
(field) {
|
|
||||||
final map = _fieldListenerByFieldId[field.id];
|
|
||||||
if (map != null) {
|
|
||||||
for (final callbacks in map.values) {
|
|
||||||
for (final callback in callbacks) {
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
///
|
|
||||||
void register(CellCacheKey cacheKey, VoidCallback onFieldChanged) {
|
|
||||||
var map = _fieldListenerByFieldId[cacheKey.fieldId];
|
|
||||||
if (map == null) {
|
|
||||||
_fieldListenerByFieldId[cacheKey.fieldId] = {};
|
|
||||||
map = _fieldListenerByFieldId[cacheKey.fieldId];
|
|
||||||
map![cacheKey.rowId] = [onFieldChanged];
|
|
||||||
} else {
|
|
||||||
var objects = map[cacheKey.rowId];
|
|
||||||
if (objects == null) {
|
|
||||||
map[cacheKey.rowId] = [onFieldChanged];
|
|
||||||
} else {
|
|
||||||
objects.add(onFieldChanged);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void unregister(CellCacheKey cacheKey, VoidCallback fn) {
|
|
||||||
var callbacks = _fieldListenerByFieldId[cacheKey.fieldId]?[cacheKey.rowId];
|
|
||||||
final index = callbacks?.indexWhere((callback) => callback == fn);
|
|
||||||
if (index != null && index != -1) {
|
|
||||||
callbacks?.removeAt(index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> dispose() async {
|
|
||||||
notifier.onCellDispose();
|
|
||||||
_fieldListenerByFieldId.clear();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +1,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:collection';
|
import 'dart:collection';
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:equatable/equatable.dart';
|
|
||||||
import 'package:appflowy_backend/dispatch/dispatch.dart';
|
import 'package:appflowy_backend/dispatch/dispatch.dart';
|
||||||
import 'package:appflowy_backend/log.dart';
|
import 'package:appflowy_backend/log.dart';
|
||||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
||||||
@ -15,13 +14,8 @@ import 'package:freezed_annotation/freezed_annotation.dart';
|
|||||||
import 'dart:convert' show utf8;
|
import 'dart:convert' show utf8;
|
||||||
|
|
||||||
import '../field/field_controller.dart';
|
import '../field/field_controller.dart';
|
||||||
import '../field/field_service.dart';
|
|
||||||
import '../field/type_option/type_option_context.dart';
|
|
||||||
import 'cell_field_notifier.dart';
|
|
||||||
import 'cell_listener.dart';
|
|
||||||
part 'cell_service.freezed.dart';
|
part 'cell_service.freezed.dart';
|
||||||
part 'cell_data_loader.dart';
|
part 'cell_data_loader.dart';
|
||||||
part 'cell_controller.dart';
|
|
||||||
part 'cell_cache.dart';
|
part 'cell_cache.dart';
|
||||||
part 'cell_data_persistence.dart';
|
part 'cell_data_persistence.dart';
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import 'type_option/type_option_data_controller.dart';
|
|||||||
part 'field_editor_bloc.freezed.dart';
|
part 'field_editor_bloc.freezed.dart';
|
||||||
|
|
||||||
class FieldEditorBloc extends Bloc<FieldEditorEvent, FieldEditorState> {
|
class FieldEditorBloc extends Bloc<FieldEditorEvent, FieldEditorState> {
|
||||||
final TypeOptionDataController dataController;
|
final TypeOptionController dataController;
|
||||||
|
|
||||||
FieldEditorBloc({
|
FieldEditorBloc({
|
||||||
required String viewId,
|
required String viewId,
|
||||||
@ -18,7 +18,7 @@ class FieldEditorBloc extends Bloc<FieldEditorEvent, FieldEditorState> {
|
|||||||
required bool isGroupField,
|
required bool isGroupField,
|
||||||
required IFieldTypeOptionLoader loader,
|
required IFieldTypeOptionLoader loader,
|
||||||
}) : dataController =
|
}) : dataController =
|
||||||
TypeOptionDataController(viewId: viewId, loader: loader),
|
TypeOptionController(viewId: viewId, loader: loader),
|
||||||
super(FieldEditorState.initial(viewId, fieldName, isGroupField)) {
|
super(FieldEditorState.initial(viewId, fieldName, isGroupField)) {
|
||||||
on<FieldEditorEvent>(
|
on<FieldEditorEvent>(
|
||||||
(event, emit) async {
|
(event, emit) async {
|
||||||
|
@ -8,10 +8,10 @@ part 'field_type_option_edit_bloc.freezed.dart';
|
|||||||
|
|
||||||
class FieldTypeOptionEditBloc
|
class FieldTypeOptionEditBloc
|
||||||
extends Bloc<FieldTypeOptionEditEvent, FieldTypeOptionEditState> {
|
extends Bloc<FieldTypeOptionEditEvent, FieldTypeOptionEditState> {
|
||||||
final TypeOptionDataController _dataController;
|
final TypeOptionController _dataController;
|
||||||
void Function()? _fieldListenFn;
|
void Function()? _fieldListenFn;
|
||||||
|
|
||||||
FieldTypeOptionEditBloc(TypeOptionDataController dataController)
|
FieldTypeOptionEditBloc(TypeOptionController dataController)
|
||||||
: _dataController = dataController,
|
: _dataController = dataController,
|
||||||
super(FieldTypeOptionEditState.initial(dataController)) {
|
super(FieldTypeOptionEditState.initial(dataController)) {
|
||||||
on<FieldTypeOptionEditEvent>(
|
on<FieldTypeOptionEditEvent>(
|
||||||
@ -58,9 +58,9 @@ class FieldTypeOptionEditState with _$FieldTypeOptionEditState {
|
|||||||
}) = _FieldTypeOptionEditState;
|
}) = _FieldTypeOptionEditState;
|
||||||
|
|
||||||
factory FieldTypeOptionEditState.initial(
|
factory FieldTypeOptionEditState.initial(
|
||||||
TypeOptionDataController typeOptionDataController,
|
TypeOptionController typeOptionController,
|
||||||
) =>
|
) =>
|
||||||
FieldTypeOptionEditState(
|
FieldTypeOptionEditState(
|
||||||
field: typeOptionDataController.field,
|
field: typeOptionController.field,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -109,11 +109,11 @@ class ChecklistTypeOptionWidgetDataParser
|
|||||||
class TypeOptionContext<T extends GeneratedMessage> {
|
class TypeOptionContext<T extends GeneratedMessage> {
|
||||||
T? _typeOptionObject;
|
T? _typeOptionObject;
|
||||||
final TypeOptionParser<T> dataParser;
|
final TypeOptionParser<T> dataParser;
|
||||||
final TypeOptionDataController _dataController;
|
final TypeOptionController _dataController;
|
||||||
|
|
||||||
TypeOptionContext({
|
TypeOptionContext({
|
||||||
required this.dataParser,
|
required this.dataParser,
|
||||||
required TypeOptionDataController dataController,
|
required TypeOptionController dataController,
|
||||||
}) : _dataController = dataController;
|
}) : _dataController = dataController;
|
||||||
|
|
||||||
String get viewId => _dataController.viewId;
|
String get viewId => _dataController.viewId;
|
||||||
|
@ -9,25 +9,25 @@ import 'package:appflowy_backend/log.dart';
|
|||||||
import '../field_service.dart';
|
import '../field_service.dart';
|
||||||
import 'type_option_context.dart';
|
import 'type_option_context.dart';
|
||||||
|
|
||||||
class TypeOptionDataController {
|
class TypeOptionController {
|
||||||
final String viewId;
|
final String viewId;
|
||||||
|
late TypeOptionPB _typeOption;
|
||||||
final IFieldTypeOptionLoader loader;
|
final IFieldTypeOptionLoader loader;
|
||||||
late TypeOptionPB _typeOptiondata;
|
|
||||||
final PublishNotifier<FieldPB> _fieldNotifier = PublishNotifier();
|
final PublishNotifier<FieldPB> _fieldNotifier = PublishNotifier();
|
||||||
|
|
||||||
/// Returns a [TypeOptionDataController] used to modify the specified
|
/// Returns a [TypeOptionController] used to modify the specified
|
||||||
/// [FieldPB]'s data
|
/// [FieldPB]'s data
|
||||||
///
|
///
|
||||||
/// Should call [loadTypeOptionData] if the passed-in [FieldInfo]
|
/// Should call [loadTypeOptionData] if the passed-in [FieldInfo]
|
||||||
/// is null
|
/// is null
|
||||||
///
|
///
|
||||||
TypeOptionDataController({
|
TypeOptionController({
|
||||||
required this.viewId,
|
required this.viewId,
|
||||||
required this.loader,
|
required this.loader,
|
||||||
FieldInfo? fieldInfo,
|
FieldInfo? fieldInfo,
|
||||||
}) {
|
}) {
|
||||||
if (fieldInfo != null) {
|
if (fieldInfo != null) {
|
||||||
_typeOptiondata = TypeOptionPB.create()
|
_typeOption = TypeOptionPB.create()
|
||||||
..viewId = viewId
|
..viewId = viewId
|
||||||
..field_2 = fieldInfo.field;
|
..field_2 = fieldInfo.field;
|
||||||
}
|
}
|
||||||
@ -38,7 +38,7 @@ class TypeOptionDataController {
|
|||||||
return result.fold(
|
return result.fold(
|
||||||
(data) {
|
(data) {
|
||||||
data.freeze();
|
data.freeze();
|
||||||
_typeOptiondata = data;
|
_typeOption = data;
|
||||||
_fieldNotifier.value = data.field_2;
|
_fieldNotifier.value = data.field_2;
|
||||||
return left(data);
|
return left(data);
|
||||||
},
|
},
|
||||||
@ -50,28 +50,28 @@ class TypeOptionDataController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FieldPB get field {
|
FieldPB get field {
|
||||||
return _typeOptiondata.field_2;
|
return _typeOption.field_2;
|
||||||
}
|
}
|
||||||
|
|
||||||
T getTypeOption<T>(TypeOptionParser<T> parser) {
|
T getTypeOption<T>(TypeOptionParser<T> parser) {
|
||||||
return parser.fromBuffer(_typeOptiondata.typeOptionData);
|
return parser.fromBuffer(_typeOption.typeOptionData);
|
||||||
}
|
}
|
||||||
|
|
||||||
set fieldName(String name) {
|
set fieldName(String name) {
|
||||||
_typeOptiondata = _typeOptiondata.rebuild((rebuildData) {
|
_typeOption = _typeOption.rebuild((rebuildData) {
|
||||||
rebuildData.field_2 = rebuildData.field_2.rebuild((rebuildField) {
|
rebuildData.field_2 = rebuildData.field_2.rebuild((rebuildField) {
|
||||||
rebuildField.name = name;
|
rebuildField.name = name;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
_fieldNotifier.value = _typeOptiondata.field_2;
|
_fieldNotifier.value = _typeOption.field_2;
|
||||||
|
|
||||||
FieldBackendService(viewId: viewId, fieldId: field.id)
|
FieldBackendService(viewId: viewId, fieldId: field.id)
|
||||||
.updateField(name: name);
|
.updateField(name: name);
|
||||||
}
|
}
|
||||||
|
|
||||||
set typeOptionData(List<int> typeOptionData) {
|
set typeOptionData(List<int> typeOptionData) {
|
||||||
_typeOptiondata = _typeOptiondata.rebuild((rebuildData) {
|
_typeOption = _typeOption.rebuild((rebuildData) {
|
||||||
if (typeOptionData.isNotEmpty) {
|
if (typeOptionData.isNotEmpty) {
|
||||||
rebuildData.typeOptionData = typeOptionData;
|
rebuildData.typeOptionData = typeOptionData;
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,20 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import '../../grid/presentation/widgets/cell/cell_builder.dart';
|
|
||||||
import '../cell/cell_field_notifier.dart';
|
|
||||||
import '../cell/cell_service.dart';
|
import '../cell/cell_service.dart';
|
||||||
import '../field/field_controller.dart';
|
|
||||||
import 'row_cache.dart';
|
import 'row_cache.dart';
|
||||||
|
|
||||||
typedef OnRowChanged = void Function(CellByFieldId, RowsChangedReason);
|
typedef OnRowChanged = void Function(CellByFieldId, RowsChangedReason);
|
||||||
|
|
||||||
class RowDataController extends GridCellBuilderDelegate {
|
class RowDataController {
|
||||||
final RowInfo rowInfo;
|
final RowInfo rowInfo;
|
||||||
final List<VoidCallback> _onRowChangedListeners = [];
|
final List<VoidCallback> _onRowChangedListeners = [];
|
||||||
final FieldController _fieldController;
|
|
||||||
final RowCache _rowCache;
|
final RowCache _rowCache;
|
||||||
|
|
||||||
|
get cellCache => _rowCache.cellCache;
|
||||||
|
|
||||||
RowDataController({
|
RowDataController({
|
||||||
required this.rowInfo,
|
required this.rowInfo,
|
||||||
required FieldController fieldController,
|
|
||||||
required RowCache rowCache,
|
required RowCache rowCache,
|
||||||
}) : _fieldController = fieldController,
|
}) : _rowCache = rowCache;
|
||||||
_rowCache = rowCache;
|
|
||||||
|
|
||||||
CellByFieldId loadData() {
|
CellByFieldId loadData() {
|
||||||
return _rowCache.loadGridCells(rowInfo.rowPB.id);
|
return _rowCache.loadGridCells(rowInfo.rowPB.id);
|
||||||
@ -36,14 +32,4 @@ class RowDataController extends GridCellBuilderDelegate {
|
|||||||
_rowCache.removeRowListener(fn);
|
_rowCache.removeRowListener(fn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GridCellBuilderDelegate implementation
|
|
||||||
@override
|
|
||||||
CellFieldNotifier buildFieldNotifier() {
|
|
||||||
return CellFieldNotifier(
|
|
||||||
notifier: GridCellFieldNotifierImpl(_fieldController));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
CellCache get cellCache => _rowCache.cellCache;
|
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ typedef OnResetGroups = void Function(List<GroupPB>);
|
|||||||
|
|
||||||
class BoardDataController {
|
class BoardDataController {
|
||||||
final String viewId;
|
final String viewId;
|
||||||
final DatabaseBackendService _databaseFFIService;
|
final DatabaseBackendService _databaseSvc;
|
||||||
final FieldController fieldController;
|
final FieldController fieldController;
|
||||||
final BoardListener _listener;
|
final BoardListener _listener;
|
||||||
late DatabaseViewCache _viewCache;
|
late DatabaseViewCache _viewCache;
|
||||||
@ -38,7 +38,7 @@ class BoardDataController {
|
|||||||
BoardDataController({required ViewPB view})
|
BoardDataController({required ViewPB view})
|
||||||
: viewId = view.id,
|
: viewId = view.id,
|
||||||
_listener = BoardListener(view.id),
|
_listener = BoardListener(view.id),
|
||||||
_databaseFFIService = DatabaseBackendService(viewId: view.id),
|
_databaseSvc = DatabaseBackendService(viewId: view.id),
|
||||||
fieldController = FieldController(viewId: view.id) {
|
fieldController = FieldController(viewId: view.id) {
|
||||||
//
|
//
|
||||||
_viewCache = DatabaseViewCache(
|
_viewCache = DatabaseViewCache(
|
||||||
@ -100,7 +100,7 @@ class BoardDataController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<Either<Unit, FlowyError>> openGrid() async {
|
Future<Either<Unit, FlowyError>> openGrid() async {
|
||||||
final result = await _databaseFFIService.openGrid();
|
final result = await _databaseSvc.openGrid();
|
||||||
return result.fold(
|
return result.fold(
|
||||||
(grid) async {
|
(grid) async {
|
||||||
_onDatabaseChanged?.call(grid);
|
_onDatabaseChanged?.call(grid);
|
||||||
@ -121,17 +121,17 @@ class BoardDataController {
|
|||||||
|
|
||||||
Future<Either<RowPB, FlowyError>> createBoardCard(String groupId,
|
Future<Either<RowPB, FlowyError>> createBoardCard(String groupId,
|
||||||
{String? startRowId}) {
|
{String? startRowId}) {
|
||||||
return _databaseFFIService.createBoardCard(groupId, startRowId);
|
return _databaseSvc.createBoardCard(groupId, startRowId);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> dispose() async {
|
Future<void> dispose() async {
|
||||||
await _viewCache.dispose();
|
await _viewCache.dispose();
|
||||||
await _databaseFFIService.closeView();
|
await _databaseSvc.closeView();
|
||||||
await fieldController.dispose();
|
await fieldController.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _loadGroups() async {
|
Future<void> _loadGroups() async {
|
||||||
final result = await _databaseFFIService.loadGroups();
|
final result = await _databaseSvc.loadGroups();
|
||||||
return Future(
|
return Future(
|
||||||
() => result.fold(
|
() => result.fold(
|
||||||
(groups) {
|
(groups) {
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
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';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import '../../../application/cell/cell_controller_builder.dart';
|
||||||
import '../../../application/cell/cell_service.dart';
|
|
||||||
|
|
||||||
part 'board_checkbox_cell_bloc.freezed.dart';
|
part 'board_checkbox_cell_bloc.freezed.dart';
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import '../../../application/cell/cell_service.dart';
|
import '../../../application/cell/cell_controller_builder.dart';
|
||||||
import '../../../application/field/field_controller.dart';
|
import '../../../application/field/field_controller.dart';
|
||||||
part 'board_date_cell_bloc.freezed.dart';
|
part 'board_date_cell_bloc.freezed.dart';
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
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';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import '../../../application/cell/cell_service.dart';
|
|
||||||
|
import '../../../application/cell/cell_controller_builder.dart';
|
||||||
|
|
||||||
part 'board_number_cell_bloc.freezed.dart';
|
part 'board_number_cell_bloc.freezed.dart';
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:appflowy/plugins/database_view/application/cell/cell_service.dart';
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.dart';
|
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.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';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import 'package:appflowy/plugins/database_view/application/cell/cell_service.dart';
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.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';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:appflowy_backend/protobuf/flowy-database/url_type_option_entities.pb.dart';
|
import 'package:appflowy_backend/protobuf/flowy-database/url_type_option_entities.pb.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';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import '../../../application/cell/cell_service.dart';
|
|
||||||
|
|
||||||
part 'board_url_cell_bloc.freezed.dart';
|
part 'board_url_cell_bloc.freezed.dart';
|
||||||
|
|
||||||
class BoardURLCellBloc extends Bloc<BoardURLCellEvent, BoardURLCellState> {
|
class BoardURLCellBloc extends Bloc<BoardURLCellEvent, BoardURLCellState> {
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
import 'package:appflowy_backend/protobuf/flowy-database/row_entities.pb.dart';
|
import 'package:appflowy_backend/protobuf/flowy-database/row_entities.pb.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
|
|
||||||
import '../../../application/cell/cell_field_notifier.dart';
|
|
||||||
import '../../../application/cell/cell_service.dart';
|
import '../../../application/cell/cell_service.dart';
|
||||||
import '../../../application/field/field_controller.dart';
|
|
||||||
import '../../../application/row/row_cache.dart';
|
import '../../../application/row/row_cache.dart';
|
||||||
import '../../presentation/card/card_cell_builder.dart';
|
import '../../presentation/card/card_cell_builder.dart';
|
||||||
|
|
||||||
@ -11,16 +9,13 @@ typedef OnCardChanged = void Function(CellByFieldId, RowsChangedReason);
|
|||||||
|
|
||||||
class CardDataController extends BoardCellBuilderDelegate {
|
class CardDataController extends BoardCellBuilderDelegate {
|
||||||
final RowPB rowPB;
|
final RowPB rowPB;
|
||||||
final FieldController _fieldController;
|
|
||||||
final RowCache _rowCache;
|
final RowCache _rowCache;
|
||||||
final List<VoidCallback> _onCardChangedListeners = [];
|
final List<VoidCallback> _onCardChangedListeners = [];
|
||||||
|
|
||||||
CardDataController({
|
CardDataController({
|
||||||
required this.rowPB,
|
required this.rowPB,
|
||||||
required FieldController fieldController,
|
|
||||||
required RowCache rowCache,
|
required RowCache rowCache,
|
||||||
}) : _fieldController = fieldController,
|
}) : _rowCache = rowCache;
|
||||||
_rowCache = rowCache;
|
|
||||||
|
|
||||||
CellByFieldId loadData() {
|
CellByFieldId loadData() {
|
||||||
return _rowCache.loadGridCells(rowPB.id);
|
return _rowCache.loadGridCells(rowPB.id);
|
||||||
@ -39,12 +34,6 @@ class CardDataController extends BoardCellBuilderDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
CellFieldNotifier buildFieldNotifier() {
|
|
||||||
return CellFieldNotifier(
|
|
||||||
notifier: GridCellFieldNotifierImpl(_fieldController));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
CellCache get cellCache => _rowCache.cellCache;
|
CellCache get cellCache => _rowCache.cellCache;
|
||||||
}
|
}
|
||||||
|
@ -229,7 +229,6 @@ class _BoardContentState extends State<BoardContent> {
|
|||||||
final fieldController = context.read<BoardBloc>().fieldController;
|
final fieldController = context.read<BoardBloc>().fieldController;
|
||||||
final viewId = context.read<BoardBloc>().viewId;
|
final viewId = context.read<BoardBloc>().viewId;
|
||||||
final cardController = CardDataController(
|
final cardController = CardDataController(
|
||||||
fieldController: fieldController,
|
|
||||||
rowCache: rowCache,
|
rowCache: rowCache,
|
||||||
rowPB: rowPB,
|
rowPB: rowPB,
|
||||||
);
|
);
|
||||||
@ -306,7 +305,6 @@ class _BoardContentState extends State<BoardContent> {
|
|||||||
|
|
||||||
final dataController = RowDataController(
|
final dataController = RowDataController(
|
||||||
rowInfo: rowInfo,
|
rowInfo: rowInfo,
|
||||||
fieldController: fieldController,
|
|
||||||
rowCache: rowCache,
|
rowCache: rowCache,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -314,7 +312,7 @@ class _BoardContentState extends State<BoardContent> {
|
|||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return RowDetailPage(
|
return RowDetailPage(
|
||||||
cellBuilder: GridCellBuilder(delegate: dataController),
|
cellBuilder: GridCellBuilder(cellCache: dataController.cellCache),
|
||||||
dataController: dataController,
|
dataController: dataController,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import 'package:appflowy/plugins/database_view/application/cell/cell_service.dart';
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:appflowy/plugins/database_view/board/application/card/board_checkbox_cell_bloc.dart';
|
import 'package:appflowy/plugins/database_view/board/application/card/board_checkbox_cell_bloc.dart';
|
||||||
import 'package:flowy_infra/image.dart';
|
import 'package:flowy_infra/image.dart';
|
||||||
import 'package:flowy_infra_ui/style_widget/icon_button.dart';
|
import 'package:flowy_infra_ui/style_widget/icon_button.dart';
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
import '../../../application/cell/cell_service.dart';
|
|
||||||
import '../../../grid/application/cell/checklist_cell_bloc.dart';
|
import '../../../grid/application/cell/checklist_cell_bloc.dart';
|
||||||
import '../../../grid/presentation/widgets/cell/checklist_cell/checklist_progress_bar.dart';
|
import '../../../grid/presentation/widgets/cell/checklist_cell/checklist_progress_bar.dart';
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:appflowy/plugins/database_view/board/application/card/board_date_cell_bloc.dart';
|
import 'package:appflowy/plugins/database_view/board/application/card/board_date_cell_bloc.dart';
|
||||||
import 'package:flowy_infra_ui/style_widget/text.dart';
|
import 'package:flowy_infra_ui/style_widget/text.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
import '../../../application/cell/cell_service.dart';
|
|
||||||
import 'define.dart';
|
import 'define.dart';
|
||||||
|
|
||||||
class BoardDateCell extends StatefulWidget {
|
class BoardDateCell extends StatefulWidget {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:flowy_infra_ui/style_widget/text.dart';
|
import 'package:flowy_infra_ui/style_widget/text.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import '../../../application/cell/cell_service.dart';
|
|
||||||
import '../../application/card/board_number_cell_bloc.dart';
|
import '../../application/card/board_number_cell_bloc.dart';
|
||||||
import 'define.dart';
|
import 'define.dart';
|
||||||
|
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:appflowy_popover/appflowy_popover.dart';
|
import 'package:appflowy_popover/appflowy_popover.dart';
|
||||||
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
import '../../../application/cell/cell_service.dart';
|
|
||||||
import '../../../grid/presentation/widgets/cell/select_option_cell/extension.dart';
|
import '../../../grid/presentation/widgets/cell/select_option_cell/extension.dart';
|
||||||
import '../../../grid/presentation/widgets/cell/select_option_cell/select_option_editor.dart';
|
import '../../../grid/presentation/widgets/cell/select_option_cell/select_option_editor.dart';
|
||||||
import '../../application/card/board_select_option_cell_bloc.dart';
|
import '../../application/card/board_select_option_cell_bloc.dart';
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:appflowy/plugins/database_view/grid/presentation/widgets/cell/cell_builder.dart';
|
import 'package:appflowy/plugins/database_view/grid/presentation/widgets/cell/cell_builder.dart';
|
||||||
import 'package:flowy_infra/size.dart';
|
import 'package:flowy_infra/size.dart';
|
||||||
import 'package:flowy_infra_ui/style_widget/text.dart';
|
import 'package:flowy_infra_ui/style_widget/text.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:textstyle_extensions/textstyle_extensions.dart';
|
import 'package:textstyle_extensions/textstyle_extensions.dart';
|
||||||
import '../../../application/cell/cell_service.dart';
|
|
||||||
import '../../application/card/board_text_cell_bloc.dart';
|
import '../../application/card/board_text_cell_bloc.dart';
|
||||||
import 'board_cell.dart';
|
import 'board_cell.dart';
|
||||||
import 'define.dart';
|
import 'define.dart';
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:flowy_infra/size.dart';
|
import 'package:flowy_infra/size.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:textstyle_extensions/textstyle_extensions.dart';
|
import 'package:textstyle_extensions/textstyle_extensions.dart';
|
||||||
|
|
||||||
import '../../../application/cell/cell_service.dart';
|
|
||||||
import '../../application/card/board_url_cell_bloc.dart';
|
import '../../application/card/board_url_cell_bloc.dart';
|
||||||
import 'define.dart';
|
import 'define.dart';
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
@ -11,7 +12,7 @@ import 'board_select_option_cell.dart';
|
|||||||
import 'board_text_cell.dart';
|
import 'board_text_cell.dart';
|
||||||
import 'board_url_cell.dart';
|
import 'board_url_cell.dart';
|
||||||
|
|
||||||
abstract class BoardCellBuilderDelegate extends CellControllerBuilderDelegate {
|
abstract class BoardCellBuilderDelegate {
|
||||||
CellCache get cellCache;
|
CellCache get cellCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,7 +27,6 @@ class BoardCellBuilder {
|
|||||||
EditableCellNotifier cellNotifier,
|
EditableCellNotifier cellNotifier,
|
||||||
) {
|
) {
|
||||||
final cellControllerBuilder = CellControllerBuilder(
|
final cellControllerBuilder = CellControllerBuilder(
|
||||||
delegate: delegate,
|
|
||||||
cellId: cellId,
|
cellId: cellId,
|
||||||
cellCache: delegate.cellCache,
|
cellCache: delegate.cellCache,
|
||||||
);
|
);
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:appflowy/plugins/database_view/application/cell/cell_service.dart';
|
import 'package:appflowy/plugins/database_view/application/cell/cell_service.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';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import 'package:appflowy/plugins/database_view/application/cell/cell_service.dart';
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:appflowy_backend/log.dart';
|
import 'package:appflowy_backend/log.dart';
|
||||||
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.dart';
|
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
@ -10,12 +10,12 @@ part 'checklist_cell_bloc.freezed.dart';
|
|||||||
|
|
||||||
class ChecklistCellBloc extends Bloc<ChecklistCellEvent, ChecklistCellState> {
|
class ChecklistCellBloc extends Bloc<ChecklistCellEvent, ChecklistCellState> {
|
||||||
final ChecklistCellController cellController;
|
final ChecklistCellController cellController;
|
||||||
final SelectOptionFFIService _selectOptionService;
|
final SelectOptionBackendService _selectOptionSvc;
|
||||||
void Function()? _onCellChangedFn;
|
void Function()? _onCellChangedFn;
|
||||||
ChecklistCellBloc({
|
ChecklistCellBloc({
|
||||||
required this.cellController,
|
required this.cellController,
|
||||||
}) : _selectOptionService =
|
}) : _selectOptionSvc =
|
||||||
SelectOptionFFIService(cellId: cellController.cellId),
|
SelectOptionBackendService(cellId: cellController.cellId),
|
||||||
super(ChecklistCellState.initial(cellController)) {
|
super(ChecklistCellState.initial(cellController)) {
|
||||||
on<ChecklistCellEvent>(
|
on<ChecklistCellEvent>(
|
||||||
(event, emit) async {
|
(event, emit) async {
|
||||||
@ -60,7 +60,7 @@ class ChecklistCellBloc extends Bloc<ChecklistCellEvent, ChecklistCellState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _loadOptions() {
|
void _loadOptions() {
|
||||||
_selectOptionService.getOptionContext().then((result) {
|
_selectOptionSvc.getCellData().then((result) {
|
||||||
if (isClosed) return;
|
if (isClosed) return;
|
||||||
|
|
||||||
return result.fold(
|
return result.fold(
|
||||||
|
@ -1,25 +1,24 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:appflowy/plugins/database_view/application/cell/cell_service.dart';
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:appflowy_backend/log.dart';
|
import 'package:appflowy_backend/log.dart';
|
||||||
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.dart';
|
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.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';
|
||||||
|
|
||||||
import 'select_option_service.dart';
|
import 'select_option_service.dart';
|
||||||
|
|
||||||
part 'checklist_cell_editor_bloc.freezed.dart';
|
part 'checklist_cell_editor_bloc.freezed.dart';
|
||||||
|
|
||||||
class ChecklistCellEditorBloc
|
class ChecklistCellEditorBloc
|
||||||
extends Bloc<ChecklistCellEditorEvent, ChecklistCellEditorState> {
|
extends Bloc<ChecklistCellEditorEvent, ChecklistCellEditorState> {
|
||||||
final SelectOptionFFIService _selectOptionService;
|
final SelectOptionBackendService _selectOptionService;
|
||||||
final ChecklistCellController cellController;
|
final ChecklistCellController cellController;
|
||||||
|
|
||||||
ChecklistCellEditorBloc({
|
ChecklistCellEditorBloc({
|
||||||
required this.cellController,
|
required this.cellController,
|
||||||
}) : _selectOptionService =
|
}) : _selectOptionService =
|
||||||
SelectOptionFFIService(cellId: cellController.cellId),
|
SelectOptionBackendService(cellId: cellController.cellId),
|
||||||
super(ChecklistCellEditorState.initial(cellController)) {
|
super(ChecklistCellEditorState.initial(cellController)) {
|
||||||
on<ChecklistCellEditorEvent>(
|
on<ChecklistCellEditorEvent>(
|
||||||
(event, emit) async {
|
(event, emit) async {
|
||||||
@ -87,7 +86,7 @@ class ChecklistCellEditorBloc
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _loadOptions() {
|
void _loadOptions() {
|
||||||
_selectOptionService.getOptionContext().then((result) {
|
_selectOptionService.getCellData().then((result) {
|
||||||
if (isClosed) return;
|
if (isClosed) return;
|
||||||
|
|
||||||
return result.fold(
|
return result.fold(
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import 'package:appflowy/generated/locale_keys.g.dart';
|
import 'package:appflowy/generated/locale_keys.g.dart';
|
||||||
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:appflowy/plugins/database_view/application/cell/cell_service.dart';
|
import 'package:appflowy/plugins/database_view/application/cell/cell_service.dart';
|
||||||
import 'package:appflowy/plugins/database_view/application/field/field_service.dart';
|
import 'package:appflowy/plugins/database_view/application/field/field_service.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart'
|
import 'package:easy_localization/easy_localization.dart'
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import 'package:appflowy/plugins/database_view/application/cell/cell_service.dart';
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:appflowy/plugins/database_view/application/field/field_controller.dart';
|
import 'package:appflowy/plugins/database_view/application/field/field_controller.dart';
|
||||||
import 'package:appflowy_backend/protobuf/flowy-database/date_type_option_entities.pb.dart';
|
import 'package:appflowy_backend/protobuf/flowy-database/date_type_option_entities.pb.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import 'package:appflowy/plugins/database_view/application/cell/cell_service.dart';
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:appflowy_backend/log.dart';
|
import 'package:appflowy_backend/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';
|
||||||
@ -49,22 +49,13 @@ class NumberCellBloc extends Bloc<NumberCellEvent, NumberCellState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _startListening() {
|
void _startListening() {
|
||||||
_onCellChangedFn =
|
_onCellChangedFn = cellController.startListening(
|
||||||
cellController.startListening(onCellChanged: ((cellContent) {
|
onCellChanged: ((cellContent) {
|
||||||
if (!isClosed) {
|
if (!isClosed) {
|
||||||
add(NumberCellEvent.didReceiveCellUpdate(cellContent));
|
add(NumberCellEvent.didReceiveCellUpdate(cellContent));
|
||||||
}
|
}
|
||||||
}), listenWhenOnCellChanged: (oldValue, newValue) {
|
}),
|
||||||
// If the new value is not the same as the content, which means the
|
);
|
||||||
// backend formatted the content that user enter. For example:
|
|
||||||
//
|
|
||||||
// state.cellContent: "abc"
|
|
||||||
// oldValue: ""
|
|
||||||
// newValue: ""
|
|
||||||
// The oldValue is the same as newValue. So the [onCellChanged] won't
|
|
||||||
// get called. So just return true to refresh the cell content
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:appflowy/plugins/database_view/application/cell/cell_service.dart';
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.dart';
|
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.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';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:appflowy/plugins/database_view/application/cell/cell_service.dart';
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:appflowy_backend/log.dart';
|
import 'package:appflowy_backend/log.dart';
|
||||||
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.dart';
|
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.dart';
|
||||||
@ -11,13 +11,13 @@ part 'select_option_editor_bloc.freezed.dart';
|
|||||||
|
|
||||||
class SelectOptionCellEditorBloc
|
class SelectOptionCellEditorBloc
|
||||||
extends Bloc<SelectOptionEditorEvent, SelectOptionEditorState> {
|
extends Bloc<SelectOptionEditorEvent, SelectOptionEditorState> {
|
||||||
final SelectOptionFFIService _selectOptionService;
|
final SelectOptionBackendService _selectOptionService;
|
||||||
final SelectOptionCellController cellController;
|
final SelectOptionCellController cellController;
|
||||||
|
|
||||||
SelectOptionCellEditorBloc({
|
SelectOptionCellEditorBloc({
|
||||||
required this.cellController,
|
required this.cellController,
|
||||||
}) : _selectOptionService =
|
}) : _selectOptionService =
|
||||||
SelectOptionFFIService(cellId: cellController.cellId),
|
SelectOptionBackendService(cellId: cellController.cellId),
|
||||||
super(SelectOptionEditorState.initial(cellController)) {
|
super(SelectOptionEditorState.initial(cellController)) {
|
||||||
on<SelectOptionEditorEvent>(
|
on<SelectOptionEditorEvent>(
|
||||||
(event, emit) async {
|
(event, emit) async {
|
||||||
@ -159,7 +159,7 @@ class SelectOptionCellEditorBloc
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _loadOptions() async {
|
Future<void> _loadOptions() async {
|
||||||
final result = await _selectOptionService.getOptionContext();
|
final result = await _selectOptionService.getCellData();
|
||||||
if (isClosed) {
|
if (isClosed) {
|
||||||
Log.warn("Unexpected closing the bloc");
|
Log.warn("Unexpected closing the bloc");
|
||||||
return;
|
return;
|
||||||
|
@ -6,9 +6,9 @@ import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
|||||||
import 'package:appflowy_backend/protobuf/flowy-database/cell_entities.pb.dart';
|
import 'package:appflowy_backend/protobuf/flowy-database/cell_entities.pb.dart';
|
||||||
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.dart';
|
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.dart';
|
||||||
|
|
||||||
class SelectOptionFFIService {
|
class SelectOptionBackendService {
|
||||||
final CellIdentifier cellId;
|
final CellIdentifier cellId;
|
||||||
SelectOptionFFIService({required this.cellId});
|
SelectOptionBackendService({required this.cellId});
|
||||||
|
|
||||||
String get viewId => cellId.viewId;
|
String get viewId => cellId.viewId;
|
||||||
String get fieldId => cellId.fieldInfo.id;
|
String get fieldId => cellId.fieldInfo.id;
|
||||||
@ -60,7 +60,7 @@ class SelectOptionFFIService {
|
|||||||
return DatabaseEventUpdateSelectOption(payload).send();
|
return DatabaseEventUpdateSelectOption(payload).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Either<SelectOptionCellDataPB, FlowyError>> getOptionContext() {
|
Future<Either<SelectOptionCellDataPB, FlowyError>> getCellData() {
|
||||||
final payload = CellIdPB.create()
|
final payload = CellIdPB.create()
|
||||||
..viewId = viewId
|
..viewId = viewId
|
||||||
..fieldId = fieldId
|
..fieldId = fieldId
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import 'package:appflowy/plugins/database_view/application/cell/cell_service.dart';
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.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';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import 'package:appflowy/plugins/database_view/application/cell/cell_service.dart';
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:appflowy_backend/protobuf/flowy-database/url_type_option_entities.pb.dart';
|
import 'package:appflowy_backend/protobuf/flowy-database/url_type_option_entities.pb.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';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import 'package:appflowy/plugins/database_view/application/cell/cell_service.dart';
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:appflowy_backend/protobuf/flowy-database/url_type_option_entities.pb.dart';
|
import 'package:appflowy_backend/protobuf/flowy-database/url_type_option_entities.pb.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,14 +13,11 @@ class ChecklistFilterEditorBloc
|
|||||||
extends Bloc<ChecklistFilterEditorEvent, ChecklistFilterEditorState> {
|
extends Bloc<ChecklistFilterEditorEvent, ChecklistFilterEditorState> {
|
||||||
final FilterInfo filterInfo;
|
final FilterInfo filterInfo;
|
||||||
final FilterBackendService _filterBackendSvc;
|
final FilterBackendService _filterBackendSvc;
|
||||||
// final SelectOptionFFIService _selectOptionService;
|
|
||||||
final FilterListener _listener;
|
final FilterListener _listener;
|
||||||
|
|
||||||
ChecklistFilterEditorBloc({
|
ChecklistFilterEditorBloc({
|
||||||
required this.filterInfo,
|
required this.filterInfo,
|
||||||
}) : _filterBackendSvc = FilterBackendService(viewId: filterInfo.viewId),
|
}) : _filterBackendSvc = FilterBackendService(viewId: filterInfo.viewId),
|
||||||
// _selectOptionService =
|
|
||||||
// SelectOptionFFIService(cellId: cellController.cellId)
|
|
||||||
_listener = FilterListener(
|
_listener = FilterListener(
|
||||||
viewId: filterInfo.viewId,
|
viewId: filterInfo.viewId,
|
||||||
filterId: filterInfo.filter.id,
|
filterId: filterInfo.filter.id,
|
||||||
|
@ -15,10 +15,9 @@ import 'dart:collection';
|
|||||||
part 'grid_bloc.freezed.dart';
|
part 'grid_bloc.freezed.dart';
|
||||||
|
|
||||||
class GridBloc extends Bloc<GridEvent, GridState> {
|
class GridBloc extends Bloc<GridEvent, GridState> {
|
||||||
final DatabaseController gridController;
|
final DatabaseController databaseController;
|
||||||
void Function()? _createRowOperation;
|
|
||||||
|
|
||||||
GridBloc({required ViewPB view, required this.gridController})
|
GridBloc({required ViewPB view, required this.databaseController})
|
||||||
: super(GridState.initial(view.id)) {
|
: super(GridState.initial(view.id)) {
|
||||||
on<GridEvent>(
|
on<GridEvent>(
|
||||||
(event, emit) async {
|
(event, emit) async {
|
||||||
@ -28,12 +27,7 @@ class GridBloc extends Bloc<GridEvent, GridState> {
|
|||||||
await _openGrid(emit);
|
await _openGrid(emit);
|
||||||
},
|
},
|
||||||
createRow: () {
|
createRow: () {
|
||||||
state.loadingState.when(
|
databaseController.createRow();
|
||||||
loading: () {
|
|
||||||
_createRowOperation = () => gridController.createRow();
|
|
||||||
},
|
|
||||||
finish: (_) => gridController.createRow(),
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
deleteRow: (rowInfo) async {
|
deleteRow: (rowInfo) async {
|
||||||
final rowService = RowBackendService(
|
final rowService = RowBackendService(
|
||||||
@ -63,16 +57,16 @@ class GridBloc extends Bloc<GridEvent, GridState> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> close() async {
|
Future<void> close() async {
|
||||||
await gridController.dispose();
|
await databaseController.dispose();
|
||||||
return super.close();
|
return super.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
RowCache? getRowCache(String blockId, String rowId) {
|
RowCache? getRowCache(String blockId, String rowId) {
|
||||||
return gridController.rowCache;
|
return databaseController.rowCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _startListening() {
|
void _startListening() {
|
||||||
gridController.addListener(
|
databaseController.addListener(
|
||||||
onGridChanged: (grid) {
|
onGridChanged: (grid) {
|
||||||
if (!isClosed) {
|
if (!isClosed) {
|
||||||
add(GridEvent.didReceiveGridUpdate(grid));
|
add(GridEvent.didReceiveGridUpdate(grid));
|
||||||
@ -92,13 +86,9 @@ class GridBloc extends Bloc<GridEvent, GridState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _openGrid(Emitter<GridState> emit) async {
|
Future<void> _openGrid(Emitter<GridState> emit) async {
|
||||||
final result = await gridController.openGrid();
|
final result = await databaseController.openGrid();
|
||||||
result.fold(
|
result.fold(
|
||||||
(grid) {
|
(grid) {
|
||||||
if (_createRowOperation != null) {
|
|
||||||
_createRowOperation?.call();
|
|
||||||
_createRowOperation = null;
|
|
||||||
}
|
|
||||||
emit(
|
emit(
|
||||||
state.copyWith(loadingState: GridLoadingState.finish(left(unit))),
|
state.copyWith(loadingState: GridLoadingState.finish(left(unit))),
|
||||||
);
|
);
|
||||||
|
@ -35,11 +35,11 @@ class GridPage extends StatefulWidget {
|
|||||||
required this.view,
|
required this.view,
|
||||||
this.onDeleted,
|
this.onDeleted,
|
||||||
Key? key,
|
Key? key,
|
||||||
}) : gridController = DatabaseController(view: view),
|
}) : databaseController = DatabaseController(view: view),
|
||||||
super(key: key);
|
super(key: key);
|
||||||
|
|
||||||
final ViewPB view;
|
final ViewPB view;
|
||||||
final DatabaseController gridController;
|
final DatabaseController databaseController;
|
||||||
final VoidCallback? onDeleted;
|
final VoidCallback? onDeleted;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -54,19 +54,19 @@ class _GridPageState extends State<GridPage> {
|
|||||||
BlocProvider<GridBloc>(
|
BlocProvider<GridBloc>(
|
||||||
create: (context) => GridBloc(
|
create: (context) => GridBloc(
|
||||||
view: widget.view,
|
view: widget.view,
|
||||||
gridController: widget.gridController,
|
databaseController: widget.databaseController,
|
||||||
)..add(const GridEvent.initial()),
|
)..add(const GridEvent.initial()),
|
||||||
),
|
),
|
||||||
BlocProvider<GridFilterMenuBloc>(
|
BlocProvider<GridFilterMenuBloc>(
|
||||||
create: (context) => GridFilterMenuBloc(
|
create: (context) => GridFilterMenuBloc(
|
||||||
viewId: widget.view.id,
|
viewId: widget.view.id,
|
||||||
fieldController: widget.gridController.fieldController,
|
fieldController: widget.databaseController.fieldController,
|
||||||
)..add(const GridFilterMenuEvent.initial()),
|
)..add(const GridFilterMenuEvent.initial()),
|
||||||
),
|
),
|
||||||
BlocProvider<SortMenuBloc>(
|
BlocProvider<SortMenuBloc>(
|
||||||
create: (context) => SortMenuBloc(
|
create: (context) => SortMenuBloc(
|
||||||
viewId: widget.view.id,
|
viewId: widget.view.id,
|
||||||
fieldController: widget.gridController.fieldController,
|
fieldController: widget.databaseController.fieldController,
|
||||||
)..add(const SortMenuEvent.initial()),
|
)..add(const SortMenuEvent.initial()),
|
||||||
),
|
),
|
||||||
BlocProvider<DatabaseSettingBloc>(
|
BlocProvider<DatabaseSettingBloc>(
|
||||||
@ -190,7 +190,7 @@ class _FlowyGridState extends State<FlowyGrid> {
|
|||||||
|
|
||||||
Widget _gridHeader(BuildContext context, String viewId) {
|
Widget _gridHeader(BuildContext context, String viewId) {
|
||||||
final fieldController =
|
final fieldController =
|
||||||
context.read<GridBloc>().gridController.fieldController;
|
context.read<GridBloc>().databaseController.fieldController;
|
||||||
return GridHeaderSliverAdaptor(
|
return GridHeaderSliverAdaptor(
|
||||||
viewId: viewId,
|
viewId: viewId,
|
||||||
fieldController: fieldController,
|
fieldController: fieldController,
|
||||||
@ -274,10 +274,9 @@ class _GridRowsState extends State<_GridRows> {
|
|||||||
if (rowCache == null) return const SizedBox();
|
if (rowCache == null) return const SizedBox();
|
||||||
|
|
||||||
final fieldController =
|
final fieldController =
|
||||||
context.read<GridBloc>().gridController.fieldController;
|
context.read<GridBloc>().databaseController.fieldController;
|
||||||
final dataController = RowDataController(
|
final dataController = RowDataController(
|
||||||
rowInfo: rowInfo,
|
rowInfo: rowInfo,
|
||||||
fieldController: fieldController,
|
|
||||||
rowCache: rowCache,
|
rowCache: rowCache,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -286,7 +285,7 @@ class _GridRowsState extends State<_GridRows> {
|
|||||||
child: GridRowWidget(
|
child: GridRowWidget(
|
||||||
rowInfo: rowInfo,
|
rowInfo: rowInfo,
|
||||||
dataController: dataController,
|
dataController: dataController,
|
||||||
cellBuilder: GridCellBuilder(delegate: dataController),
|
cellBuilder: GridCellBuilder(cellCache: dataController.cellCache),
|
||||||
openDetailPage: (context, cellBuilder) {
|
openDetailPage: (context, cellBuilder) {
|
||||||
_openRowDetailPage(
|
_openRowDetailPage(
|
||||||
context,
|
context,
|
||||||
@ -310,7 +309,6 @@ class _GridRowsState extends State<_GridRows> {
|
|||||||
) {
|
) {
|
||||||
final dataController = RowDataController(
|
final dataController = RowDataController(
|
||||||
rowInfo: rowInfo,
|
rowInfo: rowInfo,
|
||||||
fieldController: fieldController,
|
|
||||||
rowCache: rowCache,
|
rowCache: rowCache,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
@ -13,21 +14,16 @@ import 'select_option_cell/select_option_cell.dart';
|
|||||||
import 'text_cell.dart';
|
import 'text_cell.dart';
|
||||||
import 'url_cell/url_cell.dart';
|
import 'url_cell/url_cell.dart';
|
||||||
|
|
||||||
abstract class GridCellBuilderDelegate extends CellControllerBuilderDelegate {
|
|
||||||
CellCache get cellCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
class GridCellBuilder {
|
class GridCellBuilder {
|
||||||
final GridCellBuilderDelegate delegate;
|
final CellCache cellCache;
|
||||||
GridCellBuilder({
|
GridCellBuilder({
|
||||||
required this.delegate,
|
required this.cellCache,
|
||||||
});
|
});
|
||||||
|
|
||||||
GridCellWidget build(CellIdentifier cellId, {GridCellStyle? style}) {
|
GridCellWidget build(CellIdentifier cellId, {GridCellStyle? style}) {
|
||||||
final cellControllerBuilder = CellControllerBuilder(
|
final cellControllerBuilder = CellControllerBuilder(
|
||||||
cellId: cellId,
|
cellId: cellId,
|
||||||
cellCache: delegate.cellCache,
|
cellCache: cellCache,
|
||||||
delegate: delegate,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
final key = cellId.key();
|
final key = cellId.key();
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:appflowy/startup/startup.dart';
|
import 'package:appflowy/startup/startup.dart';
|
||||||
import 'package:flowy_infra/image.dart';
|
import 'package:flowy_infra/image.dart';
|
||||||
import 'package:flowy_infra_ui/style_widget/icon_button.dart';
|
import 'package:flowy_infra_ui/style_widget/icon_button.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import '../../../../application/cell/cell_service.dart';
|
|
||||||
import '../../../application/cell/checkbox_cell_bloc.dart';
|
import '../../../application/cell/checkbox_cell_bloc.dart';
|
||||||
import '../../layout/sizes.dart';
|
import '../../layout/sizes.dart';
|
||||||
import 'cell_builder.dart';
|
import 'cell_builder.dart';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import 'package:appflowy/plugins/database_view/application/cell/cell_service.dart';
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:appflowy/plugins/database_view/grid/application/cell/checklist_cell_bloc.dart';
|
import 'package:appflowy/plugins/database_view/grid/application/cell/checklist_cell_bloc.dart';
|
||||||
import 'package:appflowy/plugins/database_view/grid/presentation/layout/sizes.dart';
|
import 'package:appflowy/plugins/database_view/grid/presentation/layout/sizes.dart';
|
||||||
import 'package:appflowy_popover/appflowy_popover.dart';
|
import 'package:appflowy_popover/appflowy_popover.dart';
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:appflowy_popover/appflowy_popover.dart';
|
import 'package:appflowy_popover/appflowy_popover.dart';
|
||||||
import 'package:flowy_infra/image.dart';
|
import 'package:flowy_infra/image.dart';
|
||||||
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
||||||
@ -8,7 +9,6 @@ import 'package:flowy_infra_ui/widget/spacing.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
import '../../../../../application/cell/cell_service.dart';
|
|
||||||
import '../../../../application/cell/checklist_cell_editor_bloc.dart';
|
import '../../../../application/cell/checklist_cell_editor_bloc.dart';
|
||||||
import '../../../layout/sizes.dart';
|
import '../../../layout/sizes.dart';
|
||||||
import '../../header/type_option/select_option_editor.dart';
|
import '../../header/type_option/select_option_editor.dart';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import 'package:appflowy/plugins/database_view/application/cell/cell_service.dart';
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:appflowy/plugins/database_view/grid/application/cell/date_cell_bloc.dart';
|
import 'package:appflowy/plugins/database_view/grid/application/cell/date_cell_bloc.dart';
|
||||||
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import 'package:appflowy/generated/locale_keys.g.dart';
|
import 'package:appflowy/generated/locale_keys.g.dart';
|
||||||
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:appflowy/plugins/database_view/application/field/type_option/type_option_context.dart';
|
import 'package:appflowy/plugins/database_view/application/field/type_option/type_option_context.dart';
|
||||||
import 'package:appflowy/plugins/database_view/grid/application/cell/date_cal_bloc.dart';
|
import 'package:appflowy/plugins/database_view/grid/application/cell/date_cal_bloc.dart';
|
||||||
import 'package:appflowy/workspace/presentation/widgets/toggle/toggle.dart';
|
import 'package:appflowy/workspace/presentation/widgets/toggle/toggle.dart';
|
||||||
@ -20,7 +21,6 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:table_calendar/table_calendar.dart';
|
import 'package:table_calendar/table_calendar.dart';
|
||||||
import 'package:textstyle_extensions/textstyle_extensions.dart';
|
import 'package:textstyle_extensions/textstyle_extensions.dart';
|
||||||
import '../../../../../application/cell/cell_service.dart';
|
|
||||||
import '../../../layout/sizes.dart';
|
import '../../../layout/sizes.dart';
|
||||||
import '../../common/type_option_separator.dart';
|
import '../../common/type_option_separator.dart';
|
||||||
import '../../header/type_option/date.dart';
|
import '../../header/type_option/date.dart';
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:appflowy/startup/startup.dart';
|
import 'package:appflowy/startup/startup.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
import '../../../../application/cell/cell_service.dart';
|
|
||||||
import '../../../application/cell/number_cell_bloc.dart';
|
import '../../../application/cell/number_cell_bloc.dart';
|
||||||
import '../../layout/sizes.dart';
|
import '../../layout/sizes.dart';
|
||||||
import 'cell_builder.dart';
|
import 'cell_builder.dart';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import 'package:appflowy/plugins/database_view/application/cell/cell_service.dart';
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:appflowy/startup/startup.dart';
|
import 'package:appflowy/startup/startup.dart';
|
||||||
import 'package:appflowy_popover/appflowy_popover.dart';
|
import 'package:appflowy_popover/appflowy_popover.dart';
|
||||||
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import 'dart:collection';
|
import 'dart:collection';
|
||||||
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:appflowy/plugins/database_view/grid/application/cell/select_option_editor_bloc.dart';
|
import 'package:appflowy/plugins/database_view/grid/application/cell/select_option_editor_bloc.dart';
|
||||||
import 'package:appflowy_popover/appflowy_popover.dart';
|
import 'package:appflowy_popover/appflowy_popover.dart';
|
||||||
import 'package:flowy_infra/theme_extension.dart';
|
import 'package:flowy_infra/theme_extension.dart';
|
||||||
@ -15,7 +16,6 @@ import 'package:easy_localization/easy_localization.dart';
|
|||||||
import 'package:appflowy/generated/locale_keys.g.dart';
|
import 'package:appflowy/generated/locale_keys.g.dart';
|
||||||
import 'package:textfield_tags/textfield_tags.dart';
|
import 'package:textfield_tags/textfield_tags.dart';
|
||||||
|
|
||||||
import '../../../../../application/cell/cell_service.dart';
|
|
||||||
import '../../../layout/sizes.dart';
|
import '../../../layout/sizes.dart';
|
||||||
import '../../common/type_option_separator.dart';
|
import '../../common/type_option_separator.dart';
|
||||||
import '../../header/type_option/select_option_editor.dart';
|
import '../../header/type_option/select_option_editor.dart';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:appflowy/plugins/database_view/application/cell/cell_service.dart';
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:appflowy/plugins/database_view/grid/application/cell/text_cell_bloc.dart';
|
import 'package:appflowy/plugins/database_view/grid/application/cell/text_cell_bloc.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
import '../../../../../application/cell/cell_service.dart';
|
|
||||||
import '../../../../application/cell/url_cell_editor_bloc.dart';
|
import '../../../../application/cell/url_cell_editor_bloc.dart';
|
||||||
|
|
||||||
class URLCellEditor extends StatefulWidget {
|
class URLCellEditor extends StatefulWidget {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:appflowy/generated/locale_keys.g.dart';
|
import 'package:appflowy/generated/locale_keys.g.dart';
|
||||||
import 'package:appflowy/plugins/database_view/application/cell/cell_service.dart';
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:appflowy/workspace/presentation/home/toast.dart';
|
import 'package:appflowy/workspace/presentation/home/toast.dart';
|
||||||
import 'package:appflowy_popover/appflowy_popover.dart';
|
import 'package:appflowy_popover/appflowy_popover.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
@ -23,11 +23,11 @@ typedef SwitchToFieldCallback = Future<Either<TypeOptionPB, FlowyError>>
|
|||||||
);
|
);
|
||||||
|
|
||||||
class FieldTypeOptionEditor extends StatelessWidget {
|
class FieldTypeOptionEditor extends StatelessWidget {
|
||||||
final TypeOptionDataController _dataController;
|
final TypeOptionController _dataController;
|
||||||
final PopoverMutex popoverMutex;
|
final PopoverMutex popoverMutex;
|
||||||
|
|
||||||
const FieldTypeOptionEditor({
|
const FieldTypeOptionEditor({
|
||||||
required TypeOptionDataController dataController,
|
required TypeOptionController dataController,
|
||||||
required this.popoverMutex,
|
required this.popoverMutex,
|
||||||
Key? key,
|
Key? key,
|
||||||
}) : _dataController = dataController,
|
}) : _dataController = dataController,
|
||||||
|
@ -48,7 +48,7 @@ abstract class TypeOptionWidgetBuilder {
|
|||||||
|
|
||||||
Widget? makeTypeOptionWidget({
|
Widget? makeTypeOptionWidget({
|
||||||
required BuildContext context,
|
required BuildContext context,
|
||||||
required TypeOptionDataController dataController,
|
required TypeOptionController dataController,
|
||||||
required PopoverMutex popoverMutex,
|
required PopoverMutex popoverMutex,
|
||||||
}) {
|
}) {
|
||||||
final builder = makeTypeOptionWidgetBuilder(
|
final builder = makeTypeOptionWidgetBuilder(
|
||||||
@ -59,7 +59,7 @@ Widget? makeTypeOptionWidget({
|
|||||||
}
|
}
|
||||||
|
|
||||||
TypeOptionWidgetBuilder makeTypeOptionWidgetBuilder({
|
TypeOptionWidgetBuilder makeTypeOptionWidgetBuilder({
|
||||||
required TypeOptionDataController dataController,
|
required TypeOptionController dataController,
|
||||||
required PopoverMutex popoverMutex,
|
required PopoverMutex popoverMutex,
|
||||||
}) {
|
}) {
|
||||||
final viewId = dataController.viewId;
|
final viewId = dataController.viewId;
|
||||||
@ -144,7 +144,7 @@ TypeOptionContext<T> makeTypeOptionContext<T extends GeneratedMessage>({
|
|||||||
required FieldInfo fieldInfo,
|
required FieldInfo fieldInfo,
|
||||||
}) {
|
}) {
|
||||||
final loader = FieldTypeOptionLoader(viewId: viewId, field: fieldInfo.field);
|
final loader = FieldTypeOptionLoader(viewId: viewId, field: fieldInfo.field);
|
||||||
final dataController = TypeOptionDataController(
|
final dataController = TypeOptionController(
|
||||||
viewId: viewId,
|
viewId: viewId,
|
||||||
loader: loader,
|
loader: loader,
|
||||||
fieldInfo: fieldInfo,
|
fieldInfo: fieldInfo,
|
||||||
@ -178,7 +178,7 @@ TypeOptionContext<T> makeSelectTypeOptionContext<T extends GeneratedMessage>({
|
|||||||
viewId: viewId,
|
viewId: viewId,
|
||||||
field: fieldPB,
|
field: fieldPB,
|
||||||
);
|
);
|
||||||
final dataController = TypeOptionDataController(
|
final dataController = TypeOptionController(
|
||||||
viewId: viewId,
|
viewId: viewId,
|
||||||
loader: loader,
|
loader: loader,
|
||||||
);
|
);
|
||||||
@ -194,7 +194,7 @@ TypeOptionContext<T>
|
|||||||
makeTypeOptionContextWithDataController<T extends GeneratedMessage>({
|
makeTypeOptionContextWithDataController<T extends GeneratedMessage>({
|
||||||
required String viewId,
|
required String viewId,
|
||||||
required FieldType fieldType,
|
required FieldType fieldType,
|
||||||
required TypeOptionDataController dataController,
|
required TypeOptionController dataController,
|
||||||
}) {
|
}) {
|
||||||
switch (fieldType) {
|
switch (fieldType) {
|
||||||
case FieldType.Checkbox:
|
case FieldType.Checkbox:
|
||||||
|
@ -35,7 +35,7 @@ class _SettingButtonState extends State<SettingButton> {
|
|||||||
return BlocSelector<GridBloc, GridState, GridSettingContext>(
|
return BlocSelector<GridBloc, GridState, GridSettingContext>(
|
||||||
selector: (state) {
|
selector: (state) {
|
||||||
final fieldController =
|
final fieldController =
|
||||||
context.read<GridBloc>().gridController.fieldController;
|
context.read<GridBloc>().databaseController.fieldController;
|
||||||
return GridSettingContext(
|
return GridSettingContext(
|
||||||
viewId: state.viewId,
|
viewId: state.viewId,
|
||||||
fieldController: fieldController,
|
fieldController: fieldController,
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import 'package:appflowy/core/network_monitor.dart';
|
import 'package:appflowy/core/network_monitor.dart';
|
||||||
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:appflowy/plugins/database_view/application/cell/cell_service.dart';
|
import 'package:appflowy/plugins/database_view/application/cell/cell_service.dart';
|
||||||
import 'package:appflowy/plugins/database_view/application/field/field_action_sheet_bloc.dart';
|
import 'package:appflowy/plugins/database_view/application/field/field_action_sheet_bloc.dart';
|
||||||
import 'package:appflowy/plugins/database_view/application/field/field_controller.dart';
|
import 'package:appflowy/plugins/database_view/application/field/field_controller.dart';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import 'package:appflowy/plugins/database_view/application/cell/cell_service.dart';
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:appflowy/plugins/database_view/application/setting/group_bloc.dart';
|
import 'package:appflowy/plugins/database_view/application/setting/group_bloc.dart';
|
||||||
import 'package:appflowy/plugins/database_view/board/application/board_bloc.dart';
|
import 'package:appflowy/plugins/database_view/board/application/board_bloc.dart';
|
||||||
import 'package:appflowy/plugins/database_view/grid/application/cell/select_option_editor_bloc.dart';
|
import 'package:appflowy/plugins/database_view/grid/application/cell/select_option_editor_bloc.dart';
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import 'package:appflowy/plugins/database_view/application/cell/cell_service.dart';
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller.dart';
|
||||||
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:appflowy/plugins/database_view/application/field/field_controller.dart';
|
import 'package:appflowy/plugins/database_view/application/field/field_controller.dart';
|
||||||
import 'package:appflowy/plugins/database_view/application/field/field_editor_bloc.dart';
|
import 'package:appflowy/plugins/database_view/application/field/field_editor_bloc.dart';
|
||||||
import 'package:appflowy/plugins/database_view/application/field/field_service.dart';
|
import 'package:appflowy/plugins/database_view/application/field/field_service.dart';
|
||||||
@ -105,11 +106,9 @@ class BoardTestContext {
|
|||||||
) async {
|
) async {
|
||||||
final RowInfo rowInfo = rowInfos.last;
|
final RowInfo rowInfo = rowInfos.last;
|
||||||
final rowCache = _boardDataController.rowCache;
|
final rowCache = _boardDataController.rowCache;
|
||||||
final fieldController = _boardDataController.fieldController;
|
|
||||||
|
|
||||||
final rowDataController = RowDataController(
|
final rowDataController = RowDataController(
|
||||||
rowInfo: rowInfo,
|
rowInfo: rowInfo,
|
||||||
fieldController: fieldController,
|
|
||||||
rowCache: rowCache,
|
rowCache: rowCache,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -122,7 +121,6 @@ class BoardTestContext {
|
|||||||
return CellControllerBuilder(
|
return CellControllerBuilder(
|
||||||
cellId: rowBloc.state.cellByFieldId[fieldId]!,
|
cellId: rowBloc.state.cellByFieldId[fieldId]!,
|
||||||
cellCache: rowCache.cellCache,
|
cellCache: rowCache.cellCache,
|
||||||
delegate: rowDataController,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ void main() {
|
|||||||
final gridController = DatabaseController(view: context.gridView);
|
final gridController = DatabaseController(view: context.gridView);
|
||||||
final gridBloc = GridBloc(
|
final gridBloc = GridBloc(
|
||||||
view: context.gridView,
|
view: context.gridView,
|
||||||
gridController: gridController,
|
databaseController: gridController,
|
||||||
)..add(const GridEvent.initial());
|
)..add(const GridEvent.initial());
|
||||||
await gridResponseFuture();
|
await gridResponseFuture();
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ void main() {
|
|||||||
final gridController = DatabaseController(view: context.gridView);
|
final gridController = DatabaseController(view: context.gridView);
|
||||||
final gridBloc = GridBloc(
|
final gridBloc = GridBloc(
|
||||||
view: context.gridView,
|
view: context.gridView,
|
||||||
gridController: gridController,
|
databaseController: gridController,
|
||||||
)..add(const GridEvent.initial());
|
)..add(const GridEvent.initial());
|
||||||
await gridResponseFuture();
|
await gridResponseFuture();
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ void main() {
|
|||||||
final gridController = DatabaseController(view: context.gridView);
|
final gridController = DatabaseController(view: context.gridView);
|
||||||
final gridBloc = GridBloc(
|
final gridBloc = GridBloc(
|
||||||
view: context.gridView,
|
view: context.gridView,
|
||||||
gridController: gridController,
|
databaseController: gridController,
|
||||||
)..add(const GridEvent.initial());
|
)..add(const GridEvent.initial());
|
||||||
|
|
||||||
await gridResponseFuture();
|
await gridResponseFuture();
|
||||||
@ -134,7 +134,7 @@ void main() {
|
|||||||
final gridController = DatabaseController(view: context.gridView);
|
final gridController = DatabaseController(view: context.gridView);
|
||||||
final gridBloc = GridBloc(
|
final gridBloc = GridBloc(
|
||||||
view: context.gridView,
|
view: context.gridView,
|
||||||
gridController: gridController,
|
databaseController: gridController,
|
||||||
)..add(const GridEvent.initial());
|
)..add(const GridEvent.initial());
|
||||||
|
|
||||||
await gridResponseFuture();
|
await gridResponseFuture();
|
||||||
|
@ -20,7 +20,7 @@ void main() {
|
|||||||
"create a row",
|
"create a row",
|
||||||
build: () => GridBloc(
|
build: () => GridBloc(
|
||||||
view: context.gridView,
|
view: context.gridView,
|
||||||
gridController: DatabaseController(view: context.gridView))
|
databaseController: DatabaseController(view: context.gridView))
|
||||||
..add(const GridEvent.initial()),
|
..add(const GridEvent.initial()),
|
||||||
act: (bloc) => bloc.add(const GridEvent.createRow()),
|
act: (bloc) => bloc.add(const GridEvent.createRow()),
|
||||||
wait: const Duration(milliseconds: 300),
|
wait: const Duration(milliseconds: 300),
|
||||||
@ -33,7 +33,7 @@ void main() {
|
|||||||
"delete the last row",
|
"delete the last row",
|
||||||
build: () => GridBloc(
|
build: () => GridBloc(
|
||||||
view: context.gridView,
|
view: context.gridView,
|
||||||
gridController: DatabaseController(view: context.gridView))
|
databaseController: DatabaseController(view: context.gridView))
|
||||||
..add(const GridEvent.initial()),
|
..add(const GridEvent.initial()),
|
||||||
act: (bloc) async {
|
act: (bloc) async {
|
||||||
await gridResponseFuture();
|
await gridResponseFuture();
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import 'package:appflowy/plugins/database_view/application/cell/cell_service.dart';
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller.dart';
|
||||||
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:appflowy/plugins/database_view/application/field/field_controller.dart';
|
import 'package:appflowy/plugins/database_view/application/field/field_controller.dart';
|
||||||
import 'package:appflowy/plugins/database_view/application/field/field_editor_bloc.dart';
|
import 'package:appflowy/plugins/database_view/application/field/field_editor_bloc.dart';
|
||||||
import 'package:appflowy/plugins/database_view/application/field/field_service.dart';
|
import 'package:appflowy/plugins/database_view/application/field/field_service.dart';
|
||||||
@ -66,11 +67,9 @@ class GridTestContext {
|
|||||||
) async {
|
) async {
|
||||||
final RowInfo rowInfo = rowInfos[rowIndex];
|
final RowInfo rowInfo = rowInfos[rowIndex];
|
||||||
final rowCache = gridController.rowCache;
|
final rowCache = gridController.rowCache;
|
||||||
final fieldController = gridController.fieldController;
|
|
||||||
|
|
||||||
final rowDataController = RowDataController(
|
final rowDataController = RowDataController(
|
||||||
rowInfo: rowInfo,
|
rowInfo: rowInfo,
|
||||||
fieldController: fieldController,
|
|
||||||
rowCache: rowCache,
|
rowCache: rowCache,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -83,7 +82,6 @@ class GridTestContext {
|
|||||||
return CellControllerBuilder(
|
return CellControllerBuilder(
|
||||||
cellId: rowBloc.state.cellByFieldId[fieldId]!,
|
cellId: rowBloc.state.cellByFieldId[fieldId]!,
|
||||||
cellCache: rowCache.cellCache,
|
cellCache: rowCache.cellCache,
|
||||||
delegate: rowDataController,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user