Skip to content

Commit

Permalink
version 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vladd-g committed Oct 1, 2024
1 parent e1495a7 commit 1e7c56b
Show file tree
Hide file tree
Showing 129 changed files with 7,191 additions and 5,939 deletions.
31 changes: 23 additions & 8 deletions adapty-ui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
defaultConfig {
minSdk 21
targetSdk 31
buildConfigField 'String', 'VERSION_NAME', "\"2.11.3\""
buildConfigField 'String', 'BUILDER_VERSION', "\"3\""
buildConfigField 'String', 'VERSION_NAME', "\"3.0.0\""
buildConfigField 'String', 'BUILDER_VERSION', "\"4_0\""

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
Expand All @@ -23,21 +23,36 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.4.1"
}
kotlinOptions {
freeCompilerArgs += ['-Xexplicit-api=strict', '-Xopt-in=kotlin.RequiresOptIn']
freeCompilerArgs += ['-Xopt-in=kotlin.RequiresOptIn']
}
namespace 'com.adapty.ui'
}

def composeBom = '2024.09.02'

dependencies {

compileOnly 'io.adapty:android-sdk:2.11.4'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.core:core:1.9.0'
compileOnly 'io.adapty:android-sdk:3.0.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

implementation platform("androidx.compose:compose-bom:$composeBom")
api 'androidx.compose.ui:ui'
implementation 'androidx.compose.material3:material3'
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.8.0'

debugCompileOnly 'androidx.compose.ui:ui-tooling'
debugCompileOnly 'androidx.compose.ui:ui-test-manifest'
}
45 changes: 0 additions & 45 deletions adapty-ui/src/main/java/com/adapty/ui/AdaptyPaywallInsets.kt

This file was deleted.

81 changes: 81 additions & 0 deletions adapty-ui/src/main/java/com/adapty/ui/AdaptyPaywallScreen.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package com.adapty.ui

import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.platform.LocalContext
import androidx.lifecycle.viewmodel.compose.viewModel
import com.adapty.models.AdaptyPaywallProduct
import com.adapty.ui.internal.ui.AdaptyPaywallInternal
import com.adapty.ui.internal.ui.PaywallViewModel
import com.adapty.ui.internal.ui.PaywallViewModelArgs
import com.adapty.ui.internal.ui.PaywallViewModelFactory
import com.adapty.ui.internal.ui.UserArgs
import com.adapty.ui.internal.utils.ProductLoadingFailureCallback
import com.adapty.ui.internal.utils.getCurrentLocale
import com.adapty.ui.listeners.AdaptyUiDefaultEventListener
import com.adapty.ui.listeners.AdaptyUiEventListener
import com.adapty.ui.listeners.AdaptyUiObserverModeHandler
import com.adapty.ui.listeners.AdaptyUiPersonalizedOfferResolver
import com.adapty.ui.listeners.AdaptyUiTagResolver
import com.adapty.ui.listeners.AdaptyUiTimerResolver
import java.util.UUID

/**
* Paywall screen composable representation
*
* @param[viewConfiguration] An [AdaptyUI.LocalizedViewConfiguration] object containing information
* about the visual part of the paywall. To load it, use the [AdaptyUI.getViewConfiguration] method.
*
* @param[products] Optional [AdaptyPaywallProduct] list. Pass this value in order to optimize
* the display time of the products on the screen. If you pass `null`, `AdaptyUI` will
* automatically fetch the required products.
*
* @param[eventListener] An object that implements the [AdaptyUiEventListener] interface.
* Use it to respond to different events happening inside the purchase screen.
* Also you can extend [AdaptyUiDefaultEventListener] so you don't need to override all the methods.
*
* @param[personalizedOfferResolver] In case you want to indicate whether the price is personalized ([read more](https://developer.android.com/google/play/billing/integrate#personalized-price)),
* you can implement [AdaptyUiPersonalizedOfferResolver] and pass your own logic
* that maps [AdaptyPaywallProduct] to `true`, if the price of the product is personalized, otherwise `false`.
*
* @param[tagResolver] If you are going to use custom tags functionality, pass the resolver function here.
*
* @param[timerResolver] If you are going to use custom timer functionality, pass the resolver function here.
*
* @param[observerModeHandler] If you use Adapty in [Observer mode](https://adapty.io/docs/observer-vs-full-mode),
* pass the [AdaptyUiObserverModeHandler] implementation to handle purchases on your own.
*/
@Composable
public fun AdaptyPaywallScreen(
viewConfiguration: AdaptyUI.LocalizedViewConfiguration,
products: List<AdaptyPaywallProduct>?,
eventListener: AdaptyUiEventListener,
personalizedOfferResolver: AdaptyUiPersonalizedOfferResolver = AdaptyUiPersonalizedOfferResolver.DEFAULT,
tagResolver: AdaptyUiTagResolver = AdaptyUiTagResolver.DEFAULT,
timerResolver: AdaptyUiTimerResolver = AdaptyUiTimerResolver.DEFAULT,
observerModeHandler: AdaptyUiObserverModeHandler? = null,
) {
val context = LocalContext.current
val vmArgs = remember {
val userArgs = UserArgs.create(
viewConfiguration,
eventListener,
personalizedOfferResolver,
tagResolver,
timerResolver,
observerModeHandler,
products,
ProductLoadingFailureCallback { error -> eventListener.onLoadingProductsFailure(error, context) },
)
PaywallViewModelArgs.create(
"${UUID.randomUUID().toString().hashCode()}",
userArgs,
context.getCurrentLocale(),
)
} ?: return

val viewModel: PaywallViewModel = viewModel(
factory = PaywallViewModelFactory(vmArgs)
)
AdaptyPaywallInternal(viewModel)
}
Loading

0 comments on commit 1e7c56b

Please sign in to comment.