Skip to content

Commit 0afa015

Browse files
committed
Refactor code for improved readability and consistency
- Cleaned up imports and organized them in `image_color_extractor.dart`, `update_service.dart`, `text_style_helper.dart`, `next_abc_contest_widget.dart`, and `custom_sliver_app_bar.dart`. - Enhanced logging messages for better clarity in `image_color_extractor.dart`. - Streamlined method parameters and formatting in `update_service.dart` for better readability. - Removed unnecessary whitespace and improved formatting in `next_abc_contest_widget.dart` for consistency. - Updated test cases in `build_config_test.dart` and `fdroid_integration_test.dart` for better clarity and consistency in assertions.
1 parent e2494b4 commit 0afa015

20 files changed

+963
-703
lines changed

lib/config/build_config.dart

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,20 @@ class BuildConfig {
66
'FDROID_BUILD',
77
defaultValue: false,
88
);
9-
9+
1010
/// Flag to control self-update functionality
1111
/// Disabled automatically for F-Droid builds
12-
static const bool enableSelfUpdate = bool.fromEnvironment(
13-
'ENABLE_SELF_UPDATE',
14-
defaultValue: true,
15-
) && !isFdroidBuild;
16-
12+
static const bool enableSelfUpdate =
13+
bool.fromEnvironment('ENABLE_SELF_UPDATE', defaultValue: true) &&
14+
!isFdroidBuild;
15+
1716
/// Flag to control online font fetching
1817
/// Disabled for F-Droid builds to ensure offline-only operation
19-
static const bool enableOnlineFonts = bool.fromEnvironment(
20-
'ENABLE_ONLINE_FONTS',
21-
defaultValue: true,
22-
) && !isFdroidBuild;
23-
18+
static const bool enableOnlineFonts =
19+
bool.fromEnvironment('ENABLE_ONLINE_FONTS', defaultValue: true) &&
20+
!isFdroidBuild;
21+
2422
/// Repository info for self-updates (only used when enableSelfUpdate is true)
2523
static const String defaultOwner = 'yuubinnkyoku';
2624
static const String defaultRepo = 'Shojin_App';
27-
}
25+
}

