| 1 |
package com.example.oxygenhub.ui |
| 2 |
|
| 3 |
import androidx.compose.foundation.layout.* |
| 4 |
import androidx.compose.material.icons.Icons |
| 5 |
import androidx.compose.material.icons.filled.Home |
| 6 |
import androidx.compose.material.icons.filled.Notifications |
| 7 |
import androidx.compose.material.icons.filled.Person |
| 8 |
import androidx.compose.material.icons.filled.PlayArrow |
| 9 |
import androidx.compose.material3.* |
| 10 |
import androidx.compose.runtime.* |
| 11 |
import androidx.compose.ui.Modifier |
| 12 |
import androidx.compose.ui.text.font.FontWeight |
| 13 |
import androidx.compose.ui.unit.dp |
| 14 |
import uniffi.rust_core.oxygenGreeting |
| 15 |
|
| 16 |
import androidx.compose.foundation.Image |
| 17 |
import androidx.compose.ui.res.painterResource |
| 18 |
import androidx.compose.ui.Alignment |
| 19 |
import com.example.oxygenhub.R |
| 20 |
|
| 21 |
@OptIn(ExperimentalMaterial3Api::class) |
| 22 |
@Composable |
| 23 |
fun MainScreen() { |
| 24 |
var selectedItem by remember { mutableIntStateOf(0) } |
| 25 |
val items = listOf("Home", "Notifications", "Flow", "Profile") |
| 26 |
val icons = listOf(Icons.Filled.Home, Icons.Filled.Notifications, Icons.Filled.PlayArrow, Icons.Filled.Person) |
| 27 |
|
| 28 |
Scaffold( |
| 29 |
topBar = { |
| 30 |
TopAppBar( |
| 31 |
title = { |
| 32 |
Row(verticalAlignment = Alignment.CenterVertically) { |
| 33 |
Image( |
| 34 |
painter = painterResource(id = R.drawable.mark), |
| 35 |
contentDescription = "OxygenHub Logo", |
| 36 |
modifier = Modifier.size(24.dp) |
| 37 |
) |
| 38 |
Spacer(modifier = Modifier.width(8.dp)) |
| 39 |
Text("OxygenHub", fontWeight = FontWeight.Bold) |
| 40 |
} |
| 41 |
}, |
| 42 |
colors = TopAppBarDefaults.topAppBarColors( |
| 43 |
containerColor = MaterialTheme.colorScheme.primaryContainer, |
| 44 |
titleContentColor = MaterialTheme.colorScheme.onPrimaryContainer |
| 45 |
) |
| 46 |
) |
| 47 |
}, |
| 48 |
bottomBar = { |
| 49 |
NavigationBar { |
| 50 |
items.forEachIndexed { index, item -> |
| 51 |
NavigationBarItem( |
| 52 |
icon = { Icon(icons[index], contentDescription = item) }, |
| 53 |
label = { Text(item) }, |
| 54 |
selected = selectedItem == index, |
| 55 |
onClick = { selectedItem = index } |
| 56 |
) |
| 57 |
} |
| 58 |
} |
| 59 |
} |
| 60 |
) { innerPadding -> |
| 61 |
Surface( |
| 62 |
modifier = Modifier |
| 63 |
.fillMaxSize() |
| 64 |
.padding(innerPadding), |
| 65 |
color = MaterialTheme.colorScheme.background |
| 66 |
) { |
| 67 |
// Render the selected tab |
| 68 |
when (selectedItem) { |
| 69 |
0 -> HomeTab() |
| 70 |
1 -> NotificationsTab() |
| 71 |
2 -> FlowTab() |
| 72 |
3 -> ProfileTab() |
| 73 |
} |
| 74 |
} |
| 75 |
} |
| 76 |
} |
| 77 |
|
| 78 |
@Composable |
| 79 |
fun HomeTab() { |
| 80 |
Column(modifier = Modifier.padding(16.dp)) { |
| 81 |
Text("Activity", style = MaterialTheme.typography.headlineMedium, fontWeight = FontWeight.Bold) |
| 82 |
Spacer(modifier = Modifier.height(16.dp)) |
| 83 |
Card(modifier = Modifier.fillMaxWidth()) { |
| 84 |
Column(modifier = Modifier.padding(16.dp)) { |
| 85 |
Text("Native Core Status:", style = MaterialTheme.typography.titleMedium) |
| 86 |
Spacer(modifier = Modifier.height(8.dp)) |
| 87 |
// This calls our Rust FFI function! |
| 88 |
Text(text = oxygenGreeting("Andy"), color = MaterialTheme.colorScheme.primary) |
| 89 |
} |
| 90 |
} |
| 91 |
} |
| 92 |
} |
| 93 |
|
| 94 |
@Composable |
| 95 |
fun NotificationsTab() { |
| 96 |
Box(modifier = Modifier.fillMaxSize(), contentAlignment = androidx.compose.ui.Alignment.Center) { |
| 97 |
Text("No new notifications") |
| 98 |
} |
| 99 |
} |
| 100 |
|
| 101 |
@Composable |
| 102 |
fun FlowTab() { |
| 103 |
Column(modifier = Modifier.padding(16.dp)) { |
| 104 |
Text("Active Pipelines", style = MaterialTheme.typography.headlineMedium, fontWeight = FontWeight.Bold) |
| 105 |
Spacer(modifier = Modifier.height(16.dp)) |
| 106 |
Card(modifier = Modifier.fillMaxWidth()) { |
| 107 |
Column(modifier = Modifier.padding(16.dp)) { |
| 108 |
Text("oxygenhub-android / main", fontWeight = FontWeight.Bold) |
| 109 |
Text("🧱 Build - Passing", color = androidx.compose.ui.graphics.Color(0xFF4CAF50)) |
| 110 |
Text("🧪 Functional Tests - Passing", color = androidx.compose.ui.graphics.Color(0xFF4CAF50)) |
| 111 |
} |
| 112 |
} |
| 113 |
} |
| 114 |
} |
| 115 |
|
| 116 |
@Composable |
| 117 |
fun ProfileTab() { |
| 118 |
Box(modifier = Modifier.fillMaxSize(), contentAlignment = androidx.compose.ui.Alignment.Center) { |
| 119 |
Text("Profile Settings") |
| 120 |
} |
| 121 |
} |