From b2a34e0031f298c83b4353414c61f55f2ec6edec Mon Sep 17 00:00:00 2001 From: Ren Amamiya Date: Mon, 15 Jun 2026 07:40:56 +0700 Subject: [PATCH] add contact list screen --- .../androidMain/kotlin/su/reya/coop/App.kt | 8 +-- .../kotlin/su/reya/coop/Navigation.kt | 3 + .../su/reya/coop/screens/ContactListScreen.kt | 63 +++++++++++++++++++ .../kotlin/su/reya/coop/screens/HomeScreen.kt | 3 +- 4 files changed, 71 insertions(+), 6 deletions(-) create mode 100644 composeApp/src/androidMain/kotlin/su/reya/coop/screens/ContactListScreen.kt diff --git a/composeApp/src/androidMain/kotlin/su/reya/coop/App.kt b/composeApp/src/androidMain/kotlin/su/reya/coop/App.kt index bd27100..1b246d3 100644 --- a/composeApp/src/androidMain/kotlin/su/reya/coop/App.kt +++ b/composeApp/src/androidMain/kotlin/su/reya/coop/App.kt @@ -16,14 +16,12 @@ import androidx.compose.material3.darkColorScheme import androidx.compose.material3.dynamicDarkColorScheme import androidx.compose.material3.dynamicLightColorScheme import androidx.compose.material3.expressiveLightColorScheme -import androidx.compose.material3.rememberModalBottomSheetState import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember -import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue import androidx.compose.runtime.staticCompositionLocalOf import androidx.compose.ui.platform.LocalContext @@ -37,6 +35,7 @@ import androidx.navigation3.runtime.rememberNavBackStack import androidx.navigation3.runtime.rememberSaveableStateHolderNavEntryDecorator import androidx.navigation3.ui.NavDisplay import su.reya.coop.screens.ChatScreen +import su.reya.coop.screens.ContactListScreen import su.reya.coop.screens.HomeScreen import su.reya.coop.screens.ImportScreen import su.reya.coop.screens.MyQrScreen @@ -69,8 +68,6 @@ val LocalScanResult = staticCompositionLocalOf { fun App(viewModel: NostrViewModel) { val context = LocalContext.current val activity = context as? ComponentActivity - val scope = rememberCoroutineScope() - val sheetState = rememberModalBottomSheetState() val backStack = rememberNavBackStack(Screen.Home) val navigator = remember(backStack) { Navigator(backStack) } val qrScanResult = remember { QrScanResult() } @@ -194,6 +191,9 @@ fun App(viewModel: NostrViewModel) { entry { MyQrScreen() } + entry { + ContactListScreen() + } entry { RelayScreen() } diff --git a/composeApp/src/androidMain/kotlin/su/reya/coop/Navigation.kt b/composeApp/src/androidMain/kotlin/su/reya/coop/Navigation.kt index a5bd384..50aca39 100644 --- a/composeApp/src/androidMain/kotlin/su/reya/coop/Navigation.kt +++ b/composeApp/src/androidMain/kotlin/su/reya/coop/Navigation.kt @@ -29,6 +29,9 @@ sealed interface Screen : NavKey { @Serializable data class Profile(val pubkey: String) : Screen + @Serializable + data object ContactList : Screen + @Serializable data object UpdateProfile : Screen diff --git a/composeApp/src/androidMain/kotlin/su/reya/coop/screens/ContactListScreen.kt b/composeApp/src/androidMain/kotlin/su/reya/coop/screens/ContactListScreen.kt new file mode 100644 index 0000000..d7a7fdd --- /dev/null +++ b/composeApp/src/androidMain/kotlin/su/reya/coop/screens/ContactListScreen.kt @@ -0,0 +1,63 @@ +package su.reya.coop.screens + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Scaffold +import androidx.compose.material3.SnackbarHost +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBar +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import coop.composeapp.generated.resources.Res +import coop.composeapp.generated.resources.ic_arrow_back +import org.jetbrains.compose.resources.painterResource +import su.reya.coop.LocalNavigator +import su.reya.coop.LocalNostrViewModel +import su.reya.coop.LocalSnackbarHostState + +@Composable +fun ContactListScreen() { + val navigator = LocalNavigator.current + val snackbarHostState = LocalSnackbarHostState.current + val viewModel = LocalNostrViewModel.current + val currentUser = viewModel.currentUser() ?: return + + Scaffold( + snackbarHost = { SnackbarHost(snackbarHostState) }, + topBar = { + TopAppBar( + title = { + Text( + text = "My Contacts", + style = MaterialTheme.typography.titleMediumEmphasized + ) + }, + navigationIcon = { + IconButton(onClick = { navigator.goBack() }) { + Icon( + painter = painterResource(Res.drawable.ic_arrow_back), + contentDescription = "Back" + ) + } + } + ) + }, + content = { innerPadding -> + Column( + modifier = Modifier + .fillMaxSize() + .padding(innerPadding), + verticalArrangement = Arrangement.Center, + horizontalAlignment = Alignment.CenterHorizontally, + ) { + Text("Contact List Screen") + } + } + ) +} \ No newline at end of file diff --git a/composeApp/src/androidMain/kotlin/su/reya/coop/screens/HomeScreen.kt b/composeApp/src/androidMain/kotlin/su/reya/coop/screens/HomeScreen.kt index 559ebf6..d29813d 100644 --- a/composeApp/src/androidMain/kotlin/su/reya/coop/screens/HomeScreen.kt +++ b/composeApp/src/androidMain/kotlin/su/reya/coop/screens/HomeScreen.kt @@ -656,8 +656,7 @@ fun BottomMenuList( val defaultMenuList = listOf( "Update Profile" to { navigator.navigate(Screen.UpdateProfile) }, - "Contact List" to { }, - "Spams & Blocks" to { }, + "Contact List" to { navigator.navigate(Screen.ContactList) }, "Relay Management" to { navigator.navigate(Screen.Relay) }, "Settings" to { } )