스팀 앱 - 개발 중: 사용자 히스토리 항목 클릭 (8) 내용 정리: AccountHistoryItemLink 리스트를 정의하기 위한 AccountHistoryItem 클래스의 확장 함수 추가

스팀 앱 - 개발 중: 사용자 히스토리 항목 클릭 (8) 내용 정리: AccountHistoryItemLink 리스트를 정의하기 위한 AccountHistoryItem 클래스의 확장 함수 추가

2024. 08. 27 (화) | Written by @dorian-mobileapp

지난 포스트에서 AccountHistoryItemLink 데이터 클래스를 소개했습니다. 오늘은 AccountHistoryItem 객체의 내용을 활용하여 AccountHistoryItemLink 리스트를 생성하는 방법을 정리합니다.

개별 AccountHistoryItem 객체로부터 AccountHistoryItemLink 리스트 생성

AccountHistoryItem 객체의 type 값이 무엇이냐에 따라 AccountHistoryItemLink 리스트 생성하는 각기 다른 메소드들을 호출합니다.

fun AccountHistoryItem.getLinkList(): List<AccountHistoryItemLink> {
    return when (type) {
        "author_reward" -> getAuthorRewardLinks()
        "comment" -> getCommentLinks()
        "comment_benefactor_reward" -> getCommentBenefactorRewardLinks()
        "curation_reward" -> getCurationRewardLinks()
        "transfer" -> getTransferLinks()
        "transfer_to_vesting" -> getTransferToVestingLinks()
        "vote" -> getVoteLinks()
        else -> listOf()
    }
}

AccountHistoryItem.get...Links() 확장 함수들

아래 함수는 저자 보상 항목의 링크 리스트를 생성합니다.

fun AccountHistoryItem.getAuthorRewardLinks(): List<AccountHistoryItemLink> {
    val author = content.read("author", "")
    val permlink = content.read("permlink", "")

    return listOf(
        AccountHistoryItemLink("profile", "@${author}", "@${author}"),
        AccountHistoryItemLink("post", "@${author}/${permlink}", "@${author}/${permlink}")
    )
}
  • AccountHistoryItemLink("profile", "@${author}", "@${author}")
    • "profile": 클릭시 프로필 화면으로 연결하기 위함입니다.
    • "@${author}": 팝업 메뉴의 항목 이름으로 보여지는 것입니다. (예: "@dorian-mobileapp")
    • "@${author}": 프로필 화면으로 연결하기 위한 계정입니다.(예: "@dorian-mobileapp")
  • AccountHistoryItemLink("post", "@${author}/${permlink}", "@${author}/${permlink}")
    • "post": 클릭시 포스트 화면으로 연결하기 위함입니다.
    • "@${author}/${permlink}": 팝업 메뉴의 항목 이름으로 보여지는 것입니다. (예: "@dorian-mobileapp/100")
    • "@${author}/${permlink}": 포스트 화면으로 연결하기 위한 주소입니다.(예: "@dorian-mobileapp/100")

나머지 get...Links() 메소드들은 편의상 생략합니다. 나중에 GitHub commit 링크를 공유드릴께요.


Layout provided by Steemit Enhancer hommage by ayogom


Posted through the ECblog app (https://blog.etain.club)
Sort:  

[광고] STEEM 개발자 커뮤니티에 참여 하시면, 다양한 혜택을 받을 수 있습니다.

Coin Marketplace

STEEM 0.04
TRX 0.33
JST 0.097
BTC 64507.51
ETH 1870.78
USDT 1.00
SBD 0.38