Skip to content

Commit

Permalink
Added ContactDetailsScreen
Browse files Browse the repository at this point in the history
  • Loading branch information
binayshaw7777 committed Jun 1, 2024
1 parent 038ea73 commit 1b324cd
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import androidx.compose.ui.unit.dp
import coil.compose.rememberAsyncImagePainter
import com.binay.shaw.justap.R
import com.binay.shaw.justap.presentation.themes.DMSansFontFamily
import timber.log.Timber

@Composable
fun EmptyState(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.binay.shaw.justap.presentation.contact

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import com.binay.shaw.justap.presentation.navigation.LocalNavHost

@Composable
fun ContactDetailsScreen(modifier: Modifier = Modifier) {

val context = LocalContext.current
val navController = LocalNavHost.current

Scaffold { paddingValues ->
Column(
modifier = Modifier
.fillMaxSize()
.padding(paddingValues)
.padding(16.dp)
.then(modifier)
) {
Text(text = "Contact Details")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ import com.binay.shaw.justap.presentation.components.AccountCard
import com.binay.shaw.justap.presentation.components.EmptyState
import com.binay.shaw.justap.presentation.components.SearchBar
import com.binay.shaw.justap.presentation.mainScreens.homeScreen.accountFragments.AddEditViewModel
import com.binay.shaw.justap.presentation.navigation.LocalNavHost
import com.binay.shaw.justap.presentation.navigation.Screens
import com.binay.shaw.justap.viewModel.AccountsViewModel
import com.binay.shaw.justap.viewModel.LocalUserViewModel
import com.theapache64.rebugger.Rebugger
import timber.log.Timber


Expand All @@ -50,8 +53,26 @@ fun HomeScreen(

val userAccountList by accountViewModel.userAccountList.collectAsState(emptyList())
val user by localUserViewModel.user.collectAsState()
val navController = LocalNavHost.current

var search by remember { mutableStateOf("") }
val filteredAccountList = if (search.isBlank()) {
userAccountList
} else {
userAccountList.filter {
it.accountName.contains(search, ignoreCase = true) ||
it.accountData.contains(search, ignoreCase = true)
}
}

Rebugger(
trackMap = mapOf(
"userAccountList" to userAccountList,
"user" to user,
"search" to search,
"filteredAccountList" to filteredAccountList
)
)

LaunchedEffect(Unit) {
accountViewModel.getAllUserAccounts()
Expand All @@ -77,8 +98,7 @@ fun HomeScreen(
floatingActionButton = {
FloatingActionButton(
onClick = {
// Navigate to add account screen
Timber.d("Add account clicked")
navController.navigate(Screens.ContactDetailsScreen.name)
}
) {
Icon(imageVector = Icons.Default.Add, contentDescription = "Add account")
Expand All @@ -97,29 +117,24 @@ fun HomeScreen(
SearchBar(
search = search,
onValueChange = { search = it },
onSearchClick = {
// Handle search click
Timber.d("Search clicked with value: $search")
}
onSearchClick = {}
)

Spacer(Modifier.height(16.dp))

if (userAccountList.isEmpty()) {
Timber.d("User account list is empty")
EmptyState(showTextButton = true) {
EmptyState(showTextButton = true) {
// Navigate to add account screen
Timber.d("Add account clicked")
navController.navigate(Screens.ContactDetailsScreen.name)
}

} else if (filteredAccountList.isEmpty()) {
EmptyState(text = "No accounts found",)
} else {
Timber.d("User account list is not empty")

LazyColumn(
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
items(
items = userAccountList,
items = filteredAccountList,
key = { account -> account.accountID }
) { account ->
AccountCard(account) { newValue ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import com.binay.shaw.justap.R
import com.binay.shaw.justap.presentation.account.AccountScreen
import com.binay.shaw.justap.presentation.connect.ConnectScannerScreen
import com.binay.shaw.justap.presentation.connect.ConnectScreen
import com.binay.shaw.justap.presentation.contact.ContactDetailsScreen
import com.binay.shaw.justap.presentation.history.HistoryScreen
import com.binay.shaw.justap.presentation.home.HomeScreen
import com.binay.shaw.justap.presentation.themes.DMSansFontFamily
Expand All @@ -68,7 +69,8 @@ fun Navigation(
val backStackEntry = navController.currentBackStackEntryAsState()

val screensWithoutNavBar = persistentListOf(
Screens.ConnectScannerScreen.name
Screens.ConnectScannerScreen.name,
Screens.ContactDetailsScreen.name
)

BackPressCompose()
Expand All @@ -93,10 +95,12 @@ fun Navigation(
popEnterTransition = { FadeIn },
popExitTransition = { FadeOut },
) {

composable(route = Screens.HomeScreen.name) {
HomeScreen()
}
composable(route = Screens.ContactDetailsScreen.name) {
ContactDetailsScreen()
}

composable(route = Screens.ConnectScreen.name) {
ConnectScreen()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package com.binay.shaw.justap.presentation.navigation
import com.binay.shaw.justap.utilities.Constants

sealed class Screens(val name: String) {
object HomeScreen : Screens(Constants.HOME_SCREEN)
object ConnectScreen : Screens(Constants.CONNECT_SCREEN)
object HistoryScreen : Screens(Constants.HISTORY_SCREEN)
object AccountScreen : Screens(Constants.ACCOUNT_SCREEN)
object ConnectScannerScreen : Screens(Constants.CONNECT_SCANNER_SCREEN)
data object HomeScreen : Screens(Constants.HOME_SCREEN)
data object ConnectScreen : Screens(Constants.CONNECT_SCREEN)
data object HistoryScreen : Screens(Constants.HISTORY_SCREEN)
data object AccountScreen : Screens(Constants.ACCOUNT_SCREEN)
data object ConnectScannerScreen : Screens(Constants.CONNECT_SCANNER_SCREEN)
data object ContactDetailsScreen : Screens(Constants.CONTACT_DETAILS_SCREEN)
}


Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ object Constants {
const val HISTORY_SCREEN = "HISTORY_SCREEN"
const val ACCOUNT_SCREEN = "ACCOUNT_SCREEN"
const val CONNECT_SCANNER_SCREEN = "CONNECT_SCANNER_SCREEN"
const val CONTACT_DETAILS_SCREEN = "CONTACT_DETAILS_SCREEN"

const val inviteFriendsMessage = """
Hey there! I've been using this amazing app and thought you might like it too! 😊 Check it out: https://play.google.com/store/apps/details?id=com.binay.shaw.justap
Expand Down

0 comments on commit 1b324cd

Please sign in to comment.