-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement empty Become a Legend screen;
Connect support with become a legend and buying premium;
- Loading branch information
1 parent
a5362d8
commit b56c421
Showing
6 changed files
with
155 additions
and
61 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
12 changes: 12 additions & 0 deletions
12
app/src/main/kotlin/net/primal/android/premium/legend/PremiumBecomeLegendContract.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,12 @@ | ||
package net.primal.android.premium.legend | ||
|
||
class PremiumBecomeLegendContract { | ||
|
||
data class UiState( | ||
val loading: Boolean = true, | ||
) | ||
|
||
sealed class UiEvent { | ||
data object ShowAmountEditor : UiEvent() | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
app/src/main/kotlin/net/primal/android/premium/legend/PremiumBecomeLegendScreen.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,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, | ||
) { | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
app/src/main/kotlin/net/primal/android/premium/legend/PremiumBecomeLegendViewModel.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,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 | ||
} | ||
} | ||
} | ||
} |
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