Compare commits

..

No commits in common. "ui" and "2024-02-29" have entirely different histories.

7 changed files with 37 additions and 153 deletions

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<value>
<entry key="app">
<State>
<targetSelectedWithDropDown>
<Target>
<type value="QUICK_BOOT_TARGET" />
<deviceKey>
<Key>
<type value="VIRTUAL_DEVICE_PATH" />
<value value="$USER_HOME$/.android/avd/Pixel_3a_API_34_extension_level_7_x86_64.avd" />
</Key>
</deviceKey>
</Target>
</targetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2024-02-26T15:23:42.854086595Z" />
</State>
</entry>
</value>
</component>
</project>

View File

@ -54,7 +54,7 @@ dependencies {
implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0")
implementation("androidx.activity:activity-compose:1.8.2")
implementation(platform("androidx.compose:compose-bom:2024.02.01"))
implementation(platform("androidx.compose:compose-bom:2023.08.00"))
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-graphics")
implementation("androidx.compose.ui:ui-tooling-preview")
@ -62,7 +62,7 @@ dependencies {
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
androidTestImplementation(platform("androidx.compose:compose-bom:2024.02.01"))
androidTestImplementation(platform("androidx.compose:compose-bom:2023.08.00"))
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
debugImplementation("androidx.compose.ui:ui-tooling")
debugImplementation("androidx.compose.ui:ui-test-manifest")

View File

@ -3,9 +3,6 @@ package it.edu.cassandroferminervi.flowschool
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.Surface
import androidx.compose.ui.Modifier
import com.ramcosta.composedestinations.DestinationsNavHost
import com.ramcosta.composedestinations.NavGraphs
import it.edu.cassandroferminervi.flowschool.ui.theme.FlowSchoolTheme
@ -15,12 +12,8 @@ class MainActivity : ComponentActivity() {
super.onCreate(savedInstanceState)
setContent {
FlowSchoolTheme {
Surface(
modifier = Modifier.fillMaxSize()
) {
DestinationsNavHost(navGraph = NavGraphs.root)
}
}
}
}
}

View File

@ -1,129 +1,20 @@
package it.edu.cassandroferminervi.flowschool.screens
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.MaterialTheme
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.TextField
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.ramcosta.composedestinations.TeacherScreenDestination
import com.ramcosta.composedestinations.annotation.Destination
import com.ramcosta.composedestinations.navigation.DestinationsNavigator
@Destination
@Composable
fun SearchingScreen(navigator: DestinationsNavigator) {
val teachers = listOf(
"Mario Rossi",
"Michele Verdi",
"Fabio Bianchi"
).groupBy {
it.first()
}.toSortedMap()
.map {
Category(
it.key.toString(),
items = it.value
)
}
var filter by remember { mutableStateOf("") }
Column {
TextField(
value = filter,
onValueChange = { filter = it },
label = { Text("Cerca") },
singleLine = true,
modifier = Modifier
.fillMaxWidth()
.padding(16.dp)
)
CategorizedLazyColumn(
categories = teachers,
navigator = navigator,
filter = filter
)
}
}
data class Category(
val name: String,
val items: List<String>
)
@Composable
private fun CategoryHeader(
text: String,
modifier: Modifier = Modifier
) {
Text(
text = text,
fontSize = 16.sp,
fontWeight = FontWeight.Bold,
modifier = modifier
.fillMaxWidth()
.background(MaterialTheme.colorScheme.primaryContainer)
.padding(16.dp)
)
}
@Composable
private fun CategoryItem(
text: String,
navigator: DestinationsNavigator,
modifier: Modifier = Modifier
) {
TextButton(onClick = {
navigator.navigate(TeacherScreenDestination("test"))
}) {
Text(
text = text,
fontSize = 14.sp,
modifier = modifier
.fillMaxWidth()
.background(MaterialTheme.colorScheme.background)
.padding(16.dp)
)
}
}
@OptIn(ExperimentalFoundationApi::class)
@Composable
private fun CategorizedLazyColumn(
categories: List<Category>,
navigator: DestinationsNavigator,
filter: String,
modifier: Modifier = Modifier
) {
LazyColumn(modifier) {
categories.forEach { category ->
if (category.items.any {
it.contains(filter, ignoreCase = true)
}) {
stickyHeader {
CategoryHeader(category.name)
}
}
items(items = category.items.filter {
it.contains(filter, ignoreCase = true)
}) { text ->
CategoryItem(text, navigator)
}
}
fun SearchingScreen() {
Box (
contentAlignment = Alignment.Center,
modifier = Modifier.fillMaxSize()
) {
Text("Searching screen")
}
}

View File

@ -1,23 +0,0 @@
package it.edu.cassandroferminervi.flowschool.screens
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import com.ramcosta.composedestinations.annotation.Destination
@Destination
@Composable
fun TeacherScreen(codice: String) {
Column(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center,
modifier = Modifier.fillMaxSize()
) {
Text("Codice prof: $codice")
Text("Presente: si")
}
}

View File

@ -1,5 +1,5 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("com.android.application") version "8.3.0" apply false
id("com.android.application") version "8.2.2" apply false
id("org.jetbrains.kotlin.android") version "1.9.0" apply false
}

View File

@ -1,6 +1,6 @@
#Wed Feb 21 15:30:24 CET 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists