@@ -5,6 +5,7 @@ import 'package:appflowy/plugins/document/presentation/editor_plugins/simple_tab
55import 'package:appflowy_editor/appflowy_editor.dart' ;
66import 'package:flutter/material.dart' ;
77import 'package:provider/provider.dart' ;
8+ import 'package:universal_platform/universal_platform.dart' ;
89
910typedef SimpleTableColumnWidthMap = Map <String , double >;
1011typedef SimpleTableRowAlignMap = Map <String , String >;
@@ -187,28 +188,34 @@ class _SimpleTableBlockWidgetState extends State<SimpleTableBlockWidget>
187188 @override
188189 Widget build (BuildContext context) {
189190 Widget child = Transform .translate (
190- offset: const Offset (
191- - SimpleTableConstants .tableLeftPadding,
191+ offset: Offset (
192+ UniversalPlatform .isDesktop
193+ ? - SimpleTableConstants .tableLeftPadding
194+ : 0 ,
192195 0 ,
193196 ),
194197 child: _buildTable (),
195198 );
196199
197- child = Provider .value (
198- value: simpleTableContext,
199- child: MouseRegion (
200- onEnter: (event) =>
201- simpleTableContext.isHoveringOnTableBlock.value = true ,
202- onExit: (event) {
203- simpleTableContext.isHoveringOnTableBlock.value = false ;
204- },
205- child: Container (
206- alignment: Alignment .topLeft,
207- padding: padding,
200+ child = Container (
201+ alignment: Alignment .topLeft,
202+ padding: padding,
203+ child: child,
204+ );
205+
206+ if (UniversalPlatform .isDesktop) {
207+ child = Provider .value (
208+ value: simpleTableContext,
209+ child: MouseRegion (
210+ onEnter: (event) =>
211+ simpleTableContext.isHoveringOnTableBlock.value = true ,
212+ onExit: (event) {
213+ simpleTableContext.isHoveringOnTableBlock.value = false ;
214+ },
208215 child: child,
209216 ),
210- ),
211- );
217+ );
218+ }
212219
213220 if (widget.showActions && widget.actionBuilder != null ) {
214221 child = BlockComponentActionWrapper (
@@ -222,6 +229,14 @@ class _SimpleTableBlockWidgetState extends State<SimpleTableBlockWidget>
222229 }
223230
224231 Widget _buildTable () {
232+ if (UniversalPlatform .isDesktop) {
233+ return _buildDesktopTable ();
234+ } else {
235+ return _buildMobileTable ();
236+ }
237+ }
238+
239+ Widget _buildDesktopTable () {
225240 // IntrinsicWidth and IntrinsicHeight are used to make the table size fit the content.
226241 return MouseRegion (
227242 onEnter: (event) => simpleTableContext.isHoveringOnTableArea.value = true ,
@@ -260,24 +275,45 @@ class _SimpleTableBlockWidgetState extends State<SimpleTableBlockWidget>
260275 ),
261276 ),
262277 ),
263- SimpleTableAddColumnHoverButton (
264- editorState: editorState,
265- node: node,
266- ),
267- SimpleTableAddRowHoverButton (
268- editorState: editorState,
269- tableNode: node,
270- ),
271- SimpleTableAddColumnAndRowHoverButton (
272- editorState: editorState,
273- node: node,
274- ),
278+ if (UniversalPlatform .isDesktop) ...[
279+ SimpleTableAddColumnHoverButton (
280+ editorState: editorState,
281+ node: node,
282+ ),
283+ SimpleTableAddRowHoverButton (
284+ editorState: editorState,
285+ tableNode: node,
286+ ),
287+ SimpleTableAddColumnAndRowHoverButton (
288+ editorState: editorState,
289+ node: node,
290+ ),
291+ ],
275292 ],
276293 ),
277294 ),
278295 );
279296 }
280297
298+ Widget _buildMobileTable () {
299+ return Provider .value (
300+ value: simpleTableContext,
301+ child: SingleChildScrollView (
302+ controller: scrollController,
303+ scrollDirection: Axis .horizontal,
304+ child: IntrinsicWidth (
305+ child: IntrinsicHeight (
306+ child: Column (
307+ mainAxisSize: MainAxisSize .min,
308+ crossAxisAlignment: CrossAxisAlignment .start,
309+ children: _buildRows (),
310+ ),
311+ ),
312+ ),
313+ ),
314+ );
315+ }
316+
281317 List <Widget > _buildRows () {
282318 final List <Widget > rows = [];
283319
0 commit comments