-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3947810
commit 6b48a3e
Showing
9 changed files
with
167 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
120 changes: 120 additions & 0 deletions
120
android/app/src/main/java/com/pras/slugcourses/ui/elements/CourseCard.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
package com.pras.slugcourses.ui.elements | ||
|
||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.widthIn | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.Person | ||
import androidx.compose.material3.Card | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.painter.Painter | ||
import androidx.compose.ui.graphics.vector.ImageVector | ||
import androidx.compose.ui.platform.UriHandler | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import com.pras.slugcourses.R | ||
import com.pras.slugcourses.api.Course | ||
|
||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
fun CourseCard(course: Course, uriHandler: UriHandler) { | ||
val uri = "https://pisa.ucsc.edu/class_search/"+course.url | ||
Card(onClick = { uriHandler.openUri(uri) },modifier = Modifier.padding(6.dp).widthIn(max=800.dp)) { | ||
Column(modifier = Modifier.fillMaxSize().padding(8.dp)) { | ||
SectionTitle(course.description) | ||
SectionSubtitle(Icons.Default.Person, course.instructor) | ||
if (course.location.contains("Online") || course.location.contains("Remote Instruction")) { | ||
SectionSubtitle(painterResource(R.drawable.chat_filled), course.location) | ||
} else { | ||
SectionSubtitle(painterResource(R.drawable.chat_filled), course.location) | ||
} | ||
SectionSubtitle(painterResource(R.drawable.chat_filled), course.time) | ||
if (course.alt_location != "Not Found") { | ||
if (course.alt_location.contains("Online") || course.alt_location.contains("Remote Instruction")) { | ||
SectionSubtitle(painterResource(R.drawable.chat_filled), course.alt_location) | ||
} else { | ||
SectionSubtitle(painterResource(R.drawable.chat_filled), course.alt_location) | ||
} | ||
} | ||
if (course.alt_time != "Not Found") { | ||
SectionSubtitle(painterResource(R.drawable.chat_filled), course.alt_time) | ||
} | ||
SectionSubtitle(painterResource(R.drawable.chat_filled), course.enrolled) | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
@Composable | ||
fun SectionTitle(title: String) { | ||
Text( | ||
text = title, | ||
fontWeight = FontWeight.SemiBold, | ||
fontSize = 20.sp | ||
) | ||
} | ||
|
||
val ROW_PADDING = 4.dp | ||
|
||
@Composable | ||
fun SectionSubtitle(icon: ImageVector, subtitle: String) { | ||
Row { | ||
Icon(icon,null, modifier = Modifier.padding(end = ROW_PADDING)) | ||
Text( | ||
text = subtitle, | ||
fontSize = 16.sp | ||
) | ||
} | ||
} | ||
|
||
@Composable | ||
fun SectionSubtitle(icon: Painter, subtitle: String) { | ||
Row { | ||
Icon(icon,null, modifier = Modifier.padding(end = ROW_PADDING)) | ||
Text( | ||
text = subtitle, | ||
fontSize = 16.sp | ||
) | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
fun CoursePreview() { | ||
CourseCard( | ||
Course( | ||
1, | ||
2240, | ||
"Patrick Tantalo", | ||
"Remote Instruction", | ||
"MWF 10:00AM - 10:50AM", | ||
"Remote Instruction", | ||
"MWF 10:00AM - 10:50AM", | ||
"0", | ||
"", | ||
"", | ||
"", | ||
"", | ||
"", | ||
"", | ||
"", | ||
"", | ||
"", | ||
), | ||
object : UriHandler { | ||
override fun openUri(uri: String) { | ||
|
||
} | ||
} | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Top-level build file where you can add configuration options common to all sub-projects/modules. | ||
plugins { | ||
id("com.android.application") version "8.2.1" apply false | ||
id("org.jetbrains.kotlin.android") version "1.9.22" apply false | ||
id("org.jetbrains.kotlin.plugin.serialization") version "1.9.22" apply false | ||
id("org.jetbrains.kotlin.android") version "1.9.20" apply false | ||
id("org.jetbrains.kotlin.plugin.serialization") version "1.9.20" apply false | ||
} |