Skip to content

Commit

Permalink
🎨 优化
Browse files Browse the repository at this point in the history
  • Loading branch information
yaoxieyoulei committed May 28, 2024
1 parent db52e79 commit 3d6585e
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 26 deletions.
1 change: 1 addition & 0 deletions app/src/main/java/top/yogiczy/mytv/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class MainActivity : ComponentActivity() {
SP.AppDeviceDisplayType.PAD -> PadActivity::class.java
}

// TODO 切换时变化生硬
startActivity(Intent(this, activityClass).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ private fun LeanbackMainScreenError(message: String?, serverUrl: String = HttpSe
.width(100.dp)
.height(100.dp)
.background(
androidx.tv.material3.MaterialTheme.colorScheme.onBackground,
androidx.tv.material3.MaterialTheme.shapes.medium,
color = MaterialTheme.colorScheme.onBackground,
shape = MaterialTheme.shapes.medium,
),
) {
Image(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,37 @@ package top.yogiczy.mytv.ui.screens.leanback.settings.components

import android.content.Context
import android.content.pm.PackageInfo
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.DialogProperties
import androidx.tv.foundation.lazy.list.TvLazyColumn
import io.github.alexzhirkevich.qrose.options.QrBallShape
import io.github.alexzhirkevich.qrose.options.QrFrameShape
import io.github.alexzhirkevich.qrose.options.QrPixelShape
import io.github.alexzhirkevich.qrose.options.QrShapes
import io.github.alexzhirkevich.qrose.options.circle
import io.github.alexzhirkevich.qrose.options.roundCorners
import io.github.alexzhirkevich.qrose.rememberQrCodePainter
import top.yogiczy.mytv.data.utils.Constants
import top.yogiczy.mytv.ui.theme.LeanbackTheme

Expand Down Expand Up @@ -38,10 +61,48 @@ fun LeanbackSettingsCategoryAbout(
}

item {
var showQrDialog by remember { mutableStateOf(false) }

LeanbackSettingsCategoryListItem(
headlineContent = "代码仓库",
trailingContent = Constants.APP_REPO,
onSelected = { showQrDialog = true },
)

if (showQrDialog) {
AlertDialog(
properties = DialogProperties(usePlatformDefaultWidth = false),
onDismissRequest = { showQrDialog = false },
confirmButton = { Text(text = "扫码前往代码仓库") },
text = {
Box(
modifier = Modifier
.width(240.dp)
.height(240.dp)
.background(
color = MaterialTheme.colorScheme.onBackground,
shape = MaterialTheme.shapes.medium,
)
) {
Image(
modifier = Modifier
.fillMaxSize()
.align(Alignment.Center)
.padding(10.dp),
painter = rememberQrCodePainter(
data = Constants.APP_REPO,
shapes = QrShapes(
ball = QrBallShape.circle(),
darkPixel = QrPixelShape.roundCorners(),
frame = QrFrameShape.roundCorners(.25f),
),
),
contentDescription = Constants.APP_REPO,
)
}
},
)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand All @@ -24,6 +29,7 @@ import io.github.alexzhirkevich.qrose.options.QrShapes
import io.github.alexzhirkevich.qrose.options.circle
import io.github.alexzhirkevich.qrose.options.roundCorners
import io.github.alexzhirkevich.qrose.rememberQrCodePainter
import kotlinx.coroutines.delay
import top.yogiczy.mytv.ui.theme.LeanbackTheme
import top.yogiczy.mytv.ui.utils.HttpServer

Expand All @@ -45,32 +51,41 @@ fun LeanbackSettingsCategoryMore(
}

item {
Row(
horizontalArrangement = Arrangement.End,
modifier = Modifier.fillMaxWidth(),
) {
Box(
modifier = Modifier
.width(200.dp)
.height(200.dp)
.background(
MaterialTheme.colorScheme.onBackground,
MaterialTheme.shapes.medium,
)
.padding(10.dp),
var show by remember { mutableStateOf(false) }

LaunchedEffect(Unit) {
delay(100)
show = true
}

if (show) {
Row(
horizontalArrangement = Arrangement.End,
modifier = Modifier.fillMaxWidth(),
) {
Image(
modifier = modifier.fillMaxSize(),
painter = rememberQrCodePainter(
data = serverUrl,
shapes = QrShapes(
ball = QrBallShape.circle(),
darkPixel = QrPixelShape.roundCorners(),
frame = QrFrameShape.roundCorners(.25f),
Box(
modifier = Modifier
.width(200.dp)
.height(200.dp)
.background(
MaterialTheme.colorScheme.onBackground,
MaterialTheme.shapes.medium,
)
.padding(10.dp),
) {
Image(
modifier = modifier.fillMaxSize(),
painter = rememberQrCodePainter(
data = serverUrl,
shapes = QrShapes(
ball = QrBallShape.circle(),
darkPixel = QrPixelShape.roundCorners(),
frame = QrFrameShape.roundCorners(.25f),
),
),
),
contentDescription = serverUrl,
)
contentDescription = serverUrl,
)
}
}
}
}
Expand Down

0 comments on commit 3d6585e

Please sign in to comment.