Skip to content

Commit

Permalink
Add Team Leaders
Browse files Browse the repository at this point in the history
  • Loading branch information
thekaailashsharma committed Nov 26, 2023
1 parent e698efa commit 6080e02
Show file tree
Hide file tree
Showing 6 changed files with 296 additions and 132 deletions.
7 changes: 7 additions & 0 deletions app/src/main/java/app/waste2wealth/com/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ import androidx.activity.compose.setContent
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.material.BottomDrawerValue
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.FabPosition
import androidx.compose.material.FloatingActionButton
import androidx.compose.material.Icon
import androidx.compose.material.Scaffold
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.LocationOn
import androidx.compose.material.rememberBottomDrawerState
import androidx.compose.material.rememberScaffoldState
import androidx.compose.runtime.getValue
Expand All @@ -31,6 +37,7 @@ import app.waste2wealth.com.newcommunities.CommunitiesScreen
import app.waste2wealth.com.newcommunities.CommunityInfo
import app.waste2wealth.com.ui.theme.Waste2WealthTheme
import app.waste2wealth.com.ui.theme.appBackground
import app.waste2wealth.com.ui.theme.textColor
import com.google.accompanist.navigation.animation.rememberAnimatedNavController
import com.google.accompanist.permissions.ExperimentalPermissionsApi
import com.google.accompanist.permissions.rememberMultiplePermissionsState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import androidx.compose.animation.slideOutHorizontally
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand All @@ -26,24 +27,30 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Card
import androidx.compose.material.DropdownMenu
import androidx.compose.material.DropdownMenuItem
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.ExposedDropdownMenuBox
import androidx.compose.material.FabPosition
import androidx.compose.material.FloatingActionButton
import androidx.compose.material.Icon
import androidx.compose.material.ModalBottomSheetLayout
import androidx.compose.material.ModalBottomSheetValue
import androidx.compose.material.Scaffold
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.ArrowDropDown
import androidx.compose.material.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
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.ui.Alignment
import androidx.compose.ui.Modifier
Expand All @@ -66,6 +73,7 @@ import com.jet.firestore.getListOfObjects
import app.waste2wealth.com.communities.CommunitiesViewModel
import app.waste2wealth.com.newcommunities.CommunitiesScreen
import app.waste2wealth.com.newcommunities.CommunityInfo
import app.waste2wealth.com.newcommunities.Form
import app.waste2wealth.com.profile.ProfileImage
import app.waste2wealth.com.ui.theme.CardColor
import app.waste2wealth.com.ui.theme.CardTextColor
Expand All @@ -74,11 +82,12 @@ import com.airbnb.lottie.compose.LottieAnimation
import com.airbnb.lottie.compose.LottieCompositionSpec
import com.airbnb.lottie.compose.rememberLottieComposition
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