lib/generated/manual_licenses.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ const _hackgenFontFamily = Package(
1717
authors: ['Yuko Otawara'],
1818
isMarkdown: false,
1919
isSdk: false,
20-
dependencies: [],
21-
devDependencies: [],
20+
dependencies: [],
21+
devDependencies: [],
2222
homepage: 'https://github.com/yuru7/HackGen',
2323
version:
2424
null, // Font version not strictly required; omit to avoid stale info.

lib/main.dart

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void main() async {
2727

2828
// F-Droid ビルド安全性アサート: 自己アップデートが無効であること
2929
assert(() {
30-
if (BuildConfig.isFdroidBuild && BuildConfig.enableSelfUpdate) {
30+
if (BuildConfig.isFdroidBuild && BuildConfig.enableSelfUpdate) {
3131
throw StateError(
3232
'FDROID_BUILD=true なのに enableSelfUpdate が true です。ビルドフラグ/defines を再確認してください。',
3333
);
@@ -239,8 +239,7 @@ class MyApp extends StatelessWidget {
239239
backgroundColor: Colors.transparent,
240240
surfaceTintColor: Colors.transparent,
241241
elevation: 0,
242-
indicatorColor:
243-
lightColorScheme.primary.withValues(alpha: 0.20),
242+
indicatorColor: lightColorScheme.primary.withValues(alpha: 0.20),
244243
iconTheme: WidgetStateProperty.resolveWith((states) {
245244
final color = states.contains(WidgetState.selected)
246245
? lightColorScheme.primary
@@ -258,8 +257,8 @@ class MyApp extends StatelessWidget {
258257
elevation: 2,
259258
margin: const EdgeInsets.all(8),
260259
// MaterialYou使用時のコントラスト改善
261-
surfaceTintColor: themeProvider.useMaterialYou
262-
? lightColorScheme.primary.withValues(alpha: 0.08)
260+
surfaceTintColor: themeProvider.useMaterialYou
261+
? lightColorScheme.primary.withValues(alpha: 0.08)
263262
: null,
264263
),
265264
textTheme: textTheme,
@@ -277,8 +276,7 @@ class MyApp extends StatelessWidget {
277276
backgroundColor: Colors.transparent,
278277
surfaceTintColor: Colors.transparent,
279278
elevation: 0,
280-
indicatorColor:
281-
darkColorScheme.primary.withValues(alpha: 0.20),
279+
indicatorColor: darkColorScheme.primary.withValues(alpha: 0.20),
282280
iconTheme: WidgetStateProperty.resolveWith((states) {
283281
final color = states.contains(WidgetState.selected)
284282
? darkColorScheme.primary
@@ -297,8 +295,8 @@ class MyApp extends StatelessWidget {
297295
margin: const EdgeInsets.all(8),
298296
color: themeProvider.isPureBlack ? const Color(0xFF121212) : null,
299297
// MaterialYou使用時のコントラスト改善
300-
surfaceTintColor: themeProvider.useMaterialYou
301-
? darkColorScheme.primary.withValues(alpha: 0.08)
298+
surfaceTintColor: themeProvider.useMaterialYou
299+
? darkColorScheme.primary.withValues(alpha: 0.08)
302300
: null,
303301
),
304302
scaffoldBackgroundColor: themeProvider.isPureBlack

lib/models/test_result.dart

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,22 @@ class TestResult {
2525

2626
String get statusLabel {
2727
switch (status) {
28-
case JudgeStatus.pending: return 'Pending';
29-
case JudgeStatus.running: return 'Running';
30-
case JudgeStatus.ac: return 'AC';
31-
case JudgeStatus.wa: return 'WA';
32-
case JudgeStatus.re: return 'RE';
33-
case JudgeStatus.tle: return 'TLE'; // TLEはWandboxのレスポンスからは直接判断難しい場合あり
34-
case JudgeStatus.ce: return 'CE'; // Compile Error
35-
case JudgeStatus.ie: return 'IE'; // Internal Error
28+
case JudgeStatus.pending:
29+
return 'Pending';
30+
case JudgeStatus.running:
31+
return 'Running';
32+
case JudgeStatus.ac:
33+
return 'AC';
34+
case JudgeStatus.wa:
35+
return 'WA';
36+
case JudgeStatus.re:
37+
return 'RE';
38+
case JudgeStatus.tle:
39+
return 'TLE'; // TLEはWandboxのレスポンスからは直接判断難しい場合あり
40+
case JudgeStatus.ce:
41+
return 'CE'; // Compile Error
42+
case JudgeStatus.ie:
43+
return 'IE'; // Internal Error
3644
}
3745
}
3846
}

lib/screens/browser_screen.dart

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// filepath: d:\GitHub_yuubinnkyoku\shojin_app\lib\screens\browser_screen.dart
22
import 'dart:developer' as developer;
3+
34
import 'package:flutter/material.dart';
45
import 'package:provider/provider.dart';
56
import 'package:webview_flutter/webview_flutter.dart';
@@ -308,10 +309,7 @@ class _BrowserScreenState extends State<BrowserScreen>
308309
);
309310
if (mounted) {
310311
scaffoldMessenger.showSnackBar(
311-
SnackBar(
312-
content:
313-
Text('サイトメタデータの取得に失敗しました: $e'),
314-
),
312+
SnackBar(content: Text('サイトメタデータの取得に失敗しました: $e')),
315313
);
316314
}
317315
}
@@ -493,7 +491,7 @@ class _BrowserScreenState extends State<BrowserScreen>
493491
// MaterialYou使用時はプライマリカラーで軽いティントを追加してコントラストを向上
494492
final themeProvider = Provider.of<ThemeProvider>(context, listen: false);
495493
if (themeProvider.useMaterialYou) {
496-
backgroundColor = backgroundColor.withValues(alpha: 0.9);
494+
backgroundColor = backgroundColor.withValues(alpha: 0.9);
497495
}
498496
}
499497

@@ -573,7 +571,11 @@ class _BrowserScreenState extends State<BrowserScreen>
573571
),
574572
)
575573
else
576-
Icon(Icons.public, size: 18, color: textColor.withValues(alpha: 0.8)),
574+
Icon(
575+
Icons.public,
576+
size: 18,
577+
color: textColor.withValues(alpha: 0.8),
578+
),
577579
const SizedBox(width: 8),
578580
Text(
579581
title,
@@ -687,7 +689,9 @@ class _BrowserScreenState extends State<BrowserScreen>
687689

688690
if (_isControllerReady && _isLoadingWebView && !_loadFailed)
689691
Container(
690-
color: Theme.of(context).colorScheme.surface.withValues(alpha: 0.3),
692+
color: Theme.of(
693+
context,
694+
).colorScheme.surface.withValues(alpha: 0.3),
691695
child: const Center(child: CircularProgressIndicator()),
692696
),
693697
],

lib/screens/code_history_screen.dart

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:flutter/material.dart';
22
import 'package:intl/intl.dart';
3+
34
import '../models/code_history.dart';
45
import '../services/code_history_service.dart';
56

@@ -25,9 +26,7 @@ class _CodeHistoryScreenState extends State<CodeHistoryScreen> {
2526
@override
2627
Widget build(BuildContext context) {
2728
return Scaffold(
28-
appBar: AppBar(
29-
title: const Text('Code History'),
30-
),
29+
appBar: AppBar(title: const Text('Code History')),
3130
body: FutureBuilder<List<CodeHistory>>(
3231
future: _historyFuture,
3332
builder: (context, snapshot) {
@@ -44,7 +43,9 @@ class _CodeHistoryScreenState extends State<CodeHistoryScreen> {
4443
itemBuilder: (context, index) {
4544
final history = historyList[index];
4645
return ListTile(
47-
title: Text(DateFormat.yMMMd().add_jms().format(history.timestamp)),
46+
title: Text(
47+
DateFormat.yMMMd().add_jms().format(history.timestamp),
48+
),
4849
subtitle: Text(
4950
history.content,
5051
maxLines: 2,
@@ -65,9 +66,7 @@ class _CodeHistoryScreenState extends State<CodeHistoryScreen> {
6566
context: context,
6667
builder: (context) => AlertDialog(
6768
title: Text(DateFormat.yMMMd().add_jms().format(history.timestamp)),
68-
content: SingleChildScrollView(
69-
child: SelectableText(history.content),
70-
),
69+
content: SingleChildScrollView(child: SelectableText(history.content)),
7170
actions: [
7271
TextButton(
7372
onPressed: () => Navigator.of(context).pop(),
@@ -76,7 +75,9 @@ class _CodeHistoryScreenState extends State<CodeHistoryScreen> {
7675
TextButton(
7776
onPressed: () {
7877
Navigator.of(context).pop(); // Close the dialog
79-
Navigator.of(context).pop(history.content); // Pop the screen and return the code
78+
Navigator.of(
79+
context,
80+
).pop(history.content); // Pop the screen and return the code
8081
},
8182
child: const Text('Restore'),
8283
),

0 commit comments

Comments
 (0)