common: make UrlLauncher use expect/actual

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
Harsh Shandilya 2021-03-15 00:00:37 +05:30
parent 3021f96465
commit f5c3a950bf
No known key found for this signature in database
GPG key ID: 366D7BBAD1031E80
5 changed files with 15 additions and 11 deletions

View file

@ -3,10 +3,9 @@ package dev.msfjarvis.lobsters.ui.urllauncher
import android.content.Context
import android.net.Uri
import androidx.browser.customtabs.CustomTabsIntent
import dev.msfjarvis.lobsters.ui.urllauncher.UrlLauncher
class AndroidUrlLauncherImpl(private val context: Context) : UrlLauncher {
override fun launch(url: String) {
actual class UrlLauncher(private val context: Context) {
actual fun launch(url: String) {
val customTabsIntent = CustomTabsIntent.Builder()
.setShareState(CustomTabsIntent.SHARE_STATE_ON)
.setShowTitle(true)

View file

@ -1,5 +1,5 @@
package dev.msfjarvis.lobsters.ui.urllauncher
fun interface UrlLauncher {
expect class UrlLauncher {
fun launch(url: String)
}

View file

@ -3,8 +3,8 @@ package dev.msfjarvis.lobsters.ui.urllauncher
import java.awt.Desktop
import java.net.URI
class JVMUrlLauncherImpl() : UrlLauncher {
override fun launch(url: String) {
actual class UrlLauncher {
actual fun launch(url: String) {
val desktop = Desktop.getDesktop()
if (Desktop.isDesktopSupported() && desktop.isSupported(Desktop.Action.BROWSE)) {