From 24a28f2837e4303badb5cd2e841722490e605a5c Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 13 Sep 2025 12:56:31 +0800 Subject: [PATCH] :lipstick: Optimize and bug fixes --- ios/Runner.xcodeproj/project.pbxproj | 4 +- lib/screens/calculator_home_page.dart | 156 ++++++++++++++++++++++---- lib/solver.dart | 2 +- 3 files changed, 141 insertions(+), 21 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 8ee663e..08f14b3 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -97,7 +97,6 @@ EA2DD3AF98ED146A30B33E80 /* Pods-RunnerTests.release.xcconfig */, BAC0E182EE058A579F8BAF8B /* Pods-RunnerTests.profile.xcconfig */, ); - name = Pods; path = Pods; sourceTree = ""; }; @@ -474,6 +473,7 @@ DEVELOPMENT_TEAM = W7HPZ53V6B; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = SimpleMathCalc; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -657,6 +657,7 @@ DEVELOPMENT_TEAM = W7HPZ53V6B; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = SimpleMathCalc; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -680,6 +681,7 @@ DEVELOPMENT_TEAM = W7HPZ53V6B; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = SimpleMathCalc; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/lib/screens/calculator_home_page.dart b/lib/screens/calculator_home_page.dart index ec61c68..85efbc9 100644 --- a/lib/screens/calculator_home_page.dart +++ b/lib/screens/calculator_home_page.dart @@ -104,6 +104,7 @@ class _CalculatorHomePageState extends State { floatingLabelAlignment: FloatingLabelAlignment.center, hintText: '例如: 2x^2 - 8x + 6 = 0', ), + keyboardType: TextInputType.number, onSubmitted: (_) => _solveEquation(), ), ), @@ -159,7 +160,18 @@ class _CalculatorHomePageState extends State { style: Theme.of(context).textTheme.titleMedium, ), const SizedBox(height: 4), - SelectableText(step.explanation), + if (!step.explanation.contains(r'$')) + SelectableText( + step.explanation, + textAlign: TextAlign.center, + ) + else + LaTexT( + laTeXCode: Text( + step.explanation, + textAlign: TextAlign.center, + ), + ), Center( child: LaTexT( laTeXCode: Text( @@ -182,6 +194,7 @@ class _CalculatorHomePageState extends State { backgroundColor: Theme.of( context, ).colorScheme.primary, + textColor: Theme.of(context).colorScheme.onPrimary, label: Text( step.stepNumber.toString(), style: TextStyle(fontSize: 32), @@ -229,27 +242,132 @@ class _CalculatorHomePageState extends State { elevation: 8, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 12), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - spacing: 16, + child: Column( + mainAxisSize: MainAxisSize.min, children: [ - Expanded( - child: ElevatedButton( - onPressed: () => _insertSymbol('('), - child: Text('(', style: GoogleFonts.robotoMono()), - ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + spacing: 16, + children: [ + Expanded( + child: Tooltip( + message: '左括号', + child: FilledButton.tonal( + onPressed: () => _insertSymbol('('), + child: Text('(', style: GoogleFonts.robotoMono()), + ), + ), + ), + Expanded( + child: Tooltip( + message: '右括号', + child: FilledButton.tonal( + onPressed: () => _insertSymbol(')'), + child: Text(')', style: GoogleFonts.robotoMono()), + ), + ), + ), + Expanded( + child: Tooltip( + message: '幂符号', + child: FilledButton.tonal( + onPressed: () => _insertSymbol('^'), + child: Text('^', style: GoogleFonts.robotoMono()), + ), + ), + ), + Expanded( + child: Tooltip( + message: '平方', + child: FilledButton.tonal( + onPressed: () => _insertSymbol('^2'), + child: Text('^2', style: GoogleFonts.robotoMono()), + ), + ), + ), + Expanded( + child: Tooltip( + message: '未知数', + child: FilledButton.tonal( + onPressed: () => _insertSymbol('x'), + child: Text('x', style: GoogleFonts.robotoMono()), + ), + ), + ), + ], ), - Expanded( - child: ElevatedButton( - onPressed: () => _insertSymbol(')'), - child: Text(')', style: GoogleFonts.robotoMono()), - ), + const SizedBox(height: 8), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + spacing: 16, + children: [ + Expanded( + child: Tooltip( + message: '加法', + child: FilledButton.tonal( + onPressed: () => _insertSymbol('+'), + child: Text('+', style: GoogleFonts.robotoMono()), + ), + ), + ), + Expanded( + child: Tooltip( + message: '减法', + child: FilledButton.tonal( + onPressed: () => _insertSymbol('-'), + child: Text('-', style: GoogleFonts.robotoMono()), + ), + ), + ), + Expanded( + child: Tooltip( + message: '乘法', + child: FilledButton.tonal( + onPressed: () => _insertSymbol('*'), + child: Text('*', style: GoogleFonts.robotoMono()), + ), + ), + ), + Expanded( + child: Tooltip( + message: '除法', + child: FilledButton.tonal( + onPressed: () => _insertSymbol('/'), + child: Text('/', style: GoogleFonts.robotoMono()), + ), + ), + ), + Expanded( + child: Tooltip( + message: '小数点', + child: FilledButton.tonal( + onPressed: () => _insertSymbol('.'), + child: Text('.', style: GoogleFonts.robotoMono()), + ), + ), + ), + Expanded( + child: Tooltip( + message: '等于号', + child: FilledButton.tonal( + onPressed: () => _insertSymbol('='), + child: Text('=', style: GoogleFonts.robotoMono()), + ), + ), + ), + ], ), - Expanded( - child: ElevatedButton( - onPressed: () => _insertSymbol('^'), - child: Text('^', style: GoogleFonts.robotoMono()), - ), + const SizedBox(height: 8), + Row( + children: [ + Expanded( + child: FilledButton.icon( + icon: const Icon(Icons.keyboard_hide), + onPressed: () => _focusNode.unfocus(), + label: Text('收起键盘'), + ), + ), + ], ), ], ), diff --git a/lib/solver.dart b/lib/solver.dart index d8f050d..4e21159 100644 --- a/lib/solver.dart +++ b/lib/solver.dart @@ -149,7 +149,7 @@ class SolverService { CalculationStep( stepNumber: 1, title: '整理方程', - explanation: r'将方程整理成标准形式 ax^2+bx+c=0。', + explanation: r'将方程整理成标准形式 $ax^2+bx+c=0$。', formula: '\$\$${a}x^2 ${b >= 0 ? '+' : ''} ${b}x ${c >= 0 ? '+' : ''} $c = 0\$\$', ),