스팀 앱 - 개발 중: 사용자 히스토리 항목 클릭 (4) 내용 정리: 프래그먼트 간 내비게이션

스팀 앱 - 개발 중: 사용자 히스토리 항목 클릭 (4) 내용 정리: 프래그먼트 간 내비게이션

2024. 08. 21 (수) | Written by @dorian-mobileapp


내용 정리가 필요하다고 생각합니다. 모든 걸 정리할 수는 없겠지만, 개략적인 점들만이라도 적어 두는 게 좋지 않을까 해요. 그렇게 하고 다음 단계로 넘어가야 나중에 혼란이 덜 할 거예요.

프래그먼트 간 이동

프래그먼트의 이동은 mobile_navigation.xml 파일에 정의합니다. 사용자 히스토리 화면(AccountHistoryFragment)에서 팝업 메뉴 항목을 클릭하면, 프로필(ProfileFragment)/포스트(PostContentFragment)/지갑(WalletFragment) 화면 중 하나로 이동합니다. 이를 위해 아래와 같이 action 요소들을 fragment 요소에 추가하였습니다.

<fragment
    android:id="@+id/navigation_account_history"
    android:name="lee.dorian.steem_ui.ui.history.AccountHistoryFragment"
    android:label="Account History"
    tools:layout="@layout/fragment_account_history">
    <argument
        android:name="author"
        app:argType="string" />
    <action
       
 android:id="@+id/action_navigation_account_history_to_navigation_post"
        app:destination="@id/navigation_post" />
    <action
        android:id="@+id/action_navigation_account_history_to_navigation_profile"
        app:destination="@id/navigation_profile" />
    <action
        android:id="@+id/action_navigation_account_history_to_navigation_wallet"
        app:destination="@id/navigation_wallet" />
</fragment>

ProfileFragment에 파라메터 추가

AccountHistoryFragment에서 ProfileFragment로 이동할 때 전자가 후자에게 스팀잇 계정을 보내줘야 합니다. 그래야 후자가 계정의 프로필을 보여줄 수 있기 때문입니다. 이것은 ProfileFragment에 해당하는 fragment 요소에 argument 요소를 아래와 같이 추가하면 됩니다. 파라메터의 이름은 account이고, 데이터 타입은 string이며, 디폴트 값은 빈 값입니다.

<fragment
    android:id="@+id/navigation_profile"
    android:name="lee.dorian.steem_ui.ui.profile.ProfileFragment"
    android:label="@string/title_profile"
    tools:layout="@layout/fragment_profile" >
    <argument
        android:name="account"
        app:argType="string"
        android:defaultValue="" />
    <action
        android:id="@+id/action_navigation_profile_to_navigation_post_list"
        app:destination="@id/navigation_post_list" />
    <action
        android:id="@+id/action_navigation_profile_to_navigation_account_history"
        app:destination="@id/navigation_account_history" />
</fragment>

WalletFragment에 파라메터 추가

WalletFragment도 마찬가지로 account 파라메터가 필요하죠. 위와 같은 방식으로 fragment 요소에 argument 요소를 추가했습니다.

<fragment
    android:id="@+id/navigation_wallet"
    android:name="lee.dorian.steem_ui.ui.wallet.WalletFragment"
    android:label="@string/title_wallet"
    tools:layout="@layout/fragment_wallet">
    <argument
        android:name="account"
        app:argType="string"
        android:defaultValue="" />
</fragment>

마치며...

많은 내용을 한 포스트에 넣는 것보다는 하나의 파일 단위로 내용 정리를 하는 게 효율적인 것 같습니다. 이번 주에는 이런 방식으로 내용 정리를 하려고 합니다. 너무 오래 끌지는 않도록 할께요. 다음 작업도 늦지 않게 해야 하니까요.


Layout provided by Steemit Enhancer hommage by ayogom


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

Thank you, friend!
I'm @steem.history, who is steem witness.
Thank you for witnessvoting for me.
image.png
please click it!
image.png
(Go to https://steemit.com/~witnesses and type fbslo at the bottom of the page)

The weight is reduced because of the lack of Voting Power. If you vote for me as a witness, you can get my little vote.

안녕하세요.
SteemitKorea팀에서 제공하는 'steemit-enhancer'를 사용해 주셔서 감사합니다. 개선 사항이 있으면 언제나 저에게 연락을 주시면 되고, 관심이 있으신 분들은 https://cafe.naver.com/steemitkorea/425 에서 받아보실 수 있습니다. 사용시 @응원해 가 포함이 되며, 악용시에는 모든 서비스에서 제외될 수 있음을 알려드립니다.

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


안녕하세요.
이 글은 SteemitKorea팀(@ayogom)님께서 저자이신 @dorian-mobileapp님을 응원하는 글입니다.
소정의 보팅을 해드렸습니다 ^^ 항상 좋은글 부탁드립니다
SteemitKorea팀에서는 보다 즐거운 steemit 생활을 위해 노력하고 있습니다.
이 글은 다음날 다시 한번 포스팅을 통해 소개 될 예정입니다. 감사합니다!

Upvoted! Thank you for supporting witness @jswit.

Coin Marketplace

STEEM 0.19
TRX 0.16
JST 0.033
BTC 64105.03
ETH 2757.74
USDT 1.00
SBD 2.66