Apis apus pitur

This commit is contained in:
202310715082 FAZRI ABDURRAHMAN 2025-11-12 17:19:09 +07:00
parent 8d03328ec2
commit a142b4a942
2 changed files with 87 additions and 205 deletions

View File

@ -5,9 +5,6 @@
<SelectionState runConfigName="app"> <SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" /> <option name="selectionMode" value="DROPDOWN" />
</SelectionState> </SelectionState>
<SelectionState runConfigName="Notebook">
<option name="selectionMode" value="DROPDOWN" />
</SelectionState>
</selectionStates> </selectionStates>
</component> </component>
</project> </project>

View File

@ -51,11 +51,12 @@ class MainActivity : ComponentActivity() {
} }
} }
@OptIn(ExperimentalMaterial3Api::class) @OptIn(ExperimentalMaterial3Api::class)
@Composable @Composable
fun NotebookApp() { fun NotebookApp() {
var selectedTabIndex by remember { mutableStateOf(0) } var selectedTabIndex by remember { mutableStateOf(0) }
val tabs = listOf("Sources", "Chat", "Studio") val tabs = listOf("Studio", "Chat", "Sources")
var showGoogleAppsMenu by remember { mutableStateOf(false) } var showGoogleAppsMenu by remember { mutableStateOf(false) }
var showSettingsMenu by remember { mutableStateOf(false) } var showSettingsMenu by remember { mutableStateOf(false) }
var showAccountScreen by remember { mutableStateOf(false) } var showAccountScreen by remember { mutableStateOf(false) }
@ -67,11 +68,9 @@ fun NotebookApp() {
Scaffold( Scaffold(
topBar = { topBar = {
TopAppBar( TopAppBar(
title = { Text("Apis Notepad") }, title = { Text("NoteBook") },
actions = { actions = {
IconButton(onClick = { /* do something */ }) { // [DIHAPUS] Tombol Share
Icon(Icons.Filled.Share, contentDescription = "Share")
}
Box { Box {
IconButton(onClick = { showSettingsMenu = true }) { IconButton(onClick = { showSettingsMenu = true }) {
Icon(Icons.Filled.Settings, contentDescription = "Settings") Icon(Icons.Filled.Settings, contentDescription = "Settings")
@ -108,9 +107,9 @@ fun NotebookApp() {
} }
} }
when (selectedTabIndex) { when (selectedTabIndex) {
0 -> SourcesScreen() 0 -> StudioScreen()
1 -> ChatScreen() 1 -> ChatScreen()
2 -> StudioScreen() 2 -> SourcesScreen()
} }
} }
} }
@ -318,14 +317,10 @@ fun GoogleAppsMenu(expanded: Boolean, onDismiss: () -> Unit) {
@Composable @Composable
fun SourcesScreen() { fun SourcesScreen() {
var showAddSourcesSheet by remember { mutableStateOf(false) } var showAddSourcesSheet by remember { mutableStateOf(false) }
var showDiscoverDialog by remember { mutableStateOf(false) }
if (showAddSourcesSheet) { if (showAddSourcesSheet) {
AddSourcesSheet(onDismiss = { showAddSourcesSheet = false }) AddSourcesSheet(onDismiss = { showAddSourcesSheet = false })
} }
if (showDiscoverDialog) {
DiscoverSourcesDialog(onDismiss = { showDiscoverDialog = false })
}
Column( Column(
modifier = Modifier modifier = Modifier
@ -335,18 +330,13 @@ fun SourcesScreen() {
) { ) {
Row( Row(
modifier = Modifier.fillMaxWidth(), modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(8.dp) horizontalArrangement = Arrangement.Center
) { ) {
Button(onClick = { showAddSourcesSheet = true }, modifier = Modifier.weight(1f)) { Button(onClick = { showAddSourcesSheet = true }) {
Icon(Icons.Filled.Add, contentDescription = "Add") Icon(Icons.Filled.Add, contentDescription = "Add")
Spacer(modifier = Modifier.width(4.dp)) Spacer(modifier = Modifier.width(4.dp))
Text("Add") Text("Add")
} }
Button(onClick = { showDiscoverDialog = true }, modifier = Modifier.weight(1f)) {
Icon(Icons.Filled.Search, contentDescription = "Discover")
Spacer(modifier = Modifier.width(4.dp))
Text("Discover")
}
} }
Column( Column(
modifier = Modifier.fillMaxSize(), modifier = Modifier.fillMaxSize(),
@ -367,98 +357,6 @@ fun SourcesScreen() {
} }
} }
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun DiscoverSourcesDialog(onDismiss: () -> Unit) {
var description by remember { mutableStateOf("") }
val findFromOptions = listOf("Web", "Google Drive")
var selectedOption by remember { mutableStateOf(findFromOptions[0]) }
Dialog(onDismissRequest = onDismiss, properties = DialogProperties(usePlatformDefaultWidth = false)) {
Scaffold(
topBar = {
TopAppBar(
title = { Text("Discover sources") },
actions = {
IconButton(onClick = onDismiss) {
Icon(Icons.Default.Close, contentDescription = "Close")
}
}
)
},
bottomBar = {
Row(
modifier = Modifier.fillMaxWidth().padding(16.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
Button(
onClick = { /* TODO */ },
modifier = Modifier.weight(1f)
) {
Icon(Icons.Default.Celebration, contentDescription = null)
Spacer(modifier = Modifier.width(4.dp))
Text("I'm feeling curious")
}
Button(
onClick = { /* TODO */ },
modifier = Modifier.weight(1f),
enabled = description.isNotBlank()
) {
Text("Submit")
}
}
}
) { paddingValues ->
Column(
modifier = Modifier
.fillMaxSize()
.padding(paddingValues)
.padding(16.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(16.dp)
) {
Icon(
imageVector = Icons.Default.TravelExplore,
contentDescription = null,
modifier = Modifier.size(48.dp)
)
Text("What are you interested in?", style = MaterialTheme.typography.titleLarge)
OutlinedTextField(
value = description,
onValueChange = { description = it },
placeholder = { Text("Describe something you'd like to learn about or click \"I'm feeling curious\" to explore a new topic.") },
modifier = Modifier.fillMaxWidth().height(150.dp)
)
Column(modifier = Modifier.fillMaxWidth()) {
Text("Find sources from:", style = MaterialTheme.typography.titleMedium)
findFromOptions.forEach { text ->
Row(
Modifier
.fillMaxWidth()
.selectable(
selected = (text == selectedOption),
onClick = { selectedOption = text }
)
.padding(vertical = 8.dp),
verticalAlignment = Alignment.CenterVertically
) {
RadioButton(
selected = (text == selectedOption),
onClick = { selectedOption = text }
)
Text(
text = text,
style = MaterialTheme.typography.bodyLarge,
modifier = Modifier.padding(start = 8.dp)
)
}
}
}
}
}
}
}
@OptIn(ExperimentalMaterial3Api::class) @OptIn(ExperimentalMaterial3Api::class)
@Composable @Composable
fun AddSourcesSheet(onDismiss: () -> Unit) { fun AddSourcesSheet(onDismiss: () -> Unit) {
@ -497,11 +395,6 @@ fun AddSourcesSheet(onDismiss: () -> Unit) {
Row(verticalAlignment = Alignment.CenterVertically) { Row(verticalAlignment = Alignment.CenterVertically) {
Text("Add sources", style = MaterialTheme.typography.titleLarge) Text("Add sources", style = MaterialTheme.typography.titleLarge)
Spacer(modifier = Modifier.weight(1f)) Spacer(modifier = Modifier.weight(1f))
Button(onClick = { /*TODO*/ }) {
Icon(Icons.Default.Search, contentDescription = null)
Spacer(modifier = Modifier.width(4.dp))
Text("Discover sources")
}
} }
Text("Get started by selecting sources", style = MaterialTheme.typography.bodyMedium, color = Color.Gray) Text("Get started by selecting sources", style = MaterialTheme.typography.bodyMedium, color = Color.Gray)
@ -579,29 +472,6 @@ fun AddSourcesSheet(onDismiss: () -> Unit) {
} }
} }
} }
// Link card
Card(modifier = Modifier.fillMaxWidth()) {
Column(modifier = Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {
Row(verticalAlignment = Alignment.CenterVertically) {
Icon(Icons.Default.Link, contentDescription = null)
Spacer(modifier = Modifier.width(8.dp))
Text("Link", fontWeight = FontWeight.Bold)
}
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
Button(onClick = { /*TODO*/ }) {
Icon(Icons.Default.Language, contentDescription = null)
Spacer(modifier = Modifier.width(4.dp))
Text("Website")
}
Button(onClick = { /*TODO*/ }) {
Icon(Icons.Default.PlayCircle, contentDescription = null)
Spacer(modifier = Modifier.width(4.dp))
Text("YouTube")
}
}
}
}
} }
} }
} }
@ -658,78 +528,93 @@ fun ChatScreen() {
} }
} }
@OptIn(ExperimentalMaterial3Api::class)
@Composable @Composable
fun StudioScreen() { fun StudioScreen() {
val studioActions = listOf( // State untuk dropdown menu
"Audio Overview" to Icons.Default.GraphicEq, var showUploadMenu by remember { mutableStateOf(false) }
"Video Overview" to Icons.Default.OndemandVideo,
"Mind Map" to Icons.Default.AccountTree, // Launcher untuk mengambil media
"Reports" to Icons.Default.Assessment, val photoPickerLauncher = rememberLauncherForActivityResult(
"Flashcards" to Icons.Default.Style, contract = ActivityResultContracts.PickVisualMedia(),
"Quiz" to Icons.Default.Quiz onResult = { uri -> /* Handle URI */ }
)
val filePickerLauncher = rememberLauncherForActivityResult(
contract = ActivityResultContracts.GetContent(),
onResult = { uri -> /* Handle URI */ }
) )
Column( Column(modifier = Modifier.fillMaxSize().background(Color.White).padding(16.dp)) {
modifier = Modifier Text("Notebook terbaru", style = MaterialTheme.typography.titleLarge, fontWeight = FontWeight.Bold, color = Color.Black)
.fillMaxSize()
.padding(16.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
LazyVerticalGrid(
columns = GridCells.Fixed(2),
verticalArrangement = Arrangement.spacedBy(8.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
items(studioActions) { (title, icon) ->
StudioActionCard(title = title, icon = icon)
}
}
Column(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Icon(Icons.Default.AutoAwesome, contentDescription = null, tint = Color.Gray)
Spacer(modifier = Modifier.height(8.dp))
Text("Studio output will be saved here.", style = MaterialTheme.typography.titleMedium)
Spacer(modifier = Modifier.height(8.dp))
Text(
text = "After adding sources, click to add Audio Overview, Study Guide, Mind Map, and more!",
style = MaterialTheme.typography.bodyMedium,
textAlign = TextAlign.Center,
color = Color.Gray
)
Spacer(modifier = Modifier.height(16.dp)) Spacer(modifier = Modifier.height(16.dp))
Button(onClick = { /*TODO*/ }) {
Icon(Icons.Default.NoteAdd, contentDescription = null) // Box untuk menjadi anchor bagi DropdownMenu
Spacer(modifier = Modifier.width(4.dp)) Box {
Text("Add note") NewNotebookCard(onClick = { showUploadMenu = true })
DropdownMenu(
expanded = showUploadMenu,
onDismissRequest = { showUploadMenu = false }
) {
DropdownMenuItem(
text = { Text("Perpustakaan Foto") },
onClick = {
photoPickerLauncher.launch(PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.ImageAndVideo))
showUploadMenu = false
},
leadingIcon = { Icon(Icons.Default.PhotoLibrary, contentDescription = null) }
)
DropdownMenuItem(
text = { Text("Ambil Video") },
onClick = { /* TODO: Implement Camera Launcher */ showUploadMenu = false },
leadingIcon = { Icon(Icons.Default.PhotoCamera, contentDescription = null) }
)
DropdownMenuItem(
text = { Text("Pilih File") },
onClick = {
filePickerLauncher.launch("*/*")
showUploadMenu = false
},
leadingIcon = { Icon(Icons.Default.Folder, contentDescription = null) }
)
DropdownMenuItem(
text = { Text("Google Drive") },
onClick = {
filePickerLauncher.launch("*/*")
showUploadMenu = false
},
leadingIcon = { Icon(Icons.Default.Cloud, contentDescription = null) }
)
} }
} }
} }
} }
@Composable @Composable
fun StudioActionCard(title: String, icon: ImageVector) { fun NewNotebookCard(onClick: () -> Unit) {
Card( Card(
modifier = Modifier.fillMaxWidth(),
shape = MaterialTheme.shapes.medium
) {
Box(modifier = Modifier.padding(12.dp)) {
Column(horizontalAlignment = Alignment.Start) {
Icon(icon, contentDescription = null, modifier = Modifier.size(24.dp))
Spacer(modifier = Modifier.height(8.dp))
Text(title, style = MaterialTheme.typography.bodyLarge)
}
Icon(
Icons.Default.Edit,
contentDescription = "Edit",
modifier = Modifier modifier = Modifier
.align(Alignment.TopEnd) .size(width = 180.dp, height = 150.dp)
.size(18.dp), .clickable(onClick = onClick),
tint = Color.Gray shape = RoundedCornerShape(16.dp),
) colors = CardDefaults.cardColors(containerColor = Color(0xFFF0F4F7))
) {
Column(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Box(
modifier = Modifier
.size(40.dp)
.clip(CircleShape)
.background(Color(0xFFE1E3E6)),
contentAlignment = Alignment.Center
) {
Icon(Icons.Default.Add, contentDescription = "Buat notebook baru", tint = Color.Black)
}
Spacer(modifier = Modifier.height(8.dp))
Text("Buat notebook baru", color = Color.Black)
} }
} }
} }
@ -738,6 +623,6 @@ fun StudioActionCard(title: String, icon: ImageVector) {
@Composable @Composable
fun DefaultPreview() { fun DefaultPreview() {
NotebookTheme { NotebookTheme {
NotebookApp() StudioScreen()
} }
} }