Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BackButton and Skip support added on login page #99

Merged
merged 1 commit into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,30 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.techlads.composetv.navigation.Screens
import com.techlads.composetv.theme.ComposeTvTheme

@Composable
fun DeviceTokenAuthenticationScreen(
modifier: Modifier = Modifier,
onSkip: () -> Unit,
goToScreen: (Screens) -> Unit,
) {
Box(modifier = modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
DeviceTokenAuthenticationContent(token = "OTF2", "www.google.com") {
DeviceTokenAuthenticationContent(token = "OTF2", "www.google.com", skip = onSkip) {
goToScreen(Screens.Login)
}
}
}


@Preview
@Composable
private fun DeviceTokenAuthenticationScreenPreview() {
ComposeTvTheme {
DeviceTokenAuthenticationScreen(Modifier.fillMaxSize(), onSkip = {}) {

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
package com.techlads.composetv.features.login.withToken

import androidx.compose.foundation.Image
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
Expand All @@ -15,7 +13,6 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material3.Divider
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
Expand All @@ -27,24 +24,28 @@ import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.core.graphics.drawable.toBitmap
import androidx.tv.material3.ButtonDefaults
import androidx.tv.material3.ExperimentalTvMaterial3Api
import androidx.tv.material3.MaterialTheme
import androidx.tv.material3.Text
import com.github.alexzhirkevich.customqrgenerator.QrData
import com.github.alexzhirkevich.customqrgenerator.vector.QrCodeDrawable
import com.github.alexzhirkevich.customqrgenerator.vector.QrVectorOptions
import com.github.alexzhirkevich.customqrgenerator.vector.style.QrVectorColor
import com.github.alexzhirkevich.customqrgenerator.vector.style.QrVectorColors
import com.techlads.composetv.theme.ComposeTvTheme
import com.techlads.composetv.widgets.TvButton

@OptIn(ExperimentalTvMaterial3Api::class)
@Composable
fun DeviceTokenAuthenticationContent(
token: String,
url: String,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
skip: () -> Unit,
onLoginClick: (token: String) -> Unit,
) {
val context = LocalContext.current
Expand Down Expand Up @@ -149,14 +150,14 @@ fun DeviceTokenAuthenticationContent(

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

Box(
Row(
modifier = Modifier
.width(300.dp)
.padding(40.dp, 0.dp, 40.dp, 0.dp),
) {
TvButton(
modifier = Modifier.padding(start = 20.dp, end = 20.dp),
interactionSource = interactionSource,
modifier = Modifier
.weight(1f)
.padding(start = 20.dp, end = 20.dp),
onClick = { onLoginClick(token) },
) {
Text(
Expand All @@ -169,6 +170,36 @@ fun DeviceTokenAuthenticationContent(
),
)
}

TvButton(
modifier = Modifier
.weight(1f)
.padding(start = 20.dp, end = 20.dp),
colors = ButtonDefaults.colors(
containerColor = MaterialTheme.colorScheme.surface,
contentColor = MaterialTheme.colorScheme.onSurface,
),
onClick = { skip() },
) {
Text(
modifier = Modifier.fillMaxWidth(),
text = "Skip",
style = TextStyle(
fontFamily = FontFamily.SansSerif,
fontWeight = FontWeight.Light,
textAlign = TextAlign.Center,
),
)
}
}
}
}


@Preview
@Composable
fun DeviceTokenAuthenticationContentPreview() {
ComposeTvTheme {
DeviceTokenAuthenticationContent(token = "OTF2", "www.google.com", skip = {}, onLoginClick = {})
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.techlads.composetv.features.mp3.player

import androidx.activity.compose.BackHandler
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
Expand All @@ -8,12 +9,13 @@ import androidx.compose.ui.tooling.preview.Preview


@Composable
fun Mp3PlayerScreen() {
Mp3PlayerScreenContent(modifier = Modifier.fillMaxSize())
fun AudioPlayerScreen(onBackPressed: () -> Unit) {
BackHandler(onBack = onBackPressed)
AudioPlayerScreenContent(modifier = Modifier.fillMaxSize())
}

@Preview(device = Devices.TV_1080p)
@Composable
private fun Mp3PlayerScreenPrev() {
Mp3PlayerScreen()
private fun AudioPlayerScreenPrev() {
AudioPlayerScreen {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import com.techlads.composetv.features.player.controls.VideoPlayerControllerIndi
import com.techlads.composetv.features.player.controls.rememberVideoPlayerState

@Composable
fun Mp3PlayerScreenContent(modifier: Modifier){
fun AudioPlayerScreenContent(modifier: Modifier){
Box(contentAlignment = Alignment.Center, modifier = modifier.fillMaxSize()) {
Column(horizontalAlignment = Alignment.CenterHorizontally) {
Poster()
Expand Down Expand Up @@ -132,7 +132,6 @@ fun SongProgressBar(

@Composable
fun Details() {

Column(horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier.fillMaxWidth()) {
Text(text = "Chris Brown - Babie ft. Tyga", style = MaterialTheme.typography.titleLarge)
Spacer(modifier = Modifier.size(2.dp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import com.techlads.composetv.features.details.ProductDetailsScreen
import com.techlads.composetv.features.home.HomeScreen
import com.techlads.composetv.features.login.withEmailPassword.LoginScreen
import com.techlads.composetv.features.login.withToken.DeviceTokenAuthenticationScreen
import com.techlads.composetv.features.mp3.player.Mp3PlayerScreen
import com.techlads.composetv.features.mp3.player.AudioPlayerScreen
import com.techlads.composetv.features.player.PlayerScreen
import com.techlads.composetv.features.wiw.WhoIsWatchingScreen

Expand All @@ -38,7 +38,9 @@ fun AppNavigation(navController: NavHostController) {
enterTransition = { tabEnterTransition() },
exitTransition = { tabExitTransition() },
) {
DeviceTokenAuthenticationScreen {
DeviceTokenAuthenticationScreen(onSkip = {
navController.navigateSingleTopTo(Screens.Home.title)
}) {
navController.navigateSingleTopTo(it.title)
}
}
Expand All @@ -56,7 +58,9 @@ fun AppNavigation(navController: NavHostController) {
Screens.Mp3Player.title,
enterTransition = { tabEnterTransition() },
exitTransition = { tabExitTransition() }) {
Mp3PlayerScreen()
AudioPlayerScreen {
navController.navigateUp()
}
}

composable(
Expand Down