mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
refactor: remove unused code
This commit is contained in:
parent
8ab2fe3e30
commit
933689269b
@ -12,17 +12,10 @@ import 'package:styled_widget/styled_widget.dart';
|
||||
import 'item.dart';
|
||||
import 'package:async/async.dart';
|
||||
|
||||
//? @gaganyadav80: Build 3 times on startup. Then one time on each doc change.
|
||||
|
||||
class ViewSection extends StatefulWidget {
|
||||
class ViewSection extends StatelessWidget {
|
||||
final AppDataNotifier appData;
|
||||
const ViewSection({Key? key, required this.appData}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<ViewSection> createState() => _ViewSectionState();
|
||||
}
|
||||
|
||||
class _ViewSectionState extends State<ViewSection> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// The ViewSectionNotifier will be updated after AppDataNotifier changed passed by parent widget
|
||||
@ -30,46 +23,21 @@ class _ViewSectionState extends State<ViewSection> {
|
||||
create: (_) {
|
||||
return ViewSectionNotifier(
|
||||
context: context,
|
||||
views: widget.appData.views,
|
||||
initialSelectedView: widget.appData.selectedView,
|
||||
views: appData.views,
|
||||
initialSelectedView: appData.selectedView,
|
||||
);
|
||||
},
|
||||
update: (_, notifier, controller) => controller!..update(notifier),
|
||||
child: Consumer(builder: (context, ViewSectionNotifier notifier, child) {
|
||||
log("BUILD: Section Bloc section update triggered + ${notifier.views.length}");
|
||||
return RenderSectionItems(views: notifier.views);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
// Widget _renderSectionItems(BuildContext context, List<View> views) {
|
||||
// return Container();
|
||||
// }
|
||||
}
|
||||
|
||||
class RenderSectionItems extends StatefulWidget {
|
||||
const RenderSectionItems({Key? key, required this.views}) : super(key: key);
|
||||
|
||||
final List<View> views;
|
||||
|
||||
@override
|
||||
State<RenderSectionItems> createState() => _RenderSectionItemsState();
|
||||
}
|
||||
|
||||
class _RenderSectionItemsState extends State<RenderSectionItems> {
|
||||
// List<Widget> viewWidgets = List.empty(growable: true);
|
||||
// List<Widget> sectionItems = List.empty(growable: true);
|
||||
List<View> views = <View>[];
|
||||
|
||||
/// Maps the hasmap value of the section items to their index in the reorderable list.
|
||||
//TODO @gaganyadav80: Retain this map to persist the order of the items.
|
||||
final Map<String, int> _sectionItemIndex = <String, int>{};
|
||||
|
||||
void _initItemList() {
|
||||
views.addAll(widget.views);
|
||||
// log(widget.views.length.toString());
|
||||
// if (widget.views.isNotEmpty) {
|
||||
// viewWidgets = widget.views
|
||||
// List<Widget> viewWidgets = [];
|
||||
// if (views.isNotEmpty) {
|
||||
// viewWidgets = views
|
||||
// .map(
|
||||
// (view) => ViewSectionItem(
|
||||
// view: view,
|
||||
@ -83,14 +51,41 @@ class _RenderSectionItemsState extends State<RenderSectionItems> {
|
||||
// .toList(growable: false);
|
||||
// }
|
||||
|
||||
// sectionItems.clear();
|
||||
// return Column(children: viewWidgets);
|
||||
// }
|
||||
|
||||
// bool _isViewSelected(BuildContext context, String viewId) {
|
||||
// final view = context.read<ViewSectionNotifier>().selectedView;
|
||||
// if (view == null) {
|
||||
// return false;
|
||||
// }
|
||||
// return view.id == viewId;
|
||||
// }
|
||||
}
|
||||
|
||||
class RenderSectionItems extends StatefulWidget {
|
||||
const RenderSectionItems({Key? key, required this.views}) : super(key: key);
|
||||
|
||||
final List<View> views;
|
||||
|
||||
@override
|
||||
State<RenderSectionItems> createState() => _RenderSectionItemsState();
|
||||
}
|
||||
|
||||
class _RenderSectionItemsState extends State<RenderSectionItems> {
|
||||
List<View> views = <View>[];
|
||||
|
||||
/// Maps the hasmap value of the section items to their index in the reorderable list.
|
||||
//TODO @gaganyadav80: Retain this map to persist the order of the items.
|
||||
final Map<String, int> _sectionItemIndex = <String, int>{};
|
||||
|
||||
void _initItemList() {
|
||||
views.addAll(widget.views);
|
||||
|
||||
for (int i = 0; i < views.length; i++) {
|
||||
if (_sectionItemIndex[views[i].id] == null) {
|
||||
_sectionItemIndex[views[i].id] = i;
|
||||
}
|
||||
|
||||
// sectionItems.insert(_sectionItemIndex[viewWidgets[i].key.hashCode]!, viewWidgets[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,8 +103,6 @@ class _RenderSectionItemsState extends State<RenderSectionItems> {
|
||||
|
||||
log("BUILD: Section items: ${views.length}");
|
||||
return ReorderableColumn(
|
||||
// itemCount: sectionItems.length,
|
||||
// buildDefaultDragHandles: false,
|
||||
needsLongPressDraggable: false,
|
||||
onReorder: (oldIndex, index) {
|
||||
setState(() {
|
||||
@ -120,14 +113,11 @@ class _RenderSectionItemsState extends State<RenderSectionItems> {
|
||||
_sectionItemIndex[section.id] = index;
|
||||
});
|
||||
},
|
||||
// physics: StyledScrollPhysics(),
|
||||
// itemBuilder: (context, index) {},
|
||||
children: List.generate(
|
||||
views.length,
|
||||
(index) {
|
||||
return Container(
|
||||
key: ValueKey(views[index].id),
|
||||
// index: index,
|
||||
child: views
|
||||
.map(
|
||||
(view) => ViewSectionItem(
|
||||
|
@ -1,8 +1,6 @@
|
||||
export './app/header/header.dart';
|
||||
export './app/menu_app.dart';
|
||||
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:app_flowy/workspace/presentation/home/home_stack.dart';
|
||||
import 'package:app_flowy/workspace/presentation/plugins/trash/menu.dart';
|
||||
import 'package:flowy_infra/notifier.dart';
|
||||
@ -47,9 +45,8 @@ class HomeMenu extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _HomeMenuState extends State<HomeMenu> {
|
||||
// final List<Widget> _menuItems = List.empty(growable: true);
|
||||
/// Maps the hashmap of the menu items to their index in reorderable list view.
|
||||
//TODO @gaganyadav80: need to retain this to persist on app restarts.
|
||||
//TODO @gaganyadav80: Retain this map to persist on app restarts.
|
||||
final Map<int, int> _menuItemIndex = <int, int>{};
|
||||
|
||||
@override
|
||||
@ -140,19 +137,6 @@ class _HomeMenuState extends State<HomeMenu> {
|
||||
menuItems.insert(_menuItemIndex[appWidgets[i].key.hashCode]!, appWidgets[i]);
|
||||
}
|
||||
|
||||
// for (var app in appWidgets) {
|
||||
// if (!_menuItems.any((oldElement) => oldElement.key == app.key)) {
|
||||
// _menuItems.add(app);
|
||||
// }
|
||||
// }
|
||||
// // TODO @gaganyadav80: fix: concurrent modification exception
|
||||
// // Unhandled Exception: Concurrent modification during iteration: Instance(length:3) of '_GrowableList'.
|
||||
// for (var item in _menuItems) {
|
||||
// if (!appWidgets.any((oldElement) => oldElement.key == item.key)) {
|
||||
// _menuItems.remove(item);
|
||||
// }
|
||||
// }
|
||||
|
||||
return menuItems;
|
||||
},
|
||||
builder: (context, menuItems) {
|
||||
@ -179,7 +163,7 @@ class _HomeMenuState extends State<HomeMenu> {
|
||||
},
|
||||
physics: StyledScrollPhysics(),
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
//? To mimic the ListView.separated behavior, we need to add a padding.
|
||||
//? @gaganyadav80: To mimic the ListView.separated behavior, we need to add a padding.
|
||||
// EdgeInsets padding = EdgeInsets.zero;
|
||||
// if (index == 0) {
|
||||
// padding = EdgeInsets.only(bottom: MenuAppSizes.appVPadding / 2);
|
||||
|
Loading…
Reference in New Issue
Block a user