diff --git a/common/compose-ui/src/androidMain/kotlin/com/shabinder/common/ui/Images.kt b/common/compose-ui/src/androidMain/kotlin/com/shabinder/common/ui/AndroidImages.kt similarity index 92% rename from common/compose-ui/src/androidMain/kotlin/com/shabinder/common/ui/Images.kt rename to common/compose-ui/src/androidMain/kotlin/com/shabinder/common/ui/AndroidImages.kt index ecae215d..0a3efacc 100644 --- a/common/compose-ui/src/androidMain/kotlin/com/shabinder/common/ui/Images.kt +++ b/common/compose-ui/src/androidMain/kotlin/com/shabinder/common/ui/AndroidImages.kt @@ -1,3 +1,5 @@ +@file:Suppress("FunctionName") + package com.shabinder.common.ui import androidx.compose.foundation.Image @@ -34,6 +36,9 @@ actual fun DownloadImageArrow(modifier: Modifier){ @Composable actual fun DownloadAllImage() = vectorResource(R.drawable.ic_download_arrow) +@Composable +actual fun ShareImage() = vectorResource(R.drawable.ic_share_open) + @Composable actual fun PlaceHolderImage() = vectorResource(R.drawable.music) diff --git a/common/compose-ui/src/androidMain/kotlin/com/shabinder/common/ui/Actual.kt b/common/compose-ui/src/androidMain/kotlin/com/shabinder/common/ui/AndroidToast.kt similarity index 86% rename from common/compose-ui/src/androidMain/kotlin/com/shabinder/common/ui/Actual.kt rename to common/compose-ui/src/androidMain/kotlin/com/shabinder/common/ui/AndroidToast.kt index fa4021b2..11d120cb 100644 --- a/common/compose-ui/src/androidMain/kotlin/com/shabinder/common/ui/Actual.kt +++ b/common/compose-ui/src/androidMain/kotlin/com/shabinder/common/ui/AndroidToast.kt @@ -3,6 +3,9 @@ package com.shabinder.common.ui import androidx.compose.runtime.Composable import androidx.compose.runtime.MutableState import com.shabinder.common.database.appContext +import kotlinx.coroutines.Dispatchers + +actual val dispatcherIO = Dispatchers.IO @Composable actual fun Toast( diff --git a/common/compose-ui/src/commonMain/kotlin/com/shabinder/common/list/SpotiFlyerListUi.kt b/common/compose-ui/src/commonMain/kotlin/com/shabinder/common/list/SpotiFlyerListUi.kt index d3a85490..0eca9978 100644 --- a/common/compose-ui/src/commonMain/kotlin/com/shabinder/common/list/SpotiFlyerListUi.kt +++ b/common/compose-ui/src/commonMain/kotlin/com/shabinder/common/list/SpotiFlyerListUi.kt @@ -21,6 +21,7 @@ import com.shabinder.common.ui.* import com.shabinder.common.ui.SpotiFlyerTypography import com.shabinder.common.ui.colorAccent import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @Composable @@ -67,7 +68,7 @@ fun TrackCard( Row(verticalAlignment = Alignment.CenterVertically,modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp)) { var pic by mutableStateOf(null) val scope = rememberCoroutineScope() - scope.launch { + scope.launch(Dispatchers.Unconfined) { pic = loadImage(track.albumArtURL) } ImageLoad( @@ -127,7 +128,7 @@ fun CoverImage( horizontalAlignment = Alignment.CenterHorizontally ) { var pic by mutableStateOf(null) - scope.launch { + scope.launch(Dispatchers.Unconfined) { pic = loadImage(coverURL) } ImageLoad( diff --git a/common/compose-ui/src/commonMain/kotlin/com/shabinder/common/main/SpotiFlyerMainUi.kt b/common/compose-ui/src/commonMain/kotlin/com/shabinder/common/main/SpotiFlyerMainUi.kt index 47f1dfbf..296532be 100644 --- a/common/compose-ui/src/commonMain/kotlin/com/shabinder/common/main/SpotiFlyerMainUi.kt +++ b/common/compose-ui/src/commonMain/kotlin/com/shabinder/common/main/SpotiFlyerMainUi.kt @@ -348,7 +348,7 @@ fun DownloadRecordItem( } } Image( - imageVector = Icons.Rounded.Share, + imageVector = ShareImage(), "Research", modifier = Modifier.clickable(onClick = { //if(!isOnline(ctx)) showDialog("Check Your Internet Connection") else diff --git a/common/compose-ui/src/commonMain/kotlin/com/shabinder/common/root/integration/SpotiFlyerRootImpl.kt b/common/compose-ui/src/commonMain/kotlin/com/shabinder/common/root/integration/SpotiFlyerRootImpl.kt index 5ddff2b4..aaa39081 100644 --- a/common/compose-ui/src/commonMain/kotlin/com/shabinder/common/root/integration/SpotiFlyerRootImpl.kt +++ b/common/compose-ui/src/commonMain/kotlin/com/shabinder/common/root/integration/SpotiFlyerRootImpl.kt @@ -14,7 +14,6 @@ import com.shabinder.common.main.SpotiFlyerMain import com.shabinder.common.root.SpotiFlyerRoot import com.shabinder.common.root.SpotiFlyerRoot.Child import com.shabinder.common.root.SpotiFlyerRoot.Dependencies -import com.shabinder.common.ui.showPopUpMessage import com.shabinder.common.utils.Consumer internal class SpotiFlyerRootImpl( @@ -57,12 +56,10 @@ internal class SpotiFlyerRootImpl( } ) - private fun onMainOutput(output: SpotiFlyerMain.Output){ - showPopUpMessage("Button Pressed") + private fun onMainOutput(output: SpotiFlyerMain.Output) = when (output) { is SpotiFlyerMain.Output.Search -> router.push(Configuration.List(link = output.link)) } - } private fun onListOutput(output: SpotiFlyerList.Output): Unit = when (output) { diff --git a/common/compose-ui/src/commonMain/kotlin/com/shabinder/common/ui/Expect.kt b/common/compose-ui/src/commonMain/kotlin/com/shabinder/common/ui/Expect.kt index ea0afda8..89717871 100644 --- a/common/compose-ui/src/commonMain/kotlin/com/shabinder/common/ui/Expect.kt +++ b/common/compose-ui/src/commonMain/kotlin/com/shabinder/common/ui/Expect.kt @@ -1,3 +1,7 @@ package com.shabinder.common.ui -expect fun showPopUpMessage(text: String) \ No newline at end of file +import kotlinx.coroutines.CoroutineDispatcher + +expect fun showPopUpMessage(text: String) + +expect val dispatcherIO: CoroutineDispatcher diff --git a/common/compose-ui/src/commonMain/kotlin/com/shabinder/common/ui/Images.kt b/common/compose-ui/src/commonMain/kotlin/com/shabinder/common/ui/ExpectImages.kt similarity index 93% rename from common/compose-ui/src/commonMain/kotlin/com/shabinder/common/ui/Images.kt rename to common/compose-ui/src/commonMain/kotlin/com/shabinder/common/ui/ExpectImages.kt index b0492868..693fabf4 100644 --- a/common/compose-ui/src/commonMain/kotlin/com/shabinder/common/ui/Images.kt +++ b/common/compose-ui/src/commonMain/kotlin/com/shabinder/common/ui/ExpectImages.kt @@ -1,3 +1,4 @@ +@file:Suppress("FunctionName") package com.shabinder.common.ui import androidx.compose.foundation.Image @@ -17,6 +18,9 @@ expect fun DownloadImageTick() @Composable expect fun DownloadAllImage():ImageVector +@Composable +expect fun ShareImage():ImageVector + @Composable expect fun PlaceHolderImage():ImageVector diff --git a/common/compose-ui/src/desktopMain/kotlin/com/shabinder/common/ui/Actual.kt b/common/compose-ui/src/desktopMain/kotlin/com/shabinder/common/ui/Actual.kt deleted file mode 100644 index c4a732bf..00000000 --- a/common/compose-ui/src/desktopMain/kotlin/com/shabinder/common/ui/Actual.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.shabinder.common.ui - -import androidx.compose.foundation.Image -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.asImageBitmap -import androidx.compose.ui.res.vectorXmlResource -import com.shabinder.common.di.Picture -import java.awt.image.BufferedImage -import java.io.ByteArrayOutputStream -import javax.imageio.ImageIO diff --git a/common/compose-ui/src/desktopMain/kotlin/com/shabinder/common/ui/DesktopImages.kt b/common/compose-ui/src/desktopMain/kotlin/com/shabinder/common/ui/DesktopImages.kt new file mode 100644 index 00000000..e51cb119 --- /dev/null +++ b/common/compose-ui/src/desktopMain/kotlin/com/shabinder/common/ui/DesktopImages.kt @@ -0,0 +1,64 @@ +@file:Suppress("FunctionName") +package com.shabinder.common.ui + +import androidx.compose.foundation.Image +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.vector.ImageVector +import androidx.compose.ui.res.vectorXmlResource + +@Composable +actual fun DownloadImageTick(){ + Image( + vectorXmlResource("drawable/ic_tick.xml"), + "Downloaded" + ) +} + +@Composable +actual fun DownloadImageError(){ + Image( + vectorXmlResource("drawable/ic_error.xml"), + "Can't Download" + ) +} + +@Composable +actual fun DownloadImageArrow(modifier: Modifier){ + Image( + vectorXmlResource("drawable/ic_arrow.xml"), + "Download", + modifier + ) +} + +@Composable +actual fun DownloadAllImage():ImageVector = vectorXmlResource("drawable/ic_download_arrow.xml") + +@Composable +actual fun ShareImage():ImageVector = vectorXmlResource("drawable/ic_share_open.xml") + +@Composable +actual fun PlaceHolderImage():ImageVector = vectorXmlResource("drawable/music.xml") + + +@Composable +actual fun SpotiFlyerLogo():ImageVector = vectorXmlResource("drawable/ic_spotiflyer_logo.xml") + +@Composable +actual fun HeartIcon():ImageVector = vectorXmlResource("drawable/ic_heart.xml") + +@Composable +actual fun SpotifyLogo():ImageVector = vectorXmlResource("drawable/ic_spotify_logo.xml") + +@Composable +actual fun YoutubeLogo():ImageVector = vectorXmlResource("drawable/ic_youtube.xml") + +@Composable +actual fun GaanaLogo():ImageVector = vectorXmlResource("drawable/ic_gaana.xml") + +@Composable +actual fun YoutubeMusicLogo():ImageVector = vectorXmlResource("drawable/ic_youtube_music_logo.xml") + +@Composable +actual fun GithubLogo():ImageVector = vectorXmlResource("drawable/ic_github.xml") diff --git a/common/compose-ui/src/desktopMain/kotlin/com/shabinder/common/ui/Toast.kt b/common/compose-ui/src/desktopMain/kotlin/com/shabinder/common/ui/DesktopToast.kt similarity index 96% rename from common/compose-ui/src/desktopMain/kotlin/com/shabinder/common/ui/Toast.kt rename to common/compose-ui/src/desktopMain/kotlin/com/shabinder/common/ui/DesktopToast.kt index a99cb435..ce95e745 100644 --- a/common/compose-ui/src/desktopMain/kotlin/com/shabinder/common/ui/Toast.kt +++ b/common/compose-ui/src/desktopMain/kotlin/com/shabinder/common/ui/DesktopToast.kt @@ -15,10 +15,13 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.delay import kotlinx.coroutines.launch +actual val dispatcherIO = Dispatchers.IO + private val message: MutableState = mutableStateOf("") private val state: MutableState = mutableStateOf(false) diff --git a/common/compose-ui/src/desktopMain/kotlin/com/shabinder/common/ui/Images.kt b/common/compose-ui/src/desktopMain/kotlin/com/shabinder/common/ui/Images.kt deleted file mode 100644 index 17b80cb3..00000000 --- a/common/compose-ui/src/desktopMain/kotlin/com/shabinder/common/ui/Images.kt +++ /dev/null @@ -1,60 +0,0 @@ -package com.shabinder.common.ui - -import androidx.compose.foundation.Image -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.vector.ImageVector -import androidx.compose.ui.res.vectorXmlResource - -@Composable -actual fun DownloadImageTick(){ - Image( - vectorXmlResource("common/compose-ui/src/main/res/drawable/ic_tick.xml"), - "Downloaded" - ) -} - -@Composable -actual fun DownloadImageError(){ - Image( - vectorXmlResource("common/compose-ui/src/main/res/drawable/ic_error.xml"), - "Can't Download" - ) -} - -@Composable -actual fun DownloadImageArrow(modifier: Modifier){ - Image( - vectorXmlResource("common/compose-ui/src/main/res/drawable/ic_arrow.xml"), - "Download", - modifier - ) -} - -@Composable -actual fun DownloadAllImage():ImageVector = vectorXmlResource("common/compose-ui/src/main/res/drawable/ic_download_arrow.xml") - -@Composable -actual fun PlaceHolderImage():ImageVector = vectorXmlResource("common/compose-ui/src/main/res/drawable/music.xml") - - -@Composable -actual fun SpotiFlyerLogo():ImageVector = vectorXmlResource("common/compose-ui/src/main/res/drawable/ic_spotiflyer_logo.xml") - -@Composable -actual fun HeartIcon():ImageVector = vectorXmlResource("common/compose-ui/src/main/res/drawable/ic_heart.xml") - -@Composable -actual fun SpotifyLogo():ImageVector = vectorXmlResource("common/compose-ui/src/main/res/drawable/ic_spotify_logo.xml") - -@Composable -actual fun YoutubeLogo():ImageVector = vectorXmlResource("common/compose-ui/src/main/res/drawable/ic_youtube.xml") - -@Composable -actual fun GaanaLogo():ImageVector = vectorXmlResource("common/compose-ui/src/main/res/drawable/ic_gaana.xml") - -@Composable -actual fun YoutubeMusicLogo():ImageVector = vectorXmlResource("common/compose-ui/src/main/res/drawable/ic_youtube_music_logo.xml") - -@Composable -actual fun GithubLogo():ImageVector = vectorXmlResource("common/compose-ui/src/main/res/drawable/ic_github.xml") diff --git a/common/compose-ui/src/main/res/drawable/ic_arrow.xml b/common/data-models/src/main/res/drawable/ic_arrow.xml similarity index 100% rename from common/compose-ui/src/main/res/drawable/ic_arrow.xml rename to common/data-models/src/main/res/drawable/ic_arrow.xml diff --git a/common/compose-ui/src/main/res/drawable/ic_download_arrow.xml b/common/data-models/src/main/res/drawable/ic_download_arrow.xml similarity index 100% rename from common/compose-ui/src/main/res/drawable/ic_download_arrow.xml rename to common/data-models/src/main/res/drawable/ic_download_arrow.xml diff --git a/common/compose-ui/src/main/res/drawable/ic_error.xml b/common/data-models/src/main/res/drawable/ic_error.xml similarity index 100% rename from common/compose-ui/src/main/res/drawable/ic_error.xml rename to common/data-models/src/main/res/drawable/ic_error.xml diff --git a/common/compose-ui/src/main/res/drawable/ic_gaana.xml b/common/data-models/src/main/res/drawable/ic_gaana.xml similarity index 100% rename from common/compose-ui/src/main/res/drawable/ic_gaana.xml rename to common/data-models/src/main/res/drawable/ic_gaana.xml diff --git a/common/compose-ui/src/main/res/drawable/ic_github.xml b/common/data-models/src/main/res/drawable/ic_github.xml similarity index 100% rename from common/compose-ui/src/main/res/drawable/ic_github.xml rename to common/data-models/src/main/res/drawable/ic_github.xml diff --git a/common/compose-ui/src/main/res/drawable/ic_heart.xml b/common/data-models/src/main/res/drawable/ic_heart.xml similarity index 100% rename from common/compose-ui/src/main/res/drawable/ic_heart.xml rename to common/data-models/src/main/res/drawable/ic_heart.xml diff --git a/common/compose-ui/src/main/res/drawable/ic_spotiflyer_logo.xml b/common/data-models/src/main/res/drawable/ic_spotiflyer_logo.xml similarity index 100% rename from common/compose-ui/src/main/res/drawable/ic_spotiflyer_logo.xml rename to common/data-models/src/main/res/drawable/ic_spotiflyer_logo.xml diff --git a/common/compose-ui/src/main/res/drawable/ic_spotify_logo.xml b/common/data-models/src/main/res/drawable/ic_spotify_logo.xml similarity index 100% rename from common/compose-ui/src/main/res/drawable/ic_spotify_logo.xml rename to common/data-models/src/main/res/drawable/ic_spotify_logo.xml diff --git a/common/compose-ui/src/main/res/drawable/ic_tick.xml b/common/data-models/src/main/res/drawable/ic_tick.xml similarity index 100% rename from common/compose-ui/src/main/res/drawable/ic_tick.xml rename to common/data-models/src/main/res/drawable/ic_tick.xml diff --git a/common/compose-ui/src/main/res/drawable/ic_youtube.xml b/common/data-models/src/main/res/drawable/ic_youtube.xml similarity index 100% rename from common/compose-ui/src/main/res/drawable/ic_youtube.xml rename to common/data-models/src/main/res/drawable/ic_youtube.xml diff --git a/common/compose-ui/src/main/res/drawable/ic_youtube_music_logo.xml b/common/data-models/src/main/res/drawable/ic_youtube_music_logo.xml similarity index 100% rename from common/compose-ui/src/main/res/drawable/ic_youtube_music_logo.xml rename to common/data-models/src/main/res/drawable/ic_youtube_music_logo.xml diff --git a/common/compose-ui/src/main/res/drawable/music.xml b/common/data-models/src/main/res/drawable/music.xml similarity index 100% rename from common/compose-ui/src/main/res/drawable/music.xml rename to common/data-models/src/main/res/drawable/music.xml diff --git a/common/compose-ui/src/main/res/font/montserrat_light.ttf b/common/data-models/src/main/res/font/montserrat_light.ttf similarity index 100% rename from common/compose-ui/src/main/res/font/montserrat_light.ttf rename to common/data-models/src/main/res/font/montserrat_light.ttf diff --git a/common/compose-ui/src/main/res/font/montserrat_medium.ttf b/common/data-models/src/main/res/font/montserrat_medium.ttf similarity index 100% rename from common/compose-ui/src/main/res/font/montserrat_medium.ttf rename to common/data-models/src/main/res/font/montserrat_medium.ttf diff --git a/common/compose-ui/src/main/res/font/montserrat_regular.ttf b/common/data-models/src/main/res/font/montserrat_regular.ttf similarity index 100% rename from common/compose-ui/src/main/res/font/montserrat_regular.ttf rename to common/data-models/src/main/res/font/montserrat_regular.ttf diff --git a/common/compose-ui/src/main/res/font/montserrat_semibold.ttf b/common/data-models/src/main/res/font/montserrat_semibold.ttf similarity index 100% rename from common/compose-ui/src/main/res/font/montserrat_semibold.ttf rename to common/data-models/src/main/res/font/montserrat_semibold.ttf diff --git a/common/compose-ui/src/main/res/font/pristine_script.ttf b/common/data-models/src/main/res/font/pristine_script.ttf similarity index 100% rename from common/compose-ui/src/main/res/font/pristine_script.ttf rename to common/data-models/src/main/res/font/pristine_script.ttf diff --git a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/Dir.kt b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/Dir.kt index 989a33d5..ffb025df 100644 --- a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/Dir.kt +++ b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/Dir.kt @@ -7,6 +7,7 @@ import com.shabinder.common.models.TrackDetails import io.ktor.client.request.* import io.ktor.client.statement.* import io.ktor.http.* +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow import kotlin.math.roundToInt