factor:布局颜色重构
This commit is contained in:
58
lib/layout/app_body.dart
Normal file
58
lib/layout/app_body.dart
Normal file
@@ -0,0 +1,58 @@
|
||||
import 'package:flisp_app/pages/calendar_page.dart';
|
||||
import 'package:flisp_app/pages/flisp_page.dart';
|
||||
import 'package:flisp_app/pages/stats_page.dart';
|
||||
import 'package:flisp_app/pages/todo_page.dart';
|
||||
import 'package:flisp_app/provider/app_provider.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class AppBody extends StatefulWidget {
|
||||
const AppBody({super.key});
|
||||
|
||||
@override
|
||||
State<AppBody> createState() => AppBodyState();
|
||||
}
|
||||
|
||||
class AppBodyState extends State<AppBody> {
|
||||
final GlobalKey<FlispPageState> _flispPageKey = GlobalKey();
|
||||
final GlobalKey<TodoPageState> _todoPageKey = GlobalKey();
|
||||
final GlobalKey<CalendarPageState> _calendarPageKey = GlobalKey();
|
||||
|
||||
Widget _buildPage(int index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return FlispPage(key: _flispPageKey);
|
||||
case 1:
|
||||
return TodoPage(key: _todoPageKey);
|
||||
case 2:
|
||||
return CalendarPage(key: _calendarPageKey);
|
||||
case 3:
|
||||
return StatsPage();
|
||||
default:
|
||||
return FlispPage(key: _flispPageKey);
|
||||
}
|
||||
}
|
||||
|
||||
void showPageAddDialog(int index) {
|
||||
if (index == 0) {
|
||||
if (_flispPageKey.currentState != null) {
|
||||
_flispPageKey.currentState!.showAddDialog();
|
||||
}
|
||||
} else if (index == 1) {
|
||||
if (_todoPageKey.currentState != null) {
|
||||
_todoPageKey.currentState!.showAddDialog();
|
||||
}
|
||||
} else if (index == 2) {
|
||||
if (_calendarPageKey.currentState != null) {
|
||||
_calendarPageKey.currentState!.showAddDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final appProvider = context.watch<AppProvider>();
|
||||
|
||||
return _buildPage(appProvider.currentTab);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user