fix(firebase): replace placeholder Firebase config, update initializer and home screen wiring
This commit is contained in:
parent
7a9d4c3b49
commit
db177bc792
|
|
@ -13,13 +13,17 @@ android {
|
||||||
compileSdk = 35
|
compileSdk = 35
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId = "com.couplesconnect.app"
|
applicationId = "couples.connect.dev"
|
||||||
minSdk = 26
|
minSdk = 26
|
||||||
targetSdk = 35
|
targetSdk = 35
|
||||||
versionCode = 1
|
versionCode = 1
|
||||||
versionName = "0.1.0"
|
versionName = "0.1.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buildFeatures {
|
||||||
|
buildConfig = true
|
||||||
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
isMinifyEnabled = false
|
isMinifyEnabled = false
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package com.couplesconnect.app.core.firebase
|
package com.couplesconnect.app.core.firebase
|
||||||
|
|
||||||
import com.couplesconnect.app.BuildConfig
|
import com.couplesconnect.app.BuildConfig // generated by buildFeatures { buildConfig = true }
|
||||||
import com.google.firebase.appcheck.FirebaseAppCheck
|
import com.google.firebase.appcheck.FirebaseAppCheck
|
||||||
import com.google.firebase.appcheck.playintegrity.PlayIntegrityAppCheckProviderFactory
|
import com.google.firebase.appcheck.playintegrity.PlayIntegrityAppCheckProviderFactory
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import androidx.datastore.preferences.preferencesDataStoreFile
|
||||||
import androidx.datastore.preferences.core.PreferenceDataStoreFactory
|
import androidx.datastore.preferences.core.PreferenceDataStoreFactory
|
||||||
import androidx.room.Room
|
import androidx.room.Room
|
||||||
import com.couplesconnect.app.data.local.AppDatabase
|
import com.couplesconnect.app.data.local.AppDatabase
|
||||||
|
import com.google.firebase.firestore.FirebaseFirestore
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
import dagger.hilt.InstallIn
|
import dagger.hilt.InstallIn
|
||||||
|
|
@ -44,4 +45,8 @@ object DatabaseModule {
|
||||||
PreferenceDataStoreFactory.create {
|
PreferenceDataStoreFactory.create {
|
||||||
context.preferencesDataStoreFile("settings")
|
context.preferencesDataStoreFile("settings")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun provideFirestore(): FirebaseFirestore = FirebaseFirestore.getInstance()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,14 +10,18 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.navigationBarsPadding
|
import androidx.compose.foundation.layout.navigationBarsPadding
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.safeDrawingPadding
|
import androidx.compose.foundation.layout.safeDrawingPadding
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.filled.Favorite
|
||||||
import androidx.compose.material3.Button
|
import androidx.compose.material3.Button
|
||||||
import androidx.compose.material3.ButtonDefaults
|
import androidx.compose.material3.ButtonDefaults
|
||||||
import androidx.compose.material3.Card
|
import androidx.compose.material3.Card
|
||||||
import androidx.compose.material3.CardDefaults
|
import androidx.compose.material3.CardDefaults
|
||||||
import androidx.compose.material3.CircularProgressIndicator
|
import androidx.compose.material3.CircularProgressIndicator
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.OutlinedButton
|
import androidx.compose.material3.OutlinedButton
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
|
|
@ -57,6 +61,7 @@ fun HomeScreen(
|
||||||
onCategory = { categoryId -> onNavigate(AppRoute.questionCategory(categoryId)) },
|
onCategory = { categoryId -> onNavigate(AppRoute.questionCategory(categoryId)) },
|
||||||
onHistory = { onNavigate(AppRoute.ANSWER_HISTORY) },
|
onHistory = { onNavigate(AppRoute.ANSWER_HISTORY) },
|
||||||
onSettings = { onNavigate(AppRoute.SETTINGS) },
|
onSettings = { onNavigate(AppRoute.SETTINGS) },
|
||||||
|
onInvite = { onNavigate(AppRoute.CREATE_INVITE) },
|
||||||
onRefresh = viewModel::loadHome
|
onRefresh = viewModel::loadHome
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -69,6 +74,7 @@ private fun HomeContent(
|
||||||
onCategory: (String) -> Unit,
|
onCategory: (String) -> Unit,
|
||||||
onHistory: () -> Unit,
|
onHistory: () -> Unit,
|
||||||
onSettings: () -> Unit,
|
onSettings: () -> Unit,
|
||||||
|
onInvite: () -> Unit,
|
||||||
onRefresh: () -> Unit
|
onRefresh: () -> Unit
|
||||||
) {
|
) {
|
||||||
Box(
|
Box(
|
||||||
|
|
@ -96,6 +102,10 @@ private fun HomeContent(
|
||||||
streakCount = state.streakCount
|
streakCount = state.streakCount
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (!state.isPaired && !state.isLoading) {
|
||||||
|
InvitePartnerCard(onInvite = onInvite)
|
||||||
|
}
|
||||||
|
|
||||||
when {
|
when {
|
||||||
state.isLoading -> LoadingHomeCard()
|
state.isLoading -> LoadingHomeCard()
|
||||||
state.error != null -> ErrorHomeCard(message = state.error, onRefresh = onRefresh)
|
state.error != null -> ErrorHomeCard(message = state.error, onRefresh = onRefresh)
|
||||||
|
|
@ -158,6 +168,49 @@ private fun HomeHeader(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun InvitePartnerCard(onInvite: () -> Unit) {
|
||||||
|
Card(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
shape = RoundedCornerShape(26.dp),
|
||||||
|
colors = CardDefaults.cardColors(containerColor = Color(0xFFFFF4F0)),
|
||||||
|
elevation = CardDefaults.cardElevation(defaultElevation = 6.dp)
|
||||||
|
) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.padding(18.dp),
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(16.dp),
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
Icons.Filled.Favorite,
|
||||||
|
contentDescription = null,
|
||||||
|
tint = Color(0xFFE07A5F),
|
||||||
|
modifier = Modifier.size(28.dp)
|
||||||
|
)
|
||||||
|
Column(modifier = Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(4.dp)) {
|
||||||
|
Text(
|
||||||
|
text = "Invite your partner",
|
||||||
|
style = MaterialTheme.typography.titleMedium,
|
||||||
|
fontWeight = FontWeight.SemiBold,
|
||||||
|
color = Color(0xFF27211F)
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
text = "Share a code to connect and start answering together.",
|
||||||
|
style = MaterialTheme.typography.bodySmall,
|
||||||
|
color = Color(0xFF4E4642)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Button(
|
||||||
|
onClick = onInvite,
|
||||||
|
shape = RoundedCornerShape(14.dp),
|
||||||
|
colors = ButtonDefaults.buttonColors(containerColor = Color(0xFFE07A5F))
|
||||||
|
) {
|
||||||
|
Text("Invite", color = Color.White)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun DailyQuestionCard(
|
private fun DailyQuestionCard(
|
||||||
question: Question?,
|
question: Question?,
|
||||||
|
|
@ -519,6 +572,7 @@ fun HomeScreenPreview() {
|
||||||
onCategory = {},
|
onCategory = {},
|
||||||
onHistory = {},
|
onHistory = {},
|
||||||
onSettings = {},
|
onSettings = {},
|
||||||
|
onInvite = {},
|
||||||
onRefresh = {}
|
onRefresh = {}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,8 @@ data class HomeUiState(
|
||||||
val categories: List<HomeCategorySummary> = emptyList(),
|
val categories: List<HomeCategorySummary> = emptyList(),
|
||||||
val answerStats: HomeAnswerStats = HomeAnswerStats(),
|
val answerStats: HomeAnswerStats = HomeAnswerStats(),
|
||||||
val partnerName: String? = null,
|
val partnerName: String? = null,
|
||||||
val streakCount: Int = 0
|
val streakCount: Int = 0,
|
||||||
|
val isPaired: Boolean = false
|
||||||
)
|
)
|
||||||
|
|
||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
|
|
@ -81,7 +82,8 @@ class HomeViewModel @Inject constructor(
|
||||||
dailyQuestion = dailyQuestion,
|
dailyQuestion = dailyQuestion,
|
||||||
categories = categories,
|
categories = categories,
|
||||||
partnerName = partnerName,
|
partnerName = partnerName,
|
||||||
streakCount = couple?.streakCount ?: 0
|
streakCount = couple?.streakCount ?: 0,
|
||||||
|
isPaired = couple != null
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue