Skip to content

Conversation

@Omj-8
Copy link

@Omj-8 Omj-8 commented Aug 20, 2025

task3

  • 下にスワイプして更新できる機能追加
  • 更新失敗時にエラーメッセージ表示
  • 更新用testの追加

Comment on lines 108 to 112
SwipeRefresh(
state = swipeRefreshState,
onRefresh = { viewModel.refreshMessages() },
modifier = Modifier.fillMaxSize()
) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[必須]
AccompanistのSwipeRefreshは最新のAccompanistでは削除されました。
google/accompanist#1797

AccompanistからSwipeRefreshが消えた理由はCompose公式でPullToRefreshがサポートされたからです。
なので、公式のPullToRefreshBoxを使う形に変えたほうが良さそうです。
https://developer.android.com/develop/ui/compose/components/pull-to-refresh

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ビルド時にワーニングも出てました

w: file:///Users/i001197/work/android/android-developer-journey/feature/communicate/src/main/java/com/cybozu/sample/kintone/spaces/feature/communicate/thread/ThreadScreen.kt:68:29 'fun rememberSwipeRefreshState(isRefreshing: Boolean): SwipeRefreshState' is deprecated. accompanist/swiperefresh is deprecated.
The androidx.compose equivalent of rememberSwipeRefreshState() is rememberPullRefreshState().
For more migration information, please visit https://google.github.io/accompanist/swiperefresh/#migration.

Column(horizontalAlignment = Alignment.CenterHorizontally) {
CircularProgressIndicator()
Spacer(modifier = Modifier.height(16.dp))
Text("Loarding...")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Good]
ロード中、インジケータだけじゃなくてテキストでロード状態を伝えるテキストを出すのはユーザに優しくていいですね!

(たまたま誤字見つけました)

Suggested change
Text("Loarding...")
Text("Loading...")

Comment on lines 96 to 98
is ThreadUiState.Initial -> {
Text("Initial State")
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[必須]
ユーザに「Initial State」と提示するのは伝わらなさそうに思いました。
InitialのときのTextは無くて良さそうですね。

successState.threadMessage[1].body shouldBe "thread-2"
successState.threadMessage[1].creator shouldBe Creator(name = "name2")

cancelAndIgnoreRemainingEvents()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[質問]
これってなんで必要なんです?
ViewModelの実装をみていると、2回目のSuccessの後はState更新がないのが期待動作のように見えるんですが。。。

Comment on lines +87 to +94
val initialState = awaitItem()
(initialState is ThreadUiState.Initial) shouldBe true

val loadingState = awaitItem()
(loadingState is ThreadUiState.Loading) shouldBe true

val loadedState = awaitItem()
(loadedState is ThreadUiState.Success)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[任意]
余裕があれば、1回目のデータと2回目のデータが違うことも検証してみてください!

例(このパターンじゃなくてもOKです)
1回目は2つのメッセージが取れる
2回目は3つのメッセージが取れる

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants