Skip to content

Commit 2fee73e

Browse files
committed
feat: コンテスト名をProblemモデルに追加し、詳細画面に表示する処理を実装
1 parent 3cf8bdd commit 2fee73e

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

lib/models/problem.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
class Problem {
22
final String title;
33
final String contestId;
4+
final String contestName;
45
final String statement;
56
final String constraints;
67
final String inputFormat;
@@ -11,6 +12,7 @@ class Problem {
1112
Problem({
1213
required this.title,
1314
required this.contestId,
15+
required this.contestName,
1416
required this.statement,
1517
required this.constraints,
1618
required this.inputFormat,

lib/screens/problem_detail_screen.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,17 @@ class _ProblemDetailScreenState extends State<ProblemDetailScreen> {
290290
child: Column(
291291
crossAxisAlignment: CrossAxisAlignment.start,
292292
children: [
293+
if (problem.contestName.isNotEmpty && problem.contestName != 'コンテスト名が見つかりません')
294+
Padding(
295+
padding: const EdgeInsets.only(bottom: 8.0),
296+
child: Text(
297+
problem.contestName,
298+
style: TextStyle(
299+
fontSize: 14,
300+
color: Theme.of(context).colorScheme.onSurfaceVariant,
301+
),
302+
),
303+
),
293304
TexWidget(
294305
content: problem.title,
295306
textStyle: const TextStyle(

lib/services/atcoder_service.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ class AtCoderService {
2828
// コンテストIDの取得
2929
final contestId = _extractContestId(url);
3030

31+
// コンテスト名の取得
32+
final contestTitleElement = document.querySelector('.contest-title');
33+
final contestName = contestTitleElement?.text.trim() ?? 'コンテスト名が見つかりません';
34+
3135
// デバッグ: HTMLの構造を調査
3236
developer.log("HTML構造の分析を開始...");
3337
_analyzeHtmlStructure(document);
@@ -86,6 +90,7 @@ class AtCoderService {
8690
return Problem(
8791
title: title,
8892
contestId: contestId,
93+
contestName: contestName,
8994
statement: statement,
9095
constraints: constraints,
9196
inputFormat: inputFormat,

0 commit comments

Comments
 (0)