Skip to content

Commit e8080dd

Browse files
committed
revert(editor): restore TabBarView in emoji_bottom_sheet
Closes: #360
1 parent ce8a9f5 commit e8080dd

File tree

1 file changed

+11
-33
lines changed

1 file changed

+11
-33
lines changed

lib/features/editor/widgets/emoji_bottom_sheet.dart

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -34,37 +34,22 @@ class _EmojiBottomSheet extends StatefulWidget {
3434

3535
class _EmojiBottomSheetState extends State<_EmojiBottomSheet> with SingleTickerProviderStateMixin {
3636
TabController? tabController;
37-
int sheetIndex = 0;
38-
39-
void onSheetIndexChanged() {
40-
if (tabController?.indexIsChanging ?? false) {
41-
final currIndex = tabController?.index;
42-
if (currIndex != null) {
43-
setState(() {
44-
sheetIndex = currIndex;
45-
});
46-
}
47-
}
48-
}
4937

5038
@override
5139
void dispose() {
52-
tabController
53-
?..removeListener(onSheetIndexChanged)
54-
..dispose();
40+
tabController?.dispose();
5541
super.dispose();
5642
}
5743

5844
/// When calling this function, assume all emoji is available.
5945
Widget _buildEmojiTab(BuildContext context, EmojiState state) {
6046
final emojiGroupList = state.emojiGroupList!;
61-
tabController ??= TabController(length: emojiGroupList.length, vsync: this)..addListener(onSheetIndexChanged);
47+
tabController ??= TabController(length: emojiGroupList.length, vsync: this);
6248

6349
final tabs = emojiGroupList.map((e) => Tab(child: Text(e.name)));
6450
final tabViews = emojiGroupList.map(
6551
(e) => GridView.builder(
6652
padding: edgeInsetsL12R12,
67-
physics: const NeverScrollableScrollPhysics(),
6853
shrinkWrap: true,
6954
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
7055
maxCrossAxisExtent: 50,
@@ -90,21 +75,14 @@ class _EmojiBottomSheetState extends State<_EmojiBottomSheet> with SingleTickerP
9075
),
9176
);
9277

93-
return SingleChildScrollView(
94-
padding: context.safePadding(),
95-
child: Column(
96-
mainAxisSize: .min,
97-
children: [
98-
TabBar(isScrollable: true, tabAlignment: TabAlignment.start, controller: tabController, tabs: tabs.toList()),
99-
sizedBoxW12H12,
100-
// Use IndexStack instead of TabBarView to make contents having minimum height for the bottom sheet.
101-
// But it stucks more than TabBarView.
102-
IndexedStack(
103-
index: sheetIndex,
104-
children: tabViews.toList(),
105-
),
106-
],
107-
),
78+
return Column(
79+
children: [
80+
TabBar(isScrollable: true, tabAlignment: TabAlignment.start, controller: tabController, tabs: tabs.toList()),
81+
sizedBoxW12H12,
82+
Expanded(
83+
child: TabBarView(controller: tabController, children: tabViews.toList()),
84+
),
85+
],
10886
);
10987
}
11088

@@ -137,7 +115,7 @@ class _EmojiBottomSheetState extends State<_EmojiBottomSheet> with SingleTickerP
137115
EmojiStatus.success => _buildEmojiTab(context, state),
138116
};
139117

140-
return body;
118+
return ConstrainedBox(constraints: const BoxConstraints(maxHeight: 400), child: body);
141119
},
142120
),
143121
);

0 commit comments

Comments
 (0)