Skip to content

Commit

Permalink
Implement empty Become a Legend screen;
Browse files Browse the repository at this point in the history
Connect support with become a legend and buying premium;
  • Loading branch information
AleksandarIlic committed Nov 11, 2024
1 parent a5362d8 commit b56c421
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ import net.primal.android.premium.buying.PremiumBuyingViewModel
import net.primal.android.premium.home.PremiumHomeScreen
import net.primal.android.premium.home.PremiumHomeViewModel
import net.primal.android.premium.info.PremiumMoreInfoScreen
import net.primal.android.premium.legend.PremiumBecomeLegendScreen
import net.primal.android.premium.legend.PremiumBecomeLegendViewModel
import net.primal.android.premium.manage.PremiumManageContract
import net.primal.android.premium.manage.PremiumManageScreen
import net.primal.android.premium.manage.contact.PremiumContactListScreen
Expand Down Expand Up @@ -250,6 +252,7 @@ private fun NavController.navigateToPremiumBuying() = navigate(route = "premium/
private fun NavController.navigateToPremiumHome() = navigate(route = "premium/home")
private fun NavController.navigateToPremiumSupportPrimal() = navigate(route = "premium/supportPrimal")
private fun NavController.navigateToPremiumMoreInfo() = navigate(route = "premium/info")
private fun NavController.navigateToPremiumBecomeLegend() = navigate(route = "premium/legend/become")
private fun NavController.navigateToPremiumManage() = navigate(route = "premium/manage")
private fun NavController.navigateToPremiumMediaManagement() = navigate(route = "premium/manage/media")
private fun NavController.navigateToPremiumContactList() = navigate(route = "premium/manage/contacts")
Expand Down Expand Up @@ -390,10 +393,7 @@ fun PrimalAppNavigation() {
onDrawerScreenClick = drawerDestinationHandler,
)

bookmarks(
route = "bookmarks",
navController = navController,
)
bookmarks(route = "bookmarks", navController = navController)

exploreFeed(
route = "explore/note?$EXPLORE_FEED_SPEC={$EXPLORE_FEED_SPEC}&$RENDER_TYPE={$RENDER_TYPE}",
Expand Down Expand Up @@ -435,65 +435,31 @@ fun PrimalAppNavigation() {
),
)

premiumBuying(
route = "premium/buying",
navController = navController,
)
premiumBuying(route = "premium/buying", navController = navController)

premiumHome(
route = "premium/home",
navController = navController,
)
premiumHome(route = "premium/home", navController = navController)

premiumSupportPrimal(
route = "premium/supportPrimal",
navController = navController,
)
premiumSupportPrimal(route = "premium/supportPrimal", navController = navController)

premiumMoreInfo(
route = "premium/info",
navController = navController,
)
premiumMoreInfo(route = "premium/info", navController = navController)

premiumManage(
route = "premium/manage",
navController = navController,
)
premiumBecomeLegend(route = "premium/legend/become", navController = navController)

premiumContactList(
route = "premium/manage/contacts",
navController = navController,
)
premiumManage(route = "premium/manage", navController = navController)

premiumContentBackup(
route = "premium/manage/content",
navController = navController,
)
premiumContactList(route = "premium/manage/contacts", navController = navController)

premiumMediaManagement(
route = "premium/manage/media",
navController = navController,
)
premiumContentBackup(route = "premium/manage/content", navController = navController)

premiumChangePrimalName(
route = "premium/manage/changePrimalName",
navController = navController,
)
premiumMediaManagement(route = "premium/manage/media", navController = navController)

premiumOrderHistory(
route = "premium/manage/order",
navController = navController,
)
premiumChangePrimalName(route = "premium/manage/changePrimalName", navController = navController)

premiumRelay(
route = "premium/manage/relay",
navController = navController,
)
premiumOrderHistory(route = "premium/manage/order", navController = navController)

messages(
route = "messages",
navController = navController,
)
premiumRelay(route = "premium/manage/relay", navController = navController)

messages(route = "messages", navController = navController)

chat(
route = "messages/{$PROFILE_ID}",
Expand All @@ -505,10 +471,7 @@ fun PrimalAppNavigation() {
navController = navController,
)

newMessage(
route = "messages/new",
navController = navController,
)
newMessage(route = "messages/new", navController = navController)

notifications(
route = "notifications",
Expand Down Expand Up @@ -1024,8 +987,8 @@ private fun NavGraphBuilder.premiumSupportPrimal(route: String, navController: N
viewModel = viewModel,
callbacks = SupportPrimalContract.ScreenCallbacks(
onClose = { navController.navigateUp() },
onBuySubscription = { },
onBecomeLegend = { },
onBuySubscription = { navController.navigateToPremiumBuying() },
onBecomeLegend = { navController.navigateToPremiumBecomeLegend() },
),
)
}
Expand All @@ -1046,6 +1009,24 @@ private fun NavGraphBuilder.premiumMoreInfo(route: String, navController: NavCon
)
}

private fun NavGraphBuilder.premiumBecomeLegend(route: String, navController: NavController) =
composable(
route = route,
enterTransition = { primalSlideInHorizontallyFromEnd },
exitTransition = { primalScaleOut },
popEnterTransition = { primalScaleIn },
popExitTransition = { primalSlideOutHorizontallyToEnd },
) {
val viewModel = hiltViewModel<PremiumBecomeLegendViewModel>()
ApplyEdgeToEdge()
LockToOrientationPortrait()

PremiumBecomeLegendScreen(
viewModel = viewModel,
onClose = { navController.navigateUp() },
)
}

private fun NavGraphBuilder.premiumManage(route: String, navController: NavController) =
composable(
route = route,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package net.primal.android.premium.legend

class PremiumBecomeLegendContract {

data class UiState(
val loading: Boolean = true,
)

sealed class UiEvent {
data object ShowAmountEditor : UiEvent()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package net.primal.android.premium.legend

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import net.primal.android.R
import net.primal.android.core.compose.PrimalTopAppBar
import net.primal.android.core.compose.icons.PrimalIcons
import net.primal.android.core.compose.icons.primaliconpack.ArrowBack

@Composable
fun PremiumBecomeLegendScreen(viewModel: PremiumBecomeLegendViewModel, onClose: () -> Unit) {
val state = viewModel.state.collectAsState()

PremiumBecomeLegendScreen(
state = state.value,
eventPublisher = viewModel::setEvent,
onClose = onClose,
)
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun PremiumBecomeLegendScreen(
state: PremiumBecomeLegendContract.UiState,
eventPublisher: (PremiumBecomeLegendContract.UiEvent) -> Unit,
onClose: () -> Unit,
) {
Scaffold(
modifier = Modifier.fillMaxSize(),
topBar = {
PrimalTopAppBar(
title = stringResource(id = R.string.premium_become_legend_primal_title),
navigationIcon = PrimalIcons.ArrowBack,
onNavigationIconClick = onClose,
showDivider = false,
)
},
) { paddingValues ->
Column(
modifier = Modifier
.fillMaxSize()
.verticalScroll(state = rememberScrollState())
.padding(paddingValues)
.padding(horizontal = 16.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Top,
) {
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package net.primal.android.premium.legend

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.getAndUpdate
import kotlinx.coroutines.launch
import net.primal.android.premium.legend.PremiumBecomeLegendContract.UiEvent
import net.primal.android.premium.legend.PremiumBecomeLegendContract.UiState

@HiltViewModel
class PremiumBecomeLegendViewModel @Inject constructor() : ViewModel() {

private val _state = MutableStateFlow(UiState())
val state = _state.asStateFlow()
private fun setState(reducer: UiState.() -> UiState) = _state.getAndUpdate(reducer)

private val events: MutableSharedFlow<UiEvent> = MutableSharedFlow()
fun setEvent(event: UiEvent) = viewModelScope.launch { events.emit(event) }

init {
observeEvents()
}

private fun observeEvents() =
viewModelScope.launch {
events.collect {
when (it) {
UiEvent.ShowAmountEditor -> Unit
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,14 @@ private fun SupportPrimalScreen(

Spacer(modifier = Modifier.height(20.dp))

if (!state.hasMembership) {
if (!state.hasMembership || true) {
SupportCard(
modifier = Modifier.fillMaxSize(),
painter = painterResource(R.drawable.support_primal_buy_subscription),
title = stringResource(R.string.premium_support_primal_buy_subscription_title),
description = stringResource(R.string.premium_support_primal_buy_subscription_description),
buttonText = stringResource(R.string.premium_support_primal_buy_subscription_button_text),
onClick = {},
onClick = callbacks.onBuySubscription,
)

Spacer(modifier = Modifier.height(20.dp))
Expand All @@ -119,7 +119,7 @@ private fun SupportPrimalScreen(
title = stringResource(R.string.premium_support_primal_become_a_legend_title),
description = stringResource(R.string.premium_support_primal_become_a_legend_description),
buttonText = stringResource(R.string.premium_support_primal_become_a_legend_button_text),
onClick = {},
onClick = callbacks.onBecomeLegend,
)

Spacer(modifier = Modifier.height(16.dp))
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@

<string name="premium_support_primal_title">Support Primal</string>

<string name="premium_become_legend_primal_title">Become a Primal Legend</string>

<string name="premium_manage_title">Manage Premium</string>
<string name="premium_manage_nostr_tools">Nostr Tools</string>
<string name="premium_manage_primal_account">Primal Account</string>
Expand Down

0 comments on commit b56c421

Please sign in to comment.