chore: revert reorder rows in grid (#2533) (#2669)

This reverts commit f8f0599462.
This commit is contained in:
Nathan.fooo 2023-05-31 11:21:33 +08:00 committed by GitHub
parent e8665dc76c
commit 757009a97d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 196 additions and 315 deletions

View File

@ -109,7 +109,6 @@
"openAsPage": "Open as a Page", "openAsPage": "Open as a Page",
"addNewRow": "Add a new row", "addNewRow": "Add a new row",
"openMenu": "Click to open menu", "openMenu": "Click to open menu",
"dragRow": "Long press to reorder the row",
"viewDataBase": "View database", "viewDataBase": "View database",
"referencePage": "This {name} is referenced" "referencePage": "This {name} is referenced"
}, },

View File

@ -175,28 +175,18 @@ class DatabaseController {
); );
} }
Future<Either<Unit, FlowyError>> moveGroupRow({ Future<Either<Unit, FlowyError>> moveRow({
required RowPB fromRow, required RowPB fromRow,
required String groupId, required String groupId,
RowPB? toRow, RowPB? toRow,
}) { }) {
return _databaseViewBackendSvc.moveGroupRow( return _databaseViewBackendSvc.moveRow(
fromRowId: fromRow.id, fromRowId: fromRow.id,
toGroupId: groupId, toGroupId: groupId,
toRowId: toRow?.id, toRowId: toRow?.id,
); );
} }
Future<Either<Unit, FlowyError>> moveRow({
required RowPB fromRow,
required RowPB toRow,
}) {
return _databaseViewBackendSvc.moveRow(
fromRowId: fromRow.id,
toRowId: toRow.id,
);
}
Future<Either<Unit, FlowyError>> moveGroup({ Future<Either<Unit, FlowyError>> moveGroup({
required String fromGroupId, required String fromGroupId,
required String toGroupId, required String toGroupId,

View File

@ -44,7 +44,7 @@ class DatabaseViewBackendService {
return DatabaseEventCreateRow(payload).send(); return DatabaseEventCreateRow(payload).send();
} }
Future<Either<Unit, FlowyError>> moveGroupRow({ Future<Either<Unit, FlowyError>> moveRow({
required String fromRowId, required String fromRowId,
required String toGroupId, required String toGroupId,
String? toRowId, String? toRowId,
@ -61,18 +61,6 @@ class DatabaseViewBackendService {
return DatabaseEventMoveGroupRow(payload).send(); return DatabaseEventMoveGroupRow(payload).send();
} }
Future<Either<Unit, FlowyError>> moveRow({
required String fromRowId,
required String toRowId,
}) {
var payload = MoveRowPayloadPB.create()
..viewId = viewId
..fromRowId = fromRowId
..toRowId = toRowId;
return DatabaseEventMoveRow(payload).send();
}
Future<Either<Unit, FlowyError>> moveGroup({ Future<Either<Unit, FlowyError>> moveGroup({
required String fromGroupId, required String fromGroupId,
required String toGroupId, required String toGroupId,

View File

@ -29,7 +29,7 @@ abstract class RowCacheDelegate {
class RowCache { class RowCache {
final String viewId; final String viewId;
/// _rows contains the current block's rows /// _rows containers the current block's rows
/// Use List to reverse the order of the GridRow. /// Use List to reverse the order of the GridRow.
final RowList _rowList = RowList(); final RowList _rowList = RowList();

View File

@ -53,7 +53,7 @@ class BoardBloc extends Bloc<BoardEvent, BoardState> {
final fromRow = groupControllers[groupId]?.rowAtIndex(fromIndex); final fromRow = groupControllers[groupId]?.rowAtIndex(fromIndex);
final toRow = groupControllers[groupId]?.rowAtIndex(toIndex); final toRow = groupControllers[groupId]?.rowAtIndex(toIndex);
if (fromRow != null) { if (fromRow != null) {
_databaseController.moveGroupRow( _databaseController.moveRow(
fromRow: fromRow, fromRow: fromRow,
toRow: toRow, toRow: toRow,
groupId: groupId, groupId: groupId,
@ -69,7 +69,7 @@ class BoardBloc extends Bloc<BoardEvent, BoardState> {
final fromRow = groupControllers[fromGroupId]?.rowAtIndex(fromIndex); final fromRow = groupControllers[fromGroupId]?.rowAtIndex(fromIndex);
final toRow = groupControllers[toGroupId]?.rowAtIndex(toIndex); final toRow = groupControllers[toGroupId]?.rowAtIndex(toIndex);
if (fromRow != null) { if (fromRow != null) {
_databaseController.moveGroupRow( _databaseController.moveRow(
fromRow: fromRow, fromRow: fromRow,
toRow: toRow, toRow: toRow,
groupId: toGroupId, groupId: toGroupId,

View File

@ -35,17 +35,6 @@ class GridBloc extends Bloc<GridEvent, GridState> {
); );
await rowService.deleteRow(rowInfo.rowPB.id); await rowService.deleteRow(rowInfo.rowPB.id);
}, },
moveRow: (int from, int to) {
final List<RowInfo> rows = [...state.rowInfos];
final fromRow = rows[from].rowPB;
final toRow = rows[to].rowPB;
rows.insert(to, rows.removeAt(from));
emit(state.copyWith(rowInfos: rows));
databaseController.moveRow(fromRow: fromRow, toRow: toRow);
},
didReceiveGridUpdate: (grid) { didReceiveGridUpdate: (grid) {
emit(state.copyWith(grid: Some(grid))); emit(state.copyWith(grid: Some(grid)));
}, },
@ -121,7 +110,6 @@ class GridEvent with _$GridEvent {
const factory GridEvent.initial() = InitialGrid; const factory GridEvent.initial() = InitialGrid;
const factory GridEvent.createRow() = _CreateRow; const factory GridEvent.createRow() = _CreateRow;
const factory GridEvent.deleteRow(RowInfo rowInfo) = _DeleteRow; const factory GridEvent.deleteRow(RowInfo rowInfo) = _DeleteRow;
const factory GridEvent.moveRow(int from, int to) = _MoveRow;
const factory GridEvent.didReceiveRowUpdate( const factory GridEvent.didReceiveRowUpdate(
List<RowInfo> rows, List<RowInfo> rows,
RowsChangedReason listState, RowsChangedReason listState,

View File

@ -91,6 +91,21 @@ class _GridPageState extends State<GridPage> {
), ),
); );
} }
@override
void dispose() {
super.dispose();
}
@override
void deactivate() {
super.deactivate();
}
@override
void didUpdateWidget(covariant GridPage oldWidget) {
super.didUpdateWidget(oldWidget);
}
} }
class FlowyGrid extends StatefulWidget { class FlowyGrid extends StatefulWidget {
@ -104,12 +119,12 @@ class _FlowyGridState extends State<FlowyGrid> {
final _scrollController = GridScrollController( final _scrollController = GridScrollController(
scrollGroupController: LinkedScrollControllerGroup(), scrollGroupController: LinkedScrollControllerGroup(),
); );
late final ScrollController headerScrollController; late ScrollController headerScrollController;
@override @override
void initState() { void initState() {
super.initState();
headerScrollController = _scrollController.linkHorizontalController(); headerScrollController = _scrollController.linkHorizontalController();
super.initState();
} }
@override @override
@ -201,78 +216,49 @@ class _GridRowsState extends State<_GridRows> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Builder( return BlocConsumer<GridBloc, GridState>(
builder: (context) { listenWhen: (previous, current) => previous.reason != current.reason,
final filterState = context.watch<GridFilterMenuBloc>().state; listener: (context, state) {
final sortState = context.watch<SortMenuBloc>().state; state.reason.whenOrNull(
insert: (item) {
return BlocConsumer<GridBloc, GridState>( _key.currentState?.insertItem(item.index);
listenWhen: (previous, current) => previous.reason != current.reason, },
listener: (context, state) { delete: (item) {
state.reason.whenOrNull( _key.currentState?.removeItem(
insert: (item) { item.index,
_key.currentState?.insertItem(item.index); (context, animation) =>
}, _renderRow(context, item.rowInfo, animation),
delete: (item) {
_key.currentState?.removeItem(
item.index,
(context, animation) => _renderRow(
context,
item.rowInfo,
animation: animation,
),
);
},
); );
}, },
buildWhen: (previous, current) { reorderSingleRow: (reorderRow, rowInfo) {
return current.reason.maybeWhen( // _key.currentState?.removeItem(
// reorderRow.oldIndex,
// (context, animation) => _renderRow(context, rowInfo, animation),
// );
// _key.currentState?.insertItem(reorderRow.newIndex);
},
);
},
buildWhen: (previous, current) {
return current.reason.whenOrNull(
reorderRows: () => true, reorderRows: () => true,
reorderSingleRow: (reorderRow, rowInfo) => true, reorderSingleRow: (reorderRow, rowInfo) => true,
delete: (item) => true, ) ??
insert: (item) => true, false;
orElse: () => false, },
); builder: (context, state) {
}, return SliverAnimatedList(
builder: (context, state) { key: _key,
final rowInfos = context.watch<GridBloc>().state.rowInfos; initialItemCount: context.read<GridBloc>().state.rowInfos.length,
itemBuilder:
return SliverFillRemaining( (BuildContext context, int index, Animation<double> animation) {
child: ReorderableListView.builder( final rowInfos = context.read<GridBloc>().state.rowInfos;
key: _key, if (index >= rowInfos.length) {
buildDefaultDragHandles: false, return const SizedBox();
proxyDecorator: (child, index, animation) => Material( } else {
color: Colors.white.withOpacity(.1), final RowInfo rowInfo = rowInfos[index];
child: Opacity( return _renderRow(context, rowInfo, animation);
opacity: .5, }
child: child,
),
),
onReorder: (fromIndex, newIndex) {
final toIndex =
newIndex > fromIndex ? newIndex - 1 : newIndex;
if (fromIndex == toIndex) {
return;
}
context
.read<GridBloc>()
.add(GridEvent.moveRow(fromIndex, toIndex));
},
itemCount: rowInfos.length,
itemBuilder: (BuildContext context, int index) {
final RowInfo rowInfo = rowInfos[index];
return _renderRow(
context,
rowInfo,
index: index,
isSortEnabled: sortState.sortInfos.isNotEmpty,
isFilterEnabled: filterState.filters.isNotEmpty,
);
},
),
);
}, },
); );
}, },
@ -281,19 +267,16 @@ class _GridRowsState extends State<_GridRows> {
Widget _renderRow( Widget _renderRow(
BuildContext context, BuildContext context,
RowInfo rowInfo, { RowInfo rowInfo,
int? index, Animation<double> animation,
bool isSortEnabled = false, ) {
bool isFilterEnabled = false,
Animation<double>? animation,
}) {
final rowCache = context.read<GridBloc>().getRowCache( final rowCache = context.read<GridBloc>().getRowCache(
rowInfo.rowPB.blockId, rowInfo.rowPB.blockId,
rowInfo.rowPB.id, rowInfo.rowPB.id,
); );
/// Return placeholder widget if the rowCache is null. /// Return placeholder widget if the rowCache is null.
if (rowCache == null) return const SizedBox.shrink(); if (rowCache == null) return const SizedBox();
final fieldController = final fieldController =
context.read<GridBloc>().databaseController.fieldController; context.read<GridBloc>().databaseController.fieldController;
@ -303,32 +286,24 @@ class _GridRowsState extends State<_GridRows> {
rowCache: rowCache, rowCache: rowCache,
); );
final child = GridRow( return SizeTransition(
key: ValueKey(rowInfo.rowPB.id), sizeFactor: animation,
index: index, child: GridRow(
isDraggable: !isSortEnabled && !isFilterEnabled, rowInfo: rowInfo,
rowInfo: rowInfo, dataController: dataController,
dataController: dataController, cellBuilder: GridCellBuilder(cellCache: dataController.cellCache),
cellBuilder: GridCellBuilder(cellCache: dataController.cellCache), openDetailPage: (context, cellBuilder) {
openDetailPage: (context, cellBuilder) { _openRowDetailPage(
_openRowDetailPage( context,
context, rowInfo,
rowInfo, fieldController,
fieldController, rowCache,
rowCache, cellBuilder,
cellBuilder, );
); },
}, key: ValueKey(rowInfo.rowPB.id),
),
); );
if (animation != null) {
return SizeTransition(
sizeFactor: animation,
child: child,
);
}
return child;
} }
void _openRowDetailPage( void _openRowDetailPage(

View File

@ -25,34 +25,29 @@ class GridRow extends StatefulWidget {
final GridCellBuilder cellBuilder; final GridCellBuilder cellBuilder;
final void Function(BuildContext, GridCellBuilder) openDetailPage; final void Function(BuildContext, GridCellBuilder) openDetailPage;
final int? index;
final bool isDraggable;
const GridRow({ const GridRow({
super.key,
required this.rowInfo, required this.rowInfo,
required this.dataController, required this.dataController,
required this.cellBuilder, required this.cellBuilder,
required this.openDetailPage, required this.openDetailPage,
this.index, Key? key,
this.isDraggable = false, }) : super(key: key);
});
@override @override
State<GridRow> createState() => _GridRowState(); State<GridRow> createState() => _GridRowState();
} }
class _GridRowState extends State<GridRow> { class _GridRowState extends State<GridRow> {
late final RowBloc _rowBloc; late RowBloc _rowBloc;
@override @override
void initState() { void initState() {
super.initState();
_rowBloc = RowBloc( _rowBloc = RowBloc(
rowInfo: widget.rowInfo, rowInfo: widget.rowInfo,
dataController: widget.dataController, dataController: widget.dataController,
); );
_rowBloc.add(const RowEvent.initial()); _rowBloc.add(const RowEvent.initial());
super.initState();
} }
@override @override
@ -75,11 +70,9 @@ class _GridRowState extends State<GridRow> {
return Row( return Row(
children: [ children: [
_RowLeading( const _RowLeading(),
index: widget.index,
isDraggable: widget.isDraggable,
),
content, content,
const _RowTrailing(),
], ],
); );
}, },
@ -96,25 +89,19 @@ class _GridRowState extends State<GridRow> {
} }
class _RowLeading extends StatefulWidget { class _RowLeading extends StatefulWidget {
final int? index; const _RowLeading({Key? key}) : super(key: key);
final bool isDraggable;
const _RowLeading({
this.index,
this.isDraggable = false,
});
@override @override
State<_RowLeading> createState() => _RowLeadingState(); State<_RowLeading> createState() => _RowLeadingState();
} }
class _RowLeadingState extends State<_RowLeading> { class _RowLeadingState extends State<_RowLeading> {
late final PopoverController popoverController; late PopoverController popoverController;
@override @override
void initState() { void initState() {
super.initState();
popoverController = PopoverController(); popoverController = PopoverController();
super.initState();
} }
@override @override
@ -144,28 +131,23 @@ class _RowLeadingState extends State<_RowLeading> {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
const _InsertButton(), const _InsertButton(),
if (isDraggable) ...[ _MenuButton(
ReorderableDragStartListener( openMenu: () {
index: widget.index!, popoverController.show();
child: _MenuButton( },
isDragEnabled: isDraggable, ),
openMenu: () {
popoverController.show();
},
),
),
] else ...[
_MenuButton(
openMenu: () {
popoverController.show();
},
),
],
], ],
); );
} }
}
bool get isDraggable => widget.index != null && widget.isDraggable; class _RowTrailing extends StatelessWidget {
const _RowTrailing({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const SizedBox();
}
} }
class _InsertButton extends StatelessWidget { class _InsertButton extends StatelessWidget {
@ -190,31 +172,25 @@ class _InsertButton extends StatelessWidget {
class _MenuButton extends StatefulWidget { class _MenuButton extends StatefulWidget {
final VoidCallback openMenu; final VoidCallback openMenu;
final bool isDragEnabled;
const _MenuButton({ const _MenuButton({
required this.openMenu, required this.openMenu,
this.isDragEnabled = false, Key? key,
}); }) : super(key: key);
@override @override
State<_MenuButton> createState() => _MenuButtonState(); State<_MenuButton> createState() => _MenuButtonState();
} }
class _MenuButtonState extends State<_MenuButton> { class _MenuButtonState extends State<_MenuButton> {
@override
void initState() {
super.initState();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return FlowyIconButton( return FlowyIconButton(
tooltipText: tooltipText: LocaleKeys.tooltip_openMenu.tr(),
widget.isDragEnabled ? null : LocaleKeys.tooltip_openMenu.tr(),
richTooltipText: widget.isDragEnabled
? TextSpan(
children: [
TextSpan(text: '${LocaleKeys.tooltip_dragRow.tr()}\n'),
TextSpan(text: LocaleKeys.tooltip_openMenu.tr()),
],
)
: null,
hoverColor: AFThemeExtension.of(context).lightGreyHover, hoverColor: AFThemeExtension.of(context).lightGreyHover,
width: 20, width: 20,
height: 30, height: 30,
@ -282,7 +258,6 @@ class RowContent extends StatelessWidget {
if (builder != null) { if (builder != null) {
accessories.addAll(builder(buildContext)); accessories.addAll(builder(buildContext));
} }
return accessories; return accessories;
}, },
child: child, child: child,
@ -314,12 +289,12 @@ class _RowEnterRegion extends StatefulWidget {
} }
class _RowEnterRegionState extends State<_RowEnterRegion> { class _RowEnterRegionState extends State<_RowEnterRegion> {
late final RegionStateNotifier _rowStateNotifier; late RegionStateNotifier _rowStateNotifier;
@override @override
void initState() { void initState() {
super.initState();
_rowStateNotifier = RegionStateNotifier(); _rowStateNotifier = RegionStateNotifier();
super.initState();
} }
@override @override

View File

@ -74,7 +74,6 @@ class GridCellBuilder {
key: key, key: key,
); );
} }
throw UnimplementedError; throw UnimplementedError;
} }
} }
@ -84,7 +83,7 @@ class BlankCell extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return const SizedBox.shrink(); return Container();
} }
} }

View File

@ -68,15 +68,18 @@ class CellContainer extends StatelessWidget {
if (isFocus) { if (isFocus) {
final borderSide = BorderSide( final borderSide = BorderSide(
color: Theme.of(context).colorScheme.primary, color: Theme.of(context).colorScheme.primary,
width: 1.0,
); );
return BoxDecoration(border: Border.fromBorderSide(borderSide)); return BoxDecoration(border: Border.fromBorderSide(borderSide));
} else {
final borderSide = BorderSide(
color: Theme.of(context).dividerColor,
width: 1.0,
);
return BoxDecoration(
border: Border(right: borderSide, bottom: borderSide),
);
} }
final borderSide = BorderSide(color: Theme.of(context).dividerColor);
return BoxDecoration(
border: Border(right: borderSide, bottom: borderSide),
);
} }
} }

View File

@ -1,10 +1,10 @@
class HomeSizes { class HomeSizes {
static const double menuAddButtonHeight = 60; static double get menuAddButtonHeight => 60;
static const double topBarHeight = 60; static double get topBarHeight => 60;
static const double editPanelTopBarHeight = 60; static double get editPanelTopBarHeight => 60;
static const double editPanelWidth = 400; static double get editPanelWidth => 400;
} }
class HomeInsets { class HomeInsets {
static const double topBarTitlePadding = 12; static double get topBarTitlePadding => 12;
} }

View File

@ -170,24 +170,23 @@ class HomeStackManager {
return MultiProvider( return MultiProvider(
providers: [ChangeNotifierProvider.value(value: _notifier)], providers: [ChangeNotifierProvider.value(value: _notifier)],
child: Consumer( child: Consumer(
builder: (_, HomeStackNotifier notifier, __) { builder: (ctx, HomeStackNotifier notifier, child) {
return FadingIndexedStack( return FadingIndexedStack(
index: getIt<PluginSandbox>().indexOf(notifier.plugin.ty), index: getIt<PluginSandbox>().indexOf(notifier.plugin.ty),
children: getIt<PluginSandbox>().supportPluginTypes.map( children:
(pluginType) { getIt<PluginSandbox>().supportPluginTypes.map((pluginType) {
if (pluginType == notifier.plugin.ty) { if (pluginType == notifier.plugin.ty) {
final pluginWidget = notifier.plugin.display final pluginWidget = notifier.plugin.display
.buildWidget(PluginContext(onDeleted: onDeleted)); .buildWidget(PluginContext(onDeleted: onDeleted));
if (pluginType == PluginType.editor) { if (pluginType == PluginType.editor) {
return pluginWidget; return pluginWidget;
} } else {
return pluginWidget.padding(horizontal: 40, vertical: 28); return pluginWidget.padding(horizontal: 40, vertical: 28);
} }
} else {
return const BlankPage(); return const BlankPage();
}, }
).toList(), }).toList(),
); );
}, },
), ),
@ -205,27 +204,30 @@ class HomeTopBar extends StatelessWidget {
return Container( return Container(
color: Theme.of(context).colorScheme.onSecondaryContainer, color: Theme.of(context).colorScheme.onSecondaryContainer,
height: HomeSizes.topBarHeight, height: HomeSizes.topBarHeight,
child: Padding( child: Row(
padding: const EdgeInsets.symmetric( crossAxisAlignment: CrossAxisAlignment.center,
horizontal: HomeInsets.topBarTitlePadding, children: [
), HSpace(layout.menuSpacing),
child: Row( const FlowyNavigation(),
crossAxisAlignment: CrossAxisAlignment.center, const HSpace(16),
children: [ ChangeNotifierProvider.value(
HSpace(layout.menuSpacing), value: Provider.of<HomeStackNotifier>(context, listen: false),
const FlowyNavigation(), child: Consumer(
const HSpace(16), builder: (
ChangeNotifierProvider.value( BuildContext context,
value: Provider.of<HomeStackNotifier>(context, listen: false), HomeStackNotifier notifier,
child: Consumer( Widget? child,
builder: (_, HomeStackNotifier notifier, __) => ) {
notifier.plugin.display.rightBarItem ?? return notifier.plugin.display.rightBarItem ?? const SizedBox();
const SizedBox.shrink(), },
),
), ),
], ) // _renderMoreButton(),
).bottomBorder(color: Theme.of(context).dividerColor), ],
), )
.padding(
horizontal: HomeInsets.topBarTitlePadding,
)
.bottomBorder(color: Theme.of(context).dividerColor),
); );
} }
} }

View File

@ -17,13 +17,12 @@ class ViewLeftBarItem extends StatefulWidget {
class _ViewLeftBarItemState extends State<ViewLeftBarItem> { class _ViewLeftBarItemState extends State<ViewLeftBarItem> {
final _controller = TextEditingController(); final _controller = TextEditingController();
final _focusNode = FocusNode(); final _focusNode = FocusNode();
late final ViewService _viewService; late ViewService _viewService;
late final ViewListener _viewListener; late ViewListener _viewListener;
late ViewPB view; late ViewPB view;
@override @override
void initState() { void initState() {
super.initState();
view = widget.view; view = widget.view;
_viewService = ViewService(); _viewService = ViewService();
_focusNode.addListener(_handleFocusChanged); _focusNode.addListener(_handleFocusChanged);
@ -40,8 +39,7 @@ class _ViewLeftBarItemState extends State<ViewLeftBarItem> {
); );
}, },
); );
super.initState();
_controller.text = view.name;
} }
@override @override
@ -55,24 +53,30 @@ class _ViewLeftBarItemState extends State<ViewLeftBarItem> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GestureDetector( _controller.text = view.name;
return IntrinsicWidth(
key: ValueKey(_controller.text), key: ValueKey(_controller.text),
onDoubleTap: () { child: GestureDetector(
_controller.selection = TextSelection( onDoubleTap: () {
baseOffset: 0, _controller.selection = TextSelection(
extentOffset: _controller.text.length, baseOffset: 0,
); extentOffset: _controller.text.length,
}, );
child: TextField( },
controller: _controller, child: TextField(
focusNode: _focusNode, controller: _controller,
scrollPadding: EdgeInsets.zero, focusNode: _focusNode,
decoration: const InputDecoration( scrollPadding: EdgeInsets.zero,
contentPadding: EdgeInsets.symmetric(vertical: 4.0), decoration: const InputDecoration(
border: InputBorder.none, contentPadding: EdgeInsets.symmetric(vertical: 4.0),
isDense: true, border: InputBorder.none,
isDense: true,
),
style: Theme.of(context).textTheme.bodyMedium,
// cursorColor: widget.cursorColor,
// obscureText: widget.enableObscure,
), ),
style: Theme.of(context).textTheme.bodyMedium,
), ),
); );
} }

View File

@ -3,7 +3,7 @@ export 'package:styled_widget/styled_widget.dart';
extension FlowyStyledWidget on Widget { extension FlowyStyledWidget on Widget {
Widget bottomBorder({double width = 1.0, Color color = Colors.grey}) { Widget bottomBorder({double width = 1.0, Color color = Colors.grey}) {
return DecoratedBox( return Container(
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border( border: Border(
bottom: BorderSide(width: width, color: color), bottom: BorderSide(width: width, color: color),
@ -14,7 +14,7 @@ extension FlowyStyledWidget on Widget {
} }
Widget topBorder({double width = 1.0, Color color = Colors.grey}) { Widget topBorder({double width = 1.0, Color color = Colors.grey}) {
return DecoratedBox( return Container(
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border( border: Border(
top: BorderSide(width: width, color: color), top: BorderSide(width: width, color: color),

View File

@ -16,7 +16,6 @@ class FlowyIconButton extends StatelessWidget {
final EdgeInsets iconPadding; final EdgeInsets iconPadding;
final BorderRadius? radius; final BorderRadius? radius;
final String? tooltipText; final String? tooltipText;
final InlineSpan? richTooltipText;
final bool preferBelow; final bool preferBelow;
const FlowyIconButton({ const FlowyIconButton({
@ -30,22 +29,15 @@ class FlowyIconButton extends StatelessWidget {
this.iconPadding = EdgeInsets.zero, this.iconPadding = EdgeInsets.zero,
this.radius, this.radius,
this.tooltipText, this.tooltipText,
this.richTooltipText,
this.preferBelow = true, this.preferBelow = true,
required this.icon, required this.icon,
}) : assert((richTooltipText != null && tooltipText == null) || }) : super(key: key);
(richTooltipText == null && tooltipText != null) ||
(richTooltipText == null && tooltipText == null)),
super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Widget child = icon; Widget child = icon;
final size = Size(width, height ?? width); final size = Size(width, height ?? width);
final tooltipMessage =
tooltipText == null && richTooltipText == null ? '' : tooltipText;
assert(size.width > iconPadding.horizontal); assert(size.width > iconPadding.horizontal);
assert(size.height > iconPadding.vertical); assert(size.height > iconPadding.vertical);
@ -54,14 +46,11 @@ class FlowyIconButton extends StatelessWidget {
final childSize = Size(childWidth, childWidth); final childSize = Size(childWidth, childWidth);
return ConstrainedBox( return ConstrainedBox(
constraints: BoxConstraints.tightFor( constraints:
width: size.width, BoxConstraints.tightFor(width: size.width, height: size.height),
height: size.height,
),
child: Tooltip( child: Tooltip(
preferBelow: preferBelow, preferBelow: preferBelow,
message: tooltipMessage, message: tooltipText ?? '',
richMessage: richTooltipText,
showDuration: Duration.zero, showDuration: Duration.zero,
child: RawMaterialButton( child: RawMaterialButton(
visualDensity: VisualDensity.compact, visualDensity: VisualDensity.compact,

View File

@ -13,11 +13,9 @@ void main() {
group('Edit Grid:', () { group('Edit Grid:', () {
late GridTestContext context; late GridTestContext context;
setUp(() async { setUp(() async {
context = await gridTest.createTestGrid(); context = await gridTest.createTestGrid();
}); });
// The initial number of rows is 3 for each grid. // The initial number of rows is 3 for each grid.
blocTest<GridBloc, GridState>( blocTest<GridBloc, GridState>(
"create a row", "create a row",
@ -56,34 +54,5 @@ void main() {
); );
}, },
); );
String? firstId;
String? secondId;
String? thirdId;
blocTest(
'reorder rows',
build: () => GridBloc(
view: context.gridView,
databaseController: DatabaseController(
view: context.gridView,
layoutType: LayoutTypePB.Grid,
),
)..add(const GridEvent.initial()),
act: (bloc) async {
await gridResponseFuture();
firstId = bloc.state.rowInfos[0].rowPB.id;
secondId = bloc.state.rowInfos[1].rowPB.id;
thirdId = bloc.state.rowInfos[2].rowPB.id;
bloc.add(const GridEvent.moveRow(0, 2));
},
verify: (bloc) {
expect(secondId, bloc.state.rowInfos[0].rowPB.id);
expect(thirdId, bloc.state.rowInfos[1].rowPB.id);
expect(firstId, bloc.state.rowInfos[2].rowPB.id);
},
);
}); });
} }