From 3b315d26fae442b8222ea154f015ee1b33b21774 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 13 Sep 2025 02:26:35 +0800 Subject: [PATCH] :sparkles: About page --- lib/main.dart | 8 +- lib/screens/about_page.dart | 107 ++++++++++++------ lib/screens/calculator_home_page.dart | 2 + lib/screens/home_screen.dart | 7 +- linux/flutter/generated_plugin_registrant.cc | 4 + linux/flutter/generated_plugins.cmake | 1 + macos/Flutter/GeneratedPluginRegistrant.swift | 2 + pubspec.lock | 66 ++++++++++- pubspec.yaml | 6 +- .../flutter/generated_plugin_registrant.cc | 3 + windows/flutter/generated_plugins.cmake | 1 + 11 files changed, 157 insertions(+), 50 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index b8a6c18..813f5fa 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -17,19 +17,17 @@ class CalcApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp.router( - title: '方程计算器', + title: 'SimpleMathCalc', theme: ThemeData( primarySwatch: Colors.blue, useMaterial3: true, textTheme: GoogleFonts.notoSerifScTextTheme( - Theme.of(context).textTheme, // Inherit existing text theme + ThemeData().textTheme, // Inherit existing text theme ), ), darkTheme: ThemeData.dark().copyWith( primaryColor: Colors.blue, - textTheme: GoogleFonts.notoSerifScTextTheme( - Theme.of(context).textTheme, - ), + textTheme: GoogleFonts.notoSerifScTextTheme(ThemeData.dark().textTheme), ), themeMode: ThemeMode.system, routerConfig: _router, diff --git a/lib/screens/about_page.dart b/lib/screens/about_page.dart index b91cf25..8235e1b 100644 --- a/lib/screens/about_page.dart +++ b/lib/screens/about_page.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:url_launcher/url_launcher.dart'; class AboutPage extends StatelessWidget { const AboutPage({super.key}); @@ -6,45 +7,79 @@ class AboutPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: const Text('About')), - body: Padding( - padding: const EdgeInsets.all(16.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - const SizedBox(height: 20), - Icon( - Icons.calculate, - size: 80, - color: Theme.of(context).colorScheme.primary, + appBar: AppBar(title: const Text('关于')), + body: Center( + child: SingleChildScrollView( + padding: const EdgeInsets.all(16.0), + child: ConstrainedBox( + constraints: const BoxConstraints(maxWidth: 320), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + const SizedBox(height: 20), + Center( + child: ClipRRect( + borderRadius: const BorderRadius.all(Radius.circular(8)), + child: Image.asset( + 'assets/icon.jpg', + width: 80, + height: 80, + ), + ), + ), + const SizedBox(height: 20), + Text( + 'Simple Math Calc', + style: Theme.of(context).textTheme.headlineMedium, + textAlign: TextAlign.center, + ), + const SizedBox(height: 10), + Text( + '简单数学计算器', + style: Theme.of(context).textTheme.bodyLarge, + textAlign: TextAlign.center, + ), + const SizedBox(height: 20), + Opacity( + opacity: 0.8, + child: Text( + '这是一个用于求解方程和表达式的计算器应用。\n支持多种类型的数学计算,包括代数方程、表达式求值等。\n\n结果仅供参考,纯机器计算,无 AI 成分。\n\n在书写方程的时候,请勿使用中文符号,平方请使用 ^n 来表示 n 次方。\n\n理性使用,仅为辅助学习目的,过量使用有害考试成绩。', + style: Theme.of(context).textTheme.bodyMedium, + textAlign: TextAlign.center, + ), + ), + const SizedBox(height: 20), + Text( + '© 2025 LittleSheep', + style: Theme.of(context).textTheme.bodySmall, + textAlign: TextAlign.center, + ), + const SizedBox(height: 30), + Text( + '看看 LittleSheep 的其他作品', + style: Theme.of(context).textTheme.titleMedium, + textAlign: TextAlign.center, + ), + const SizedBox(height: 16), + ListTile( + leading: const Icon(Icons.web), + trailing: const Icon(Icons.chevron_right), + title: const Text('Solar Network'), + subtitle: const Text('aka Solian'), + onTap: () => _launchUrl('https://web.solian.app'), + ), + ], ), - const SizedBox(height: 20), - Text( - '方程计算器', - style: Theme.of(context).textTheme.headlineMedium, - textAlign: TextAlign.center, - ), - const SizedBox(height: 10), - Text( - 'Version 1.0.0', - style: Theme.of(context).textTheme.bodyLarge, - textAlign: TextAlign.center, - ), - const SizedBox(height: 20), - Text( - '这是一个用于求解方程和表达式的计算器应用。\n\n支持多种类型的数学计算,包括代数方程、表达式求值等。', - style: Theme.of(context).textTheme.bodyMedium, - textAlign: TextAlign.center, - ), - const SizedBox(height: 30), - Text( - '© 2025 Simple Math Calculator', - style: Theme.of(context).textTheme.bodySmall, - textAlign: TextAlign.center, - ), - ], + ), ), ), ); } + + Future _launchUrl(String url) async { + final Uri uri = Uri.parse(url); + if (!await launchUrl(uri)) { + throw Exception('Could not launch $url'); + } + } } diff --git a/lib/screens/calculator_home_page.dart b/lib/screens/calculator_home_page.dart index cdf22ed..5780db9 100644 --- a/lib/screens/calculator_home_page.dart +++ b/lib/screens/calculator_home_page.dart @@ -74,6 +74,8 @@ class _CalculatorHomePageState extends State { hintText: '例如: 2x^2 - 8x + 6 = 0', ), onSubmitted: (_) => _solveEquation(), + onTapOutside: (_) => + FocusManager.instance.primaryFocus?.unfocus(), ), ), IconButton( diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart index 7ed3b94..d1f4727 100644 --- a/lib/screens/home_screen.dart +++ b/lib/screens/home_screen.dart @@ -29,11 +29,8 @@ class _HomeScreenState extends State { body: _widgetOptions.elementAt(_selectedIndex), bottomNavigationBar: BottomNavigationBar( items: const [ - BottomNavigationBarItem( - icon: Icon(Icons.calculate), - label: 'Calculator', - ), - BottomNavigationBarItem(icon: Icon(Icons.info), label: 'About'), + BottomNavigationBarItem(icon: Icon(Icons.calculate), label: '计算'), + BottomNavigationBarItem(icon: Icon(Icons.info), label: '关于'), ], currentIndex: _selectedIndex, onTap: _onItemTapped, diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index e71a16d..f6f23bf 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -6,6 +6,10 @@ #include "generated_plugin_registrant.h" +#include void fl_register_plugins(FlPluginRegistry* registry) { + g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); + url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); } diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 2e1de87..f16b4c3 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + url_launcher_linux ) list(APPEND FLUTTER_FFI_PLUGIN_LIST diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index e777c67..a1cdfd0 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -6,7 +6,9 @@ import FlutterMacOS import Foundation import path_provider_foundation +import url_launcher_macos func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) + UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) } diff --git a/pubspec.lock b/pubspec.lock index 63953b1..65a1eda 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -501,6 +501,70 @@ packages: url: "https://pub.dev" source: hosted version: "2.2.2" + url_launcher: + dependency: "direct main" + description: + name: url_launcher + sha256: f6a7e5c4835bb4e3026a04793a4199ca2d14c739ec378fdfe23fc8075d0439f8 + url: "https://pub.dev" + source: hosted + version: "6.3.2" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + sha256: "07cffecb7d68cbc6437cd803d5f11a86fe06736735c3dfe46ff73bcb0f958eed" + url: "https://pub.dev" + source: hosted + version: "6.3.21" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + sha256: d80b3f567a617cb923546034cc94bfe44eb15f989fe670b37f26abdb9d939cb7 + url: "https://pub.dev" + source: hosted + version: "6.3.4" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + sha256: "4e9ba368772369e3e08f231d2301b4ef72b9ff87c31192ef471b380ef29a4935" + url: "https://pub.dev" + source: hosted + version: "3.2.1" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + sha256: c043a77d6600ac9c38300567f33ef12b0ef4f4783a2c1f00231d2b1941fea13f + url: "https://pub.dev" + source: hosted + version: "3.2.3" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029" + url: "https://pub.dev" + source: hosted + version: "2.3.2" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + sha256: "4bd2b7b4dc4d4d0b94e5babfffbca8eac1a126c7f3d6ecbc1a11013faa3abba2" + url: "https://pub.dev" + source: hosted + version: "2.4.1" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + sha256: "3284b6d2ac454cf34f114e1d3319866fdd1e19cdc329999057e44ffe936cfa77" + url: "https://pub.dev" + source: hosted + version: "3.1.4" vector_graphics: dependency: transitive description: @@ -575,4 +639,4 @@ packages: version: "3.1.3" sdks: dart: ">=3.9.2 <4.0.0" - flutter: ">=3.29.0" + flutter: ">=3.35.0" diff --git a/pubspec.yaml b/pubspec.yaml index 33fa941..a456cd8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -38,6 +38,7 @@ dependencies: latext: ^0.5.1 google_fonts: ^6.3.1 go_router: ^14.2.0 + url_launcher: ^6.3.0 dev_dependencies: flutter_test: @@ -63,9 +64,8 @@ flutter: uses-material-design: true # To add assets to your application, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg + assets: + - assets/icon.jpg # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/to/resolution-aware-images diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 8b6d468..4f78848 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -6,6 +6,9 @@ #include "generated_plugin_registrant.h" +#include void RegisterPlugins(flutter::PluginRegistry* registry) { + UrlLauncherWindowsRegisterWithRegistrar( + registry->GetRegistrarForPlugin("UrlLauncherWindows")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index b93c4c3..88b22e5 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + url_launcher_windows ) list(APPEND FLUTTER_FFI_PLUGIN_LIST