-
Notifications
You must be signed in to change notification settings - Fork 0
Home Screen #61
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
base: main
Are you sure you want to change the base?
Home Screen #61
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,26 +3,38 @@ package com.majotyler.hiittimer.presentation.homeScreen | |||||||||||||||||||
| import androidx.compose.foundation.Image | ||||||||||||||||||||
| import androidx.compose.foundation.clickable | ||||||||||||||||||||
| import androidx.compose.foundation.layout.Arrangement | ||||||||||||||||||||
| import androidx.compose.foundation.layout.Box | ||||||||||||||||||||
| import androidx.compose.foundation.layout.Column | ||||||||||||||||||||
| import androidx.compose.foundation.layout.fillMaxSize | ||||||||||||||||||||
| import androidx.compose.foundation.layout.fillMaxWidth | ||||||||||||||||||||
| import androidx.compose.foundation.layout.height | ||||||||||||||||||||
| import androidx.compose.foundation.layout.padding | ||||||||||||||||||||
| import androidx.compose.foundation.layout.widthIn | ||||||||||||||||||||
| import androidx.compose.foundation.shape.RoundedCornerShape | ||||||||||||||||||||
| import androidx.compose.material3.Button | ||||||||||||||||||||
| import androidx.compose.material3.ButtonDefaults | ||||||||||||||||||||
| import androidx.compose.material3.Text | ||||||||||||||||||||
| import androidx.compose.runtime.Composable | ||||||||||||||||||||
| import androidx.compose.runtime.LaunchedEffect | ||||||||||||||||||||
| import androidx.compose.runtime.collectAsState | ||||||||||||||||||||
| import androidx.compose.runtime.getValue | ||||||||||||||||||||
| import androidx.compose.runtime.remember | ||||||||||||||||||||
| import androidx.compose.ui.Alignment | ||||||||||||||||||||
| import androidx.compose.ui.Modifier | ||||||||||||||||||||
| import androidx.compose.ui.draw.clip | ||||||||||||||||||||
| import androidx.compose.ui.graphics.Color | ||||||||||||||||||||
| import androidx.compose.ui.layout.ContentScale | ||||||||||||||||||||
| import androidx.compose.ui.text.font.FontFamily | ||||||||||||||||||||
| import androidx.compose.ui.text.font.FontWeight | ||||||||||||||||||||
| import androidx.compose.ui.unit.dp | ||||||||||||||||||||
| import androidx.compose.ui.unit.sp | ||||||||||||||||||||
| import com.majotyler.hiittimer.platform.UrlOpener | ||||||||||||||||||||
| import hiittimer.composeapp.generated.resources.Res | ||||||||||||||||||||
| import hiittimer.composeapp.generated.resources.btn_strava_connect_with_orange | ||||||||||||||||||||
| import hiittimer.composeapp.generated.resources.home_button_label_launch_build_workouts | ||||||||||||||||||||
| import hiittimer.composeapp.generated.resources.mineral_chico | ||||||||||||||||||||
| import hiittimer.composeapp.generated.resources.rock_salt | ||||||||||||||||||||
| import org.jetbrains.compose.resources.Font | ||||||||||||||||||||
| import org.jetbrains.compose.resources.painterResource | ||||||||||||||||||||
| import org.jetbrains.compose.resources.stringResource | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
@@ -33,44 +45,81 @@ fun HomeScreen( | |||||||||||||||||||
| modifier: Modifier = Modifier, | ||||||||||||||||||||
| ) { | ||||||||||||||||||||
| val showCreateActivityButton by viewModel.showCreateActivityButton.collectAsState() | ||||||||||||||||||||
| val rockSalt = FontFamily(Font(Res.font.rock_salt)) | ||||||||||||||||||||
|
|
||||||||||||||||||||
| LaunchedEffect(Unit) { | ||||||||||||||||||||
| viewModel.openUrl.collect { url -> | ||||||||||||||||||||
| urlOpener.openUrl(url = url) | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Column( | ||||||||||||||||||||
| horizontalAlignment = Alignment.CenterHorizontally, | ||||||||||||||||||||
| modifier = modifier | ||||||||||||||||||||
| .fillMaxSize(), | ||||||||||||||||||||
| verticalArrangement = Arrangement.Center, | ||||||||||||||||||||
| ) { | ||||||||||||||||||||
| Button( | ||||||||||||||||||||
| onClick = { | ||||||||||||||||||||
| viewModel.onEvent(event = HomeViewEvent.ClickedLaunchBuildWorkouts) | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| ) { | ||||||||||||||||||||
| Text(text = stringResource(resource = Res.string.home_button_label_launch_build_workouts)) | ||||||||||||||||||||
| } | ||||||||||||||||||||
| Box(modifier = modifier.fillMaxSize()) { | ||||||||||||||||||||
| Image( | ||||||||||||||||||||
| painter = painterResource(Res.drawable.btn_strava_connect_with_orange), | ||||||||||||||||||||
| contentDescription = "Connect with Strava", | ||||||||||||||||||||
| contentScale = ContentScale.FillHeight, | ||||||||||||||||||||
| painter = painterResource(Res.drawable.mineral_chico), | ||||||||||||||||||||
| contentDescription = null, | ||||||||||||||||||||
| contentScale = ContentScale.Crop, | ||||||||||||||||||||
| modifier = Modifier.fillMaxSize() | ||||||||||||||||||||
| ) | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Text( | ||||||||||||||||||||
| text = "Track\nImprove", | ||||||||||||||||||||
| fontFamily = rockSalt, | ||||||||||||||||||||
| fontSize = 65.sp, | ||||||||||||||||||||
| color = Color.Black, | ||||||||||||||||||||
| lineHeight = 52.sp, | ||||||||||||||||||||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than specifying the |
||||||||||||||||||||
| modifier = Modifier | ||||||||||||||||||||
| .height(48.dp) | ||||||||||||||||||||
| .widthIn(min = 48.dp) | ||||||||||||||||||||
| .clip(RoundedCornerShape(6.dp)) | ||||||||||||||||||||
| .clickable { viewModel.onEvent(event = HomeViewEvent.ClickedConnectWithStrava) }, | ||||||||||||||||||||
| .align(Alignment.Center) | ||||||||||||||||||||
| .padding(bottom = 180.dp), | ||||||||||||||||||||
| ) | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if (showCreateActivityButton) { | ||||||||||||||||||||
| Column( | ||||||||||||||||||||
| modifier = Modifier | ||||||||||||||||||||
| .align(Alignment.BottomCenter) | ||||||||||||||||||||
| .padding(horizontal = 24.dp, vertical = 48.dp) | ||||||||||||||||||||
| .fillMaxWidth(), | ||||||||||||||||||||
|
Comment on lines
+72
to
+79
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like how this looks, but I feel the paddings look poorly implemented. How could I improve the spaces ? I thought about changing the text to inside column.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Is this referring to "Track" and "Improve"? I agree, I think a In the future, the "Connect with Strava" and "Create Strava Activity" buttons won't be here. Those were just temporary. I think it makes the most sense for those to be in the post-workout screen. |
||||||||||||||||||||
| verticalArrangement = Arrangement.spacedBy(16.dp), | ||||||||||||||||||||
| horizontalAlignment = Alignment.CenterHorizontally, | ||||||||||||||||||||
| ) { | ||||||||||||||||||||
| Button( | ||||||||||||||||||||
| onClick = { | ||||||||||||||||||||
| viewModel.onEvent(event = HomeViewEvent.ClickedCreateStravaActivity) | ||||||||||||||||||||
| } | ||||||||||||||||||||
| onClick = { viewModel.onEvent(event = HomeViewEvent.ClickedLaunchBuildWorkouts) }, | ||||||||||||||||||||
| modifier = Modifier | ||||||||||||||||||||
| .fillMaxWidth() | ||||||||||||||||||||
| .height(56.dp), | ||||||||||||||||||||
|
Comment on lines
+86
to
+87
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
We should get rid of this. In its place, we can increase the padding :) Why? We should do this because font-sizes are not always the same, users can increase the font size of their device. Being honest with you, most applications don't really care about this 😆 even really big applications just totally suck at big font sizes. Here, I increase the font size of my device. With a big font size, sometimes the button needs to be more than
By the way, we can also prevent text from scaling, you normally should avoid that, but we can do it for "Track" and "Improve" to avoid what you see here :)
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We actually have this problem so much worse in other parts of the application 😆 the big font-sizes breaking the application, so definitely no huge deal here |
||||||||||||||||||||
| shape = RoundedCornerShape(28.dp), | ||||||||||||||||||||
| colors = ButtonDefaults.buttonColors( | ||||||||||||||||||||
| containerColor = Color.White, | ||||||||||||||||||||
| contentColor = Color.Black, | ||||||||||||||||||||
| ), | ||||||||||||||||||||
| ) { | ||||||||||||||||||||
| Text(text = "Create Strava Activity") | ||||||||||||||||||||
| Text( | ||||||||||||||||||||
| text = stringResource(resource = Res.string.home_button_label_launch_build_workouts), | ||||||||||||||||||||
| fontSize = 16.sp, | ||||||||||||||||||||
| fontWeight = FontWeight.Bold, | ||||||||||||||||||||
| ) | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Image( | ||||||||||||||||||||
| painter = painterResource(Res.drawable.btn_strava_connect_with_orange), | ||||||||||||||||||||
| contentDescription = "Connect with Strava", | ||||||||||||||||||||
| contentScale = ContentScale.FillHeight, | ||||||||||||||||||||
| modifier = Modifier | ||||||||||||||||||||
| .padding(20.dp) | ||||||||||||||||||||
| .height(48.dp) | ||||||||||||||||||||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one is ok to have |
||||||||||||||||||||
| .widthIn(min = 48.dp) | ||||||||||||||||||||
| .clip(RoundedCornerShape(6.dp)) | ||||||||||||||||||||
| .clickable { viewModel.onEvent(event = HomeViewEvent.ClickedConnectWithStrava) }, | ||||||||||||||||||||
| ) | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if (showCreateActivityButton) { | ||||||||||||||||||||
| Button( | ||||||||||||||||||||
| onClick = { viewModel.onEvent(event = HomeViewEvent.ClickedCreateStravaActivity) }, | ||||||||||||||||||||
| modifier = Modifier | ||||||||||||||||||||
| .fillMaxWidth() | ||||||||||||||||||||
| .height(56.dp), | ||||||||||||||||||||
| shape = RoundedCornerShape(28.dp), | ||||||||||||||||||||
| ) { | ||||||||||||||||||||
| Text(text = "Create Strava Activity") | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also probably translate this :) so that means making a new String resource in those files, one for English, one for Spanish - then replacing this "hard coded String" with that.