Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QR 코드 화면에 대해 ambient mode 대응 #18

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.viewModels
import com.google.android.horologist.compose.ambient.AmbientAware
import dagger.hilt.android.AndroidEntryPoint
import dev.yjyoon.kwlibrarywearos.ui.account.AccountActivity
import dev.yjyoon.kwlibrarywearos.ui.model.User
Expand All @@ -20,11 +21,14 @@ class QrCodeActivity : ComponentActivity() {
super.onCreate(savedInstanceState)

setContent {
KwLibraryTheme {
QrCodeScreen(
viewModel = viewModel,
navigateToAccount = ::startAccountActivity
)
AmbientAware(isAlwaysOnScreen = true) {
KwLibraryTheme {
QrCodeScreen(
viewModel = viewModel,
navigateToAccount = ::startAccountActivity,
ambientStateUpdate = it
)
}
}
}
}
Expand All @@ -41,4 +45,4 @@ class QrCodeActivity : ComponentActivity() {
context.startActivity(intent)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import androidx.wear.compose.material.CompactButton
import androidx.wear.compose.material.Icon
import androidx.wear.compose.material.Scaffold
import androidx.wear.compose.material.TimeText
import com.google.android.horologist.compose.ambient.AmbientState
import com.google.android.horologist.compose.layout.fillMaxRectangle
import dev.yjyoon.kwlibrarywearos.ui.component.ForceBrightness
import dev.yjyoon.kwlibrarywearos.ui.util.QrCodeUtil.convertToQrCode
Expand All @@ -26,7 +27,8 @@ import dev.yjyoon.kwlibrarywearos.ui.util.QrCodeUtil.convertToQrCode
fun QrCodeContent(
qrcode: String,
onRefresh: () -> Unit,
onSetting: () -> Unit
onSetting: () -> Unit,
ambientState: AmbientState
) {
ForceBrightness(1f)
Scaffold(timeText = { TimeText() }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import androidx.compose.material.icons.filled.WifiOff
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import com.google.android.horologist.compose.ambient.AmbientState
import com.google.android.horologist.compose.ambient.AmbientStateUpdate
import dev.yjyoon.kwlibrarywearos.R
import dev.yjyoon.kwlibrarywearos.data.exception.FailedToSignInException
import dev.yjyoon.kwlibrarywearos.ui.component.AlertComponent
Expand All @@ -16,30 +18,34 @@ import dev.yjyoon.kwlibrarywearos.ui.component.LoadingComponent
@Composable
fun QrCodeScreen(
viewModel: QrCodeViewModel,
navigateToAccount: () -> Unit
navigateToAccount: () -> Unit,
ambientStateUpdate: AmbientStateUpdate,
) {
val state by viewModel.uiState.collectAsState()

QrCodeScreen(
uiState = state,
navigateToAccount = navigateToAccount,
refreshQrCode = viewModel::refresh
refreshQrCode = viewModel::refresh,
ambientState = ambientStateUpdate.ambientState,
)
}

@Composable
fun QrCodeScreen(
uiState: QrCodeUiState,
navigateToAccount: () -> Unit,
refreshQrCode: () -> Unit
refreshQrCode: () -> Unit,
ambientState: AmbientState
) {

when (uiState) {
is QrCodeUiState.Success -> {
QrCodeContent(
qrcode = uiState.qrcode,
onRefresh = refreshQrCode,
onSetting = navigateToAccount
onSetting = navigateToAccount,
ambientState = ambientState
)
}

Expand Down