generated from nimblehq/git-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[12] Integrate Moko Resources to share project resources between plat…
…forms
- Loading branch information
Showing
24 changed files
with
192 additions
and
42 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
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
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
20 changes: 20 additions & 0 deletions
20
sample/shared/src/androidMain/kotlin/co/nimblehq/kmm/template/Strings.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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package co.nimblehq.kmm.template | ||
|
||
import android.content.Context | ||
import dev.icerock.moko.resources.StringResource | ||
import dev.icerock.moko.resources.desc.Resource | ||
import dev.icerock.moko.resources.desc.StringDesc | ||
import dev.icerock.moko.resources.format | ||
|
||
actual class Strings(private val context: Context) { | ||
actual fun get( | ||
id: StringResource, | ||
args: List<Any>, | ||
): String { | ||
return if (args.isEmpty()) { | ||
StringDesc.Resource(id).toString(context = context) | ||
} else { | ||
id.format(*args.toTypedArray()).toString(context) | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
sample/shared/src/commonMain/kotlin/co/nimblehq/kmm/template/Strings.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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package co.nimblehq.kmm.template | ||
|
||
import dev.icerock.moko.resources.StringResource | ||
|
||
expect class Strings { | ||
fun get(id: StringResource, args: List<Any> = emptyList()): String | ||
} |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<resources> | ||
<string name="greeting">Hello, %s!</string> | ||
</resources> |
19 changes: 19 additions & 0 deletions
19
sample/shared/src/iosMain/kotlin/co/nimblehq/kmm/template/Strings.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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package co.nimblehq.kmm.template | ||
|
||
import dev.icerock.moko.resources.StringResource | ||
import dev.icerock.moko.resources.desc.Resource | ||
import dev.icerock.moko.resources.desc.StringDesc | ||
import dev.icerock.moko.resources.format | ||
|
||
actual class Strings { | ||
actual fun get( | ||
id: StringResource, | ||
args: List<Any>, | ||
): String { | ||
return if (args.isEmpty()) { | ||
StringDesc.Resource(id).localized() | ||
} else { | ||
id.format(*args.toTypedArray()).localized() | ||
} | ||
} | ||
} |
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
20 changes: 20 additions & 0 deletions
20
shared/src/androidMain/kotlin/co/nimblehq/kmm/template/Strings.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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package co.nimblehq.kmm.template | ||
|
||
import android.content.Context | ||
import dev.icerock.moko.resources.StringResource | ||
import dev.icerock.moko.resources.desc.Resource | ||
import dev.icerock.moko.resources.desc.StringDesc | ||
import dev.icerock.moko.resources.format | ||
|
||
actual class Strings(private val context: Context) { | ||
actual fun get( | ||
id: StringResource, | ||
args: List<Any>, | ||
): String { | ||
return if (args.isEmpty()) { | ||
StringDesc.Resource(id).toString(context = context) | ||
} else { | ||
id.format(*args.toTypedArray()).toString(context) | ||
} | ||
} | ||
} |
12 changes: 0 additions & 12 deletions
12
shared/src/androidUnitTest/kotlin/co/nimblehq/kmm/template/androidTest.kt
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
shared/src/commonMain/kotlin/co/nimblehq/kmm/template/Strings.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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package co.nimblehq.kmm.template | ||
|
||
import dev.icerock.moko.resources.StringResource | ||
|
||
expect class Strings { | ||
fun get(id: StringResource, args: List<Any> = emptyList()): String | ||
} |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<resources> | ||
<string name="greeting">Hello, %s!</string> | ||
</resources> |
12 changes: 0 additions & 12 deletions
12
shared/src/commonTest/kotlin/co/nimblehq/kmm/template/commonTest.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.