diff --git a/lun_launcher/src/main/java/bums/lunatic/launcher/presentation/MainActivity.kt b/lun_launcher/src/main/java/bums/lunatic/launcher/presentation/MainActivity.kt index e38f1a49..92baad97 100644 --- a/lun_launcher/src/main/java/bums/lunatic/launcher/presentation/MainActivity.kt +++ b/lun_launcher/src/main/java/bums/lunatic/launcher/presentation/MainActivity.kt @@ -14,6 +14,9 @@ import androidx.activity.compose.setContent import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.runtime.Composable @@ -22,6 +25,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview +import androidx.wear.compose.material.Button import androidx.wear.compose.material.MaterialTheme import androidx.wear.compose.material.Text import androidx.wear.compose.material.TimeText @@ -40,7 +44,9 @@ class MainActivity : ComponentActivity() , SensorEventListener { setTheme(android.R.style.Theme_DeviceDefault) setContent { - WearApp("Android") + WearApp("Android",sendGestureToLauncher = { text -> + sendGestureToLauncher(text) + }) } } @@ -53,7 +59,6 @@ class MainActivity : ComponentActivity() , SensorEventListener { event?.let { if (it.sensor.type == Sensor.TYPE_ACCELEROMETER) { val x = it.values[0] - // 임계값(Threshold)을 약간 높여 오작동 방지 if (x > 20f) { sendGestureToLauncher("/gesture/next") @@ -74,7 +79,7 @@ class MainActivity : ComponentActivity() , SensorEventListener { } @Composable -fun WearApp(greetingName: String) { +fun WearApp(greetingName: String,sendGestureToLauncher : (String) -> Unit = {}) { LunarLauncherTheme { Box( modifier = Modifier @@ -83,19 +88,49 @@ fun WearApp(greetingName: String) { contentAlignment = Alignment.Center ) { TimeText() - Greeting(greetingName = greetingName) + Greeting(greetingName = greetingName, + sendGestureToLauncher = {text -> + sendGestureToLauncher(text) + }) } } } @Composable -fun Greeting(greetingName: String) { - Text( - modifier = Modifier.fillMaxWidth(), - textAlign = TextAlign.Center, - color = MaterialTheme.colors.primary, - text = stringResource(R.string.hello_world, greetingName) - ) +fun Greeting(greetingName: String, sendGestureToLauncher : (String) -> Unit = {}) { + +// Text( +// modifier = Modifier.fillMaxWidth(), +// textAlign = TextAlign.Center, +// color = MaterialTheme.colors.primary, +// text = stringResource(R.string.hello_world, greetingName) +// ) + Column(Modifier.fillMaxWidth().fillMaxHeight()) { + Row(Modifier.fillMaxWidth().weight(0.5f)) { + Button(modifier = Modifier.weight(0.5f).fillMaxHeight(), onClick = { + sendGestureToLauncher("/gesture/next") + }) { + Text("B1") + } + Button(modifier = Modifier.weight(0.5f).fillMaxHeight(), onClick = { + sendGestureToLauncher("/gesture/prev") + }) { + Text("B2") + } + } + Row(Modifier.fillMaxWidth().weight(0.5f)) { + Button(modifier = Modifier.weight(0.5f).fillMaxHeight(), onClick = { + sendGestureToLauncher("/gesture/back") + }) { + Text("B3") + } + Button(modifier = Modifier.weight(0.5f).fillMaxHeight(), onClick = { + sendGestureToLauncher("/gesture/refresh") + }) { + Text("B4") + } + } + } } @Preview(device = WearDevices.SMALL_ROUND, showSystemUi = true)