Skip to content

Commit

Permalink
Merge pull request #11 from thekaailashsharma/avatars
Browse files Browse the repository at this point in the history
Avatars
  • Loading branch information
thekaailashsharma authored Dec 10, 2023
2 parents 43ff335 + 92102c0 commit c4bc93b
Show file tree
Hide file tree
Showing 11 changed files with 1,018 additions and 379 deletions.
10 changes: 7 additions & 3 deletions app/src/main/java/ai/travel/app/BaseActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,14 @@ class BaseActivity : ComponentActivity() {
val userPhone = userDatastore.getNumber.collectAsState(initial = "")
val userGender = userDatastore.getGender.collectAsState(initial = "")
val loginStatus = userDatastore.getLoginStatus.collectAsState(initial = false)
val pfp = userDatastore.getPfp.collectAsState(initial = "")
SplashScreen(
homeViewModel = homeViewModel,
userName = userName.value,
userPhone = userPhone.value,
userGender = userGender.value,
loginStatus = loginStatus.value
loginStatus = loginStatus.value,
pfp = pfp.value
)

}
Expand All @@ -86,7 +88,8 @@ fun SplashScreen(
userName: String,
userPhone: String,
userGender: String,
loginStatus : Boolean
loginStatus : Boolean,
pfp: String
) {
val scale = remember {
androidx.compose.animation.core.Animatable(0f)
Expand All @@ -106,7 +109,8 @@ fun SplashScreen(
userName = userName,
userPhoneNumber = userPhone,
gender = userGender,
loginStatus = loginStatus
loginStatus = loginStatus,
pfp = pfp
)
delay(1000L)
val refresh = Intent(context, MainActivity::class.java)
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/java/ai/travel/app/datastore/UserDataStore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class UserDatastore(private val context: Context) {
val userName = stringPreferencesKey("userName")
val gender = stringPreferencesKey("gender")
val isLoggedIn = booleanPreferencesKey("login")
val pfp = stringPreferencesKey("pfp")
}

val getNumber: Flow<String> = context.datastore.data.map {
Expand All @@ -30,6 +31,16 @@ class UserDatastore(private val context: Context) {
}
}

val getPfp: Flow<String> = context.datastore.data.map {
it[pfp] ?: ""
}

suspend fun savePfp(pfp: String) {
context.datastore.edit {
it[UserDatastore.pfp] = pfp
}
}

suspend fun saveLoginStatus(status: Boolean) {
context.datastore.edit {
it[isLoggedIn] = status
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/java/ai/travel/app/firestore/ProfileInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ data class ProfileInfo(
val name: String?,
val phoneNumber: String?,
val gender: String?,
)
val imageUrl: String?,
) {
constructor() : this("", "", "", "")
}
2 changes: 2 additions & 0 deletions app/src/main/java/ai/travel/app/firestore/UpdateData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ fun updateInfoToFirebase(
name: String?,
phoneNumber: String?,
gender: String?,
imageUrl: String?,

) {
val profile = ProfileInfo(
name,
phoneNumber,
gender,
imageUrl
)

val db = FirebaseFirestore.getInstance()
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/ai/travel/app/home/HomeViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ class HomeViewModel @Inject constructor(
private val _userName = MutableStateFlow("")
val userName: StateFlow<String> = _userName.asStateFlow()

private val _userPfp = MutableStateFlow("")
val userPfp: StateFlow<String> = _userPfp.asStateFlow()

private val _gender = MutableStateFlow("")
val gender: StateFlow<String> = _gender.asStateFlow()

Expand All @@ -108,11 +111,13 @@ class HomeViewModel @Inject constructor(
gender: String,
userPhoneNumber: String,
loginStatus: Boolean,
pfp: String,
) {
_userName.value = userName
_userPhoneNumber.value = userPhoneNumber
_gender.value = gender
_loginStatus.value = loginStatus
_userPfp.value = pfp
}


Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/ai/travel/app/home/ui/CollapsedTopBar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ import androidx.navigation.NavController

@Composable
fun CollapsedTopBarHomeScreen(
imageUrl: Int,
imageUrl: String,
isCollapsed: Boolean,
scroll: LazyListState
) {
Expand Down Expand Up @@ -122,7 +122,7 @@ fun CollapsedTopBarHomeScreen(
ProfileImage(
imageUrl = imageUrl,
modifier = Modifier
.size(80.dp)
.size(70.dp)
.border(
brush = appGradient, shape = CircleShape, width = 1.dp
)
Expand Down
203 changes: 184 additions & 19 deletions app/src/main/java/ai/travel/app/home/ui/HomeScreenMain.kt

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion app/src/main/java/ai/travel/app/navigation/NavController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ai.travel.app.home.ui.RtScreen
import ai.travel.app.mapsSearch.MapsSearchViewModel
import ai.travel.app.mapsSearch.ui.MapsSearchScreen
import ai.travel.app.newTrip.NewTripViewModel
import ai.travel.app.profile.NewProfileScreen
import ai.travel.app.riveanimation.LoginUI
import ai.travel.app.tripDetails.TripDetailsScreen
import androidx.compose.foundation.layout.PaddingValues
Expand Down Expand Up @@ -47,7 +48,7 @@ fun NavController(
// TripDetailsScreen(viewModel = homeViewModel, paddingValues = paddingValues)
}
composable(Screens.Profile.route) {
PfScreen()
NewProfileScreen(navHostController)
}
composable(Screens.Routes.route) {
MapsSearchScreen(viewModel = mapsViewModel, navController = navHostController)
Expand Down
Loading

0 comments on commit c4bc93b

Please sign in to comment.