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

Report Submitted Screen #60

Merged
merged 4 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
@@ -0,0 +1,146 @@
package com.cornellappdev.uplift.ui.screens

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowForward
import androidx.compose.material3.Icon
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
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 com.cornellappdev.uplift.R
import com.cornellappdev.uplift.ui.components.general.UpliftTopBarWithBack
import com.cornellappdev.uplift.util.GRAY01
import com.cornellappdev.uplift.util.GRAY04
import com.cornellappdev.uplift.util.GRAY05
import com.cornellappdev.uplift.util.montserratFamily

/**
* Screen displayed after a user submits a report.
*/
@Composable
fun ReportSubmittedScreen(
onSubmitAnother: () -> Unit = {},
onReturnHome: () -> Unit = {}
Comment on lines +43 to +44
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a TODO to replace with a viewmodel!

) {
Scaffold(topBar = {
UpliftTopBarWithBack(
title = "Report an issue",
withBack = false
)
}) { padding ->
Column(
modifier = Modifier
.padding(padding)
.fillMaxSize()
.background(Color.White),
verticalArrangement = Arrangement.spacedBy(
60.dp,
Alignment.CenterVertically
),
horizontalAlignment = Alignment.CenterHorizontally
) {
Column(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(26.dp)
) {
Image(
painter = painterResource(id = R.drawable.ic_check_circle),
contentDescription = "Check Circle",
)
Column(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(10.dp)
) {
Text(
text = "Thank you for your input!",
fontFamily = montserratFamily,
fontWeight = FontWeight.Bold,
fontSize = 16.sp,
)
Text(
text = "Your report has been submitted.",
fontFamily = montserratFamily,
fontSize = 14.sp,
)
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a tad bit difficult to read the nested composables here; please pull this out into a new private fun composable for readability!

}
Column(
verticalArrangement = Arrangement.spacedBy(16.dp),
) {
Surface(
color = GRAY01,
shape = RoundedCornerShape(38.dp),
modifier = Modifier
.width(184.dp)
.height(42.dp),
shadowElevation = 2.dp,
onClick = { onSubmitAnother() }
) {
Text(
text = "SUBMIT ANOTHER",
fontFamily = montserratFamily,
fontSize = 14.sp,
fontWeight = FontWeight.Bold,
textAlign = TextAlign.Center,
modifier = Modifier.padding(12.dp)
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing with this column, private fun composable plz!

}
Row(
modifier = Modifier
.width(184.dp)
.clickable(onClick = { onReturnHome() }),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(
8.dp,
Alignment.CenterHorizontally
),
) {
Text(
text = "Return to Home",
fontFamily = montserratFamily,
fontSize = 14.sp,
fontWeight = FontWeight.Medium,
color = GRAY04
)
Icon(
imageVector = Icons.AutoMirrored.Filled.ArrowForward,
contentDescription = "Right Arrow",
tint = GRAY05,
modifier = Modifier
.height(20.dp)

)
}

}
}
}

}

@Preview(showBackground = true)
@Composable
private fun ReportSubmittedScreenPreview() {
ReportSubmittedScreen()
}
Comment on lines +163 to +167
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do want to make sure that this screen looks correct on several device heights. I actually can't really tell how you're centering the text from the composables above, but...

In general, suppose we centered an object on one device by padding some 300.dp padding on top. If you then have a shorter screen, this might cause the object to render actually lower than the middle.

In general, usages of like Modifier.weight(1f) or verticalArrangement achieve a streamlined effect across screen sizes, but I wasn't quite sure if yours was doing anything like that. If you suspect that your code suffers from that problem above, plz fix!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, sorry for the disorganized composables, I extracted them into private composables, but the general idea for centering was I used

verticalArrangement = Arrangement.spacedBy(
                60.dp,
                Alignment.CenterVertically
            ),

from the main outermost column to center the inner most composables vertically and then space them apart by 60.dp

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay I see, I actually didn't know you could used spacedBy WITH a center vertically... that's awesome!!

17 changes: 17 additions & 0 deletions app/src/main/res/drawable/ic_check_circle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="111dp"
android:height="111dp"
android:viewportWidth="111"
android:viewportHeight="111">
<path
android:pathData="M55.5,2L55.5,2A53.5,53.5 0,0 1,109 55.5L109,55.5A53.5,53.5 0,0 1,55.5 109L55.5,109A53.5,53.5 0,0 1,2 55.5L2,55.5A53.5,53.5 0,0 1,55.5 2z"
android:strokeWidth="3"
android:fillColor="#00000000"
android:strokeColor="#64C270"/>
<path
android:pathData="M32.17,59.41L45.9,71.5C46.31,71.87 46.95,71.83 47.31,71.41L78.83,35.5"
android:strokeWidth="6"
android:fillColor="#00000000"
android:strokeColor="#64C270"
android:strokeLineCap="round"/>
</vector>