-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Tewelde, Fethi (F.)
committed
Dec 8, 2024
1 parent
9c24ca2
commit 48ccc1c
Showing
39 changed files
with
481 additions
and
424 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ksmuseum/core/designsystem/theme/Color.kt → ...in/com/tewelde/rijksmuseum/theme/Color.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ksmuseum/core/designsystem/theme/Theme.kt → ...in/com/tewelde/rijksmuseum/theme/Theme.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...jksmuseum/core/designsystem/theme/Type.kt → ...lin/com/tewelde/rijksmuseum/theme/Type.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
...src/commonMain/kotlin/com/tewelde/rijksmuseum/core/designsystem/RijksmuseumDestination.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,7 @@ | ||
import android.content.ContentValues | ||
import android.content.Context | ||
import android.graphics.Bitmap | ||
import android.graphics.BitmapFactory | ||
import android.os.Build | ||
import android.os.Environment | ||
import android.provider.MediaStore | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.platform.LocalView | ||
import com.tewelde.rijksmuseum.core.model.Art | ||
import com.tewelde.rijksmuseum.resources.Res | ||
import com.tewelde.rijksmuseum.resources.permission_denied | ||
import io.github.vinceglb.filekit.core.FileKitPlatformSettings | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.launch | ||
import okio.FileSystem | ||
import org.jetbrains.compose.resources.StringResource | ||
import kotlin.coroutines.coroutineContext | ||
|
||
@Composable | ||
actual fun screenHeight(): Int = LocalView.current.resources.displayMetrics.heightPixels | ||
|
||
@Composable | ||
actual fun screenWidth(): Int = LocalView.current.resources.displayMetrics.widthPixels | ||
|
||
|
||
actual class FileUtil(private val context: Context) { | ||
actual fun filesystem(): FileSystem? = FileSystem.SYSTEM | ||
|
||
actual suspend fun saveFile( | ||
bytes: ByteArray, | ||
baseName: String, | ||
extension: String, | ||
initialDirectory: String?, | ||
platformSettings: FileKitPlatformSettings?, | ||
onFailure: (Throwable) -> Unit, | ||
onSuccess: () -> Unit | ||
) { | ||
CoroutineScope(coroutineContext).launch(Dispatchers.IO) { | ||
runCatching { | ||
val imageBitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.size) | ||
val mContentValues = | ||
ContentValues().apply { | ||
put(MediaStore.Images.Media.DATE_ADDED, System.currentTimeMillis()) | ||
put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg") | ||
put(MediaStore.Images.Media.RELATIVE_PATH, Environment.DIRECTORY_PICTURES) | ||
put(MediaStore.Images.Media.DISPLAY_NAME, baseName) | ||
} | ||
|
||
context.contentResolver | ||
.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, mContentValues) | ||
.apply { | ||
this?.let { | ||
context.contentResolver.openOutputStream(it)?.let { outStream -> | ||
imageBitmap.compress(Bitmap.CompressFormat.JPEG, 100, outStream) | ||
} | ||
} | ||
onSuccess() | ||
} | ||
}.onFailure { | ||
it.printStackTrace() | ||
onFailure(it) | ||
} | ||
} | ||
} | ||
|
||
actual suspend fun shouldAskStorageRuntimePermission(): Boolean = | ||
Build.VERSION.SDK_INT < Build.VERSION_CODES.Q | ||
} | ||
|
||
actual val Art.artUrl: String | ||
get() = this.webImage.url | ||
|
||
actual val minGridSize: Int | ||
get() = 175 | ||
|
||
actual val permissionDeniedMessage: StringResource = Res.string.permission_denied | ||
|
||
actual val web: Boolean | ||
get() = false | ||
get() = 175 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,4 @@ | ||
import androidx.compose.runtime.Composable | ||
import com.tewelde.rijksmuseum.core.model.Art | ||
import io.github.vinceglb.filekit.core.FileKitPlatformSettings | ||
import okio.FileSystem | ||
import org.jetbrains.compose.resources.StringResource | ||
|
||
@Composable | ||
expect fun screenHeight(): Int | ||
|
||
@Composable | ||
expect fun screenWidth(): Int | ||
|
||
expect val web: Boolean | ||
|
||
expect val Art.artUrl: String | ||
|
||
expect val permissionDeniedMessage: StringResource | ||
|
||
expect val minGridSize: Int | ||
|
||
expect class FileUtil { | ||
fun filesystem(): FileSystem? | ||
suspend fun saveFile( | ||
bytes: ByteArray, | ||
baseName: String = "file", | ||
extension: String, | ||
initialDirectory: String? = null, | ||
platformSettings: FileKitPlatformSettings? = null, | ||
onFailure: (Throwable) -> Unit, | ||
onSuccess: () -> Unit | ||
) | ||
suspend fun shouldAskStorageRuntimePermission(): Boolean | ||
} | ||
expect val Art.artUrl: String |
13 changes: 3 additions & 10 deletions
13
feature/arts/src/commonMain/kotlin/com/tewelde/rijksmuseum/feature/arts/di/ArtsModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,11 @@ | ||
package com.tewelde.rijksmuseum.feature.arts.di | ||
|
||
import com.tewelde.rijksmuseum.core.domain.di.domainModule | ||
import com.tewelde.rijksmuseum.core.permissions.permissionsModule | ||
import com.tewelde.rijksmuseum.feature.arts.detail.DetailViewModel | ||
import com.tewelde.rijksmuseum.feature.arts.gallery.GalleryViewModel | ||
import org.koin.compose.viewmodel.dsl.viewModelOf | ||
import org.koin.core.module.Module | ||
import org.koin.core.module.dsl.viewModelOf | ||
import org.koin.dsl.module | ||
|
||
val artsModule = module { | ||
includes(domainModule, platformModule, permissionsModule) | ||
includes(domainModule) | ||
viewModelOf(::GalleryViewModel) | ||
viewModelOf(::DetailViewModel) | ||
} | ||
|
||
|
||
expect val platformModule: Module | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.