Skip to content

Commit

Permalink
Update onboarding flow with the new designs (#381)
Browse files Browse the repository at this point in the history
* Update onboarding flow with the new designs

* Created Welcome Screen
* Redesigned Login Screen
* Added error indicators and text errors for Login input fields

* Run spotless
  • Loading branch information
AMITGOELNY authored Aug 27, 2023
1 parent ab58d50 commit 0da8c6f
Show file tree
Hide file tree
Showing 14 changed files with 449 additions and 54 deletions.
1 change: 1 addition & 0 deletions anystream-client-android/src/main/kotlin/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ open class MainActivity : AppCompatActivity() {
.launchIn(scope)
}
when (val route = stack.last()) {
Routes.Welcome,
Routes.Login -> LoginScreen(client, androidRouter)
Routes.Home -> HomeScreen(
client = client,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ package anystream.routing
sealed class Routes {
abstract val path: String

data object Welcome : Routes() {
override val path: String = "welcome"
}

data object Login : Routes() {
override val path: String = "login"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ data class LoginScreenModel(
val loginError: CreateSessionResponse.Error? = null,
) {
enum class State {
IDLE, AUTHENTICATING, AUTHENTICATED,
IDLE, AUTHENTICATING, AUTHENTICATED;

val isAuthenticating: Boolean
get() = this == AUTHENTICATING
}

enum class ServerValidation {
Expand Down
20 changes: 11 additions & 9 deletions anystream-client-ui/src/commonMain/kotlin/anystream/ui/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import anystream.router.SharedRouter
import anystream.routing.Routes
import anystream.ui.home.HomeScreen
import anystream.ui.login.LoginScreen
import anystream.ui.login.WelcomeScreen
import anystream.ui.media.MediaScreen
import anystream.ui.movies.MoviesScreen
import anystream.ui.theme.AppTheme
Expand All @@ -52,11 +53,11 @@ fun App() {
AppTheme {
BundleScope(null) {
val defaultRoute = when {
!client.isAuthenticated() -> Routes.Login
!client.isAuthenticated() -> Routes.Welcome
else -> Routes.Home
}
Router(
defaultRoute::class.simpleName.orEmpty(),
contextId = defaultRoute::class.simpleName.orEmpty(),
defaultRouting = defaultRoute,
) { stack ->
LaunchedEffect(stack) {
Expand All @@ -65,7 +66,7 @@ fun App() {
remember {
client.authenticated
.onEach { authed ->
val isLoginRoute = stack.last() == Routes.Login
val isLoginRoute = stack.last() == Routes.Welcome
if (authed && isLoginRoute) {
stack.replace(Routes.Home)
} else if (!authed && !isLoginRoute) {
Expand All @@ -75,6 +76,7 @@ fun App() {
.launchIn(scope)
}
when (val route = stack.last()) {
Routes.Welcome -> WelcomeScreen { stack.push(Routes.Login) }
Routes.Login -> LoginScreen(client, router)
Routes.Home -> HomeScreen(
client = client,
Expand Down Expand Up @@ -108,11 +110,7 @@ fun App() {
},
backStack = stack,
)
// Routes.Tv -> TODO("Tv route not implemented")
// Routes.PairingScanner -> PairingScanner(
// client = client,
// backStack = stack,
// )

is Routes.Details -> MediaScreen(
client = client,
mediaId = route.mediaRefId,
Expand All @@ -126,7 +124,11 @@ fun App() {

is Routes.Player -> SharedVideoPlayer(route, stack, client)
Routes.PairingScanner -> TODO()
Routes.Tv -> TODO()
// Routes.PairingScanner -> PairingScanner(
// client = client,
// backStack = stack,
// )
Routes.Tv -> TODO("Tv route not implemented")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/**
* AnyStream
* Copyright (C) 2023 AnyStream Maintainers
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package anystream.ui.components

import androidx.compose.animation.AnimatedContent
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.Button
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.CircularProgressIndicator
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp

@Composable
internal fun PrimaryButton(
leftIcon: @Composable (() -> Unit)? = null,
text: String,
modifier: Modifier = Modifier,
isLoading: Boolean = false,
onClick: () -> Unit,
) {
Button(
onClick = onClick,
shape = CircleShape,
contentPadding = PaddingValues(horizontal = 16.dp, vertical = 18.dp),
enabled = !isLoading,
colors = ButtonDefaults.buttonColors(
contentColor = MaterialTheme.colors.onBackground,
disabledBackgroundColor = MaterialTheme.colors.primary,
),
modifier = modifier,
) {
AnimatedContent(targetState = isLoading) { targetState ->
when (targetState) {
true -> {
CircularProgressIndicator(
modifier = Modifier.size(20.dp),
color = MaterialTheme.colors.onBackground,
strokeWidth = 1.dp,
)
}

false -> {
leftIcon?.let { icon ->
icon()
Spacer(Modifier.width(8.dp))
}
Text(
text = text,
style = MaterialTheme.typography.body1.copy(fontWeight = FontWeight.Bold),
letterSpacing = 0.2.sp,
textAlign = TextAlign.Center,
)
}
}
}
}
}
Loading

0 comments on commit 0da8c6f

Please sign in to comment.