Skip to content

Commit

Permalink
Initiate Tags in ReportWaste
Browse files Browse the repository at this point in the history
  • Loading branch information
thekaailashsharma committed Sep 23, 2023
1 parent f344aaa commit a6e8fad
Show file tree
Hide file tree
Showing 40 changed files with 1,346 additions and 353 deletions.
Binary file added app/release/app-release.apk
Binary file not shown.
20 changes: 20 additions & 0 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": 3,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "app.waste2wealth.com",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 1,
"versionName": "1.0",
"outputFile": "app-release.apk"
}
],
"elementType": "File"
}
12 changes: 7 additions & 5 deletions app/src/main/java/app/waste2wealth/com/dashboard/NewDashboard.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,14 @@ import app.waste2wealth.com.R
import app.waste2wealth.com.communities.ui.DummyCards
import app.waste2wealth.com.firebase.firestore.ProfileInfo
import app.waste2wealth.com.firebase.firestore.updateCommunitiesToFirebase
import app.waste2wealth.com.firebase.firestore.updateTagsToFirebase
import app.waste2wealth.com.location.LocationViewModel
import app.waste2wealth.com.navigation.Screens
import app.waste2wealth.com.profile.ProfileImage
import app.waste2wealth.com.rewards.Level
import app.waste2wealth.com.rewards.LevelDialogBox
import app.waste2wealth.com.rewards.levels
import app.waste2wealth.com.tags.wasteGroups
import app.waste2wealth.com.ui.theme.CardColor
import app.waste2wealth.com.ui.theme.CardTextColor
import app.waste2wealth.com.ui.theme.appBackground
Expand Down Expand Up @@ -130,12 +132,12 @@ fun NewDashboard(
mutableStateOf(false)
}
var communities by remember { mutableStateOf<List<DummyCards>?>(null) }
val animatedProgress by animateFloatAsState(
val animatedProgress by animateFloatAsState(
targetValue = if (animStart) 0f else viewModel.currentProgress,
label = "",
animationSpec = tween(500)
)
LaunchedEffect(key1 = viewModel.showLevelDialog){
LaunchedEffect(key1 = viewModel.showLevelDialog) {
if (viewModel.showLevelDialog) {
animStart = true
delay(1000)
Expand Down Expand Up @@ -169,7 +171,7 @@ fun NewDashboard(
}
}
}
LaunchedEffect(key1 = pointsEarned){
LaunchedEffect(key1 = pointsEarned) {
animStart = true
if (pointsEarned != 0) {
viewModel.pointsEarned = pointsEarned
Expand Down Expand Up @@ -558,7 +560,7 @@ fun NewDashboard(
Spacer(modifier = Modifier.height(10.dp))
Button(
onClick = {

updateTagsToFirebase(wasteGroups)
},
shape = RoundedCornerShape(10.dp),
colors = ButtonDefaults.buttonColors(
Expand Down Expand Up @@ -623,7 +625,7 @@ fun NewDashboard(
Spacer(modifier = Modifier.height(130.dp))

}
if (viewModel.showLevelDialog){
if (viewModel.showLevelDialog) {
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
viewModel.currentLevel.value?.let { currentlevel ->
isCOinVisible = viewModel.isNewLevelUnlocked(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ package app.waste2wealth.com.firebase.firestore
import android.content.Context
import android.widget.Toast
import app.waste2wealth.com.communities.ui.DummyCards
import app.waste2wealth.com.tags.Groups
import app.waste2wealth.com.tags.Tag
import app.waste2wealth.com.tags.TagWithoutTips
import coil.request.Tags
import com.google.firebase.firestore.FirebaseFirestore

fun updateInfoToFirebase(
Expand Down Expand Up @@ -62,9 +66,10 @@ fun updateWasteToFirebase(
timeStamp: Long,
userEmail: String,
address: String,
tags: List<TagWithoutTips> = emptyList(),
) {
val wasteItem = WasteItem(
latitude, longitude, imagePath, timeStamp, userEmail, address
latitude, longitude, imagePath, timeStamp, userEmail, address, tags
)

val db = FirebaseFirestore.getInstance()
Expand Down Expand Up @@ -146,3 +151,18 @@ fun updateCommunitiesToFirebase(
}
}

fun updateTagsToFirebase(
tags: List<Groups>
) {
val db = FirebaseFirestore.getInstance()
tags.forEach {
db.collection("TagGroups").document(it.name).set(it)
.addOnSuccessListener {
println("Communities Updated successfully..")

}.addOnFailureListener { exception ->
println("Fail to update Communities : " + exception.message)
}
}
}

Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
package app.waste2wealth.com.firebase.firestore

import app.waste2wealth.com.tags.TagWithoutTips

data class WasteItem(
val latitude: Double,
val longitude: Double,
val imagePath: String,
val timeStamp: Long,
val userEmail: String,
val address: String,
val tag: List<TagWithoutTips> = emptyList(),
) {
constructor() : this(0.0, 0.0, "", 0, "", "")
constructor() : this(
0.0,
0.0,
"",
0,
"",
"",
emptyList()
)
}

data class CollectedWasteItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import app.waste2wealth.com.login.onboarding.Onboarding
import app.waste2wealth.com.login.onboarding.SettingUp
import app.waste2wealth.com.profile.NewProfileScreen
import app.waste2wealth.com.reportwaste.ReportWaste
import app.waste2wealth.com.reportwaste.ReportWasteViewModel
import app.waste2wealth.com.rewards.ClaimedRewardsScreen
import app.waste2wealth.com.rewards.NewRewardsScreen
import app.waste2wealth.com.rewards.RewardDetails
Expand All @@ -44,6 +45,7 @@ fun NavigationController(
paddingValues: PaddingValues
) {
val viewModel: LocationViewModel = hiltViewModel()
val reportWasteViewModel: ReportWasteViewModel = hiltViewModel()
val context = LocalContext.current
val store = UserDatastore(context)
val email = store.getEmail.collectAsState(initial = "")
Expand Down Expand Up @@ -151,7 +153,8 @@ fun NavigationController(
navController = navController, viewModel = viewModel,
email = email.value,
name = name.value,
pfp = profile.value
pfp = profile.value,
reportWasteViewModel = reportWasteViewModel
)
}
composable(Screens.CollectWasteLists.route) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.text.font.FontWeight
Expand All @@ -26,6 +27,7 @@ fun ProfileImage(
imageUrl: Any? = null,
initial: Char? = null,
contentScale: ContentScale = ContentScale.Crop,
colorFilter: ColorFilter? = null,
onClick: (() -> Unit)? = null,
) {
if (imageUrl != null) {
Expand All @@ -43,7 +45,8 @@ fun ProfileImage(
Modifier
}
),
contentScale = contentScale
contentScale = contentScale,
colorFilter = colorFilter
)
} else {
BoxWithConstraints(
Expand Down
Loading

0 comments on commit a6e8fad

Please sign in to comment.