Skip to content

Commit 4d2af57

Browse files
committed
使用新的超链接API
1 parent 1c20d4a commit 4d2af57

File tree

2 files changed

+15
-24
lines changed

2 files changed

+15
-24
lines changed

build.gradle.kts

+5-4
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,16 @@ kotlin {
2626
sourceSets {
2727
val desktopMain by getting
2828
commonMain.dependencies {
29-
implementation(compose.components.resources)
30-
}
31-
32-
desktopMain.dependencies {
3329
implementation(compose.runtime)
3430
implementation(compose.foundation)
3531
implementation(compose.material)
3632
implementation(compose.ui)
3733
implementation(compose.components.uiToolingPreview)
34+
implementation(compose.components.resources)
35+
}
36+
37+
desktopMain.dependencies {
38+
implementation(compose.desktop.currentOs)
3839
implementation("org.apache.commons:commons-lang3:3.12.0")
3940
implementation("org.mapdb:mapdb:3.0.8") {
4041
exclude("org.jetbrains.kotlin", "kotlin-stdlib")
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
11
package top.ntutn.floatclock
22

33
import androidx.compose.foundation.Image
4-
import androidx.compose.foundation.layout.*
5-
import androidx.compose.foundation.text.ClickableText
4+
import androidx.compose.foundation.layout.Column
5+
import androidx.compose.foundation.layout.Spacer
6+
import androidx.compose.foundation.layout.fillMaxSize
7+
import androidx.compose.foundation.layout.height
8+
import androidx.compose.foundation.layout.size
69
import androidx.compose.material.Text
710
import androidx.compose.runtime.Composable
811
import androidx.compose.ui.Alignment
912
import androidx.compose.ui.Modifier
10-
import androidx.compose.ui.graphics.Color
11-
import androidx.compose.ui.text.SpanStyle
13+
import androidx.compose.ui.text.LinkAnnotation
1214
import androidx.compose.ui.text.buildAnnotatedString
13-
import androidx.compose.ui.text.font.FontWeight
14-
import androidx.compose.ui.text.withStyle
15+
import androidx.compose.ui.text.withLink
1516
import androidx.compose.ui.unit.dp
16-
import kotlinx.coroutines.Dispatchers
17-
import kotlinx.coroutines.GlobalScope
18-
import kotlinx.coroutines.launch
1917
import org.jetbrains.compose.resources.painterResource
2018
import top.ntutn.floatclock.generated.resources.Res
2119
import top.ntutn.floatclock.generated.resources.clock
22-
import top.ntutn.floatclock.util.DesktopBrowse
23-
import java.net.URI
2420

2521
@Composable
2622
fun AboutContent() {
@@ -37,16 +33,10 @@ fun AboutContent() {
3733
Spacer(modifier.height(8.dp))
3834
Text("${BuildConfig.APP_NAME} ${BuildConfig.APP_VERSION}", modifier = modifier)
3935
Spacer(modifier.height(8.dp))
40-
ClickableText(buildAnnotatedString {
41-
pushStringAnnotation(tag = "URL", annotation = url)
42-
withStyle(style = SpanStyle(color = Color.Blue, fontWeight = FontWeight.Bold)) {
36+
Text(buildAnnotatedString {
37+
withLink(LinkAnnotation.Url(url)) {
4338
append(url)
4439
}
45-
pop()
46-
}, modifier = modifier, onClick = {
47-
GlobalScope.launch(Dispatchers.Default) {
48-
DesktopBrowse.browse(URI.create(url))
49-
}
50-
})
40+
}, modifier = modifier)
5141
}
5242
}

0 commit comments

Comments
 (0)