fix-ups for Non-Mac system

This commit is contained in:
shabinder 2021-05-08 23:20:49 +05:30
parent 1776b67306
commit 789818474e
11 changed files with 110 additions and 93 deletions

View File

@ -29,7 +29,6 @@ allprojects {
maven(url = "https://dl.bintray.com/ekito/koin") maven(url = "https://dl.bintray.com/ekito/koin")
maven(url = "https://kotlin.bintray.com/kotlinx/") maven(url = "https://kotlin.bintray.com/kotlinx/")
maven(url = "https://dl.bintray.com/icerockdev/moko") maven(url = "https://dl.bintray.com/icerockdev/moko")
// maven(url = "https://kotlin.bintray.com/kotlin-js-wrappers/")
maven(url = "https://dl.bintray.com/kotlin/kotlin-js-wrappers") maven(url = "https://dl.bintray.com/kotlin/kotlin-js-wrappers")
maven(url = "https://maven.pkg.jetbrains.space/public/p/compose/dev") maven(url = "https://maven.pkg.jetbrains.space/public/p/compose/dev")
} }

View File

@ -18,52 +18,16 @@
package com.shabinder.common.uikit package com.shabinder.common.uikit
import androidx.compose.animation.Crossfade
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.foundation.Image import androidx.compose.foundation.Image
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.MutableState
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.Modifier
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.Font import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.font.FontWeight
import com.shabinder.common.database.R import com.shabinder.common.database.R
import com.shabinder.common.di.Picture
import com.shabinder.common.di.dispatcherIO
import com.shabinder.common.models.methods
import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.withContext
@Composable
actual fun ImageLoad(
link: String,
loader: suspend (String) -> Picture,
desc: String,
modifier: Modifier,
// placeholder: ImageVector
) {
var pic by remember(link) { mutableStateOf<ImageBitmap?>(null) }
LaunchedEffect(link) {
withContext(dispatcherIO) {
pic = loader(link).image
}
}
Crossfade(pic) {
if (it == null) {
Image(PlaceHolderImage(), desc, modifier, contentScale = ContentScale.Crop)
} else Image(it, desc, modifier, contentScale = ContentScale.Crop)
}
}
actual fun montserratFont() = FontFamily( actual fun montserratFont() = FontFamily(
Font(R.font.montserrat_light, FontWeight.Light), Font(R.font.montserrat_light, FontWeight.Light),

View File

@ -0,0 +1,35 @@
package com.shabinder.common.uikit
import androidx.compose.animation.Crossfade
import androidx.compose.foundation.Image
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.layout.ContentScale
import com.shabinder.common.di.Picture
import com.shabinder.common.di.dispatcherIO
import kotlinx.coroutines.withContext
@Composable
actual fun ImageLoad(
link: String,
loader: suspend (String) -> Picture,
desc: String,
modifier: Modifier,
// placeholder: ImageVector
) {
var pic by remember(link) { mutableStateOf<ImageBitmap?>(null) }
LaunchedEffect(link) {
withContext(dispatcherIO) {
pic = loader(link).image
}
}
Crossfade(pic) {
if (it == null) {
Image(PlaceHolderImage(), desc, modifier, contentScale = ContentScale.Crop)
} else Image(it, desc, modifier, contentScale = ContentScale.Crop)
}
}

View File

@ -22,15 +22,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.graphics.painter.Painter
import com.shabinder.common.di.Picture import com.shabinder.common.di.Picture
@Composable
expect fun ImageLoad(
link: String,
loader: suspend (String) -> Picture,
desc: String = "Album Art",
modifier: Modifier = Modifier,
// placeholder:Painter = PlaceHolderImage()
)
@Composable @Composable
expect fun DownloadImageTick() expect fun DownloadImageTick()

View File

@ -0,0 +1,14 @@
package com.shabinder.common.uikit
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.shabinder.common.di.Picture
@Composable
expect fun ImageLoad(
link: String,
loader: suspend (String) -> Picture,
desc: String = "Album Art",
modifier: Modifier = Modifier,
// placeholder:Painter = PlaceHolderImage()
)

View File

@ -424,14 +424,14 @@ fun HistoryColumn(
modifier = Modifier.padding(top = 8.dp).fillMaxSize() modifier = Modifier.padding(top = 8.dp).fillMaxSize()
) )
VerticalScrollbar( /*VerticalScrollbar(
modifier = Modifier.padding(end = 2.dp).align(Alignment.CenterEnd).fillMaxHeight(), modifier = Modifier.padding(end = 2.dp).align(Alignment.CenterEnd).fillMaxHeight(),
adapter = rememberScrollbarAdapter( adapter = rememberScrollbarAdapter(
scrollState = listState, scrollState = listState,
itemCount = itemList.size, itemCount = itemList.size,
averageItemSize = 70.dp averageItemSize = 70.dp
) )
) )*/
} }
} }
} }

