Skip to content

Commit 423db4a

Browse files
committed
♻️ NewsItem 분리
1 parent 897285a commit 423db4a

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class NewsItem {
2+
final String title;
3+
final String subtitle;
4+
final String imageUrl;
5+
final String linkUrl;
6+
7+
const NewsItem({
8+
required this.title,
9+
required this.subtitle,
10+
required this.imageUrl,
11+
required this.linkUrl,
12+
});
13+
14+
factory NewsItem.fromJson(Map<String, dynamic> json) {
15+
return NewsItem(
16+
title: json['title'] as String,
17+
subtitle: json['subtitle'] as String,
18+
imageUrl: json['imageUrl'] as String,
19+
linkUrl: json['linkUrl'] as String,
20+
);
21+
}
22+
}

lib/presentation/news/screens/news_list_screen.dart

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,9 @@ import 'dart:convert';
22
import 'package:flutter/material.dart';
33
import 'package:flutter_screenutil/flutter_screenutil.dart';
44
import 'package:jusicool_design_system/jusicool_design_system.dart';
5+
import 'package:jusicool_ios/presentation/news/screens/news_item.dart';
56
import 'package:url_launcher/url_launcher.dart';
67

7-
class NewsItem {
8-
final String title;
9-
final String subtitle;
10-
final String imageUrl;
11-
final String linkUrl;
12-
13-
const NewsItem({
14-
required this.title,
15-
required this.subtitle,
16-
required this.imageUrl,
17-
required this.linkUrl,
18-
});
19-
20-
factory NewsItem.fromJson(Map<String, dynamic> json) {
21-
return NewsItem(
22-
title: json['title'] as String,
23-
subtitle: json['subtitle'] as String,
24-
imageUrl: json['imageUrl'] as String,
25-
linkUrl: json['linkUrl'] as String,
26-
);
27-
}
28-
}
29-
308
class NewsListScreen extends StatefulWidget {
319
const NewsListScreen({super.key});
3210

@@ -93,7 +71,7 @@ class _NewsListScreenState extends State<NewsListScreen> {
9371
: ListView.separated(
9472
controller: _scrollController,
9573
itemCount: newsItems.length,
96-
separatorBuilder: (_, __) => SizedBox(height: 20.h),
74+
separatorBuilder: (_, _) => SizedBox(height: 20.h),
9775
itemBuilder: (context, index) {
9876
final item = newsItems[index];
9977
return GestureDetector(

0 commit comments

Comments
 (0)