|
@@ -1,6 +1,7 @@
|
|
|
|
+import 'package:app_flowy/plugins/grid/application/row/row_data_controller.dart';
|
|
import 'package:app_flowy/startup/startup.dart';
|
|
import 'package:app_flowy/startup/startup.dart';
|
|
-import 'package:app_flowy/workspace/application/grid/grid_bloc.dart';
|
|
|
|
-import 'package:app_flowy/workspace/application/grid/row/row_service.dart';
|
|
|
|
|
|
+import 'package:app_flowy/plugins/grid/application/grid_bloc.dart';
|
|
|
|
+import 'package:app_flowy/plugins/grid/application/row/row_service.dart';
|
|
import 'package:flowy_infra/theme.dart';
|
|
import 'package:flowy_infra/theme.dart';
|
|
import 'package:flowy_infra_ui/style_widget/scrolling/styled_list.dart';
|
|
import 'package:flowy_infra_ui/style_widget/scrolling/styled_list.dart';
|
|
import 'package:flowy_infra_ui/style_widget/scrolling/styled_scroll_bar.dart';
|
|
import 'package:flowy_infra_ui/style_widget/scrolling/styled_scroll_bar.dart';
|
|
@@ -35,13 +36,15 @@ class _GridPageState extends State<GridPage> {
|
|
return MultiBlocProvider(
|
|
return MultiBlocProvider(
|
|
providers: [
|
|
providers: [
|
|
BlocProvider<GridBloc>(
|
|
BlocProvider<GridBloc>(
|
|
- create: (context) => getIt<GridBloc>(param1: widget.view)..add(const GridEvent.initial()),
|
|
|
|
|
|
+ create: (context) => getIt<GridBloc>(param1: widget.view)
|
|
|
|
+ ..add(const GridEvent.initial()),
|
|
),
|
|
),
|
|
],
|
|
],
|
|
child: BlocBuilder<GridBloc, GridState>(
|
|
child: BlocBuilder<GridBloc, GridState>(
|
|
builder: (context, state) {
|
|
builder: (context, state) {
|
|
return state.loadingState.map(
|
|
return state.loadingState.map(
|
|
- loading: (_) => const Center(child: CircularProgressIndicator.adaptive()),
|
|
|
|
|
|
+ loading: (_) =>
|
|
|
|
+ const Center(child: CircularProgressIndicator.adaptive()),
|
|
finish: (result) => result.successOrFail.fold(
|
|
finish: (result) => result.successOrFail.fold(
|
|
(_) => const GridShortcuts(child: FlowyGrid()),
|
|
(_) => const GridShortcuts(child: FlowyGrid()),
|
|
(err) => FlowyErrorPage(err.toString()),
|
|
(err) => FlowyErrorPage(err.toString()),
|
|
@@ -76,7 +79,8 @@ class FlowyGrid extends StatefulWidget {
|
|
}
|
|
}
|
|
|
|
|
|
class _FlowyGridState extends State<FlowyGrid> {
|
|
class _FlowyGridState extends State<FlowyGrid> {
|
|
- final _scrollController = GridScrollController(scrollGroupContorller: LinkedScrollControllerGroup());
|
|
|
|
|
|
+ final _scrollController = GridScrollController(
|
|
|
|
+ scrollGroupController: LinkedScrollControllerGroup());
|
|
late ScrollController headerScrollController;
|
|
late ScrollController headerScrollController;
|
|
|
|
|
|
@override
|
|
@override
|
|
@@ -150,7 +154,7 @@ class _FlowyGridState extends State<FlowyGrid> {
|
|
}
|
|
}
|
|
|
|
|
|
Widget _gridHeader(BuildContext context, String gridId) {
|
|
Widget _gridHeader(BuildContext context, String gridId) {
|
|
- final fieldCache = context.read<GridBloc>().fieldCache;
|
|
|
|
|
|
+ final fieldCache = context.read<GridBloc>().dataController.fieldCache;
|
|
return GridHeaderSliverAdaptor(
|
|
return GridHeaderSliverAdaptor(
|
|
gridId: gridId,
|
|
gridId: gridId,
|
|
fieldCache: fieldCache,
|
|
fieldCache: fieldCache,
|
|
@@ -166,7 +170,7 @@ class _GridToolbarAdaptor extends StatelessWidget {
|
|
Widget build(BuildContext context) {
|
|
Widget build(BuildContext context) {
|
|
return BlocSelector<GridBloc, GridState, GridToolbarContext>(
|
|
return BlocSelector<GridBloc, GridState, GridToolbarContext>(
|
|
selector: (state) {
|
|
selector: (state) {
|
|
- final fieldCache = context.read<GridBloc>().fieldCache;
|
|
|
|
|
|
+ final fieldCache = context.read<GridBloc>().dataController.fieldCache;
|
|
return GridToolbarContext(
|
|
return GridToolbarContext(
|
|
gridId: state.gridId,
|
|
gridId: state.gridId,
|
|
fieldCache: fieldCache,
|
|
fieldCache: fieldCache,
|
|
@@ -204,7 +208,8 @@ class _GridRowsState extends State<_GridRows> {
|
|
for (final item in value.items) {
|
|
for (final item in value.items) {
|
|
_key.currentState?.removeItem(
|
|
_key.currentState?.removeItem(
|
|
item.index,
|
|
item.index,
|
|
- (context, animation) => _renderRow(context, item.row, animation),
|
|
|
|
|
|
+ (context, animation) =>
|
|
|
|
+ _renderRow(context, item.row, animation),
|
|
);
|
|
);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
@@ -215,8 +220,10 @@ class _GridRowsState extends State<_GridRows> {
|
|
return SliverAnimatedList(
|
|
return SliverAnimatedList(
|
|
key: _key,
|
|
key: _key,
|
|
initialItemCount: context.read<GridBloc>().state.rowInfos.length,
|
|
initialItemCount: context.read<GridBloc>().state.rowInfos.length,
|
|
- itemBuilder: (BuildContext context, int index, Animation<double> animation) {
|
|
|
|
- final GridRowInfo rowInfo = context.read<GridBloc>().state.rowInfos[index];
|
|
|
|
|
|
+ itemBuilder:
|
|
|
|
+ (BuildContext context, int index, Animation<double> animation) {
|
|
|
|
+ final GridRowInfo rowInfo =
|
|
|
|
+ context.read<GridBloc>().state.rowInfos[index];
|
|
return _renderRow(context, rowInfo, animation);
|
|
return _renderRow(context, rowInfo, animation);
|
|
},
|
|
},
|
|
);
|
|
);
|
|
@@ -229,15 +236,22 @@ class _GridRowsState extends State<_GridRows> {
|
|
GridRowInfo rowInfo,
|
|
GridRowInfo rowInfo,
|
|
Animation<double> animation,
|
|
Animation<double> animation,
|
|
) {
|
|
) {
|
|
- final rowCache = context.read<GridBloc>().getRowCache(rowInfo.blockId, rowInfo.id);
|
|
|
|
- final fieldCache = context.read<GridBloc>().fieldCache;
|
|
|
|
|
|
+ final rowCache =
|
|
|
|
+ context.read<GridBloc>().getRowCache(rowInfo.blockId, rowInfo.id);
|
|
|
|
+
|
|
|
|
+ final fieldCache = context.read<GridBloc>().dataController.fieldCache;
|
|
if (rowCache != null) {
|
|
if (rowCache != null) {
|
|
|
|
+ final dataController = GridRowDataController(
|
|
|
|
+ rowId: rowInfo.id,
|
|
|
|
+ fieldCache: fieldCache,
|
|
|
|
+ rowCache: rowCache,
|
|
|
|
+ );
|
|
|
|
+
|
|
return SizeTransition(
|
|
return SizeTransition(
|
|
sizeFactor: animation,
|
|
sizeFactor: animation,
|
|
child: GridRowWidget(
|
|
child: GridRowWidget(
|
|
rowData: rowInfo,
|
|
rowData: rowInfo,
|
|
- rowCache: rowCache,
|
|
|
|
- fieldCache: fieldCache,
|
|
|
|
|
|
+ dataController: dataController,
|
|
key: ValueKey(rowInfo.id),
|
|
key: ValueKey(rowInfo.id),
|
|
),
|
|
),
|
|
);
|
|
);
|
|
@@ -266,10 +280,10 @@ class _GridFooter extends StatelessWidget {
|
|
SizedBox(width: GridSize.leadingHeaderPadding),
|
|
SizedBox(width: GridSize.leadingHeaderPadding),
|
|
Column(
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
- children: [
|
|
|
|
|
|
+ children: [
|
|
const SizedBox(width: 120, child: GridAddRowButton()),
|
|
const SizedBox(width: 120, child: GridAddRowButton()),
|
|
const SizedBox(height: 30),
|
|
const SizedBox(height: 30),
|
|
- _rowCountTextWidget(theme: theme,count: rowCount)
|
|
|
|
|
|
+ _rowCountTextWidget(theme: theme, count: rowCount)
|
|
],
|
|
],
|
|
),
|
|
),
|
|
],
|
|
],
|
|
@@ -280,16 +294,18 @@ class _GridFooter extends StatelessWidget {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
- Widget _rowCountTextWidget({required AppTheme theme, required int count}){
|
|
|
|
|
|
+ Widget _rowCountTextWidget({required AppTheme theme, required int count}) {
|
|
return Row(
|
|
return Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
children: [
|
|
- FlowyText.regular('Count : ',
|
|
|
|
- fontSize: 13,
|
|
|
|
- color: theme.shader3,
|
|
|
|
|
|
+ FlowyText.regular(
|
|
|
|
+ 'Count : ',
|
|
|
|
+ fontSize: 13,
|
|
|
|
+ color: theme.shader3,
|
|
),
|
|
),
|
|
- FlowyText.regular(count.toString(),
|
|
|
|
- fontSize: 13,
|
|
|
|
|
|
+ FlowyText.regular(
|
|
|
|
+ count.toString(),
|
|
|
|
+ fontSize: 13,
|
|
),
|
|
),
|
|
],
|
|
],
|
|
);
|
|
);
|