| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- import 'package:flutter/material.dart';
- import 'package:provider/provider.dart';
- import 'calculator_page.dart';
- import 'console_page.dart';
- import 'symja.dart';
- import 'tools_page.dart';
- void main() => runApp(const CalApp());
- class CalApp extends StatelessWidget {
- const CalApp({super.key});
- @override
- Widget build(BuildContext context) {
- return ChangeNotifierProvider(
- create: (_) => SymjaSession(),
- child: MaterialApp(
- title: '某人的计算器2',
- debugShowCheckedModeBanner: false,
- theme: ThemeData(colorSchemeSeed: Colors.indigo, useMaterial3: true),
- home: const ShellPage(),
- ),
- );
- }
- }
- /// 三个界面(Q16 的「双界面」+ 插件页):
- /// 计算器 —— 默认入口,卡西欧式按键
- /// 工具 —— 16 个插件的网格入口
- /// 控制台 —— 表达式 REPL
- ///
- /// 用 IndexedStack 保住各页状态:切回来时控制台的历史、计算器正在输入的
- /// 表达式都还在。
- class ShellPage extends StatefulWidget {
- const ShellPage({super.key});
- @override
- State<ShellPage> createState() => _ShellPageState();
- }
- class _ShellPageState extends State<ShellPage> {
- int _index = 0;
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- body: IndexedStack(
- index: _index,
- children: const [
- CalculatorPage(),
- ToolsPage(),
- ConsolePage(),
- ],
- ),
- bottomNavigationBar: NavigationBar(
- selectedIndex: _index,
- onDestinationSelected: (i) => setState(() => _index = i),
- destinations: const [
- NavigationDestination(
- icon: Icon(Icons.calculate_outlined),
- selectedIcon: Icon(Icons.calculate),
- label: '计算器',
- ),
- NavigationDestination(
- icon: Icon(Icons.widgets_outlined),
- selectedIcon: Icon(Icons.widgets),
- label: '工具',
- ),
- NavigationDestination(
- icon: Icon(Icons.terminal_outlined),
- selectedIcon: Icon(Icons.terminal),
- label: '控制台',
- ),
- ],
- ),
- );
- }
- }
|