Skip to content

Commit 3fef3fd

Browse files
authored
Merge pull request #25 from Jusicool-Ver-2-0/refactor/codebase-cleanup
🔀 :: (#24) User 화면 코드 리팩토링
2 parents 16ea244 + 9504599 commit 3fef3fd

File tree

13 files changed

+1324
-1273
lines changed

13 files changed

+1324
-1273
lines changed

lib/presentation/my_capital/screens/maincapital_screen.dart

Lines changed: 498 additions & 411 deletions
Large diffs are not rendered by default.

lib/presentation/my_capital/screens/my_assets_screen.dart

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class _MyAssetsScreenState extends State<MyAssetsScreen> {
2424
_futureData = _loadAssetsData();
2525
}
2626

27-
/// ====================================
27+
/* --------------------- 데이터 로드 --------------------- */
2828
Future<MyAssetsData> _loadAssetsData() async {
2929
final jsonString = await rootBundle.loadString(
3030
'assets/data/my_assets.json',
@@ -33,11 +33,10 @@ class _MyAssetsScreenState extends State<MyAssetsScreen> {
3333
return MyAssetsData.fromJson(jsonMap);
3434
}
3535

36-
/// ====================================
37-
36+
/* ----------------- HEX → Color 유틸 ------------------ */
3837
Color hexToColor(String hex) {
3938
final buffer = StringBuffer();
40-
if (hex.length == 7) buffer.write('ff'); // 투명도 설정 (기본값: 100%)
39+
if (hex.length == 7) buffer.write('ff'); // 투명도(100%)
4140
buffer.write(hex.replaceFirst('#', ''));
4241
return Color(int.parse(buffer.toString(), radix: 16));
4342
}
@@ -130,31 +129,38 @@ class _MyAssetsScreenState extends State<MyAssetsScreen> {
130129
sectionsSpace: 4,
131130
centerSpaceRadius: 80,
132131
sections:
133-
data.sections.map((s) {
134-
return PieChartSectionData(
135-
color: hexToColor(s.colorHex),
136-
value: s.percentage,
137-
title: '',
138-
radius: 45, // ✅ 모든 조각 동일 크기
139-
);
140-
}).toList(),
132+
data.sections
133+
.map(
134+
(s) => PieChartSectionData(
135+
color: hexToColor(s.colorHex),
136+
value: s.percentage,
137+
title: '',
138+
radius: 45,
139+
),
140+
)
141+
.toList(),
141142
),
142143
),
143144
),
144145
const SizedBox(height: 24),
145-
...data.sections.map(
146-
(s) => Column(
147-
children: [
148-
MyAssetTile(
149-
stockName: s.name,
150-
stockPrice: "${formatter.format(s.price)}원",
151-
percentage: "${s.percentage.toStringAsFixed(1)}%",
152-
iconColor: hexToColor(s.colorHex),
153-
),
154-
const SizedBox(height: 24),
155-
],
156-
),
146+
147+
/* ---------- 자산 리스트: ListView.separated ---------- */
148+
ListView.separated(
149+
physics: const NeverScrollableScrollPhysics(),
150+
shrinkWrap: true,
151+
itemCount: data.sections.length,
152+
separatorBuilder: (_, __) => const SizedBox(height: 24),
153+
itemBuilder: (context, index) {
154+
final s = data.sections[index];
155+
return MyAssetTile(
156+
stockName: s.name,
157+
stockPrice: "${formatter.format(s.price)}원",
158+
percentage: "${s.percentage.toStringAsFixed(1)}%",
159+
iconColor: hexToColor(s.colorHex),
160+
);
161+
},
157162
),
163+
158164
const SizedBox(height: 32),
159165
],
160166
),

lib/presentation/my_capital/screens/order_detail.dart renamed to lib/presentation/my_capital/screens/order_screens/order_detail_screen.dart

Lines changed: 6 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,8 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_screenutil/flutter_screenutil.dart';
3-
import 'package:intl/intl.dart';
43
import 'package:jusicool_design_system/src/core/theme/colors/color_palette.dart';
54
import 'package:jusicool_design_system/src/core/theme/texts/typography.dart';
6-
7-
class OrderItem extends StatelessWidget {
8-
final String companyName;
9-
final int amount;
10-
final String statusText;
11-
12-
const OrderItem({
13-
super.key,
14-
required this.companyName,
15-
required this.amount,
16-
required this.statusText,
17-
});
18-
19-
@override
20-
Widget build(BuildContext context) {
21-
final numberFormat = NumberFormat("#,###", "en_US");
22-
final formattedAmount = numberFormat.format(amount.abs());
23-
final changeColor = amount >= 0 ? JusicoolColor.error : JusicoolColor.main;
24-
25-
return Container(
26-
width: 312.w,
27-
height: 40.h,
28-
child: Column(
29-
crossAxisAlignment: CrossAxisAlignment.start,
30-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
31-
children: [
32-
Text(
33-
companyName,
34-
style: JusicoolTypography.bodySmall.copyWith(
35-
fontSize: 16.sp,
36-
fontWeight: FontWeight.w400,
37-
color: JusicoolColor.black,
38-
),
39-
),
40-
Text(
41-
"$formattedAmount원 $statusText",
42-
style: JusicoolTypography.label.copyWith(
43-
fontSize: 12.sp,
44-
fontWeight: FontWeight.w400,
45-
color: changeColor,
46-
),
47-
),
48-
],
49-
),
50-
);
51-
}
52-
}
5+
import 'package:jusicool_ios/presentation/my_capital/screens/order_screens/order_item.dart';
536

