-
Notifications
You must be signed in to change notification settings - Fork 1
Title: Fix step control and score text display [fix] #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| ## 更新内容 | ||
|
|
||
| 这是一个预览版本。仅用于早期技术预览。 | ||
| 1. 修复了步长控制 | ||
| 2. 修复了分数过长时显示不全的问题 | ||
|
|
||
| ## 我应该下载哪个文件? | ||
|
|
||
| | 文件 | 描述 | | ||
| |-------------------------------------------------|-------------------------------------------------------------------------------------------------| | ||
| | **安卓** | | | ||
| | UtopiaScoreboard-x.x.x-Android-v8a.apk | 64位包,适用于常见主流的安卓手机 | | ||
| | UtopiaScoreboard-x.x.x-Android-v7a.apk | 32位包,适用于非常老旧的安卓手机 | | ||
| | UtopiaScoreboard-x.x.x-Android-x86_64.apk | 桌面模拟器或x86架构的设备如Chrome Book等 | | ||
| | **iPhone** | | | ||
| | UtopiaScoreboard-x.x.x-iOS-universal.ipa | 请使用[AltStore](https://altstore.io/)进行侧载安装。具体教程请参考[官方文档](https://faq.altstore.io/)。 | | ||
| | **macOS** | | | ||
| | UtopiaScoreboard-x.x.x-macOS-universal.dmg | 请开启信任任何来源,请参考: [打开来自未知开发者的 Mac App](https://support.apple.com/zh-cn/guide/mac-help/mh40616/mac) | | ||
| | **Windows** | | | ||
| | UtopiaScoreboard-x.x.x-Windows-x64-setup.exe | 推荐。需要安装。 | | ||
| | UtopiaScoreboard-x.x.x-Windows-x64-setup.msi | 暂无,无法打包。 | | ||
| | UtopiaScoreboard-x.x.x-Windows-x64-portable.zip | 便携版。如不希望安装可以使用本包。 | | ||
| | **Linux** | | | ||
| | UtopiaScoreboard-x.x.x-Linux-x64.AppImage | 推荐,通用不限平台 | | ||
| | UtopiaScoreboard-x.x.x-Linux-x64.rpm | RHEL、CentOS、Fedora等 (RedHat系) | | ||
| | UtopiaScoreboard-x.x.x-Linux-x64.deb | Debian、Ubuntu等 (Debian系) | | ||
| | **Web** | | | ||
| | UtopiaScoreboard-x.x.x-Web.zip | 静态前端APP | | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,15 @@ | ||
| import 'dart:convert'; | ||
| import 'package:flutter/material.dart'; | ||
| import 'package:shared_preferences/shared_preferences.dart'; | ||
|
|
||
| class SettingsProvider extends ChangeNotifier { | ||
| double _uiScale = 1.0; | ||
| bool _initialized = false; | ||
| List<int> _globalScoreSteps = [1, 2, 4, 8, 16, 32, 64, 128]; | ||
|
|
||
| double get uiScale => _uiScale; | ||
| bool get initialized => _initialized; | ||
| List<int> get globalScoreSteps => _globalScoreSteps; | ||
|
|
||
| SettingsProvider() { | ||
| _loadSettings(); | ||
|
|
@@ -21,6 +24,10 @@ class SettingsProvider extends ChangeNotifier { | |
| _uiScale = 1.0; | ||
| _initialized = false; | ||
| } | ||
| final stepsJson = prefs.getString('global_score_steps'); | ||
| if (stepsJson != null) { | ||
| _globalScoreSteps = (jsonDecode(stepsJson) as List<dynamic>).cast<int>(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The try {
_globalScoreSteps = (jsonDecode(stepsJson) as List<dynamic>).cast<int>();
} catch (e) {
// Log the error and fall back to the initial default.
print('Failed to parse global score steps: $e');
} |
||
| } | ||
| notifyListeners(); | ||
| } | ||
|
|
||
|
|
@@ -40,4 +47,23 @@ class SettingsProvider extends ChangeNotifier { | |
| await prefs.setDouble('uiScale', _uiScale); | ||
| notifyListeners(); | ||
| } | ||
|
|
||
| Future<void> setGlobalScoreSteps(List<int> steps) async { | ||
| _globalScoreSteps = steps; | ||
| final prefs = await SharedPreferences.getInstance(); | ||
| await prefs.setString('global_score_steps', jsonEncode(_globalScoreSteps)); | ||
| notifyListeners(); | ||
| } | ||
|
|
||
| /// Reload global score steps from SharedPreferences (call after ScoreStepsEditor saves) | ||
| Future<void> reloadGlobalScoreSteps() async { | ||
| final prefs = await SharedPreferences.getInstance(); | ||
| final stepsJson = prefs.getString('global_score_steps'); | ||
| if (stepsJson != null) { | ||
| _globalScoreSteps = (jsonDecode(stepsJson) as List<dynamic>).cast<int>(); | ||
| } else { | ||
| _globalScoreSteps = [1, 2, 4, 8, 16, 32, 64, 128]; | ||
| } | ||
|
Comment on lines
+62
to
+66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to if (stepsJson != null) {
try {
_globalScoreSteps = (jsonDecode(stepsJson) as List<dynamic>).cast<int>();
} catch (e) {
print('Failed to parse global score steps: $e');
_globalScoreSteps = [1, 2, 4, 8, 16, 32, 64, 128];
}
} else {
_globalScoreSteps = [1, 2, 4, 8, 16, 32, 64, 128];
} |
||
| notifyListeners(); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,9 @@ | ||
| import 'dart:convert'; | ||
| import 'package:flutter/material.dart'; | ||
| import 'package:google_fonts/google_fonts.dart'; | ||
| import 'package:provider/provider.dart'; | ||
| import 'package:shared_preferences/shared_preferences.dart'; | ||
| import '../providers/settings_provider.dart'; | ||
|
|
||
| /// Editor for customizing the score step values. | ||
| class ScoreStepsEditor extends StatefulWidget { | ||
|
|
@@ -33,6 +35,10 @@ class _ScoreStepsEditorState extends State<ScoreStepsEditor> { | |
| Future<void> _saveSteps() async { | ||
| final prefs = await SharedPreferences.getInstance(); | ||
| await prefs.setString('global_score_steps', jsonEncode(_steps)); | ||
| if (mounted) { | ||
| Provider.of<SettingsProvider>(context, listen: false) | ||
| .reloadGlobalScoreSteps(); | ||
| } | ||
| } | ||
|
Comment on lines
35
to
42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Future<void> _saveSteps() async {
if (mounted) {
await Provider.of<SettingsProvider>(context, listen: false)
.setGlobalScoreSteps(_steps);
}
} |
||
|
|
||
| @override | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,9 @@ | ||
| import 'package:flutter/material.dart'; | ||
| import 'package:google_fonts/google_fonts.dart'; | ||
| import 'package:provider/provider.dart'; | ||
| import '../../models/player.dart'; | ||
| import '../../providers/game_provider.dart'; | ||
| import '../../providers/settings_provider.dart'; | ||
|
|
||
| /// Inline score adjustment row shown when a player is selected. | ||
| class ScoreRow extends StatelessWidget { | ||
|
|
@@ -49,7 +51,7 @@ class ScoreRow extends StatelessWidget { | |
| const SizedBox(width: 8), | ||
| _SignToggle(game: game), | ||
| const SizedBox(width: 6), | ||
| ...game.scoreSteps.map((step) => _ScoreStepButton( | ||
| ...Provider.of<SettingsProvider>(context).globalScoreSteps.map((step) => _ScoreStepButton( | ||
| game: game, | ||
| step: step, | ||
| )), | ||
|
Comment on lines
+54
to
57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# 检查 game.scoreSteps 在其他地方的使用情况,以及是否有单局步长自定义的入口
# 查找 updateScoreSteps 的调用点
echo "=== updateScoreSteps 调用点 ==="
rg -n "updateScoreSteps" --type dart
# 查找 scoreSteps 的其他引用
echo -e "\n=== scoreSteps 在 GameProvider 中的使用 ==="
rg -n "scoreSteps" lib/providers/game_provider.dart
# 检查是否有 UI 入口允许用户设置单局步长
echo -e "\n=== 可能的单局步长设置 UI ==="
rg -n -C2 "scoreSteps" lib/screens/ lib/widgets/Repository: UtopiaXC/UtopiaScoreboard Length of output: 2009 🏁 Script executed: # Mencari pemanggilan actual ke updateScoreSteps (bukan hanya definisi)
echo "=== Pemanggilan updateScoreSteps (actual calls) ==="
rg -n "updateScoreSteps\(" --type dart
# Melihat konteks penuh dari game_provider.dart untuk updateScoreSteps
echo -e "\n=== Konteks updateScoreSteps method ==="
sed -n '495,505p' lib/providers/game_provider.dart
# Melihat score_row.dart secara lengkap untuk konteks
echo -e "\n=== Isi score_row.dart ==="
wc -l lib/widgets/game/score_row.dartRepository: UtopiaXC/UtopiaScoreboard Length of output: 508 🏁 Script executed: # Lihat full score_row.dart
echo "=== Full score_row.dart ==="
cat -n lib/widgets/game/score_row.dart
# Cek apakah ada UI untuk mengatur scoreSteps per game
echo -e "\n=== Cari settings atau dialog untuk scoreSteps ==="
rg -n "scoreSteps" lib/screens/ -A 2 -B 2
# Lihat full context dari transfer_dialog.dart untuk scoreSteps usage
echo -e "\n=== transfer_dialog.dart context (lines 70-80) ==="
sed -n '70,80p' lib/widgets/game/transfer_dialog.dartRepository: UtopiaXC/UtopiaScoreboard Length of output: 5179 注意:scoreSteps 迁移不完整,存在使用源不一致的问题。 虽然
应统一这两个文件的实现方式,确保整个应用中步长配置来源保持一致。 🤖 Prompt for AI Agents |
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -73,28 +73,34 @@ class PlayerAvatar extends StatelessWidget { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Row( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| children: [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Flexible( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| child: Text( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| '积分:${player.totalScore}', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| style: GoogleFonts.notoSansSc( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| color: Colors.white.withValues(alpha: 0.9), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fontSize: 15, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fontWeight: FontWeight.w500, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| child: FittedBox( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fit: BoxFit.scaleDown, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| alignment: Alignment.centerLeft, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| child: Text( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| '积分:${player.totalScore}', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| style: GoogleFonts.notoSansSc( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| color: Colors.white.withValues(alpha: 0.9), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fontSize: 15, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fontWeight: FontWeight.w500, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| overflow: TextOverflow.ellipsis, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (player.currentRoundChange != 0) ...[ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const SizedBox(width: 8), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Text( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| player.currentRoundChange > 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ? '+${player.currentRoundChange}' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : '${player.currentRoundChange}', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| style: GoogleFonts.outfit( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| color: player.currentRoundChange > 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ? Colors.greenAccent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : Colors.redAccent, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fontSize: 13, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fontWeight: FontWeight.bold, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FittedBox( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fit: BoxFit.scaleDown, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| child: Text( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| player.currentRoundChange > 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ? '+${player.currentRoundChange}' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : '${player.currentRoundChange}', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| style: GoogleFonts.outfit( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| color: player.currentRoundChange > 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ? Colors.greenAccent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : Colors.redAccent, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fontSize: 13, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fontWeight: FontWeight.bold, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+91
to
105
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 增量积分的 与主积分不同,这里的 🔧 建议添加 Flexible 包裹 const SizedBox(width: 8),
- FittedBox(
- fit: BoxFit.scaleDown,
- child: Text(
+ Flexible(
+ child: FittedBox(
+ fit: BoxFit.scaleDown,
+ alignment: Alignment.centerLeft,
+ child: Text(
player.currentRoundChange > 0
? '+${player.currentRoundChange}'
: '${player.currentRoundChange}',
style: GoogleFonts.outfit(
color: player.currentRoundChange > 0
? Colors.greenAccent
: Colors.redAccent,
fontSize: 13,
fontWeight: FontWeight.bold,
),
+ ),
),
),📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default score steps
[1, 2, 4, 8, 16, 32, 64, 128]are hardcoded here, inreloadGlobalScoreSteps, and also inScoreStepsEditor. To improve maintainability and avoid potential inconsistencies, consider defining this list as astatic constin a shared location (e.g.,SettingsProvider) and referencing it from all these places.