Replace Kotlin browser APIs with common APIs
This commit is contained in:
parent
00d8318818
commit
eef9608778
3 changed files with 6 additions and 17 deletions
|
@ -1,32 +1,19 @@
|
||||||
package dev.anandbose.ui.app
|
package dev.anandbose.ui.app
|
||||||
|
|
||||||
import anandbose.composeapp.generated.resources.Res
|
|
||||||
import anandbose.composeapp.generated.resources.social_bluesky
|
|
||||||
import anandbose.composeapp.generated.resources.social_github
|
|
||||||
import anandbose.composeapp.generated.resources.social_linkedin
|
|
||||||
import anandbose.composeapp.generated.resources.social_mastodon
|
|
||||||
import anandbose.composeapp.generated.resources.social_medium
|
|
||||||
import anandbose.composeapp.generated.resources.social_twitter
|
|
||||||
import androidx.compose.foundation.isSystemInDarkTheme
|
import androidx.compose.foundation.isSystemInDarkTheme
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.BoxWithConstraints
|
import androidx.compose.foundation.layout.BoxWithConstraints
|
||||||
import androidx.compose.foundation.layout.Column
|
|
||||||
import androidx.compose.foundation.layout.Row
|
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.layout.widthIn
|
import androidx.compose.foundation.layout.widthIn
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
|
||||||
import androidx.compose.foundation.lazy.grid.GridCells
|
import androidx.compose.foundation.lazy.grid.GridCells
|
||||||
import androidx.compose.foundation.lazy.grid.GridItemSpan
|
import androidx.compose.foundation.lazy.grid.GridItemSpan
|
||||||
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
||||||
import androidx.compose.foundation.lazy.grid.items
|
import androidx.compose.foundation.lazy.grid.items
|
||||||
import androidx.compose.foundation.lazy.items
|
|
||||||
import androidx.compose.foundation.rememberScrollState
|
|
||||||
import androidx.compose.foundation.shape.CircleShape
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
import androidx.compose.foundation.verticalScroll
|
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Scaffold
|
import androidx.compose.material3.Scaffold
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
|
|
|
@ -12,8 +12,8 @@ import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.ColorFilter
|
import androidx.compose.ui.graphics.ColorFilter
|
||||||
import androidx.compose.ui.graphics.painter.Painter
|
import androidx.compose.ui.graphics.painter.Painter
|
||||||
|
import androidx.compose.ui.platform.LocalUriHandler
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import kotlinx.browser.window
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun UrlButtonLarge(
|
fun UrlButtonLarge(
|
||||||
|
@ -22,6 +22,7 @@ fun UrlButtonLarge(
|
||||||
text: String,
|
text: String,
|
||||||
url: String,
|
url: String,
|
||||||
) {
|
) {
|
||||||
|
val uriHandler = LocalUriHandler.current
|
||||||
Button(
|
Button(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
shape = MaterialTheme.shapes.medium,
|
shape = MaterialTheme.shapes.medium,
|
||||||
|
@ -45,7 +46,7 @@ fun UrlButtonLarge(
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onClick = {
|
onClick = {
|
||||||
window.open(url, "_blank")
|
uriHandler.openUri(url)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
|
@ -10,8 +10,8 @@ import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.ColorFilter
|
import androidx.compose.ui.graphics.ColorFilter
|
||||||
import androidx.compose.ui.graphics.painter.Painter
|
import androidx.compose.ui.graphics.painter.Painter
|
||||||
|
import androidx.compose.ui.platform.LocalUriHandler
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import kotlinx.browser.window
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun UrlButtonSmall(
|
fun UrlButtonSmall(
|
||||||
|
@ -20,6 +20,7 @@ fun UrlButtonSmall(
|
||||||
text: String,
|
text: String,
|
||||||
url: String,
|
url: String,
|
||||||
) {
|
) {
|
||||||
|
val uriHandler = LocalUriHandler.current
|
||||||
Button(
|
Button(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
content = {
|
content = {
|
||||||
|
@ -38,7 +39,7 @@ fun UrlButtonSmall(
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
onClick = {
|
onClick = {
|
||||||
window.open(url, "_blank")
|
uriHandler.openUri(url)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue