use fading scroll for tabs (validate performance)
This commit is contained in:
+27
-15
@@ -1,6 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
|
import 'package:fading_scroll/fading_scroll.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
import 'package:flutter_material_design_icons/flutter_material_design_icons.dart';
|
import 'package:flutter_material_design_icons/flutter_material_design_icons.dart';
|
||||||
@@ -192,7 +193,7 @@ class _TabSheetHeader extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
if (!treeViewEnabled)
|
if (!treeViewEnabled)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 8.0, top: 12),
|
padding: const EdgeInsets.only(top: 12),
|
||||||
child: Consumer(
|
child: Consumer(
|
||||||
builder: (context, ref, child) {
|
builder: (context, ref, child) {
|
||||||
final selectedContainer = ref.watch(
|
final selectedContainer = ref.watch(
|
||||||
@@ -389,10 +390,14 @@ class ViewTabsSheetWidget extends HookConsumerWidget {
|
|||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 4.0),
|
padding: const EdgeInsets.symmetric(horizontal: 4.0),
|
||||||
child: ReorderableBuilder.builder(
|
child: FadingScroll(
|
||||||
|
fadingSize: 10,
|
||||||
|
controller: sheetScrollController,
|
||||||
|
builder: (context, controller) {
|
||||||
|
return ReorderableBuilder.builder(
|
||||||
//Rebuild when cross axis count changes
|
//Rebuild when cross axis count changes
|
||||||
key: ValueKey(crossAxisCount),
|
key: ValueKey(crossAxisCount),
|
||||||
scrollController: sheetScrollController,
|
scrollController: controller,
|
||||||
itemCount: tabs.length,
|
itemCount: tabs.length,
|
||||||
onDragStarted: (index) {
|
onDragStarted: (index) {
|
||||||
ref.read(willAcceptDropProvider.notifier).clear();
|
ref.read(willAcceptDropProvider.notifier).clear();
|
||||||
@@ -410,31 +415,35 @@ class ViewTabsSheetWidget extends HookConsumerWidget {
|
|||||||
containerRepositoryProvider.notifier,
|
containerRepositoryProvider.notifier,
|
||||||
);
|
);
|
||||||
|
|
||||||
final tabId = filteredTabEntities.value[oldIndex].tabId;
|
final tabId =
|
||||||
|
filteredTabEntities.value[oldIndex].tabId;
|
||||||
final containerId = await ref
|
final containerId = await ref
|
||||||
.read(tabDataRepositoryProvider.notifier)
|
.read(tabDataRepositoryProvider.notifier)
|
||||||
.containerTabId(tabId);
|
.containerTabId(tabId);
|
||||||
|
|
||||||
final String key;
|
final String key;
|
||||||
if (newIndex <= 0) {
|
if (newIndex <= 0) {
|
||||||
key = await containerRepository.getLeadingOrderKey(
|
key = await containerRepository
|
||||||
containerId,
|
.getLeadingOrderKey(containerId);
|
||||||
);
|
|
||||||
} else if (newIndex >=
|
} else if (newIndex >=
|
||||||
filteredTabEntities.value.length - 1) {
|
filteredTabEntities.value.length - 1) {
|
||||||
key = await containerRepository.getTrailingOrderKey(
|
key = await containerRepository
|
||||||
containerId,
|
.getTrailingOrderKey(containerId);
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
if (newIndex < oldIndex) {
|
if (newIndex < oldIndex) {
|
||||||
key = await containerRepository.getOrderKeyAfterTab(
|
key = await containerRepository
|
||||||
filteredTabEntities.value[newIndex - 1].tabId,
|
.getOrderKeyAfterTab(
|
||||||
|
filteredTabEntities
|
||||||
|
.value[newIndex - 1]
|
||||||
|
.tabId,
|
||||||
containerId,
|
containerId,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
key = await containerRepository
|
key = await containerRepository
|
||||||
.getOrderKeyBeforeTab(
|
.getOrderKeyBeforeTab(
|
||||||
filteredTabEntities.value[newIndex + 1].tabId,
|
filteredTabEntities
|
||||||
|
.value[newIndex + 1]
|
||||||
|
.tabId,
|
||||||
containerId,
|
containerId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -447,8 +456,9 @@ class ViewTabsSheetWidget extends HookConsumerWidget {
|
|||||||
childBuilder: (itemBuilder) {
|
childBuilder: (itemBuilder) {
|
||||||
return GridView.builder(
|
return GridView.builder(
|
||||||
key: gridViewKey,
|
key: gridViewKey,
|
||||||
controller: sheetScrollController,
|
controller: controller,
|
||||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
gridDelegate:
|
||||||
|
SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
//Sync values for itemHeight calculation _calculateItemHeight
|
//Sync values for itemHeight calculation _calculateItemHeight
|
||||||
childAspectRatio: 0.75,
|
childAspectRatio: 0.75,
|
||||||
mainAxisSpacing: 8.0,
|
mainAxisSpacing: 8.0,
|
||||||
@@ -460,6 +470,8 @@ class ViewTabsSheetWidget extends HookConsumerWidget {
|
|||||||
itemBuilder(tabs[index], index),
|
itemBuilder(tabs[index], index),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user