diff --git a/server/xefMobile/.kotlin/sessions/kotlin-compiler-859541645610285268.salive b/server/xefMobile/.kotlin/sessions/kotlin-compiler-12236840344353816343.salive similarity index 100% rename from server/xefMobile/.kotlin/sessions/kotlin-compiler-859541645610285268.salive rename to server/xefMobile/.kotlin/sessions/kotlin-compiler-12236840344353816343.salive diff --git a/server/xefMobile/composeApp/src/androidMain/AndroidManifest.xml b/server/xefMobile/composeApp/src/androidMain/AndroidManifest.xml index c6670f1a1..b64793594 100644 --- a/server/xefMobile/composeApp/src/androidMain/AndroidManifest.xml +++ b/server/xefMobile/composeApp/src/androidMain/AndroidManifest.xml @@ -1,6 +1,7 @@ + Unit, customColors: CustomColors, - onFilesSelected: () -> Unit // Callback for when files are selected + onFilesSelected: () -> Unit ) { val viewModel: PathViewModel = viewModel() val state = viewModel.state @@ -65,7 +64,7 @@ fun FilePickerDialog( fontWeight = FontWeight.Bold ) Spacer(modifier = Modifier.height(8.dp)) - HorizontalDivider() + Divider() } }, text = { diff --git a/server/xefMobile/composeApp/src/androidMain/kotlin/com/xef/xefMobile/ui/screens/SettingsScreen.kt b/server/xefMobile/composeApp/src/androidMain/kotlin/com/xef/xefMobile/ui/screens/SettingsScreen.kt new file mode 100644 index 000000000..312733d5c --- /dev/null +++ b/server/xefMobile/composeApp/src/androidMain/kotlin/com/xef/xefMobile/ui/screens/SettingsScreen.kt @@ -0,0 +1,86 @@ +package com.xef.xefMobile.ui.screens + +import androidx.compose.foundation.Image +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.* +import androidx.compose.material3.* +import androidx.compose.runtime.* +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.ColorFilter +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.navigation.NavController +import com.server.movile.xef.android.ui.viewmodels.IAuthViewModel +import kotlinx.coroutines.launch +import org.xef.xefMobile.R + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun SettingsScreen(navController: NavController, authViewModel: IAuthViewModel) { + var apiKey by remember { mutableStateOf("") } + val coroutineScope = rememberCoroutineScope() + val customColors = Color(0xFFADD8E6) + val CustomTextBlue = Color(0xFF0199D7) + + Box( + modifier = Modifier + .fillMaxSize() + .background(Color.White) + .padding(16.dp) + ) { + Column( + modifier = Modifier.align(Alignment.Center), + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.Center + ) { + Text( + text = "Settings", + fontSize = 24.sp, + fontWeight = FontWeight.Bold, + color = Color.Black + ) + Spacer(modifier = Modifier.height(8.dp)) + Text( + text = "These are xef-server settings.", + fontSize = 16.sp, + color = Color.Gray + ) + Spacer(modifier = Modifier.height(16.dp)) + TextField( + value = apiKey, + onValueChange = { apiKey = it }, + label = { Text("OpenAI API key") }, + modifier = Modifier.fillMaxWidth() + ) + Spacer(modifier = Modifier.height(16.dp)) + Button( + onClick = { + coroutineScope.launch { + // Handle saving the API key + // Example: authViewModel.saveApiKey(apiKey) + } + }, + colors = ButtonDefaults.buttonColors(containerColor = customColors), + modifier = Modifier.fillMaxWidth() + ) { + Row( + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.Center + ) { + Image( + painter = painterResource(id = R.drawable.save_24dp), + contentDescription = "save settings icon", + modifier = Modifier.size(24.dp), + colorFilter = ColorFilter.tint(CustomTextBlue) + ) + Spacer(modifier = Modifier.width(8.dp)) + Text(text = "Save Settings", color = CustomTextBlue) + } + } + } + } +} diff --git a/server/xefMobile/composeApp/src/androidMain/kotlin/com/xef/xefMobile/ui/screens/menu/AssistantScreen.kt b/server/xefMobile/composeApp/src/androidMain/kotlin/com/xef/xefMobile/ui/screens/menu/AssistantScreen.kt index defee5364..22ff013c9 100644 --- a/server/xefMobile/composeApp/src/androidMain/kotlin/com/xef/xefMobile/ui/screens/menu/AssistantScreen.kt +++ b/server/xefMobile/composeApp/src/androidMain/kotlin/com/xef/xefMobile/ui/screens/menu/AssistantScreen.kt @@ -81,21 +81,19 @@ fun AssistantScreen(navController: NavController, authViewModel: IAuthViewModel) Spacer(modifier = Modifier.height(8.dp)) } } + } - Button( - onClick = { navController.navigate(Screens.CreateAssistant.screen) }, - colors = ButtonDefaults.buttonColors( - containerColor = customColors.buttonColor, - contentColor = MaterialTheme.colorScheme.onPrimary - ), - modifier = Modifier - .align(Alignment.BottomCenter) - .padding(16.dp) - ) { - Text(text = "Create New Assistant") - } + Button( + onClick = { navController.navigate(Screens.CreateAssistant.screen) }, + colors = ButtonDefaults.buttonColors( + containerColor = customColors.buttonColor, + contentColor = MaterialTheme.colorScheme.onPrimary + ), + modifier = Modifier + .align(Alignment.BottomCenter) + .padding(16.dp) + ) { + Text(text = "Create New Assistant") } } } - - diff --git a/server/xefMobile/composeApp/src/androidMain/kotlin/com/xef/xefMobile/ui/screens/menu/CreateAssistantScreen.kt b/server/xefMobile/composeApp/src/androidMain/kotlin/com/xef/xefMobile/ui/screens/menu/CreateAssistantScreen.kt index 0527f6fbd..c782e31d7 100644 --- a/server/xefMobile/composeApp/src/androidMain/kotlin/com/xef/xefMobile/ui/screens/menu/CreateAssistantScreen.kt +++ b/server/xefMobile/composeApp/src/androidMain/kotlin/com/xef/xefMobile/ui/screens/menu/CreateAssistantScreen.kt @@ -17,13 +17,12 @@ import androidx.compose.ui.unit.sp import androidx.navigation.NavController import androidx.navigation.compose.rememberNavController import com.server.movile.xef.android.ui.themes.LocalCustomColors - +import com.xef.xefMobile.ui.composable.FilePickerDialog class CreateAssistantActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { - // Pass the NavController to CreateAssistantScreen val navController = rememberNavController() CreateAssistantScreen(navController) } @@ -43,6 +42,7 @@ fun CreateAssistantScreen(navController: NavController) { val list = listOf("gpt-4o", "gpt-4", "gpt-3.5-turbo-16K", "gpt-3.5-turbo-0125", "gpt-3.5-turbo") var isExpanded by remember { mutableStateOf(false) } var selectedText by remember { mutableStateOf(list[0]) } + var showFilePicker by remember { mutableStateOf(false) } val customColors = LocalCustomColors.current @@ -121,14 +121,14 @@ fun CreateAssistantScreen(navController: NavController) { } Spacer(modifier = Modifier.height(8.dp)) Row(verticalAlignment = Alignment.CenterVertically) { - OutlinedButton( - onClick = { /* handle cancel */ }, + TextButton( + onClick = { showFilePicker = true }, colors = ButtonDefaults.outlinedButtonColors( containerColor = Color.Transparent, contentColor = customColors.buttonColor ) ) { - Text("File Search") + Text("File Search +") } Spacer(modifier = Modifier.weight(1f)) Switch( @@ -142,14 +142,14 @@ fun CreateAssistantScreen(navController: NavController) { } Spacer(modifier = Modifier.height(8.dp)) Row(verticalAlignment = Alignment.CenterVertically) { - OutlinedButton( + TextButton( onClick = { /* handle cancel */ }, colors = ButtonDefaults.outlinedButtonColors( containerColor = Color.Transparent, contentColor = customColors.buttonColor ) ) { - Text("Code Interpreter") + Text("Code Interpreter +") } Spacer(modifier = Modifier.weight(1f)) Switch( @@ -163,14 +163,14 @@ fun CreateAssistantScreen(navController: NavController) { } Spacer(modifier = Modifier.height(8.dp)) Row(verticalAlignment = Alignment.CenterVertically) { - OutlinedButton( + TextButton( onClick = { /* handle cancel */ }, colors = ButtonDefaults.outlinedButtonColors( containerColor = Color.Transparent, contentColor = customColors.buttonColor ) ) { - Text("Functions") + Text("Functions +") } Spacer(modifier = Modifier.weight(1f)) } @@ -214,6 +214,16 @@ fun CreateAssistantScreen(navController: NavController) { } } } + if (showFilePicker) { + FilePickerDialog( + onDismissRequest = { showFilePicker = false }, + customColors = customColors, + onFilesSelected = { + // Handle file selection here if needed + showFilePicker = false + } + ) + } } } @@ -264,7 +274,6 @@ fun AssistantFloatField(label: String, value: Float, onValueChange: (Float) -> U @Preview(showBackground = false) @Composable fun CreateAssistantScreenPreview() { - // Create a mock NavController for the preview val navController = rememberNavController() CreateAssistantScreen(navController) } diff --git a/server/xefMobile/composeApp/src/androidMain/kotlin/com/xef/xefMobile/ui/viewmodels/AuthViewModel.kt b/server/xefMobile/composeApp/src/androidMain/kotlin/com/xef/xefMobile/ui/viewmodels/AuthViewModel.kt index 1bd88b147..67684fa1a 100644 --- a/server/xefMobile/composeApp/src/androidMain/kotlin/com/xef/xefMobile/ui/viewmodels/AuthViewModel.kt +++ b/server/xefMobile/composeApp/src/androidMain/kotlin/com/xef/xefMobile/ui/viewmodels/AuthViewModel.kt @@ -53,7 +53,6 @@ class AuthViewModel( }.firstOrNull() _authToken.value = token - token?.let { loadUserName() } @@ -76,7 +75,7 @@ class AuthViewModel( try { val loginResponse = apiService.loginUser(loginRequest) updateAuthToken(loginResponse.authToken) - updateUserName(loginResponse.user.name) // Extract user's name + updateUserName(loginResponse.user.name) _authToken.value = loginResponse.authToken _userName.value = loginResponse.user.name } catch (e: Exception) { @@ -110,7 +109,7 @@ class AuthViewModel( try { val registerResponse = apiService.registerUser(request) updateAuthToken(registerResponse.authToken) - updateUserName(name) // Directly use the name provided during registration + updateUserName(name) _authToken.value = registerResponse.authToken _userName.value = name } catch (e: Exception) { @@ -135,11 +134,11 @@ class AuthViewModel( withContext(Dispatchers.IO) { dataStore.edit { preferences -> preferences.remove(stringPreferencesKey("authToken")) - preferences.remove(stringPreferencesKey("userName")) // Add this line + preferences.remove(stringPreferencesKey("userName")) } } _authToken.postValue(null) - _userName.postValue(null) // Add this line + _userName.postValue(null) _errorMessage.postValue("Logged out successfully") } catch (e: Exception) { _errorMessage.postValue("Failed to sign out") diff --git a/server/xefMobile/composeApp/src/main/res/drawable/save_24dp.xml b/server/xefMobile/composeApp/src/main/res/drawable/save_24dp.xml new file mode 100644 index 000000000..6fc751aef --- /dev/null +++ b/server/xefMobile/composeApp/src/main/res/drawable/save_24dp.xml @@ -0,0 +1,9 @@ + + +