View File

@ -39,26 +39,6 @@ import com.shabinder.common.di.dispatcherIO
import com.shabinder.common.models.methods import com.shabinder.common.models.methods
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
@Composable
actual fun ImageLoad(
link: String,
loader: suspend (String) -> Picture,
desc: String,
modifier: Modifier,
// placeholder: ImageVector
) {
var pic by remember(link) { mutableStateOf<ImageBitmap?>(null) }
LaunchedEffect(link) {
withContext(dispatcherIO) {
pic = loader(link).image
}
}
Crossfade(pic) {
if (it == null) Image(PlaceHolderImage(), desc, modifier, contentScale = ContentScale.Crop) else Image(it, desc, modifier, contentScale = ContentScale.Crop)
}
}
@Composable @Composable
actual fun DownloadImageTick() { actual fun DownloadImageTick() {
Image( Image(

View File

@ -0,0 +1,32 @@
package com.shabinder.common.uikit
import androidx.compose.animation.Crossfade
import androidx.compose.foundation.Image
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.layout.ContentScale
import com.shabinder.common.di.Picture
import com.shabinder.common.di.dispatcherIO
import kotlinx.coroutines.withContext
@Composable
actual fun ImageLoad(
link: String,
loader: suspend (String) -> Picture,
desc: String,
modifier: Modifier,
// placeholder: ImageVector
) {
var pic by remember(link) { mutableStateOf<ImageBitmap?>(null) }
LaunchedEffect(link) {
withContext(dispatcherIO) {
pic = loader(link).image
}
}
Crossfade(pic) {
if (it == null) Image(PlaceHolderImage(), desc, modifier, contentScale = ContentScale.Crop) else Image(it, desc, modifier, contentScale = ContentScale.Crop)
}
}

View File

@ -42,7 +42,7 @@ interface Actions {
} }
private fun stubActions() = object :Actions { private fun stubActions(): Actions = object :Actions {
override val platformActions = StubPlatformActions override val platformActions = StubPlatformActions
override fun showPopUpMessage(string: String, long: Boolean) {} override fun showPopUpMessage(string: String, long: Boolean) {}
override fun setDownloadDirectoryAction() {} override fun setDownloadDirectoryAction() {}

View File

@ -68,33 +68,36 @@ kotlin {
} }
} }
} }
if(HostOS.isMac){
/*Required to Export `packForXcode`*/ /*Required to Export `packForXcode`*/
sourceSets { sourceSets {
named("iosMain") { named("iosMain") {
dependencies { dependencies {
api(project(":common:dependency-injection")) api(project(":common:dependency-injection"))
api(project(":common:data-models")) api(project(":common:data-models"))
api(project(":common:database")) api(project(":common:database"))
api(project(":common:list")) api(project(":common:list"))
api(project(":common:main")) api(project(":common:main"))
api(Decompose.decompose) api(Decompose.decompose)
api(MVIKotlin.mvikotlinMain) api(MVIKotlin.mvikotlinMain)
api(MVIKotlin.mvikotlinLogging) api(MVIKotlin.mvikotlinLogging)
}
} }
} }
} }
} }
val packForXcode by tasks.creating(Sync::class) { val packForXcode by tasks.creating(Sync::class) {
group = "build" if(HostOS.isMac){
val mode = System.getenv("CONFIGURATION") ?: "DEBUG" group = "build"
val targetName = "ios" val mode = System.getenv("CONFIGURATION") ?: "DEBUG"
val framework = kotlin.targets.getByName<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget>(targetName) val targetName = "ios"
.binaries.getFramework(mode) val framework = kotlin.targets.getByName<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget>(targetName)
inputs.property("mode", mode) .binaries.getFramework(mode)
dependsOn(framework.linkTask) inputs.property("mode", mode)
val targetDir = File(buildDir, "xcode-frameworks") dependsOn(framework.linkTask)
from(framework.outputDirectory) val targetDir = File(buildDir, "xcode-frameworks")
into(targetDir) from(framework.outputDirectory)
into(targetDir)
}
} }

View File

@ -47,7 +47,6 @@ import java.awt.Desktop
import java.net.URI import java.net.URI
import javax.swing.JFileChooser import javax.swing.JFileChooser
import javax.swing.JFileChooser.APPROVE_OPTION import javax.swing.JFileChooser.APPROVE_OPTION
import javax.swing.JFileChooser.CANCEL_OPTION
private val koin = initKoin(enableNetworkLogs = true).koin private val koin = initKoin(enableNetworkLogs = true).koin
private lateinit var showToast: (String)->Unit private lateinit var showToast: (String)->Unit