547
class OrderDetailScreen extends StatefulWidget {
558
const OrderDetailScreen({super.key});
@@ -73,6 +26,7 @@ class _OrderDetailScreenState extends State<OrderDetailScreen>
7326
_tabController.dispose();
7427
super.dispose();
7528
}
29+
//====================================
7630

7731
List<Map<String, dynamic>> _generateDummyCompletedOrders() {
7832
final companies = [
@@ -120,6 +74,7 @@ class _OrderDetailScreenState extends State<OrderDetailScreen>
12074
return orders;
12175
}
12276

77+
//====================================
12378
@override
12479
Widget build(BuildContext context) {
12580
final dummyCompletedOrders = _generateDummyCompletedOrders();
@@ -155,7 +110,9 @@ class _OrderDetailScreenState extends State<OrderDetailScreen>
155110
overlayColor: WidgetStateProperty.resolveWith<Color?>((
156111
Set<WidgetState> states,
157112
) {
158-
return states.contains(WidgetState.focused) ? null : JusicoolColor.white;
113+
return states.contains(WidgetState.focused)
114+
? null
115+
: JusicoolColor.white;
159116
}),
160117
splashFactory: NoSplash.splashFactory,
161118
indicator: BoxDecoration(
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_screenutil/flutter_screenutil.dart';
3+
import 'package:intl/intl.dart';
4+
import 'package:jusicool_design_system/src/core/theme/colors/color_palette.dart';
5+
import 'package:jusicool_design_system/src/core/theme/texts/typography.dart';
6+
7+
class OrderItem extends StatelessWidget {
8+
final String companyName;
9+
final int amount;
10+
final String statusText;
11+
12+
const OrderItem({
13+
super.key,
14+
required this.companyName,
15+
required this.amount,
16+
required this.statusText,
17+
});
18+
19+
@override
20+
Widget build(BuildContext context) {
21+
final numberFormat = NumberFormat("#,###", "en_US");
22+
final formattedAmount = numberFormat.format(amount.abs());
23+
final changeColor = amount >= 0 ? JusicoolColor.error : JusicoolColor.main;
24+
25+
return Container(
26+
width: 312.w,
27+
height: 40.h,
28+
child: Column(
29+
crossAxisAlignment: CrossAxisAlignment.start,
30+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
31+
children: [
32+
Text(
33+
companyName,
34+
style: JusicoolTypography.bodySmall.copyWith(
35+
fontSize: 16.sp,
36+
fontWeight: FontWeight.w400,
37+
color: JusicoolColor.black,
38+
),
39+
),
40+
Text(
41+
"$formattedAmount원 $statusText",
42+
style: JusicoolTypography.label.copyWith(
43+
fontSize: 12.sp,
44+
fontWeight: FontWeight.w400,
45+
color: changeColor,
46+
),
47+
),
48+
],
49+
),
50+
);
51+
}
52+
}

lib/presentation/my_capital/screens/monthlyrevenue_screen.dart renamed to lib/presentation/my_capital/screens/revenue_screens/monthlyrevenue_screen.dart

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
33
import 'package:intl/intl.dart';
44
import 'package:jusicool_design_system/src/core/theme/colors/color_palette.dart';
55
import 'package:jusicool_design_system/src/core/theme/texts/typography.dart';
6-
import 'package:jusicool_ios/presentation/my_capital/screens/revenuecard.dart';
6+
import 'package:jusicool_ios/presentation/my_capital/screens/revenue_screens/revenuecard.dart';
77
import 'package:go_router/go_router.dart';
88

99
const adjustedTopPadding = 16.0;
@@ -31,10 +31,12 @@ class _MonthlyRevenueScreenState extends State<MonthlyRevenueScreen>
3131
super.dispose();
3232
}
3333

34+
//=========================
3435
final List<Map<String, dynamic>> revenueData = [
3536
{
3637
'date': '1월 31일',
37-
'imagePath': 'https://1000logos.net/wp-content/uploads/2016/10/Apple-Logo-500x281.png',
38+
'imagePath':
39+
'https://1000logos.net/wp-content/uploads/2016/10/Apple-Logo-500x281.png',
3840
'companyName': '애플',
3941
'amount': 123456789,
4042
'changeValue': -1000000,
@@ -43,7 +45,8 @@ class _MonthlyRevenueScreenState extends State<MonthlyRevenueScreen>
4345
},
4446
{
4547
'date': '1월 31일',
46-
'imagePath': 'https://1000logos.net/wp-content/uploads/2016/10/Apple-Logo-500x281.png',
48+
'imagePath':
49+
'https://1000logos.net/wp-content/uploads/2016/10/Apple-Logo-500x281.png',
4750
'companyName': '삼성',
4851
'amount': 987654321,
4952
'changeValue': 2000000,
@@ -53,7 +56,8 @@ class _MonthlyRevenueScreenState extends State<MonthlyRevenueScreen>
5356
},
5457
{
5558
'date': '1월 31일',
56-
'imagePath': 'https://1000logos.net/wp-content/uploads/2016/10/Apple-Logo-500x281.png',
59+
'imagePath':
60+
'https://1000logos.net/wp-content/uploads/2016/10/Apple-Logo-500x281.png',
5761
'companyName': '비트코인',
5862
'amount': 123456789,
5963
'changeValue': 0,
@@ -62,7 +66,8 @@ class _MonthlyRevenueScreenState extends State<MonthlyRevenueScreen>
6266
},
6367
{
6468
'date': '1월 30일',
65-
'imagePath': 'https://1000logos.net/wp-content/uploads/2016/10/Apple-Logo-500x281.png',
69+
'imagePath':
70+
'https://1000logos.net/wp-content/uploads/2016/10/Apple-Logo-500x281.png',
6671
'companyName': '테슬라',
6772
'amount': 333333333,
6873
'changeValue': -500000,
@@ -71,7 +76,8 @@ class _MonthlyRevenueScreenState extends State<MonthlyRevenueScreen>
7176
},
7277
{
7378
'date': '1월 30일',
74-
'imagePath': 'https://1000logos.net/wp-content/uploads/2016/10/Apple-Logo-500x281.png',
79+
'imagePath':
80+
'https://1000logos.net/wp-content/uploads/2016/10/Apple-Logo-500x281.png',
7581
'companyName': '구글',
7682
'amount': 444444444,
7783
'changeValue': 3000000,
@@ -80,14 +86,16 @@ class _MonthlyRevenueScreenState extends State<MonthlyRevenueScreen>
8086
},
8187
{
8288
'date': '1월 30일',
83-
'imagePath': 'https://1000logos.net/wp-content/uploads/2016/10/Apple-Logo-500x281.png',
89+
'imagePath':
90+
'https://1000logos.net/wp-content/uploads/2016/10/Apple-Logo-500x281.png',
8491
'companyName': '이더리움',
8592
'amount': 777777777,
8693
'changeValue': 1500000,
8794
'changePercentage': 7.9,
8895
'isStock': false,
8996
},
9097
];
98+
//=========================
9199

92100
Map<String, dynamic> _calculateTotalRevenue() {
93101
final numberFormat = NumberFormat("#,###", "en_US");
@@ -234,28 +242,36 @@ class _MonthlyRevenueScreenState extends State<MonthlyRevenueScreen>
234242
final date = item['date'] as String;
235243
final isNewDate =
236244
index == 0 || filteredData[index - 1]['date'] != date;
237-
return Column(
238-
crossAxisAlignment: CrossAxisAlignment.start,
239-
children: [
240-
if (isNewDate)
241-
Text(
242-
date,
243-
style: JusicoolTypography.bodySmall.copyWith(
244-
fontSize: 16.sp,
245-
fontWeight: FontWeight.w400,
246-
color: JusicoolColor.black,
245+
return Padding(
246+
padding: EdgeInsets.only(
247+
top: isNewDate ? 16.h : 16.h, // 수직 간격을 Padding으로 처리
248+
bottom: index == filteredData.length - 1 ? 0 : 0,
249+
),
250+
child: Column(
251+
crossAxisAlignment: CrossAxisAlignment.start,
252+
children: [
253+
if (isNewDate)
254+
Padding(
255+
padding: EdgeInsets.only(bottom: 4.h), // 날짜와 카드 사이 간격
256+
child: Text(
257+
date,
258+
style: JusicoolTypography.bodySmall.copyWith(
259+
fontSize: 16.sp,
260+
fontWeight: FontWeight.w400,
261+
color: JusicoolColor.black,
262+
),
263+
),
247264
),
265+
// 수평 간격은 RevenueCard 내부에서 Row + Padding/margin으로 처리
266+
RevenueCard(
267+
imagePath: item['imagePath'] as String,
268+
companyName: item['companyName'] as String,
269+
amount: item['amount'] as int,
270+
changeValue: item['changeValue'] as int,
271+
changePercentage: item['changePercentage'] as double,
248272
),
249-
if (isNewDate) SizedBox(height: 4.h),
250-
RevenueCard(
251-
imagePath: item['imagePath'] as String,
252-
companyName: item['companyName'] as String,
253-
amount: item['amount'] as int,
254-
changeValue: item['changeValue'] as int,
255-
changePercentage: item['changePercentage'] as double,
256-
),
257-
if (index < filteredData.length - 1) SizedBox(height: 16.h),
258-
],
273+
],
274+
),
259275
);
260276
},
261277
),

0 commit comments

Comments
 (0)