浏览代码

Merge pull request #863 from AppFlowy-IO/feat/refresh_card

Feat: refresh card after editting the row
Nathan.fooo 2 年之前
父节点
当前提交
09ca4bc4a2

+ 3 - 1
frontend/app_flowy/lib/plugins/board/application/board_bloc.dart

@@ -253,5 +253,7 @@ class GroupControllerDelegateImpl extends GroupControllerDelegate {
   }
 
   @override
-  void updateRow(String groupId, RowPB row) {}
+  void updateRow(String groupId, RowPB row) {
+    //
+  }
 }

+ 7 - 1
frontend/app_flowy/lib/plugins/board/presentation/card/board_select_option_cell.dart

@@ -42,7 +42,13 @@ class _BoardSelectOptionCellState extends State<BoardSelectOptionCell> {
               .toList();
           return Align(
             alignment: Alignment.centerLeft,
-            child: Wrap(children: children, spacing: 4, runSpacing: 2),
+            child: AbsorbPointer(
+              child: Wrap(
+                children: children,
+                spacing: 4,
+                runSpacing: 2,
+              ),
+            ),
           );
         },
       ),

+ 8 - 3
frontend/app_flowy/lib/plugins/board/presentation/card/board_text_cell.dart

@@ -37,9 +37,14 @@ class _BoardTextCellState extends State<BoardTextCell> {
           } else {
             return Align(
               alignment: Alignment.centerLeft,
-              child: FlowyText.regular(
-                state.content,
-                fontSize: 14,
+              child: ConstrainedBox(
+                constraints: BoxConstraints.loose(
+                  const Size(double.infinity, 100),
+                ),
+                child: FlowyText.regular(
+                  state.content,
+                  fontSize: 14,
+                ),
               ),
             );
           }

+ 17 - 15
frontend/app_flowy/lib/plugins/board/presentation/card/board_url_cell.dart

@@ -35,22 +35,24 @@ class _BoardUrlCellState extends State<BoardUrlCell> {
       value: _cellBloc,
       child: BlocBuilder<BoardURLCellBloc, BoardURLCellState>(
         builder: (context, state) {
-          final richText = RichText(
-            textAlign: TextAlign.left,
-            text: TextSpan(
-              text: state.content,
-              style: TextStyle(
-                color: theme.main2,
-                fontSize: 14,
-                decoration: TextDecoration.underline,
+          if (state.content.isEmpty) {
+            return const SizedBox();
+          } else {
+            return Align(
+              alignment: Alignment.centerLeft,
+              child: RichText(
+                textAlign: TextAlign.left,
+                text: TextSpan(
+                  text: state.content,
+                  style: TextStyle(
+                    color: theme.main2,
+                    fontSize: 14,
+                    decoration: TextDecoration.underline,
+                  ),
+                ),
               ),
-            ),
-          );
-
-          return Align(
-            alignment: Alignment.centerLeft,
-            child: richText,
-          );
+            );
+          }
         },
       ),
     );

+ 1 - 1
frontend/app_flowy/lib/plugins/board/presentation/card/card.dart

@@ -73,7 +73,7 @@ class _BoardCardState extends State<BoardCard> {
       (cellId) {
         final child = widget.cellBuilder.buildCell(cellId);
         return Padding(
-          padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
+          padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 5),
           child: child,
         );
       },

+ 1 - 1
frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/context_builder.dart

@@ -242,7 +242,7 @@ class IGridCellController<T, D> extends Equatable {
         .getFieldTypeOptionData(fieldType: fieldType)
         .then((result) {
       return result.fold(
-        (data) => parser.fromBuffer(data.typeOptionData),
+        (data) => left(parser.fromBuffer(data.typeOptionData)),
         (err) => right(err),
       );
     });

+ 1 - 1
frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/date_cell/date_editor.dart

@@ -15,7 +15,6 @@ import 'package:flutter/material.dart';
 import 'package:flutter_bloc/flutter_bloc.dart';
 import 'package:table_calendar/table_calendar.dart';
 import 'package:app_flowy/plugins/grid/application/prelude.dart';
-
 import '../../../layout/sizes.dart';
 import '../../header/type_option/date.dart';
 
@@ -39,6 +38,7 @@ class DateCellEditor with FlowyOverlayDelegate {
 
     final result =
         await cellController.getFieldTypeOption(DateTypeOptionDataParser());
+
     result.fold(
       (dateTypeOptionPB) {
         final calendar = _CellCalendarWidget(

+ 8 - 3
frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/number_cell.dart

@@ -49,8 +49,10 @@ class _NumberCellState extends GridFocusNodeCellState<GridNumberCell> {
           controller: _controller,
           focusNode: focusNode,
           onEditingComplete: () => focusNode.unfocus(),
-          maxLines: null,
+          onSubmitted: (_) => focusNode.unfocus(),
+          maxLines: 1,
           style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w500),
+          textInputAction: TextInputAction.done,
           decoration: const InputDecoration(
             contentPadding: EdgeInsets.zero,
             border: InputBorder.none,
@@ -63,8 +65,6 @@ class _NumberCellState extends GridFocusNodeCellState<GridNumberCell> {
 
   @override
   Future<void> dispose() async {
-    _delayOperation?.cancel();
-    _cellBloc.close();
     super.dispose();
   }
 
@@ -76,6 +76,11 @@ class _NumberCellState extends GridFocusNodeCellState<GridNumberCell> {
         if (_cellBloc.isClosed == false &&
             _controller.text != contentFromState(_cellBloc.state)) {
           _cellBloc.add(NumberCellEvent.updateCell(_controller.text));
+
+          if (!mounted) {
+            _delayOperation = null;
+            _cellBloc.close();
+          }
         }
       });
     }

+ 5 - 2
frontend/rust-lib/flowy-grid/src/services/grid_editor.rs

@@ -287,7 +287,7 @@ impl GridRevisionEditor {
     pub async fn create_row(&self, params: CreateRowParams) -> FlowyResult<RowPB> {
         let mut row_rev = self.create_row_rev().await?;
 
-        self.view_manager.update_row(&mut row_rev, &params).await;
+        self.view_manager.fill_row(&mut row_rev, &params).await;
 
         let row_pb = self.create_row_pb(row_rev, params.start_row_id.clone()).await?;
 
@@ -314,7 +314,10 @@ impl GridRevisionEditor {
     }
 
     pub async fn update_row(&self, changeset: RowMetaChangeset) -> FlowyResult<()> {
-        self.block_manager.update_row(changeset, make_row_from_row_rev).await
+        let row_id = changeset.row_id.clone();
+        let _ = self.block_manager.update_row(changeset, make_row_from_row_rev).await?;
+        self.view_manager.did_update_row(&row_id).await;
+        Ok(())
     }
 
     pub async fn get_rows(&self, block_id: &str) -> FlowyResult<RepeatedRowPB> {

+ 1 - 1
frontend/rust-lib/flowy-grid/src/services/grid_view_editor.rs

@@ -76,7 +76,7 @@ impl GridViewRevisionEditor {
         })
     }
 
-    pub(crate) async fn update_row(&self, row_rev: &mut RowRevision, params: &CreateRowParams) {
+    pub(crate) async fn fill_row(&self, row_rev: &mut RowRevision, params: &CreateRowParams) {
         match params.layout {
             GridLayout::Table => {
                 // Table can be grouped too

+ 6 - 2
frontend/rust-lib/flowy-grid/src/services/grid_view_manager.rs

@@ -47,12 +47,16 @@ impl GridViewManager {
         })
     }
 
-    pub(crate) async fn update_row(&self, row_rev: &mut RowRevision, params: &CreateRowParams) {
+    pub(crate) async fn fill_row(&self, row_rev: &mut RowRevision, params: &CreateRowParams) {
         for view_editor in self.view_editors.iter() {
-            view_editor.update_row(row_rev, params).await;
+            view_editor.fill_row(row_rev, params).await;
         }
     }
 
+    pub(crate) async fn did_update_row(&self, row_id: &str) {
+        let row = self.block_manager.get_row_rev(row_id).await;
+    }
+
     pub(crate) async fn did_create_row(&self, row_pb: &RowPB, params: &CreateRowParams) {
         for view_editor in self.view_editors.iter() {
             view_editor.did_create_row(row_pb, params).await;