Skip to content

Commit 42d657b

Browse files
authored
Merge pull request #18 from RevenueCat/feature/customer-center
Implement CustomerCenter screen
2 parents 7994a59 + 224a1d4 commit 42d657b

File tree

18 files changed

+769
-11
lines changed

18 files changed

+769
-11
lines changed

app/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ dependencies {
6666
implementation(projects.feature.home)
6767
implementation(projects.feature.article)
6868
implementation(projects.feature.paywalls)
69+
implementation(projects.feature.account)
70+
implementation(projects.feature.subscriptions)
6971

7072
// RevenueCat
7173
implementation(libs.revenuecat)

app/src/main/kotlin/com/revenuecat/articles/paywall/compose/navigation/CatArticlesNavigation.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ import androidx.compose.animation.SharedTransitionScope
1919
import androidx.navigation.NavGraphBuilder
2020
import androidx.navigation.compose.composable
2121
import com.revenuecat.articles.paywall.core.navigation.CatArticlesScreen
22+
import com.revenuecat.articles.paywall.feature.account.AccountScreen
2223
import com.revenuecat.articles.paywall.feature.article.CatArticlesDetail
2324
import com.revenuecat.articles.paywall.feature.home.CatArticlesHome
25+
import com.revenuecat.articles.paywall.feature.subscriptions.SubscriptionManagementScreen
2426
import com.revenuecat.articles.paywall.paywalls.CatCustomPaywalls
2527

2628
fun NavGraphBuilder.catArticlesNavigation(sharedTransitionScope: SharedTransitionScope) {
@@ -38,5 +40,13 @@ fun NavGraphBuilder.catArticlesNavigation(sharedTransitionScope: SharedTransitio
3840
composable<CatArticlesScreen.Paywalls> {
3941
CatCustomPaywalls()
4042
}
43+
44+
composable<CatArticlesScreen.Account> {
45+
AccountScreen()
46+
}
47+
48+
composable<CatArticlesScreen.SubscriptionManagement> {
49+
SubscriptionManagementScreen()
50+
}
4151
}
4252
}

core/data/src/main/kotlin/com/revenuecat/articles/paywall/coredata/repository/PaywallsRepository.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ interface PaywallsRepository {
2727

2828
fun fetchOffering(): Flow<ApiResponse<Offering>>
2929

30-
fun fetchCustomerInfo(): Flow<CustomerInfo?>
30+
fun fetchCustomerInfo(): Flow<ApiResponse<CustomerInfo?>>
3131

3232
fun awaitPurchases(
3333
activity: Activity,

core/data/src/main/kotlin/com/revenuecat/articles/paywall/coredata/repository/PaywallsRepositoryImpl.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ internal class PaywallsRepositoryImpl @Inject constructor(
5050
}
5151
}.flowOn(ioDispatcher)
5252

53-
override fun fetchCustomerInfo(): Flow<CustomerInfo?> = flow {
53+
override fun fetchCustomerInfo(): Flow<ApiResponse<CustomerInfo?>> = flow {
5454
try {
5555
val customerInfo = Purchases.sharedInstance.awaitCustomerInfo()
56-
emit(customerInfo)
56+
emit(ApiResponse.of { customerInfo })
5757
} catch (e: PurchasesException) {
58-
emit(null)
58+
emit(ApiResponse.exception(e))
5959
}
60-
}
60+
}.flowOn(ioDispatcher)
6161

6262
override fun awaitPurchases(activity: Activity, availablePackage: Package) = flow {
6363
try {

core/designsystem/src/main/kotlin/com/revenuecat/articles/paywall/core/designsystem/component/CatArticlesAppBar.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ fun CatArticlesAppBar(
3434
modifier: Modifier = Modifier,
3535
title: String = stringResource(id = R.string.app_name),
3636
navigationIcon: @Composable () -> Unit = {},
37+
actions: @Composable () -> Unit = {},
3738
) {
3839
TopAppBar(
3940
modifier = modifier,
@@ -46,6 +47,7 @@ fun CatArticlesAppBar(
4647
)
4748
},
4849
navigationIcon = navigationIcon,
50+
actions = { actions() },
4951
colors = TopAppBarDefaults.topAppBarColors().copy(
5052
containerColor = Color.Transparent,
5153
),

core/navigation/src/main/kotlin/com/revenuecat/articles/paywall/core/navigation/CatArticlesScreen.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,10 @@ sealed interface CatArticlesScreen {
3333
val typeMap = mapOf(typeOf<Article>() to CatArticlesType)
3434
}
3535
}
36+
37+
@Serializable
38+
data object Account : CatArticlesScreen
39+
40+
@Serializable
41+
data object SubscriptionManagement : CatArticlesScreen
3642
}

feature/account/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

feature/account/build.gradle.kts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright (c) 2025 RevenueCat, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
plugins {
17+
id("revenuecat.android.library")
18+
id("revenuecat.android.library.compose")
19+
id("revenuecat.android.feature")
20+
id("revenuecat.android.hilt")
21+
id("revenuecat.spotless")
22+
}
23+
24+
android {
25+
namespace = "com.revenuecat.articles.paywall.compose.feature.account"
26+
}
27+
28+
dependencies {
29+
// RevenueCat Purchases
30+
implementation(libs.revenuecat)
31+
implementation(libs.revenuecat.ui)
32+
33+
// Compose
34+
implementation(libs.androidx.compose.ui)
35+
implementation(libs.androidx.compose.ui.tooling)
36+
implementation(libs.androidx.compose.foundation)
37+
implementation(libs.androidx.compose.material)
38+
implementation(libs.androidx.compose.runtime)
39+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (c) 2025 RevenueCat, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.revenuecat.articles.paywall.feature.account
17+
18+
import androidx.compose.foundation.layout.Box
19+
import androidx.compose.foundation.layout.fillMaxSize
20+
import androidx.compose.runtime.Composable
21+
import androidx.compose.ui.Modifier
22+
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
23+
import com.revenuecat.purchases.ui.revenuecatui.customercenter.CustomerCenter
24+
25+
@Composable
26+
fun AccountScreen(
27+
viewModel: AccountViewModel = hiltViewModel(),
28+
) {
29+
Box(modifier = Modifier.fillMaxSize()) {
30+
CustomerCenter(
31+
modifier = Modifier.fillMaxSize(),
32+
onDismiss = { viewModel.navigateUp() },
33+
)
34+
}
35+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright (c) 2025 RevenueCat, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.revenuecat.articles.paywall.feature.account
17+
18+
import androidx.lifecycle.ViewModel
19+
import com.revenuecat.articles.paywall.core.navigation.AppComposeNavigator
20+
import com.revenuecat.articles.paywall.core.navigation.CatArticlesScreen
21+
import dagger.hilt.android.lifecycle.HiltViewModel
22+
import javax.inject.Inject
23+
24+
@HiltViewModel
25+
class AccountViewModel @Inject constructor(
26+
private val navigator: AppComposeNavigator<CatArticlesScreen>,
27+
) : ViewModel() {
28+
29+
fun navigateUp() {
30+
navigator.navigateUp()
31+
}
32+
}

0 commit comments

Comments
 (0)