Skip to content

Commit 00c43f2

Browse files
committed
✨ UiModel -> Model 확장함수 추가
1 parent c1a3855 commit 00c43f2

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

presentation/src/main/java/com/whyranoid/presentation/model/GroupInfoUiModel.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ data class GroupInfoUiModel(
1414
val leader: UserUiModel
1515
) : Parcelable
1616

17+
fun GroupInfoUiModel.toGroupInfo() =
18+
GroupInfo(
19+
name = this.name,
20+
groupId = this.groupId,
21+
introduce = this.introduce,
22+
rules = this.rules.map { rule ->
23+
rule.toRule()
24+
},
25+
headCount = this.headCount,
26+
leader = this.leader.toUser()
27+
)
28+
1729
fun GroupInfo.toGroupInfoUiModel() =
1830
GroupInfoUiModel(
1931
name = this.name,

presentation/src/main/java/com/whyranoid/presentation/model/RuleUiModel.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ data class RuleUiModel(
1616
}
1717
}
1818

19+
fun RuleUiModel.toRule() =
20+
Rule(
21+
dayOfWeek = this.dayOfWeek,
22+
hour = this.hour,
23+
minute = this.minute
24+
)
25+
1926
fun Rule.toRuleUiModel() =
2027
RuleUiModel(
2128
dayOfWeek = this.dayOfWeek,

presentation/src/main/java/com/whyranoid/presentation/model/UserUiModel.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ data class UserUiModel(
1111
val profileUrl: String?
1212
) : Parcelable
1313

14+
fun UserUiModel.toUser() =
15+
User(
16+
uid = this.uid,
17+
name = this.name,
18+
profileUrl = this.profileUrl
19+
)
20+
1421
fun User.toUserUiModel() =
1522
UserUiModel(
1623
uid = this.uid,

0 commit comments

Comments
 (0)