-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ASAA- 122 - Migrate Launchpad compose #1
Merged
Merged
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6d64244
ASAA-122 - Migrated library to KMP
br-Emery 1b1218f
ASAA-122 - Added Publishing info
br-Emery 54ab7f6
ASAA-122 - Added github actions to publish
br-Emery eef9eb0
ASAA-122 - updated gradle github action
br-Emery f9968ed
ASAA-122 - Add README and update KtLint settings
br-Emery 327048f
ASAA-122 - Fixed publishing task
br-Emery c57aca0
ASAA-122 - Corrected README file
br-Emery 1006a12
ASAA-122 - Last pieces of original carried over
br-Emery ac1d538
ASAA-122 - Moved Double.toCurrency from ignite to library
br-Emery 4ea778d
ASAA-122 - Remove `SNAPSHOT` and ktLint
br-Emery File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
11 changes: 11 additions & 0 deletions
11
...ndroidMain/kotlin/com/bottlerocketstudios/launchpad/compose/util/CurrencyUtils.android.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,11 @@ | ||
package com.bottlerocketstudios.launchpad.compose.util | ||
|
||
import java.text.NumberFormat | ||
import java.util.Currency | ||
import java.util.Locale | ||
|
||
actual fun Double?.toCurrency(): String { | ||
val numberFormat = NumberFormat.getCurrencyInstance() | ||
numberFormat.currency = Currency.getInstance(Locale.getDefault()) | ||
return numberFormat.format(this ?: 0.0) | ||
} |
21 changes: 21 additions & 0 deletions
21
...src/androidUnitTest/kotlin/com/bottlerocketstudios/launchpad/compose/CurrencyUtilsTest.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,21 @@ | ||
package com.bottlerocketstudios.launchpad.compose | ||
|
||
import com.bottlerocketstudios.launchpad.compose.util.toCurrency | ||
import java.util.Locale | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
|
||
|
||
class CurrencyUtilsTest { | ||
|
||
@Test | ||
fun `test double toCurrency`() { | ||
Locale.setDefault(Locale.US) | ||
|
||
val input = 1234.56 | ||
val expectedOutput = "$1,234.56" | ||
val actualOutput = input.toCurrency() | ||
|
||
assertEquals(expectedOutput, actualOutput) | ||
} | ||
} |
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
15 changes: 15 additions & 0 deletions
15
...ose/src/commonMain/kotlin/com/bottlerocketstudios/launchpad/compose/util/CurrencyUtils.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,15 @@ | ||
package com.bottlerocketstudios.launchpad.compose.util | ||
|
||
|
||
/** | ||
* Kotlin Multiplatform function - convertToCurrencyString | ||
* | ||
* This function takes a Double value representing a raw amount of currency, | ||
* and returns a String representing that amount formatted appropriately as | ||
* currency for the current locale of the device running the code. | ||
* | ||
* @param [amount] The raw amount of currency as a Double | ||
* @return A string representing that amount in the appropriate currency | ||
* format for the device's current locale. | ||
*/ | ||
expect fun Double?.toCurrency(): String |
7 changes: 7 additions & 0 deletions
7
...ompose/src/commonMain/kotlin/com/bottlerocketstudios/launchpad/compose/util/StateUtils.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 @@ | ||
@file:Suppress("unused") | ||
|
||
package com.bottlerocketstudios.launchpad.compose.util | ||
|
||
import androidx.compose.runtime.mutableStateOf | ||
|
||
fun <T> T.asMutableState() = mutableStateOf(this) |
17 changes: 17 additions & 0 deletions
17
...se/src/iosMain/kotlin/com/bottlerocketstudios/launchpad/compose/util/CurrencyUtils.ios.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,17 @@ | ||
package com.bottlerocketstudios.launchpad.compose.util | ||
|
||
import platform.Foundation.NSLocale | ||
import platform.Foundation.NSNumber | ||
import platform.Foundation.NSNumberFormatter | ||
import platform.Foundation.NSNumberFormatterCurrencyStyle | ||
import platform.Foundation.currentLocale | ||
import platform.Foundation.numberWithDouble | ||
|
||
actual fun Double?.toCurrency(): String { | ||
val formatter = NSNumberFormatter() | ||
formatter.numberStyle = NSNumberFormatterCurrencyStyle | ||
formatter.locale = NSLocale.currentLocale() | ||
|
||
val number = NSNumber.numberWithDouble(this ?: 0.0) | ||
return formatter.stringFromNumber(number) ?: "NaN" | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nicely done!