-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adds a new :ui module. * Renames :ui to :paywalls. Apparently :ui conflicts with compose:ui, causing compile errors. * Increases heap space to 4 GiB. * Uses the kobankat-library plugin, and sets the package to ui.revenuecatui for consistency. * Adds the correct ui dependencies. * Adds PaywallOptions. * Adds Paywall. * Adds PaywallFooter. * Minimizes dependencies. * Fixes restoring purchases on Android. * Fixes toAndroidPaywallOptions(). * Fixes the minSdk for paywalls. * The sample app can now show paywalls. * Adds footer paywall buttons. * Fixes showing footer paywalls. * Adds the RevenueCatUI pod to iosApp. * Fixes "unrecognized selector sent to class" by using the correct (PHC) pods in iosApp. * Removes useless receiver. * Updates to Kotlin 2.0.0. Can revert later if needed. * Adds Kotlin code to the Xcode workspace. * Makes platform-to-common error conversion public. Could be made internal later, with an annotation? * Adds .kotlin to .gitignore. * Adds PaywallListener. * Adds PaywallListener to PaywallOptions. * Adds shouldDisplayDismissButton to PaywallOptions. * Adds and uses UIKitPaywall. * Propagates shouldDisplayDismissButton on Android. * Deletes PaywallViewControllerDelegate. * Sets shouldDisplayDismissButton to true. * Updates some Xcode files. * Adds a back button to CustomPaywallContent. * Fixes the height of PaywallFooter by animating it. * PaywallFooter now also works without a listener set. * UIKitPaywall uses UIKitViewController instead of UIKitView. * Adds docs to PaywallListener to fix Detekt. * Updates public api dump. * Fixes api-tester. * Adds 2 run configurations that mimic CI. * Adds public api dump for paywalls.
- Loading branch information
1 parent
7e39f42
commit 4918256
Showing
41 changed files
with
1,123 additions
and
134 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,6 @@ captures | |
.cxx | ||
local.properties | ||
xcuserdata | ||
Pods | ||
Pods | ||
.kotlin | ||
!.run |
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,25 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="kobankat [:apiTester:assemble]" | ||
type="GradleRunConfiguration" factoryName="Gradle"> | ||
<ExternalSystemSettings> | ||
<option name="executionName" /> | ||
<option name="externalProjectPath" value="$PROJECT_DIR$" /> | ||
<option name="externalSystemIdString" value="GRADLE" /> | ||
<option name="scriptParameters" value="" /> | ||
<option name="taskDescriptions"> | ||
<list /> | ||
</option> | ||
<option name="taskNames"> | ||
<list> | ||
<option value=":apiTester:assemble" /> | ||
</list> | ||
</option> | ||
<option name="vmOptions" /> | ||
</ExternalSystemSettings> | ||
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess> | ||
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess> | ||
<DebugAllEnabled>false</DebugAllEnabled> | ||
<RunAsTest>false</RunAsTest> | ||
<method v="2" /> | ||
</configuration> | ||
</component> |
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,25 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="kobankat [detektCommonMain]" type="GradleRunConfiguration" | ||
factoryName="Gradle"> | ||
<ExternalSystemSettings> | ||
<option name="executionName" /> | ||
<option name="externalProjectPath" value="$PROJECT_DIR$" /> | ||
<option name="externalSystemIdString" value="GRADLE" /> | ||
<option name="scriptParameters" value="" /> | ||
<option name="taskDescriptions"> | ||
<list /> | ||
</option> | ||
<option name="taskNames"> | ||
<list> | ||
<option value="detektCommonMain" /> | ||
</list> | ||
</option> | ||
<option name="vmOptions" /> | ||
</ExternalSystemSettings> | ||
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess> | ||
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess> | ||
<DebugAllEnabled>false</DebugAllEnabled> | ||
<RunAsTest>false</RunAsTest> | ||
<method v="2" /> | ||
</configuration> | ||
</component> |
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
100 changes: 48 additions & 52 deletions
100
composeApp/src/commonMain/kotlin/io/shortway/kobankat/sample/App.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,87 +1,83 @@ | ||
package io.shortway.kobankat.sample | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.lazy.LazyColumn | ||
import androidx.compose.foundation.lazy.items | ||
import androidx.compose.foundation.lazy.rememberLazyListState | ||
import androidx.compose.material.Button | ||
import androidx.compose.material.MaterialTheme | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.runtime.mutableStateListOf | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.snapshots.SnapshotStateList | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.text.font.FontFamily | ||
import androidx.compose.ui.unit.dp | ||
import io.shortway.kobankat.LogLevel | ||
import io.shortway.kobankat.PurchasesConfiguration | ||
import io.shortway.kobankat.PurchasesFactory | ||
import androidx.compose.ui.text.style.TextAlign | ||
import io.shortway.kobankat.Offering | ||
import io.shortway.kobankat.ui.revenuecatui.Paywall | ||
import io.shortway.kobankat.ui.revenuecatui.PaywallFooter | ||
import io.shortway.kobankat.ui.revenuecatui.PaywallOptions | ||
|
||
@Composable | ||
fun App() { | ||
val logs = remember { mutableStateListOf<String>() } | ||
LaunchedEffect(Unit) { | ||
// In a real app, you'd probably have a class dedicated to app initialization logic. | ||
PurchasesFactory.configure( | ||
PurchasesConfiguration( | ||
apiKey = "YOUR-REVENUECAT-API-KEY", | ||
) | ||
) | ||
PurchasesFactory.logLevel = LogLevel.VERBOSE | ||
PurchasesFactory.logHandler = SimpleLogHandler { logs.add(it) } | ||
} | ||
|
||
MaterialTheme { | ||
Column( | ||
modifier = Modifier | ||
.fillMaxSize(), | ||
horizontalAlignment = Alignment.CenterHorizontally | ||
) { | ||
Text( | ||
text = "KobanKat logs", | ||
modifier = Modifier.padding(all = 16.dp), | ||
style = MaterialTheme.typography.h4 | ||
) | ||
var showPaywallAsFooter by remember { mutableStateOf(false) } | ||
var paywallOffering: Offering? by remember { mutableStateOf(null) } | ||
|
||
if (paywallOffering == null) MainScreen( | ||
onShowPaywallClick = { offering, footer -> | ||
showPaywallAsFooter = footer | ||
paywallOffering = offering | ||
}, | ||
modifier = Modifier.fillMaxSize() | ||
) else { | ||
val options = PaywallOptions(dismissRequest = { paywallOffering = null }) { | ||
offering = paywallOffering | ||
shouldDisplayDismissButton = true | ||
} | ||
|
||
if (showPaywallAsFooter) PaywallFooter(options) { contentPadding -> | ||
CustomPaywallContent( | ||
onBackClick = { paywallOffering = null }, | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.background(Color.Magenta) | ||
.padding(contentPadding), | ||
) | ||
} | ||
else Paywall(options) | ||
} | ||
|
||
LogView( | ||
logs = logs, | ||
modifier = Modifier | ||
.weight(1f) | ||
.background(Color.LightGray), | ||
) | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
private fun LogView( | ||
logs: SnapshotStateList<String>, | ||
private fun CustomPaywallContent( | ||
onBackClick: () -> Unit, | ||
modifier: Modifier = Modifier, | ||
) { | ||
val listState = rememberLazyListState() | ||
LaunchedEffect(logs.size) { | ||
listState.animateScrollToItem(index = logs.lastIndex.coerceAtLeast(0)) | ||
} | ||
|
||
LazyColumn( | ||
Column( | ||
modifier = modifier, | ||
state = listState, | ||
contentPadding = PaddingValues(all = 16.dp) | ||
verticalArrangement = Arrangement.Center, | ||
horizontalAlignment = Alignment.CenterHorizontally, | ||
) { | ||
items(logs) { | ||
Text( | ||
text = it, | ||
modifier = Modifier.padding(vertical = 4.dp), | ||
fontFamily = FontFamily.Monospace, | ||
style = MaterialTheme.typography.caption | ||
) | ||
Text( | ||
text = "Custom paywall content!", | ||
textAlign = TextAlign.Center, | ||
style = MaterialTheme.typography.h4, | ||
) | ||
Button(onClick = onBackClick) { | ||
Text("Go back") | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
composeApp/src/commonMain/kotlin/io/shortway/kobankat/sample/LogView.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,41 @@ | ||
package io.shortway.kobankat.sample | ||
|
||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.lazy.LazyColumn | ||
import androidx.compose.foundation.lazy.items | ||
import androidx.compose.foundation.lazy.rememberLazyListState | ||
import androidx.compose.material.MaterialTheme | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.runtime.snapshots.SnapshotStateList | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.text.font.FontFamily | ||
import androidx.compose.ui.unit.dp | ||
|
||
@Composable | ||
internal fun LogView( | ||
logs: SnapshotStateList<String>, | ||
modifier: Modifier = Modifier, | ||
) { | ||
val listState = rememberLazyListState() | ||
LaunchedEffect(logs.size) { | ||
listState.animateScrollToItem(index = logs.lastIndex.coerceAtLeast(0)) | ||
} | ||
|
||
LazyColumn( | ||
modifier = modifier, | ||
state = listState, | ||
contentPadding = PaddingValues(all = 16.dp) | ||
) { | ||
items(logs) { | ||
Text( | ||
text = it, | ||
modifier = Modifier.padding(vertical = 4.dp), | ||
fontFamily = FontFamily.Monospace, | ||
style = MaterialTheme.typography.caption | ||
) | ||
} | ||
} | ||
} |
Oops, something went wrong.