Ahmad Hassan
11/01/2023, 11:41 AMPablichjenkov
11/02/2023, 12:18 PMPablichjenkov
11/02/2023, 12:20 PMInterface StringResolver{
fun getStringById(stringId: Int) : String
}
Then provide to koin each implementation the swift one and the Android one.Ahmad Hassan
11/02/2023, 12:22 PMPablichjenkov
11/02/2023, 12:27 PMAhmad Hassan
11/02/2023, 12:30 PMclass TextSharing_iOS: TextSharing {
override fun shareText(text: String) {
val activityItems = listOf(text)
val activityViewController = UIActivityViewController(activityItems, null)
val application = UIApplication.sharedApplication
application.keyWindow?.rootViewController?.presentViewController(
activityViewController,
animated = true,
completion = null
)
}
}
class AndroidTextSharing(private val context: Context): TextSharing {
override fun shareText(text: String) {
val shareIntent = Intent().apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_TEXT, text)
type = "text/plain"
}
context.startActivity(
Intent.createChooser(shareIntent, context.getString(
R.string.app_name)))
}
}
Now how to use in commonMain?Pablichjenkov
11/02/2023, 12:53 PMAhmad Hassan
11/03/2023, 9:42 AM