Skip to content

Commit

Permalink
screen: AboutUs: Update for contact and website
Browse files Browse the repository at this point in the history
Signed-off-by: Shashank Verma <[email protected]>
  • Loading branch information
shank03 committed Oct 30, 2023
1 parent acee31b commit 11c01b6
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 69 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mnnit.moticlubs.ui.components.aboutus

import android.widget.Toast
import android.content.Intent
import android.net.Uri
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.imePadding
Expand Down Expand Up @@ -28,6 +29,7 @@ import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.mnnit.moticlubs.domain.util.getUserId
import com.mnnit.moticlubs.domain.util.getValue
import com.mnnit.moticlubs.domain.util.isTrimmedNotEmpty
import com.mnnit.moticlubs.domain.util.publishedStateOf
Expand All @@ -39,7 +41,7 @@ fun AboutUsContactForm(modifier: Modifier = Modifier) {
val context = LocalContext.current
val keyboardController = LocalSoftwareKeyboardController.current

var name by remember { publishedStateOf("") }
var subject by remember { publishedStateOf("") }
var postMsg by remember { publishedStateOf("") }

Surface(
Expand All @@ -58,10 +60,10 @@ fun AboutUsContactForm(modifier: Modifier = Modifier) {
modifier = Modifier
.fillMaxWidth()
.imePadding(),
value = name,
onValueChange = { name = it },
value = subject,
onValueChange = { subject = it },
shape = RoundedCornerShape(24.dp),
label = { Text(text = "Name") },
label = { Text(text = "Subject") },
keyboardOptions = KeyboardOptions.Default.copy(keyboardType = KeyboardType.Text),
colors = OutlinedTextFieldDefaults.colors(
disabledTextColor = contentColorFor(backgroundColor = colorScheme.background),
Expand Down Expand Up @@ -89,14 +91,21 @@ fun AboutUsContactForm(modifier: Modifier = Modifier) {
AssistChip(
onClick = {
keyboardController?.hide()
Toast.makeText(context, "No Domain 🤨", Toast.LENGTH_SHORT).show()
context.startActivity(
Intent(Intent.ACTION_SENDTO).apply {
data = Uri.parse(
"mailto:[email protected]?subject=[MotiClubs - Query] $subject" +
"&body=[ID - ${context.getUserId()}]\n\n$postMsg",
)
},
)
},
label = {
Text(
text = "Send",
fontSize = 14.sp,
color = contentColorFor(
backgroundColor = if (postMsg.isTrimmedNotEmpty() && name.isTrimmedNotEmpty()) {
backgroundColor = if (postMsg.isTrimmedNotEmpty() && subject.isTrimmedNotEmpty()) {
colorScheme.primary
} else {
colorScheme.onSurface.copy(alpha = 0.38f)
Expand All @@ -110,7 +119,7 @@ fun AboutUsContactForm(modifier: Modifier = Modifier) {
painter = rememberVectorPainter(image = Icons.Rounded.Send),
contentDescription = "",
tint = contentColorFor(
backgroundColor = if (postMsg.isTrimmedNotEmpty() && name.isTrimmedNotEmpty()) {
backgroundColor = if (postMsg.isTrimmedNotEmpty() && subject.isTrimmedNotEmpty()) {
colorScheme.primary
} else {
colorScheme.onSurface.copy(alpha = 0.38f)
Expand All @@ -124,7 +133,7 @@ fun AboutUsContactForm(modifier: Modifier = Modifier) {
.align(Alignment.End),
shape = RoundedCornerShape(24.dp),
colors = AssistChipDefaults.assistChipColors(containerColor = colorScheme.primary),
enabled = postMsg.isTrimmedNotEmpty() && name.isTrimmedNotEmpty(),
enabled = postMsg.isTrimmedNotEmpty() && subject.isTrimmedNotEmpty(),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ fun ColumnScope.DeveloperProfile(
stream: String = "",
year: String = "",
showIcons: Boolean = true,
icons: (@Composable () -> Unit)? = null,
) {
val focusManager = LocalFocusManager.current
val uriHandler = LocalUriHandler.current
Expand Down Expand Up @@ -105,44 +106,48 @@ fun ColumnScope.DeveloperProfile(
.fillMaxHeight(),
) {
if (showIcons) {
if (userModel.avatar.isTrimmedNotEmpty()) {
IconButton(
modifier = Modifier
.size(28.dp)
.align(Alignment.CenterHorizontally),
onClick = {
focusManager.clearFocus(true)
uriHandler.openUri(userModel.avatar.replace(".png", ""))
},
) {
Icon(
if (icons != null) {
icons()
} else {
if (userModel.avatar.isTrimmedNotEmpty()) {
IconButton(
modifier = Modifier
.size(20.dp)
.size(28.dp)
.align(Alignment.CenterHorizontally),
painter = painterResource(id = R.drawable.github),
contentDescription = "",
)
onClick = {
focusManager.clearFocus(true)
uriHandler.openUri(userModel.avatar.replace(".png", ""))
},
) {
Icon(
modifier = Modifier
.size(20.dp)
.align(Alignment.CenterHorizontally),
painter = painterResource(id = R.drawable.github),
contentDescription = "",
)
}
}
}

if (linkedin.isTrimmedNotEmpty()) {
Spacer(modifier = Modifier.padding(8.dp))
IconButton(
modifier = Modifier
.size(28.dp)
.align(Alignment.CenterHorizontally),
onClick = {
focusManager.clearFocus(true)
uriHandler.openUri(linkedin)
},
) {
Icon(
if (linkedin.isTrimmedNotEmpty()) {
Spacer(modifier = Modifier.padding(8.dp))
IconButton(
modifier = Modifier
.size(20.dp)
.size(28.dp)
.align(Alignment.CenterHorizontally),
painter = painterResource(id = R.drawable.linkedin),
contentDescription = "",
)
onClick = {
focusManager.clearFocus(true)
uriHandler.openUri(linkedin)
},
) {
Icon(
modifier = Modifier
.size(20.dp)
.align(Alignment.CenterHorizontally),
painter = painterResource(id = R.drawable.linkedin),
contentDescription = "",
)
}
}
}
}
Expand Down
70 changes: 42 additions & 28 deletions app/src/main/java/com/mnnit/moticlubs/ui/screens/AboutUsScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import androidx.compose.material3.BottomSheetScaffold
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.rememberBottomSheetScaffoldState
Expand Down Expand Up @@ -58,9 +59,11 @@ import com.mnnit.moticlubs.ui.viewmodel.AboutUsViewModel
fun AboutUsScreen(modifier: Modifier = Modifier, viewModel: AboutUsViewModel = hiltViewModel()) {
val cc = "https://github.com/CC-MNNIT.png"
val shank = "https://github.com/shank03.png"
val amit = "https://github.com/hackeramitkumar.png"

val scrollState = rememberScrollState()
val scaffoldState = rememberBottomSheetScaffoldState()
val uriHandler = LocalUriHandler.current

MotiClubsTheme {
SetTransparentSystemBars(setStatusBar = 1f, setNavBar = false)
Expand Down Expand Up @@ -161,26 +164,26 @@ fun AboutUsScreen(modifier: Modifier = Modifier, viewModel: AboutUsViewModel = h
.padding(bottom = 8.dp),
name = "Made with 💻\nBy CC Club - MNNIT",
userModel = User().copy(avatar = cc),
showIcons = false,
showIcons = true,
icons = {
IconButton(
modifier = Modifier
.size(28.dp)
.align(Alignment.CenterHorizontally),
onClick = {
uriHandler.openUri("https://sac.mnnit.ac.in/moticlubs/")
},
) {
Icon(
modifier = Modifier
.size(20.dp)
.align(Alignment.CenterHorizontally),
imageVector = Icons.Rounded.OpenInNew,
contentDescription = "",
)
}
},
)

Row(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
) {
GithubLinkButton(
viewModel,
name = "App",
url = "https://github.com/CC-MNNIT/MotiClubs",
)
Spacer(modifier = Modifier.padding(4.dp))
GithubLinkButton(
viewModel,
name = "Backend",
url = "https://github.com/CC-MNNIT/MotiClubs-Service",
)
}
}
}

Expand All @@ -201,7 +204,15 @@ fun AboutUsScreen(modifier: Modifier = Modifier, viewModel: AboutUsViewModel = h
userModel = User().copy(avatar = shank),
linkedin = "https://linkedin.com/in/shank03",
name = "Shashank Verma",
stream = "CSE",
stream = "20204184 - CSE",
year = "Final year",
)
Spacer(modifier = Modifier.padding(8.dp))
DeveloperProfile(
userModel = User().copy(avatar = amit),
linkedin = "https://linkedin.com/in/amit3210",
name = "Amit Kumar",
stream = "20204022 - CSE",
year = "Final year",
)
}
Expand All @@ -228,6 +239,7 @@ private fun RowScope.GithubLinkButton(
viewModel: AboutUsViewModel,
name: String,
url: String = "",
showGithub: Boolean = true,
) {
val uriHandler = LocalUriHandler.current

Expand All @@ -254,15 +266,17 @@ private fun RowScope.GithubLinkButton(
.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween,
) {
Icon(
modifier = Modifier
.size(20.dp)
.align(Alignment.CenterVertically),
painter = painterResource(id = R.drawable.github),
contentDescription = "",
)
if (showGithub) {
Icon(
modifier = Modifier
.size(20.dp)
.align(Alignment.CenterVertically),
painter = painterResource(id = R.drawable.github),
contentDescription = "",
)

Spacer(modifier = Modifier.padding(2.dp))
Spacer(modifier = Modifier.padding(2.dp))
}

Text(
text = name,
Expand Down

0 comments on commit 11c01b6

Please sign in to comment.