mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: disable log and try to fix some weird bugs
This commit is contained in:
parent
02e10301bf
commit
2152bb7188
@ -4,9 +4,7 @@ import 'package:flutter/material.dart';
|
||||
const DART_LOG = "Dart_LOG";
|
||||
|
||||
class Log {
|
||||
// static const enableLog = bool.hasEnvironment(DART_LOG);
|
||||
// static final shared = Log();
|
||||
static const enableLog = true;
|
||||
static const enableLog = false;
|
||||
|
||||
static void info(String? message) {
|
||||
if (enableLog) {
|
||||
@ -28,7 +26,7 @@ class Log {
|
||||
|
||||
static void trace(String? message) {
|
||||
if (enableLog) {
|
||||
// debugPrint('❗️[Trace] - ${DateTime.now().second}=> $message');
|
||||
debugPrint('❗️[Trace] - ${DateTime.now().second}=> $message');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ class _BoardContentState extends State<BoardContent> {
|
||||
dataSource: widget.dataController,
|
||||
direction: Axis.horizontal,
|
||||
interceptor: interceptor,
|
||||
children: _buildColumns(),
|
||||
children: _buildColumns(interceptor.columnKeys),
|
||||
);
|
||||
|
||||
return Stack(
|
||||
@ -191,7 +191,7 @@ class _BoardContentState extends State<BoardContent> {
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> _buildColumns() {
|
||||
List<Widget> _buildColumns(List<ColumnKey> columnKeys) {
|
||||
final List<Widget> children =
|
||||
widget.dataController.columnDatas.asMap().entries.map(
|
||||
(item) {
|
||||
@ -208,21 +208,33 @@ class _BoardContentState extends State<BoardContent> {
|
||||
value: widget.dataController.columnController(columnData.id),
|
||||
child: Consumer<AFBoardColumnDataController>(
|
||||
builder: (context, value, child) {
|
||||
final boardColumn = AFBoardColumnWidget(
|
||||
margin: _marginFromIndex(columnIndex),
|
||||
itemMargin: widget.config.columnItemPadding,
|
||||
headerBuilder: widget.headerBuilder,
|
||||
footBuilder: widget.footBuilder,
|
||||
cardBuilder: widget.cardBuilder,
|
||||
dataSource: dataSource,
|
||||
scrollController: ScrollController(),
|
||||
phantomController: widget.phantomController,
|
||||
onReorder: widget.dataController.moveColumnItem,
|
||||
cornerRadius: widget.config.cornerRadius,
|
||||
backgroundColor: widget.config.columnBackgroundColor,
|
||||
);
|
||||
|
||||
// columnKeys
|
||||
// .removeWhere((element) => element.columnId == columnData.id);
|
||||
|
||||
// columnKeys.add(
|
||||
// ColumnKey(
|
||||
// columnId: columnData.id,
|
||||
// key: boardColumn.columnGlobalKey,
|
||||
// ),
|
||||
// );
|
||||
|
||||
return ConstrainedBox(
|
||||
constraints: widget.columnConstraints,
|
||||
child: AFBoardColumnWidget(
|
||||
margin: _marginFromIndex(columnIndex),
|
||||
itemMargin: widget.config.columnItemPadding,
|
||||
headerBuilder: widget.headerBuilder,
|
||||
footBuilder: widget.footBuilder,
|
||||
cardBuilder: widget.cardBuilder,
|
||||
dataSource: dataSource,
|
||||
scrollController: ScrollController(),
|
||||
phantomController: widget.phantomController,
|
||||
onReorder: widget.dataController.moveColumnItem,
|
||||
cornerRadius: widget.config.cornerRadius,
|
||||
backgroundColor: widget.config.columnBackgroundColor,
|
||||
),
|
||||
child: boardColumn,
|
||||
);
|
||||
},
|
||||
),
|
||||
|
@ -87,7 +87,9 @@ class AFBoardColumnWidget extends StatefulWidget {
|
||||
|
||||
final Color backgroundColor;
|
||||
|
||||
const AFBoardColumnWidget({
|
||||
final GlobalKey columnGlobalKey = GlobalKey();
|
||||
|
||||
AFBoardColumnWidget({
|
||||
Key? key,
|
||||
this.headerBuilder,
|
||||
this.footBuilder,
|
||||
@ -136,8 +138,8 @@ class _AFBoardColumnWidgetState extends State<AFBoardColumnWidget> {
|
||||
draggableTargetBuilder: PhantomDraggableBuilder(),
|
||||
);
|
||||
|
||||
final reorderFlex = ReorderFlex(
|
||||
key: widget.key,
|
||||
Widget reorderFlex = ReorderFlex(
|
||||
key: widget.columnGlobalKey,
|
||||
scrollController: widget.scrollController,
|
||||
config: widget.config,
|
||||
onDragStarted: (index) {
|
||||
@ -160,6 +162,9 @@ class _AFBoardColumnWidgetState extends State<AFBoardColumnWidget> {
|
||||
children: children,
|
||||
);
|
||||
|
||||
// reorderFlex =
|
||||
// KeyedSubtree(key: widget.columnGlobalKey, child: reorderFlex);
|
||||
|
||||
return Container(
|
||||
margin: widget.margin,
|
||||
clipBehavior: Clip.hardEdge,
|
||||
|
@ -132,7 +132,7 @@ class DraggingState {
|
||||
}
|
||||
|
||||
void updateNextIndex(int index) {
|
||||
Log.trace('$reorderFlexId updateNextIndex: $index');
|
||||
Log.debug('$reorderFlexId updateNextIndex: $index');
|
||||
nextIndex = index;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
import 'package:appflowy_board/src/utils/log.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@ -448,9 +447,9 @@ class _FakeDragTargetState<T extends DragTargetData>
|
||||
/// Start insert animation
|
||||
widget.insertAnimationController.forward(from: 0.0);
|
||||
|
||||
widget.eventTrigger.fakeOnDragStart((insertIndex) {
|
||||
Log.debug("[$FakeDragTarget] on drag $insertIndex");
|
||||
});
|
||||
// widget.eventTrigger.fakeOnDragStart((insertIndex) {
|
||||
// Log.trace("[$FakeDragTarget] on drag $insertIndex");
|
||||
// });
|
||||
|
||||
widget.eventTrigger.fakeOnDragEnded(() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
|
@ -55,6 +55,7 @@ class OverlappingDragTargetInterceptor extends DragTargetInterceptor {
|
||||
final String reorderFlexId;
|
||||
final List<String> acceptedReorderFlexId;
|
||||
final OverlapDragTargetDelegate delegate;
|
||||
final List<ColumnKey> columnKeys = [];
|
||||
Timer? _delayOperation;
|
||||
|
||||
OverlappingDragTargetInterceptor({
|
||||
@ -87,6 +88,15 @@ class OverlappingDragTargetInterceptor extends DragTargetInterceptor {
|
||||
Log.trace(
|
||||
'[$OverlappingDragTargetInterceptor] move to $dragTargetId at $index');
|
||||
delegate.moveTo(dragTargetId, dragTargetData, index);
|
||||
|
||||
// final columnIndex = columnKeys
|
||||
// .indexWhere((element) => element.columnId == dragTargetId);
|
||||
// if (columnIndex != -1) {
|
||||
// final state = columnKeys[columnIndex].key.currentState;
|
||||
// if (state is ReorderFlexState) {
|
||||
// state.handleOnWillAccept(context, index);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -95,6 +105,12 @@ class OverlappingDragTargetInterceptor extends DragTargetInterceptor {
|
||||
}
|
||||
}
|
||||
|
||||
class ColumnKey {
|
||||
String columnId;
|
||||
GlobalKey key;
|
||||
ColumnKey({required this.columnId, required this.key});
|
||||
}
|
||||
|
||||
abstract class CrossReorderFlexDragTargetDelegate {
|
||||
/// * [reorderFlexId] is the id that the [ReorderFlex] passed in.
|
||||
bool acceptNewDragTargetData(
|
||||
|
@ -213,8 +213,8 @@ class ReorderFlexState extends State<ReorderFlex>
|
||||
shiftedIndex = dragState.calculateShiftedIndex(childIndex);
|
||||
}
|
||||
|
||||
// Log.trace(
|
||||
// 'Rebuild: Column:[${dragState.id}] ${dragState.toString()}, childIndex: $childIndex shiftedIndex: $shiftedIndex');
|
||||
Log.trace(
|
||||
'Rebuild: Column:[${dragState.reorderFlexId}] ${dragState.toString()}, childIndex: $childIndex shiftedIndex: $shiftedIndex');
|
||||
final currentIndex = dragState.currentIndex;
|
||||
final dragPhantomIndex = dragState.phantomIndex;
|
||||
|
||||
|
@ -214,12 +214,6 @@ class BoardPhantomController extends OverlapDragTargetDelegate
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (delegate.controller(dragTargetId)?.columnData.items.isEmpty ?? false) {
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user