@OptIn(ExperimentalMaterialApi::class)
@Composable
fun CommunitiesSection(
name:String,
name: String,
paddingValues: PaddingValues,
email: String
) {
Expand Down Expand Up @@ -121,8 +130,11 @@ fun CommunitiesSection(
var myCommunities = remember {
mutableStateOf(mutableListOf(""))
}
var isFormVisible = remember {
mutableStateOf(false)
}
var selectedType by remember { mutableStateOf(TypeOfCommunities.ALL_COMMUNITIES.names) }
LaunchedEffect(key1 = Unit){
LaunchedEffect(key1 = Unit) {
isLaunched = true
}
val modalSheetState = rememberModalBottomSheetState(
Expand All @@ -135,11 +147,21 @@ fun CommunitiesSection(
easing = FastOutLinearInEasing
)
)

LaunchedEffect(key1 = modalSheetState.isVisible){
if(!modalSheetState.isVisible){
isFormVisible.value = false
}
}
ModalBottomSheetLayout(
sheetState = modalSheetState,
sheetShape = RoundedCornerShape(topStart = 12.dp, topEnd = 12.dp),
sheetContent = {
CommunityInfo(communitiesViewModel = viewModel)
if (isFormVisible.value) {
Form(modalSheetState)
} else {
CommunityInfo(communitiesViewModel = viewModel)
}
}
) {
JetFirestore(path = {
Expand Down Expand Up @@ -186,7 +208,8 @@ fun CommunitiesSection(
}

TypeOfCommunities.Memberships.names -> {
allCommunities = communities?.filter { it.name in myCommunities.value }
allCommunities =
communities?.filter { it.name in myCommunities.value }
isMemberShips = true
}

Expand All @@ -195,9 +218,15 @@ fun CommunitiesSection(

var progress2 = remember { mutableStateOf(0f) }
val visible =
animateFloatAsState(if (progress2.value > 0.35f) 1f else 0f, label = "").value
animateFloatAsState(
if (progress2.value > 0.35f) 1f else 0f,
label = ""
).value
val inVisible =
animateFloatAsState(if (progress2.value > 0.35f) 0f else 1f, label = "").value
animateFloatAsState(
if (progress2.value > 0.35f) 0f else 1f,
label = ""
).value
val isLoading = remember { mutableStateOf(false) }
var expanded by remember { mutableStateOf(false) }

Expand Down Expand Up @@ -375,7 +404,8 @@ fun CommunitiesSection(
community[viewModel.currentPage.value].cardColor
),
border = BorderStroke(
width = 1.dp, color = Color(0xFFE91E63).fromHex(
width = 1.dp,
color = Color(0xFFE91E63).fromHex(
community[viewModel.currentPage.value].cardColor
)
),
Expand Down Expand Up @@ -458,16 +488,55 @@ fun CommunitiesSection(
noOfTimesActivity,
myCommunities,
isMemberShips,
modalSheetState
modalSheetState,
isFormVisible
)
}
Log.i("ExpandedState", "HomeScreen: ${viewModel.expandedState.value}")

}
}
val coroutineScope = rememberCoroutineScope()
Box(
modifier = Modifier
.fillMaxSize()
.padding(bottom = 100.dp, end = 20.dp),
contentAlignment = Alignment.BottomEnd
) {
Card(shape = CircleShape, backgroundColor = textColor) {
Icon(
imageVector = Icons.Filled.Add,
contentDescription = null,
tint = appBackground,
modifier = Modifier
.size(35.dp)
.padding(5.dp)
.clickable(
interactionSource = remember { MutableInteractionSource() },
indication = null
) {
isFormVisible.value = true
coroutineScope.launch {
if (modalSheetState.isVisible) {
// Hide the bottom sheet
modalSheetState.hide()
isFormVisible.value = false
} else {
// Show the bottom sheet
modalSheetState.show()


}
}
}
)
}
}
}
}
}


}


Expand All @@ -476,3 +545,4 @@ fun CommunitiesSection(




Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,28 @@ data class DummyCards(
)
}

data class RegistrationForm(
val dateOfEstablishment: String,
val activeRegion: String,
val name: String,
val description: String,
val motivation: String,
val location: String,
val time: String,
val image : String = "https://firebasestorage.googleapis.com/v0/b/waste2wealth-225f8.appspot.com/o/image%207.png?alt=media&token=5ee8672f-b690-408b-b15a-756e4da1f952"
) {
constructor() : this(
"",
"",
"",
"",
"",
"",
""

)
}

data class Drive(
val name: String,
val location: String, // Assuming location is a specific place within India
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ 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.communities.ui.RegistrationForm
import app.waste2wealth.com.tags.Groups
import app.waste2wealth.com.tags.Tag
import app.waste2wealth.com.tags.TagWithoutTips
Expand Down Expand Up @@ -137,18 +138,17 @@ fun updateCollectedWasteToFirebase(
}

fun updateCommunitiesToFirebase(
communities: List<DummyCards>
communities: RegistrationForm
) {
val db = FirebaseFirestore.getInstance()
communities.forEach {
db.collection("Communities").document(it.name).set(it)
.addOnSuccessListener {
println("Communities Updated successfully..")
db.collection("Communities").document(communities.name).set(communities)
.addOnSuccessListener {
println("Communities Updated successfully..")

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

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

fun updateTagsToFirebase(
Expand All @@ -166,3 +166,18 @@ fun updateTagsToFirebase(
}
}

fun updateCommunityToFirebase(
community: DummyCards
) {
val db = FirebaseFirestore.getInstance()
db.collection("Communities").document(community.name).set(community)
.addOnSuccessListener {
println("Communities Updated successfully..")

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



Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ fun CommunitiesScreen(
noOfTimesActivity: Int,
communities: MutableState<MutableList<String>>,
isMemberships: Boolean,
modalSheetState: ModalBottomSheetState
modalSheetState: ModalBottomSheetState,
isFormVisible: MutableState<Boolean>
) {
val pagerState = rememberPagerState()
val selectedItempage = remember { mutableStateOf(0) }
Expand Down
Loading

0 comments on commit 6080e02

Please sign in to comment.