@@ -11,15 +11,25 @@ import androidx.compose.foundation.layout.fillMaxWidth
1111import androidx.compose.foundation.layout.height
1212import androidx.compose.foundation.layout.width
1313import androidx.compose.foundation.rememberScrollState
14+ import androidx.compose.foundation.shape.RoundedCornerShape
1415import androidx.compose.foundation.verticalScroll
1516import androidx.compose.material.icons.Icons
1617import androidx.compose.material.icons.automirrored.outlined.ArrowBack
18+ import androidx.compose.material.icons.outlined.CheckCircle
1719import androidx.compose.material.icons.outlined.Person
1820import androidx.compose.material.icons.outlined.Star
21+ import androidx.compose.material.icons.outlined.Warning
22+ import androidx.compose.material3.Button
23+ import androidx.compose.material3.HorizontalDivider
1924import androidx.compose.material3.Icon
2025import androidx.compose.material3.IconButton
2126import androidx.compose.material3.Text
2227import androidx.compose.runtime.Composable
28+ import androidx.compose.runtime.getValue
29+ import androidx.compose.runtime.mutableStateOf
30+ import androidx.compose.runtime.rememberCoroutineScope
31+ import androidx.compose.runtime.saveable.rememberSaveable
32+ import androidx.compose.runtime.setValue
2333import androidx.compose.ui.Alignment
2434import androidx.compose.ui.Modifier
2535import androidx.compose.ui.platform.LocalContext
@@ -30,20 +40,29 @@ import androidx.compose.ui.unit.sp
3040import androidx.navigation.NavController
3141import androidx.navigation.NavHostController
3242import androidx.navigation.compose.rememberNavController
43+ import kotlinx.coroutines.launch
3344import org.vonderheidt.hips.navigation.Screen
3445import org.vonderheidt.hips.ui.theme.HiPSTheme
46+ import org.vonderheidt.hips.utils.downloadLLM
47+ import org.vonderheidt.hips.utils.llmDownloaded
3548
3649/* *
3750 * Function that defines the settings screen.
3851 */
3952@Composable
4053fun SettingsScreen (navController : NavController , modifier : Modifier ) {
4154 // State variables
55+ var llmDownloaded by rememberSaveable { mutableStateOf(llmDownloaded()) }
56+
4257 // Scrolling
4358 val scrollState = rememberScrollState()
59+
4460 // Links
4561 val currentLocalContext = LocalContext .current
4662
63+ // Coroutines
64+ val coroutineScope = rememberCoroutineScope()
65+
4766 // UI components
4867 Column (
4968 modifier = modifier
@@ -75,6 +94,67 @@ fun SettingsScreen(navController: NavController, modifier: Modifier) {
7594 }
7695 }
7796
97+ // LLM download hint
98+ Row (
99+ modifier = modifier.fillMaxWidth(0.9f )
100+ ) {
101+ if (llmDownloaded) {
102+ Icon (
103+ imageVector = Icons .Outlined .CheckCircle ,
104+ contentDescription = " Check mark"
105+ )
106+ }
107+ else {
108+ Icon (
109+ imageVector = Icons .Outlined .Warning ,
110+ contentDescription = " Warning"
111+ )
112+ }
113+
114+ Spacer (modifier = modifier.width(16 .dp))
115+
116+ Column {
117+ Text (
118+ text = " Large Language Model" ,
119+ fontSize = 18 .sp,
120+ fontWeight = FontWeight .Bold
121+ )
122+
123+ if (llmDownloaded) {
124+ Text (text = " The LLM has been downloaded. You can now start using this app." )
125+ }
126+ else {
127+ Text (text = " Before using this app, you need to download the LLM." )
128+ }
129+ }
130+ }
131+
132+ Spacer (modifier = modifier.height(16 .dp))
133+
134+ // Download button
135+ Row {
136+ Button (
137+ onClick = {
138+ if (! llmDownloaded) {
139+ coroutineScope.launch {
140+ downloadLLM()
141+ llmDownloaded = true
142+ }
143+ }
144+ },
145+ enabled = ! llmDownloaded,
146+ shape = RoundedCornerShape (4 .dp)
147+ ) {
148+ Text (text = " Download" )
149+ }
150+ }
151+
152+ Spacer (modifier = modifier.height(16 .dp))
153+
154+ HorizontalDivider ()
155+
156+ Spacer (modifier = modifier.height(16 .dp))
157+
78158 // Author credits
79159 // Make the whole row clickable instead of just the text for better accessibility
80160 Row (
0 commit comments