界面整合v2
This commit is contained in:
@@ -12,7 +12,7 @@ class GuessPage extends StatefulWidget {
|
||||
State<GuessPage> createState() => _GuessPageState();
|
||||
}
|
||||
|
||||
class _GuessPageState extends State<GuessPage> with SingleTickerProviderStateMixin{
|
||||
class _GuessPageState extends State<GuessPage> with SingleTickerProviderStateMixin,AutomaticKeepAliveClientMixin{
|
||||
|
||||
late AnimationController controller;
|
||||
|
||||
@@ -114,4 +114,7 @@ class _GuessPageState extends State<GuessPage> with SingleTickerProviderStateMix
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ class MuyuPage extends StatefulWidget {
|
||||
State<MuyuPage> createState() => _MuyuPageState();
|
||||
}
|
||||
|
||||
class _MuyuPageState extends State<MuyuPage> {
|
||||
class _MuyuPageState extends State<MuyuPage> with AutomaticKeepAliveClientMixin {
|
||||
int _counter = 0;
|
||||
MeritRecord? _cruRecord;
|
||||
|
||||
@@ -174,4 +174,7 @@ class _MuyuPageState extends State<MuyuPage> {
|
||||
maxPlayers: 1,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ class AppNavigation extends StatefulWidget {
|
||||
|
||||
class _AppNavigationState extends State<AppNavigation> {
|
||||
int _index = 0;
|
||||
final PageController _ctrl = PageController();
|
||||
|
||||
final List<MenuData> menus = const [
|
||||
MenuData(label: '猜数字', icon: Icons.question_mark),
|
||||
@@ -26,7 +27,7 @@ class _AppNavigationState extends State<AppNavigation> {
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _buildContent(_index),
|
||||
child: _buildContent(),
|
||||
),
|
||||
AppBottomBar(
|
||||
currentIndex: _index,
|
||||
@@ -38,22 +39,22 @@ class _AppNavigationState extends State<AppNavigation> {
|
||||
}
|
||||
|
||||
void _onChangePage(int index) {
|
||||
_ctrl.jumpToPage(index);
|
||||
setState(() {
|
||||
_index = index;
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildContent(int index) {
|
||||
switch(index){
|
||||
case 0:
|
||||
return const GuessPage();
|
||||
case 1:
|
||||
return const MuyuPage();
|
||||
case 2:
|
||||
return const Paper();
|
||||
default:
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
Widget _buildContent() {
|
||||
return PageView(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
controller: _ctrl,
|
||||
children: const [
|
||||
GuessPage(),
|
||||
MuyuPage(),
|
||||
Paper(),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,12 @@ class Paper extends StatefulWidget {
|
||||
State<Paper> createState() => _PaperState();
|
||||
}
|
||||
|
||||
class _PaperState extends State<Paper> {
|
||||
class _PaperState extends State<Paper> with AutomaticKeepAliveClientMixin {
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
|
||||
List<Line> _lines = []; // 线列表
|
||||
|
||||
int _activeColorIndex = 0; // 颜色激活索引
|
||||
|
||||
Reference in New Issue
Block a user