# 코드리뷰 - Flutter & Vue.js (2022.10.26)
# 캠페인 모델 관련 이슈
- campaign --> currentCampaign
# 모델 내부 코드 일부분
# as is
Future<void> fetcheDetail(Campaign? campaign) async {
if (campaign == null) return;
this.campaign = campaign;
busy();
try {
campaignApply = await _campaignService.getCampaignApply(campaign.id);
} finally {
idle();
}
if (campaignApply != null) {
isAppliedCampaign = true;
if (campaignApply?.state == "allowed") {
isInviteCampaign = true;
} else if (campaignApply?.state == "refused") {
isRefusedCampaign = true;
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# to be 1
Future<void> fetcheDetail(int campaignId) async {
currentCampaign = await _campaignService.getCampaignDetail(campaignId);
}
class Campaign {
...
bool get applied => ...;
bool get invited => ...;
bool get refused => ...;
...
}
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
# to be 2
Future<void> fetcheDetail(int campaignId) async {
_currentCampaignId = campaignId;
campaigns[campaignId] = await _campaignService.getCampaignDetail(campaignId);
}
Campaign get currentCampaing => campaigns[_currentCampaignId];
class Campaign {
...
bool get applied => ...;
bool get invited => ...;
bool get refused => ...;
...
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
# view 객체에서 사용하고 있는 일부 코드
# as is
Widget _bannerGuide() {
final platformTitle =_campaign?.platform?.title ?? '';
if ((_model.isAppliedCampaign == true &&
_model.isInviteCampaign == false) &&
platformTitle == "naver_blog") {
return Visibility(
visible: (_model.isAppliedCampaign == true &&
_model.isInviteCampaign == false) &&
platformTitle == "naver_blog",
child: Container(
margin: EdgeInsets.only(bottom: h(35)),
child: Column(
children: [
Row(
...
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
...
],
),
SizedBox(height: h(15)),
FutureBuilder( ... ),
SizedBox(height: h(15)),
_copyBannerImageUrlButton(),
],
)),
);
} else {
return Container();
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# to be
Widget _bannerGuide() {
final platformTitle =_campaign?.platform?.title ?? '';
final needToShow =
_model.currentCampaign.applied &&
(_model.currentCampaign.invited == false) &&
(platformTitle == "naver_blog");
if (needToShow == false) return Container();
return Container(
margin: EdgeInsets.only(bottom: h(35)),
child: Column(
children: [
Row(
...
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
...
],
),
SizedBox(height: h(15)),
FutureBuilder( ... ),
SizedBox(height: h(15)),
_copyBannerImageUrlButton(),
],
),
);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# null safe issue
# List<dynamic>
# as is
ages: (json['ages'] as List<dynamic>?)?.map((e) => e as String).toList(),
1
# to be
ages: (json['ages'] as List<dynamic>?)?
.map((e) => (e ?? "") as String).toList(),
1
2
2
# check validation
# as is
void _checkAllValidation() {
if (bankController.text.length == 0) {
setState(() {
isFormValid = false;
});
return;
}
if (bankAccountController.text.length == 0) {
setState(() {
isFormValid = false;
});
return;
}
if (bankNameController.text.length == 0) {
setState(() {
isFormValid = false;
});
return;
}
if ((bankFileNameController.text.isEmpty) && (_model?.bankImage?.isEmpty ?? true)) {
setState(() {
isFormValid = false;
});
return;
}
if ((idenFileNameController.text.isEmpty) && (_model?.idenImage?.isEmpty ?? true)) {
setState(() {
isFormValid = false;
});
return;
}
if (frontNumController.text.length != 6) {
setState(() {
isFormValid = false;
});
return;
}
if (backNumController.text.length != 7) {
setState(() {
isFormValid = false;
});
return;
}
if (relationShipController.text.length == 0) {
setState(() {
isFormValid = false;
});
return;
}
setState(() {
isFormValid = true;
});
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# to be 1
void _checkAllValidation() {
setState(() {
isFormValid =
bankController.text.isNotEmpty &&
bankAccountController.text.isNotEmpty &&
bankNameController.text.isNotEmpty &&
bankFileNameController.text.isNotEmpty &&
_model?.bankImage?.isNotEmpty &&
idenFileNameController.text.isNotEmpty &&
_model?.idenImage?.isNotEmpty &&
frontNumController.text.isNotEmpty &&
backNumController.text.isNotEmpty &&
relationShipController.text.isNotEmpty;
});
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# to be 2
# Coumputed의 getter & setter
computed: {
agreeAll: {
get() {
return this.agrees.every((agree) => agree);
},
set(value) {
this.agrees.forEach((agree, index) => {
this.agrees[index] = value;
});
},
},
},
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12