From 21be910fa80c07ab121c4c4c52b007d7de7ee9d7 Mon Sep 17 00:00:00 2001 From: Kailash Sharma Date: Fri, 15 Sep 2023 04:07:47 +0530 Subject: [PATCH 1/2] Remove unwanted files --- .../waste2wealth/com/activity/Activities.kt | 42 -- .../app/waste2wealth/com/activity/Activity.kt | 559 --------------- .../waste2wealth/com/activity/MyRecording.kt | 253 ------- .../com/activity/StopRecording.kt | 642 ------------------ .../com/bottombar/BottomBarScreens.kt | 3 - .../waste2wealth/com/components/AppVersion.kt | 22 - .../waste2wealth/com/components/DrawerBody.kt | 55 -- .../com/components/DrawerHeader.kt | 39 -- .../app/waste2wealth/com/components/Logout.kt | 29 - .../waste2wealth/com/components/MenuItem.kt | 10 - .../com/components/PrivacyPolicy.kt | 26 - .../app/waste2wealth/com/components/TnC.kt | 26 - .../com/dashboard/DashBoardPage.kt | 170 ----- .../com/dashboard/DashboardContent.kt | 242 ------- .../java/app/waste2wealth/com/di/Module.kt | 9 - .../com/failuretask/TaskUndelivered.kt | 283 -------- .../waste2wealth/com/ktorClient/HttpCLient.kt | 32 - .../waste2wealth/com/ktorClient/HttpRoutes.kt | 7 - .../com/ktorClient/imageDto/Chain.kt | 13 - .../com/ktorClient/imageDto/ChainCode.kt | 13 - .../com/ktorClient/imageDto/File.kt | 9 - .../com/ktorClient/imageDto/Image.kt | 99 --- .../com/ktorClient/imageDto/ImageHost.kt | 15 - .../com/ktorClient/imageDto/ImageX.kt | 19 - .../com/ktorClient/imageDto/Medium.kt | 17 - .../com/ktorClient/imageDto/Resource.kt | 11 - .../com/ktorClient/imageDto/Success.kt | 11 - .../com/ktorClient/imageDto/Thumb.kt | 17 - .../com/location/LocationViewModel.kt | 23 - .../com/navigation/NavigationController.kt | 110 +-- .../waste2wealth/com/navigation/Screens.kt | 16 - .../waste2wealth/com/profile/ProfileScreen.kt | 187 ----- .../com/qrcode/analyzer/QrCodeAnalyzer.kt | 62 -- .../com/qrcode/sensors/AndroidSensor.kt | 51 -- .../com/qrcode/sensors/MeasurableSensors.kt | 18 - .../com/qrcode/sensors/Sensors.kt | 11 - .../app/waste2wealth/com/qrcode/ui/ScanQR.kt | 461 ------------- .../waste2wealth/com/rewards/RewardsScreen.kt | 342 ---------- .../com/successtask/DeliveryDetailsScreen.kt | 318 --------- .../waste2wealth/com/tasksDetail/TaskItem.kt | 39 -- .../com/tasksDetail/TasksDetailScreen.kt | 265 -------- .../waste2wealth/com/tasksList/TasksLists.kt | 200 ------ 42 files changed, 8 insertions(+), 4768 deletions(-) delete mode 100644 app/src/main/java/app/waste2wealth/com/activity/Activities.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/activity/Activity.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/activity/MyRecording.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/activity/StopRecording.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/components/AppVersion.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/components/DrawerBody.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/components/DrawerHeader.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/components/Logout.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/components/MenuItem.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/components/PrivacyPolicy.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/components/TnC.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/dashboard/DashBoardPage.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/dashboard/DashboardContent.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/failuretask/TaskUndelivered.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/ktorClient/HttpCLient.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/ktorClient/HttpRoutes.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/Chain.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/ChainCode.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/File.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/Image.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/ImageHost.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/ImageX.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/Medium.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/Resource.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/Success.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/Thumb.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/profile/ProfileScreen.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/qrcode/analyzer/QrCodeAnalyzer.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/qrcode/sensors/AndroidSensor.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/qrcode/sensors/MeasurableSensors.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/qrcode/sensors/Sensors.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/qrcode/ui/ScanQR.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/rewards/RewardsScreen.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/successtask/DeliveryDetailsScreen.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/tasksDetail/TaskItem.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/tasksDetail/TasksDetailScreen.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/tasksList/TasksLists.kt diff --git a/app/src/main/java/app/waste2wealth/com/activity/Activities.kt b/app/src/main/java/app/waste2wealth/com/activity/Activities.kt deleted file mode 100644 index ffe43dc..0000000 --- a/app/src/main/java/app/waste2wealth/com/activity/Activities.kt +++ /dev/null @@ -1,42 +0,0 @@ -package app.waste2wealth.com.activity - -data class Activities( - val time: String, - val title: String, - val points: Int, - val emoji: String, - val type: String -) - -val allActivities = listOf( - Activities( - time = "30 Minutes", - points = 100, - title = "Beach Clean up", - emoji = "\uD83E\uDD1D", - type = "Social Activity" - ), - Activities( - time = "1 Hour", - points = 100, - title = "Basic Clean up", - emoji = "\uD83D\uDE13", - type = "Social Activity" - ), - Activities( - time = "1 Hour", - points = 100, - title = "Public Transport", - emoji = "\uD83D\uDE1B", - type = "Social Activity" - ), - Activities( - time = "Custom time", - points = 0, - title = "Custom Activity", - emoji = "\uD83D\uDC9B", - type = "Custom Activity", - ), - - ) - diff --git a/app/src/main/java/app/waste2wealth/com/activity/Activity.kt b/app/src/main/java/app/waste2wealth/com/activity/Activity.kt deleted file mode 100644 index 610f600..0000000 --- a/app/src/main/java/app/waste2wealth/com/activity/Activity.kt +++ /dev/null @@ -1,559 +0,0 @@ -package app.waste2wealth.com.activity - -import android.Manifest -import android.graphics.Bitmap -import android.view.View -import android.widget.Toast -import androidx.activity.compose.rememberLauncherForActivityResult -import androidx.activity.result.contract.ActivityResultContracts -import androidx.activity.result.launch -import androidx.appcompat.widget.AppCompatTextView -import androidx.compose.foundation.Image -import androidx.compose.foundation.background -import androidx.compose.foundation.border -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.PaddingValues -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.lazy.grid.GridCells -import androidx.compose.foundation.lazy.grid.LazyVerticalGrid -import androidx.compose.foundation.lazy.grid.items -import androidx.compose.foundation.shape.CircleShape -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.BottomDrawerValue -import androidx.compose.material.Button -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.Card -import androidx.compose.material.ExperimentalMaterialApi -import androidx.compose.material.Icon -import androidx.compose.material.RadioButton -import androidx.compose.material.RadioButtonDefaults -import androidx.compose.material.Scaffold -import androidx.compose.material.Text -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.Title -import androidx.compose.material.icons.filled.UploadFile -import androidx.compose.material.rememberBottomDrawerState -import androidx.compose.runtime.Composable -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.ExperimentalComposeUiApi -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.ImageBitmap -import androidx.compose.ui.graphics.asImageBitmap -import androidx.compose.ui.graphics.toArgb -import androidx.compose.ui.layout.ContentScale -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.text.input.ImeAction -import androidx.compose.ui.text.input.KeyboardType -import androidx.compose.ui.text.input.TextFieldValue -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import androidx.compose.ui.viewinterop.AndroidView -import androidx.compose.ui.window.Dialog -import androidx.core.app.ActivityOptionsCompat -import androidx.navigation.NavHostController -import app.waste2wealth.com.bottombar.BottomBar -import app.waste2wealth.com.components.permissions.PermissionDrawer -import app.waste2wealth.com.firebase.firestore.updateTemporaryActivityToFirebase -import app.waste2wealth.com.location.LocationViewModel -import app.waste2wealth.com.login.TextFieldWithIcons -import app.waste2wealth.com.navigation.Screens -import app.waste2wealth.com.profile.ProfileImage -import app.waste2wealth.com.ui.theme.appBackground -import app.waste2wealth.com.ui.theme.monteBold -import app.waste2wealth.com.ui.theme.monteNormal -import app.waste2wealth.com.ui.theme.monteSB -import app.waste2wealth.com.ui.theme.textColor -import com.google.accompanist.permissions.ExperimentalPermissionsApi -import com.google.accompanist.permissions.rememberMultiplePermissionsState -import com.google.firebase.storage.FirebaseStorage -import kotlinx.coroutines.launch -import java.io.ByteArrayOutputStream - -@OptIn( - ExperimentalPermissionsApi::class, ExperimentalComposeUiApi::class, - ExperimentalMaterialApi::class -) -@Composable -fun AllActivities( - navController: NavHostController, - viewModel: LocationViewModel, - email: String, - name: String, - pfp: String -) { - - val permissionState = rememberMultiplePermissionsState( - permissions = listOf( - Manifest.permission.ACCESS_FINE_LOCATION, - Manifest.permission.ACCESS_COARSE_LOCATION, - Manifest.permission.CAMERA, - ) - ) - val permissionDrawerState = rememberBottomDrawerState( - if (permissionState.allPermissionsGranted) BottomDrawerValue.Closed else BottomDrawerValue.Open - ) - var receiver by remember { mutableStateOf(allActivities[0]) } - var isDialogOpen by remember { mutableStateOf(false) } - var title by remember { mutableStateOf(TextFieldValue("")) } - var imageBitmap by remember { - mutableStateOf(null) - } - var bitmap by remember { - mutableStateOf(null) - } - val context = LocalContext.current - val coroutineScope = rememberCoroutineScope() - val launcher = rememberLauncherForActivityResult( - contract = ActivityResultContracts.TakePicturePreview(), - onResult = { - println("Bitmaps is ${it?.asImageBitmap()}") - imageBitmap = it?.asImageBitmap() - viewModel.getPlaces() - bitmap = it - - - } - ) - - - PermissionDrawer( - drawerState = permissionDrawerState, - permissionState = permissionState, - rationaleText = "To continue, allow Report Waste2Wealth to access your device's location" + - ". Tap Settings > Permission, and turn \"Access Location On\" on.", - withoutRationaleText = "Location permission required for functionality of this app." + - " Please grant the permission.", - ) { - Scaffold(bottomBar = { - BottomBar(navController = navController) - }) { - println(it) - Column( - modifier = Modifier - .fillMaxSize() - .background(appBackground) - ) { - Row( - modifier = Modifier - .fillMaxWidth() - .padding( - top = 35.dp, - bottom = 15.dp, - start = 20.dp, - end = 20.dp - ), - horizontalArrangement = Arrangement.SpaceBetween, - verticalAlignment = Alignment.CenterVertically - ) { - Text( - text = "Activity", - color = textColor, - fontSize = 35.sp, - fontFamily = monteBold, - ) - ProfileImage( - imageUrl = pfp, - modifier = Modifier - .size(60.dp) - .border( - width = 1.dp, - color = appBackground, - shape = CircleShape - ) - .padding(3.dp) - .clip(CircleShape) - .clickable { - navController.navigate(Screens.Profile.route) - }, - ) - } - - Row( - modifier = Modifier - .fillMaxWidth() - .padding(start = 20.dp, end = 25.dp, bottom = 20.dp, top = 7.dp), - horizontalArrangement = Arrangement.Center, - verticalAlignment = Alignment.CenterVertically - ) { - Text( - text = "Select your Social Activity", - color = textColor, - fontSize = 16.sp, - fontFamily = monteNormal, - ) - - } - - Row( - modifier = Modifier - .fillMaxWidth() - .padding( - top = 0.dp, - bottom = 35.dp, - start = 20.dp, - end = 20.dp - ), - horizontalArrangement = Arrangement.SpaceBetween, - verticalAlignment = Alignment.CenterVertically - ) { - Button( - onClick = { - isDialogOpen = true - title = TextFieldValue(receiver.title) - }, - colors = ButtonDefaults.buttonColors( - backgroundColor = Color(0xFFFD5065), - contentColor = Color.White - ), - shape = RoundedCornerShape(35.dp), - modifier = Modifier.padding(start = 10.dp) - ) { - Text( - text = "Start Recording", - color = Color.White, - fontSize = 12.sp, - fontFamily = monteSB, - modifier = Modifier.padding(bottom = 4.dp), - maxLines = 1, - softWrap = true - ) - } - Button( - onClick = { - navController.navigate(Screens.MyRecordings.route) - }, - colors = ButtonDefaults.buttonColors( - backgroundColor = Color(0xFFFD5065), - contentColor = Color.White - ), - shape = RoundedCornerShape(35.dp), - modifier = Modifier.padding(start = 10.dp) - ) { - Text( - text = "My Recordings", - color = Color.White, - fontSize = 12.sp, - fontFamily = monteSB, - modifier = Modifier.padding(bottom = 4.dp), - maxLines = 1, - softWrap = true - ) - } - } - - LazyVerticalGrid( - columns = GridCells.Fixed(2), - modifier = Modifier.padding( - bottom = 50.dp, - start = 15.dp, - top = 0.dp, - end = 15.dp - ), - contentPadding = PaddingValues(bottom = 25.dp) - ) { - items(allActivities) { item -> - RepeatingActivity( - type = item.type, - emoji = item.emoji, - title = item.title, - time = item.time, - value = item, - receiver = receiver, - onRadioClick = { - receiver = item - }, - onStartRecord = { - isDialogOpen = true - title = TextFieldValue(item.title) - } - ) - } - - } - if (isDialogOpen) { - CompleteDialog( - textField1 = { - TextFieldWithIcons( - textValue = "Enter Title of your Activity", - placeholder = "Enter Title of your Activity", - icon = Icons.Filled.Title, - mutableText = title, - keyboardType = KeyboardType.Text, - imeAction = ImeAction.Next, - onValueChanged = { - title = it - } - ) - - }, - uploadImage = { - Card( - backgroundColor = appBackground, - shape = RoundedCornerShape(7.dp), - elevation = 5.dp, - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 7.dp, vertical = 10.dp) - - .clickable { - if (imageBitmap == null) { - coroutineScope.launch { - if (!permissionState.allPermissionsGranted) { - permissionDrawerState.open() - } else { - launcher.launch( - ActivityOptionsCompat.makeBasic() - ) - } - } - } - } - ) { - if (imageBitmap == null) { - Column( - modifier = Modifier.fillMaxWidth(), - verticalArrangement = Arrangement.Center, - horizontalAlignment = Alignment.CenterHorizontally - ) { - Icon( - imageVector = Icons.Filled.UploadFile, - contentDescription = "", - tint = textColor, - modifier = Modifier.size(60.dp) - ) - Text( - text = "Upload Proof of Attempt", - color = textColor, - fontSize = 16.sp - ) - } - } else { - Image( - bitmap = imageBitmap!!, - contentDescription = "", - modifier = Modifier - .fillMaxWidth() - .size(100.dp), - contentScale = ContentScale.Fit - ) - - } - - } - - }, - successRequest = { - Toast.makeText(context, "Please Wait", Toast.LENGTH_SHORT).show() - if (bitmap != null) { - val storageRef = FirebaseStorage.getInstance().reference - val allowedChars = ('A'..'Z') + ('a'..'z') + ('0'..'9') - var imageName = (1..10) - .map { allowedChars.random() } - .joinToString("") - imageName = "TemporaryActivity/${email}/${imageName}.jpg" - - val imageRef = - storageRef.child(imageName) // Set desired storage location - - val baos = ByteArrayOutputStream() - bitmap?.compress(Bitmap.CompressFormat.JPEG, 100, baos) - val imageData = baos.toByteArray() - - val uploadTask = imageRef.putBytes(imageData) - uploadTask.addOnSuccessListener { taskSnapshot -> - }.addOnFailureListener { exception -> - println("Firebase storage exception $exception") - }.addOnCompleteListener { task -> - if (task.isSuccessful) { - imageRef.downloadUrl.addOnSuccessListener { - println("Download url is $it") - updateTemporaryActivityToFirebase( - title = title.text, - context = context, - startTime = System.currentTimeMillis(), - endTime = 0L, - email = email ?: "", - beforeTaskPath = imageName - ) - - } - } - - } - - } - isDialogOpen = false - - }, dismissRequest = { - isDialogOpen = false - } - ) - } - - } - } - } -} - - -@Composable -fun RepeatingActivity( - type: String, - emoji: String, - title: String, - time: String, - value: Activities, - receiver: Activities, - onRadioClick: () -> Unit, - onStartRecord: () -> Unit = {} -) { - Card( - backgroundColor = Color(0xFFD5E1DA), - shape = RoundedCornerShape( - topStart = 10.dp, - topEnd = 10.dp, - bottomEnd = 10.dp, - bottomStart = 50.dp - ), - modifier = Modifier.padding(end = 10.dp, bottom = 20.dp) - ) { - Column(modifier = Modifier.padding(15.dp)) { - Row( - modifier = Modifier.fillMaxWidth(), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.SpaceBetween - ) { - RadioButton( - selected = (value == receiver), - onClick = { - onRadioClick() - }, - colors = RadioButtonDefaults.colors( - selectedColor = Color(0xFFFD5065), - unselectedColor = Color.Gray - ), - ) - AndroidView( - factory = { context -> - AppCompatTextView(context).apply { - setTextColor(Color.Black.toArgb()) - text = emoji - textSize = 35.0F - textAlignment = View.TEXT_ALIGNMENT_CENTER - alpha = 1f - } - }, - update = { update -> - update.apply { - text = emoji - } - }, - modifier = Modifier.padding(start = 0.dp) - ) - } - Text( - text = time, - color = Color.Black, - fontSize = 16.sp, - fontFamily = monteNormal, - modifier = Modifier.padding(bottom = 10.dp) - ) - - Button( - onClick = { onStartRecord() }, - colors = ButtonDefaults.buttonColors( - backgroundColor = Color(0xFFFD5065), - contentColor = Color.White - ), - shape = RoundedCornerShape(35.dp), - modifier = Modifier.padding(start = 10.dp) - ) { - Text( - text = "Start Now", - color = Color.White, - fontSize = 12.sp, - fontFamily = monteSB, - modifier = Modifier.padding(bottom = 4.dp), - maxLines = 1, - softWrap = true - ) - } - - } - - } -} - -@Composable -fun CompleteDialog( - textField1: @Composable () -> Unit, - uploadImage: @Composable () -> Unit = {}, - successRequest: () -> Unit, - dismissRequest: () -> Unit -) { - Dialog(onDismissRequest = dismissRequest) { - Card( - shape = RoundedCornerShape(10.dp), - modifier = Modifier - .padding(10.dp, 5.dp, 10.dp, 10.dp) - .height(600.dp), - elevation = 8.dp - ) { - Column( - modifier = Modifier - .background(appBackground) - .fillMaxWidth() - ) { - textField1() - Spacer(modifier = Modifier.height(10.dp)) - uploadImage() - Spacer(modifier = Modifier.height(10.dp)) - Row( - modifier = Modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.Center - ) { - Button( - onClick = { successRequest() }, - colors = ButtonDefaults.buttonColors( - backgroundColor = Color(0xFFFD5065), - contentColor = Color.White - ), - shape = RoundedCornerShape(35.dp), - modifier = Modifier.padding(start = 10.dp) - ) { - Text( - text = "Start Recording", - color = Color.White, - fontSize = 12.sp, - fontFamily = monteSB, - modifier = Modifier.padding(bottom = 4.dp), - maxLines = 1, - softWrap = true - ) - } - - } - - - } - - - } - } -} - diff --git a/app/src/main/java/app/waste2wealth/com/activity/MyRecording.kt b/app/src/main/java/app/waste2wealth/com/activity/MyRecording.kt deleted file mode 100644 index 8e2dafe..0000000 --- a/app/src/main/java/app/waste2wealth/com/activity/MyRecording.kt +++ /dev/null @@ -1,253 +0,0 @@ -package app.waste2wealth.com.activity - -import android.Manifest -import androidx.compose.foundation.background -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.PaddingValues -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.offset -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.foundation.lazy.itemsIndexed -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.BottomDrawerValue -import androidx.compose.material.Button -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.Card -import androidx.compose.material.ExperimentalMaterialApi -import androidx.compose.material.Icon -import androidx.compose.material.Scaffold -import androidx.compose.material.Text -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.ArrowBackIos -import androidx.compose.material.rememberBottomDrawerState -import androidx.compose.runtime.Composable -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.derivedStateOf -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue -import androidx.compose.ui.Alignment -import androidx.compose.ui.ExperimentalComposeUiApi -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.text.style.TextOverflow -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import androidx.navigation.NavHostController -import app.waste2wealth.com.R -import app.waste2wealth.com.bottombar.BottomBar -import app.waste2wealth.com.collectwaste.getTimeAgo -import app.waste2wealth.com.components.permissions.PermissionDrawer -import app.waste2wealth.com.firebase.firestore.TemporaryActivityItem -import app.waste2wealth.com.location.LocationViewModel -import app.waste2wealth.com.navigation.Screens -import app.waste2wealth.com.ui.theme.appBackground -import app.waste2wealth.com.ui.theme.monteSB -import app.waste2wealth.com.ui.theme.textColor -import com.google.accompanist.permissions.ExperimentalPermissionsApi -import com.google.accompanist.permissions.rememberMultiplePermissionsState -import com.google.firebase.auth.ktx.auth -import com.google.firebase.ktx.Firebase -import com.jet.firestore.JetFirestore -import com.jet.firestore.getListOfObjects - -@OptIn( - ExperimentalPermissionsApi::class, ExperimentalComposeUiApi::class, - ExperimentalMaterialApi::class -) -@Composable -fun MyRecordings(navController: NavHostController, viewModel: LocationViewModel) { - - var user by remember { mutableStateOf(Firebase.auth.currentUser) } - val permissionState = rememberMultiplePermissionsState( - permissions = listOf( - Manifest.permission.ACCESS_FINE_LOCATION, - Manifest.permission.ACCESS_COARSE_LOCATION, - ) - ) - val permissionDrawerState = rememberBottomDrawerState(BottomDrawerValue.Closed) - val gesturesEnabled by remember { derivedStateOf { permissionDrawerState.isOpen } } - var allRecordings by remember { mutableStateOf?>(null) } - var myRecordings by remember { mutableStateOf?>(null) } - LaunchedEffect(key1 = Unit) { - viewModel.getPlaces() - } - PermissionDrawer( - drawerState = permissionDrawerState, - permissionState = permissionState, - rationaleText = "To continue, allow Waste2Wealth to access your device's camera" + - ". Tap Settings > Permission, and turn \"Access Camera On\" on.", - withoutRationaleText = "Camera permission required for this feature to be available." + - " Please grant the permission.", - model = R.drawable.location, - gesturesEnabled = gesturesEnabled, - size = 100.dp - ) { - Scaffold(bottomBar = { - BottomBar(navController = navController) - }) { - JetFirestore(path = { - collection("TemporaryActivities") - }, onRealtimeCollectionFetch = { values, _ -> - allRecordings = values?.getListOfObjects() - - - }) { - - println(it) - Column( - modifier = Modifier - .fillMaxSize() - .background(appBackground) - ) { - Row( - modifier = Modifier - .fillMaxWidth() - .padding(top = 30.dp, start = 0.dp), - horizontalArrangement = Arrangement.Start - ) { - Icon( - imageVector = Icons.Filled.ArrowBackIos, - contentDescription = "", - tint = textColor, - modifier = Modifier - .padding(start = 15.dp) - .size(25.dp) - ) - Row( - modifier = Modifier - .fillMaxWidth() - .offset(x = (-10).dp), - horizontalArrangement = Arrangement.Center - ) { - Text( - text = "My Recordings", - color = textColor, - fontFamily = monteSB, - fontSize = 25.sp - ) - } - } - - Spacer(modifier = Modifier.height(30.dp)) - if (allRecordings != null) { - LazyColumn( - contentPadding = PaddingValues( - bottom = 150.dp, - top = 40.dp - ) - ) { - itemsIndexed(allRecordings ?: emptyList()) { _, wasteItem -> - if (wasteItem.email == user?.email) { - MyRecordingCard( - title = wasteItem.title, - time = getTimeAgo(wasteItem.startTime), - onClick = { - viewModel.beforeActivityPath.value = - wasteItem.beforeTaskPath - viewModel.activityTitle.value = wasteItem.title - viewModel.startActivityTime.value = wasteItem.startTime - navController.navigate(Screens.StopRecording.route) - } - ) - } - } - } - } - - } - - - } - } - } -} - - -@Composable -fun MyRecordingCard( - title: String, - time: String, - onClick: () -> Unit = {} -) { - Card( - modifier = Modifier - .fillMaxWidth() - .padding(13.dp) - .clickable { - onClick() - }, - shape = RoundedCornerShape(10.dp), - backgroundColor = Color(0xFFD5E1DA), - elevation = 5.dp - ) { - Column(modifier = Modifier.fillMaxWidth()) { - Row( - modifier = Modifier - .fillMaxWidth() - .padding(start = 10.dp, bottom = 7.dp, end = 15.dp) - ) { - Text( - text = title, - color = Color.Black, - fontFamily = monteSB, - fontSize = 15.sp, - maxLines = 1, - softWrap = true, - overflow = TextOverflow.Ellipsis - ) - } - Row( - modifier = Modifier - .fillMaxWidth() - .padding(start = 10.dp, bottom = 7.dp, end = 15.dp) - ) { - Text( - text = time, - color = Color.Black, - fontFamily = monteSB, - fontSize = 15.sp, - maxLines = 1, - softWrap = true, - overflow = TextOverflow.Ellipsis - ) - } - Row( - modifier = Modifier.fillMaxWidth(), - verticalAlignment = Alignment.Bottom - ) { - Button( - onClick = { - onClick() - }, - colors = ButtonDefaults.buttonColors( - backgroundColor = Color(0xFFFD5065), - contentColor = Color.White - ), - shape = RoundedCornerShape(15.dp), - modifier = Modifier.padding(start = 10.dp) - ) { - Text( - text = "Stop Recording", - color = Color.White, - fontFamily = monteSB, - fontSize = 10.sp - ) - } - - } - } - - - } - -} \ No newline at end of file diff --git a/app/src/main/java/app/waste2wealth/com/activity/StopRecording.kt b/app/src/main/java/app/waste2wealth/com/activity/StopRecording.kt deleted file mode 100644 index f19dc50..0000000 --- a/app/src/main/java/app/waste2wealth/com/activity/StopRecording.kt +++ /dev/null @@ -1,642 +0,0 @@ -package app.waste2wealth.com.activity - -import android.Manifest -import android.graphics.Bitmap -import android.widget.Toast -import androidx.activity.compose.rememberLauncherForActivityResult -import androidx.activity.result.contract.ActivityResultContracts -import androidx.activity.result.launch -import androidx.compose.foundation.Image -import androidx.compose.foundation.background -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.offset -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.BottomDrawerValue -import androidx.compose.material.Button -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.Card -import androidx.compose.material.DropdownMenuItem -import androidx.compose.material.ExperimentalMaterialApi -import androidx.compose.material.ExposedDropdownMenuBox -import androidx.compose.material.Icon -import androidx.compose.material.Scaffold -import androidx.compose.material.Text -import androidx.compose.material.TextField -import androidx.compose.material.TextFieldDefaults -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.ArrowBackIos -import androidx.compose.material.icons.filled.UploadFile -import androidx.compose.material.rememberBottomDrawerState -import androidx.compose.runtime.Composable -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.derivedStateOf -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.ExperimentalComposeUiApi -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.ImageBitmap -import androidx.compose.ui.graphics.asImageBitmap -import androidx.compose.ui.layout.ContentScale -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import androidx.core.app.ActivityOptionsCompat -import androidx.navigation.NavHostController -import app.waste2wealth.com.R -import app.waste2wealth.com.bottombar.BottomBar -import app.waste2wealth.com.collectwaste.getDownloadUrlFromPath -import app.waste2wealth.com.components.permissions.PermissionDrawer -import app.waste2wealth.com.firebase.firestore.ProfileInfo -import app.waste2wealth.com.firebase.firestore.calculateActivityPointsEarned -import app.waste2wealth.com.firebase.firestore.updateActivityToFirebase -import app.waste2wealth.com.firebase.firestore.updateInfoToFirebase -import app.waste2wealth.com.location.LocationViewModel -import app.waste2wealth.com.navigation.Screens -import app.waste2wealth.com.reportwaste.DialogBox -import app.waste2wealth.com.ui.theme.appBackground -import app.waste2wealth.com.ui.theme.monteBold -import app.waste2wealth.com.ui.theme.monteNormal -import app.waste2wealth.com.ui.theme.monteSB -import app.waste2wealth.com.ui.theme.textColor -import coil.compose.AsyncImage -import com.airbnb.lottie.compose.LottieAnimation -import com.airbnb.lottie.compose.LottieCompositionSpec -import com.airbnb.lottie.compose.rememberLottieComposition -import com.google.accompanist.permissions.ExperimentalPermissionsApi -import com.google.accompanist.permissions.rememberMultiplePermissionsState -import com.google.firebase.storage.FirebaseStorage -import com.jet.firestore.JetFirestore -import com.jet.firestore.getListOfObjects -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.delay -import kotlinx.coroutines.launch -import kotlinx.coroutines.withContext -import java.io.ByteArrayOutputStream -import java.util.concurrent.TimeUnit - -@OptIn( - ExperimentalPermissionsApi::class, ExperimentalComposeUiApi::class, - ExperimentalMaterialApi::class -) -@Composable -fun StopRecording( - navController: NavHostController, - viewModel: LocationViewModel, - email: String, - name: String -) { - - val permissionState = rememberMultiplePermissionsState( - permissions = listOf( - Manifest.permission.ACCESS_FINE_LOCATION, - Manifest.permission.ACCESS_COARSE_LOCATION, - Manifest.permission.CAMERA - ) - ) - val permissionDrawerState = rememberBottomDrawerState(BottomDrawerValue.Closed) - val gesturesEnabled by remember { derivedStateOf { permissionDrawerState.isOpen } } - var imageBitmap by remember { - mutableStateOf(null) - } - val coroutineScope = rememberCoroutineScope() - var bitmap by remember { - mutableStateOf(null) - } - val context = LocalContext.current - var isDialogVisible by remember { mutableStateOf(false) } - val launcher = rememberLauncherForActivityResult( - contract = ActivityResultContracts.TakePicturePreview(), - onResult = { - println("Bitmaps is ${it?.asImageBitmap()}") - imageBitmap = it?.asImageBitmap() - viewModel.getPlaces() - bitmap = it - - - } - ) - var isExpanded by remember { - mutableStateOf(false) - } - var address by remember { - mutableStateOf("") - } - var isCOinVisible by remember { - mutableStateOf(false) - } - var profileList by remember { - mutableStateOf?>(null) - } - var userAddress by remember { - mutableStateOf("") - } - var phoneNumber by remember { - mutableStateOf("") - } - var gender by remember { - mutableStateOf("") - } - var organization by remember { - mutableStateOf("") - } - var pointsEarned by remember { - mutableStateOf(0) - } - var pointsRedeemed by remember { - mutableStateOf(0) - } - var noOfTimesReported by remember { - mutableStateOf(0) - } - var noOfTimesCollected by remember { - mutableStateOf(0) - } - var noOfTimesActivity by remember { - mutableStateOf(0) - } - - LaunchedEffect(key1 = Unit) { - viewModel.getPlaces() - } - - JetFirestore(path = { - collection("ProfileInfo") - }, onRealtimeCollectionFetch = { value, _ -> - profileList = value?.getListOfObjects() - }) { - if (profileList != null) { - for (i in profileList!!) { - if (i.email == email) { - userAddress = i.address ?: "" - gender = i.gender ?: "" - phoneNumber = i.phoneNumber ?: "" - organization = i.organization ?: "" - pointsEarned = i.pointsEarned - pointsRedeemed = i.pointsRedeemed - noOfTimesReported = i.noOfTimesReported - noOfTimesCollected = i.noOfTimesCollected - noOfTimesActivity = i.noOfTimesActivity - } - } - } - - PermissionDrawer( - drawerState = permissionDrawerState, - permissionState = permissionState, - rationaleText = "To continue, allow Waste2Wealth to access your device's camera" + - ". Tap Settings > Permission, and turn \"Access Camera On\" on.", - withoutRationaleText = "Camera permission required for this feature to be available." + - " Please grant the permission.", - model = R.drawable.location, - gesturesEnabled = gesturesEnabled, - size = 100.dp - ) { - Scaffold(bottomBar = { - BottomBar(navController = navController) - }) { - println(it) - Box(modifier = Modifier.fillMaxSize()) { - Box(modifier = Modifier.fillMaxSize()) { - Column( - modifier = Modifier - .fillMaxSize() - .background(appBackground) - ) { - Row( - modifier = Modifier - .fillMaxWidth() - .padding(top = 30.dp, start = 0.dp), - horizontalArrangement = Arrangement.Start - ) { - Icon( - imageVector = Icons.Filled.ArrowBackIos, - contentDescription = "", - tint = textColor, - modifier = Modifier - .padding(start = 15.dp) - .size(25.dp) - ) - Row( - modifier = Modifier - .fillMaxWidth() - .offset(x = (-10).dp), - horizontalArrangement = Arrangement.Center - ) { - Text( - text = "My Recordings", - color = textColor, - fontFamily = monteSB, - fontSize = 25.sp - ) - } - } - - Spacer(modifier = Modifier.height(30.dp)) - - Row( - modifier = Modifier - .fillMaxWidth() - .padding(15.dp), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.SpaceBetween - ) { - Text( - text = "Before Activity", - fontFamily = monteBold, - fontSize = 10.sp, - color = textColor, - modifier = Modifier - .padding(start = 10.dp, bottom = 10.dp) - ) - Text( - text = "After Activity", - fontFamily = monteBold, - fontSize = 10.sp, - color = textColor, - modifier = Modifier - .padding(start = 10.dp, bottom = 10.dp) - ) - } - - Row( - modifier = Modifier - .fillMaxWidth() - .padding(15.dp), - verticalAlignment = Alignment.CenterVertically - ) { - Card( - backgroundColor = appBackground, - shape = RoundedCornerShape(7.dp), - elevation = 5.dp, - modifier = Modifier - .padding(horizontal = 7.dp, vertical = 10.dp) - ) { - - - var imageUrlState by remember { - mutableStateOf("") - } - LaunchedEffect(key1 = Unit) { - val imageUrl = withContext(Dispatchers.IO) { - try { - getDownloadUrlFromPath(viewModel.beforeActivityPath.value) - } catch (e: Exception) { - "" - } - } - imageUrlState = imageUrl - } - if (imageUrlState != "") { - AsyncImage( - model = imageUrlState, - contentDescription = "", - modifier = Modifier - .height(200.dp) - .padding(bottom = 30.dp) - .clip(RoundedCornerShape(30.dp)), - ) - } - } - - Card( - backgroundColor = appBackground, - shape = RoundedCornerShape(7.dp), - elevation = 5.dp, - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 7.dp, vertical = 10.dp) - - .clickable { - if (imageBitmap == null) { - coroutineScope.launch { - if (!permissionState.allPermissionsGranted) { - permissionDrawerState.open() - } else { - launcher.launch( - ActivityOptionsCompat.makeBasic() - ) - } - } - } - } - ) { - - if (imageBitmap == null) { - Column( - modifier = Modifier.fillMaxWidth(), - verticalArrangement = Arrangement.Center, - horizontalAlignment = Alignment.CenterHorizontally - ) { - Icon( - imageVector = Icons.Filled.UploadFile, - contentDescription = "", - tint = textColor, - modifier = Modifier.size(60.dp) - ) - Text( - text = "Upload Proof of Attempt", - color = textColor, - fontSize = 16.sp - ) - } - } else { - Image( - bitmap = imageBitmap!!, - contentDescription = "", - modifier = Modifier - .fillMaxWidth() - .height(200.dp), - contentScale = ContentScale.Fit - ) - - } - - } - } - - Row( - modifier = Modifier - .fillMaxWidth() - .padding(start = 10.dp, top = 30.dp) - .clickable { - } - ) { - Text( - text = "Choose Your Location", - color = textColor, - fontSize = 15.sp - ) - } - Row( - modifier = Modifier - .fillMaxWidth() - .padding(start = 10.dp, top = 30.dp) - ) { - ExposedDropdownMenuBox( - expanded = isExpanded, - onExpandedChange = { - isExpanded = it - } - ) { - TextField( - value = address, - onValueChange = { - address = it - }, - colors = TextFieldDefaults.textFieldColors( - textColor = textColor - ), - modifier = Modifier - .fillMaxWidth() - .padding(15.dp), - - ) - ExposedDropdownMenu( - expanded = isExpanded, - onDismissRequest = { - isExpanded = false - }) { - viewModel.listOfAddresses.forEach { - if (it != null) { - DropdownMenuItem(onClick = { - address = it - isExpanded = false - }) { - Text(text = it) - } - } - } - - - } - - } - } - - Row( - modifier = Modifier - .fillMaxWidth() - .padding(top = 15.dp), - horizontalArrangement = Arrangement.Start, - verticalAlignment = Alignment.CenterVertically - ) { - Text( - text = "Points you can Earn", - color = textColor, - fontSize = 16.sp, - fontFamily = monteBold, - modifier = Modifier.padding(start = 45.dp, end = 60.dp) - ) - Row(modifier = Modifier.padding(end = 25.dp)) { - Icon( - painter = painterResource(id = R.drawable.coins), - contentDescription = "coins", - modifier = Modifier - .size(20.dp) - .padding(end = 5.dp), - tint = Color.Unspecified - ) - Text( - text = "8999999", - color = textColor, - fontSize = 15.sp, - fontFamily = monteNormal, - ) - } - - } - Spacer(modifier = Modifier.height(15.dp)) - Row( - modifier = Modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.Center - ) { - Button( - onClick = { - isDialogVisible = true - }, colors = ButtonDefaults.buttonColors( - backgroundColor = Color(0xFFFD5065), - contentColor = Color.White - ), - shape = RoundedCornerShape(35.dp), - modifier = Modifier.padding(start = 0.dp) - ) { - Text( - text = "Report Waste", - color = textColor, - fontFamily = monteNormal, - fontSize = 15.sp - ) - - } - } - - - } - - } - } - DialogBox( - title = "Stop Activity", - description = "Are you sure you want to stop this activity?", - isVisible = isDialogVisible, - successRequest = { - Toast.makeText(context, "Please Wait", Toast.LENGTH_SHORT).show() - if (bitmap != null) { - val storageRef = FirebaseStorage.getInstance().reference - val allowedChars = ('A'..'Z') + ('a'..'z') + ('0'..'9') - var imageName = (1..10) - .map { allowedChars.random() } - .joinToString("") - imageName = "Activities/${email}/${imageName}.jpg" - - val imageRef = - storageRef.child(imageName) // Set desired storage location - - val baos = ByteArrayOutputStream() - bitmap?.compress(Bitmap.CompressFormat.JPEG, 100, baos) - val imageData = baos.toByteArray() - - val uploadTask = imageRef.putBytes(imageData) - uploadTask.addOnSuccessListener { taskSnapshot -> - }.addOnFailureListener { exception -> - println("Firebase storage exception $exception") - }.addOnCompleteListener { task -> - if (task.isSuccessful) { - imageRef.downloadUrl.addOnSuccessListener { - println("Download url is $it") - updateActivityToFirebase( - context = context, - startTime = viewModel.startActivityTime.value, - endTime = System.currentTimeMillis(), - beforeTaskPath = viewModel.beforeActivityPath.value, - endTaskPath = imageName, - title = viewModel.activityTitle.value, - email = email ?: "", - duration = calculateDuration( - viewModel.startActivityTime.value, - System.currentTimeMillis() - ) - ) - updateInfoToFirebase( - context, - name = name, - email = email, - phoneNumber = phoneNumber, - gender = gender, - organization = organization, - address = userAddress, - pointsEarned = pointsEarned + calculateActivityPointsEarned( - noOfTimesReported, - noOfTimesCollected, - noOfTimesActivity, - calculateDurationPoints( - viewModel.startActivityTime.value, - System.currentTimeMillis() - ).toInt() - ), - pointsRedeemed = pointsRedeemed, - noOfTimesReported = noOfTimesReported, - noOfTimesCollected = noOfTimesCollected + 1, - noOfTimesActivity = noOfTimesActivity, - ) - isCOinVisible = true - - } - } - - } - - } - - isDialogVisible = false - }) { - isDialogVisible = !isDialogVisible - } - } - } - if (isCOinVisible) { - Box( - modifier = Modifier.fillMaxSize(), - contentAlignment = Alignment.BottomCenter - ) { - val currenanim by rememberLottieComposition( - spec = LottieCompositionSpec.Asset("coins.json") - ) - LottieAnimation( - composition = currenanim, - iterations = 1, - contentScale = ContentScale.Crop, - speed = 1f, - modifier = Modifier - .fillMaxSize() - .size(250.dp) - ) - } - LaunchedEffect(key1 = isCOinVisible) { - if (isCOinVisible) { - delay(4000) - navController.navigate(Screens.Dashboard.route) - } - } - - } - } - - -} - -fun calculateDuration(startTime: Long, endTime: Long): String { - val durationInMillis = endTime - startTime - - val minutes = TimeUnit.MILLISECONDS.toMinutes(durationInMillis) - val hours = TimeUnit.MILLISECONDS.toHours(durationInMillis) - val days = TimeUnit.MILLISECONDS.toDays(durationInMillis) - val months = TimeUnit.MILLISECONDS.toDays(durationInMillis) / 30 - val years = TimeUnit.MILLISECONDS.toDays(durationInMillis) / 365 - - return when { - years >= 1 -> "$years years" - months >= 1 -> "$months months" - days >= 1 -> "$days days" - hours >= 1 -> "$hours hours" - else -> "$minutes minutes" - } -} - -fun calculateDurationPoints(startTime: Long, endTime: Long): Long { - val durationInMillis = endTime - startTime - - val minutes = TimeUnit.MILLISECONDS.toMinutes(durationInMillis) - val hours = TimeUnit.MILLISECONDS.toHours(durationInMillis) - val days = TimeUnit.MILLISECONDS.toDays(durationInMillis) - val months = TimeUnit.MILLISECONDS.toDays(durationInMillis) / 30 - val years = TimeUnit.MILLISECONDS.toDays(durationInMillis) / 365 - - return when { - years >= 1 -> years - months >= 1 -> months - days >= 1 -> days - hours >= 1 -> hours - else -> minutes - } -} - - - diff --git a/app/src/main/java/app/waste2wealth/com/bottombar/BottomBarScreens.kt b/app/src/main/java/app/waste2wealth/com/bottombar/BottomBarScreens.kt index d35b33b..ed45185 100644 --- a/app/src/main/java/app/waste2wealth/com/bottombar/BottomBarScreens.kt +++ b/app/src/main/java/app/waste2wealth/com/bottombar/BottomBarScreens.kt @@ -5,9 +5,6 @@ import app.waste2wealth.com.navigation.Screens sealed class BottomBarScreens(val route: String?, val title: String?, val icon: Int?) { object HomeScreen : BottomBarScreens(Screens.Dashboard.route, "Home", R.drawable.homei) - object RewardsScreen : BottomBarScreens(Screens.Rewards.route, "Rewards", R.drawable.rewardsi) - object RecordScreen : - BottomBarScreens(Screens.AllActivities.route, "Activity", R.drawable.recordsi) object CommunityScreen : BottomBarScreens(Screens.Community.route, "Community", R.drawable.commi) diff --git a/app/src/main/java/app/waste2wealth/com/components/AppVersion.kt b/app/src/main/java/app/waste2wealth/com/components/AppVersion.kt deleted file mode 100644 index 4d40a03..0000000 --- a/app/src/main/java/app/waste2wealth/com/components/AppVersion.kt +++ /dev/null @@ -1,22 +0,0 @@ -package app.waste2wealth.com.components - -import androidx.compose.foundation.layout.padding -import androidx.compose.material.Text -import androidx.compose.material.TextButton -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import com.google.android.datatransport.runtime.BuildConfig - -@Composable -fun AppVersion() { - TextButton(onClick = {}) { - Text(text = "App Version v${BuildConfig.VERSION_NAME}", - modifier = Modifier.padding(start = 10.dp), - color = Color(0xFFb4b4b4), - fontSize = 15.sp) - } - -} \ No newline at end of file diff --git a/app/src/main/java/app/waste2wealth/com/components/DrawerBody.kt b/app/src/main/java/app/waste2wealth/com/components/DrawerBody.kt deleted file mode 100644 index 18c2e46..0000000 --- a/app/src/main/java/app/waste2wealth/com/components/DrawerBody.kt +++ /dev/null @@ -1,55 +0,0 @@ -package app.waste2wealth.com.components - -import androidx.compose.foundation.background -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.* -import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.foundation.lazy.items -import androidx.compose.material.Icon -import androidx.compose.material.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.text.style.TextAlign -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import app.waste2wealth.com.navigation.Screens - -@Composable -fun DrawerBody( - items: List, - onItemClick: (MenuItem) -> Unit, - currentItem: String = Screens.Dashboard.route, -) { - LazyColumn(modifier = Modifier.padding(top = 10.dp)) { - items(items) { item -> - Row(modifier = Modifier - .fillMaxWidth() - .background(if (currentItem == item.id) Color(0xFFdcf6f5) else Color.White) - .clickable { - onItemClick(item) - } - .padding(16.dp), verticalAlignment = Alignment.CenterVertically) { - Icon( - item.icon, - contentDescription = item.contentDesc, - tint = if (currentItem == item.id) Color(0xFF48c5a3) - else Color.Black, - modifier = Modifier.size(28.dp) - ) - Spacer(modifier = Modifier.width(16.dp)) - Text( - text = item.title, - color = if (currentItem == item.id) Color(0xFF48c5a3) - else Color.Black, - modifier = Modifier, - fontSize = 16.sp, - fontWeight = if (currentItem == item.id) FontWeight.Bold else FontWeight.Normal, - textAlign = TextAlign.Justify - ) - } - } - } -} \ No newline at end of file diff --git a/app/src/main/java/app/waste2wealth/com/components/DrawerHeader.kt b/app/src/main/java/app/waste2wealth/com/components/DrawerHeader.kt deleted file mode 100644 index fb18c3e..0000000 --- a/app/src/main/java/app/waste2wealth/com/components/DrawerHeader.kt +++ /dev/null @@ -1,39 +0,0 @@ -package app.waste2wealth.com.components - -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.padding -import androidx.compose.material.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp - -@Composable -fun DrawerHeader() { - Box( - modifier = Modifier.fillMaxWidth(), - ) { - Column(horizontalAlignment = Alignment.Start) { - Text( - text = "Krishna Patil", - fontSize = 30.sp, - fontWeight = FontWeight.Bold, - color = Color.Black, - modifier = Modifier.padding(start = 15.dp, top = 50.dp, bottom = 5.dp) - ) - Text( - text = "Organization: Robin Hood", - fontSize = 18.sp, - fontWeight = FontWeight.Bold, - color = Color.Gray, - modifier = Modifier.padding(start = 15.dp, top = 5.dp, bottom = 10.dp) - ) - - } - } -} \ No newline at end of file diff --git a/app/src/main/java/app/waste2wealth/com/components/Logout.kt b/app/src/main/java/app/waste2wealth/com/components/Logout.kt deleted file mode 100644 index 5094cc1..0000000 --- a/app/src/main/java/app/waste2wealth/com/components/Logout.kt +++ /dev/null @@ -1,29 +0,0 @@ -package app.waste2wealth.com.components - -import androidx.compose.foundation.layout.padding -import androidx.compose.material.Text -import androidx.compose.material.TextButton -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import androidx.navigation.NavHostController -import app.waste2wealth.com.navigation.Screens -import app.waste2wealth.com.ui.theme.monteNormal - -@Composable -fun LogOut(navHostController: NavHostController) { - TextButton(onClick = { - navHostController.popBackStack() - navHostController.navigate(Screens.LoginScreen.route) - }) { - Text( - text = "Logout", - modifier = Modifier.padding(start = 10.dp, top = 10.dp), - color = Color.Gray, - fontSize = 15.sp, - fontFamily = monteNormal - ) - } -} \ No newline at end of file diff --git a/app/src/main/java/app/waste2wealth/com/components/MenuItem.kt b/app/src/main/java/app/waste2wealth/com/components/MenuItem.kt deleted file mode 100644 index 2ac1ca2..0000000 --- a/app/src/main/java/app/waste2wealth/com/components/MenuItem.kt +++ /dev/null @@ -1,10 +0,0 @@ -package app.waste2wealth.com.components - -import androidx.compose.ui.graphics.vector.ImageVector - -data class MenuItem( - val id: String, - val title: String, - val icon: ImageVector, - val contentDesc: String, -) \ No newline at end of file diff --git a/app/src/main/java/app/waste2wealth/com/components/PrivacyPolicy.kt b/app/src/main/java/app/waste2wealth/com/components/PrivacyPolicy.kt deleted file mode 100644 index b014c0e..0000000 --- a/app/src/main/java/app/waste2wealth/com/components/PrivacyPolicy.kt +++ /dev/null @@ -1,26 +0,0 @@ -package app.waste2wealth.com.components - -import androidx.compose.foundation.layout.padding -import androidx.compose.material.Text -import androidx.compose.material.TextButton -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import app.waste2wealth.com.ui.theme.monteNormal - -@Composable -fun PrivacyPolicy() { - TextButton(onClick = { - - }) { - Text( - text = "Privacy Policy", - modifier = Modifier.padding(start = 10.dp), - color = Color.Gray, - fontSize = 15.sp, - fontFamily = monteNormal - ) - } -} \ No newline at end of file diff --git a/app/src/main/java/app/waste2wealth/com/components/TnC.kt b/app/src/main/java/app/waste2wealth/com/components/TnC.kt deleted file mode 100644 index 579273e..0000000 --- a/app/src/main/java/app/waste2wealth/com/components/TnC.kt +++ /dev/null @@ -1,26 +0,0 @@ -package app.waste2wealth.com.components - -import androidx.compose.foundation.layout.padding -import androidx.compose.material.Text -import androidx.compose.material.TextButton -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import app.waste2wealth.com.ui.theme.monteNormal - -@Composable -fun TnC() { - TextButton(onClick = { - }) { - Text( - text = "Terms & Conditions", - modifier = Modifier.padding(start = 10.dp), - color = Color.Gray, - fontSize = 15.sp, - fontFamily = monteNormal - ) - } -} - diff --git a/app/src/main/java/app/waste2wealth/com/dashboard/DashBoardPage.kt b/app/src/main/java/app/waste2wealth/com/dashboard/DashBoardPage.kt deleted file mode 100644 index 69b69ed..0000000 --- a/app/src/main/java/app/waste2wealth/com/dashboard/DashBoardPage.kt +++ /dev/null @@ -1,170 +0,0 @@ -package app.waste2wealth.com.dashboard - -import android.Manifest -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.* -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.Home -import androidx.compose.material.icons.filled.Person -import androidx.compose.material.icons.filled.QrCodeScanner -import androidx.compose.runtime.* -import androidx.compose.ui.Alignment -import androidx.compose.ui.ExperimentalComposeUiApi -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.text.style.TextAlign -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import androidx.navigation.NavHostController -import app.waste2wealth.com.components.* -import app.waste2wealth.com.components.permissions.PermissionDrawer -import app.waste2wealth.com.location.LocationViewModel -import app.waste2wealth.com.navigation.Screens -import app.waste2wealth.com.ui.theme.backGround -import app.waste2wealth.com.ui.theme.monteNormal -import com.google.accompanist.permissions.ExperimentalPermissionsApi -import com.google.accompanist.permissions.rememberMultiplePermissionsState -import com.google.accompanist.systemuicontroller.rememberSystemUiController -import kotlinx.coroutines.launch - -@OptIn(ExperimentalMaterialApi::class, ExperimentalPermissionsApi::class, - ExperimentalComposeUiApi::class) -@Composable -fun DashBoardPage( - navHostController: NavHostController, - locationViewModel: LocationViewModel, -) { - val scaffoldState = rememberScaffoldState() - val systemUiController = rememberSystemUiController() - systemUiController.setStatusBarColor(backGround) - systemUiController.setNavigationBarColor(Color.White) - val coroutineScope = rememberCoroutineScope() - var currentItem by remember { - mutableStateOf(Screens.Dashboard.route) - } - val context = LocalContext.current - Scaffold( - scaffoldState = scaffoldState, - topBar = { - AppBar(currentPage = "Dashboard", onNavDrawer = { - coroutineScope.launch { - scaffoldState.drawerState.open() - } - }) - }, - drawerGesturesEnabled = scaffoldState.drawerState.isOpen, - drawerContent = { - DrawerHeader() - DrawerBody(items = listOf( - MenuItem( - id = Screens.Dashboard.route, - title = "Dashboard", - icon = Icons.Filled.Home, - contentDesc = "Dashboard" - ), - MenuItem( - id = Screens.Profile.route, - title = "Profile", - icon = Icons.Filled.Person, - contentDesc = "Profile" - ), - MenuItem( - id = Screens.QrCodeScanner.route, - title = "Report Waste", - icon = Icons.Filled.QrCodeScanner, - contentDesc = "Qr Code Scanner" - ) - ), onItemClick = { - currentItem = it.id - when (it.id) { - Screens.Dashboard.route -> { - navHostController.navigate(Screens.Dashboard.route) - } - Screens.Profile.route -> { - navHostController.navigate(Screens.Profile.route) - } - Screens.QrCodeScanner.route -> { - navHostController.navigate(Screens.QrCodeScanner.route) - } - } - }, currentItem = Screens.Dashboard.route) - Divider(color = Color.Gray, modifier = Modifier.padding( - top = 7.dp, - start = 10.dp, - end = 10.dp - )) - LogOut(navHostController = navHostController) - TnC() - PrivacyPolicy() - AppVersion() - - - }, - drawerBackgroundColor = Color.White, - drawerScrimColor = Color.White, - drawerElevation = 15.dp, - drawerShape = RoundedCornerShape(15.dp) - ) { - val permissionState = rememberMultiplePermissionsState( - permissions = listOf( - Manifest.permission.ACCESS_FINE_LOCATION, - Manifest.permission.ACCESS_COARSE_LOCATION - ) - ) - val permissionDrawerState = rememberBottomDrawerState( - if (permissionState.allPermissionsGranted) BottomDrawerValue.Closed else BottomDrawerValue.Open - ) - PermissionDrawer( - drawerState = permissionDrawerState, - permissionState = permissionState, - rationaleText = "To continue, allow Report WasteRider to access your device's location" + - ". Tap Settings > Permission, and turn \"Access Location On\" on.", - withoutRationaleText = "Location permission required for functionality of this app." + - " Please grant the permission.", - ) { - println(it) - Column( - modifier = Modifier - .fillMaxSize() - .background(Color.White) - ) { - if (!permissionState.allPermissionsGranted) { - Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { - Button( - onClick = { - coroutineScope.launch { - permissionDrawerState.open() - } - }, colors = ButtonDefaults.buttonColors( - backgroundColor = Color.White - ) - ) { - Text( - text = "Location permission required for this feature to be available. Please grant the permission.", - textAlign = TextAlign.Center, - color = Color.Black, - fontFamily = monteNormal, - fontWeight = FontWeight.SemiBold, - fontSize = 16.sp, - modifier = Modifier.padding(15.dp) - ) - } - } - } else { - DashboardContent( - locationViewModel = locationViewModel, - navHostController = navHostController - ) - } - } - } - - } -} \ No newline at end of file diff --git a/app/src/main/java/app/waste2wealth/com/dashboard/DashboardContent.kt b/app/src/main/java/app/waste2wealth/com/dashboard/DashboardContent.kt deleted file mode 100644 index bddc942..0000000 --- a/app/src/main/java/app/waste2wealth/com/dashboard/DashboardContent.kt +++ /dev/null @@ -1,242 +0,0 @@ -package app.waste2wealth.com.dashboard - -import androidx.compose.foundation.layout.* -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.* -import androidx.compose.runtime.Composable -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.collectAsState -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import androidx.navigation.NavHostController -import app.waste2wealth.com.R -import app.waste2wealth.com.location.LocationViewModel -import app.waste2wealth.com.navigation.Screens -import app.waste2wealth.com.tasksList.customShadow -import app.waste2wealth.com.ui.theme.backGround -import app.waste2wealth.com.ui.theme.monteNormal -import app.waste2wealth.com.ui.theme.monteSB - -@Composable -fun DashboardContent( - connected: Boolean = true, - tripID: String = "611413", - hub: String = "5 times", - tasks: String = "19", - navHostController: NavHostController, - locationViewModel: LocationViewModel, -) { - val ls = locationViewModel.locationState.collectAsState() - LaunchedEffect(ls) { - locationViewModel.updateLocation() - } - Column(modifier = Modifier.fillMaxSize()) { - Card( - elevation = 15.dp, - modifier = Modifier - .padding(15.dp) - .customShadow(), - backgroundColor = Color.White, - ) { - Column(modifier = Modifier - .fillMaxWidth() - .padding(start = 15.dp)) { - Text(text = "STATUS", - color = Color.Black, - fontFamily = monteSB, - fontSize = 14.sp, - modifier = Modifier.padding(top = 10.dp, start = 2.dp) - ) - Row(modifier = Modifier - .fillMaxWidth() - .padding(top = 5.dp, bottom = 5.dp)) { - Icon(painter = painterResource(id = R.drawable.globe), - contentDescription = "Location Icon", - tint = if (connected) backGround else Color.Red, - modifier = Modifier.size(20.dp) - ) - Text( - text = if (connected) "Capturing your Location" else "Not Connected", - color = if (connected) Color(0xFF388365) else Color.Red, - fontFamily = monteSB, - modifier = Modifier.padding(start = 2.dp) - ) - } - } - } - Card( - elevation = 15.dp, - modifier = Modifier - .padding(15.dp) - .customShadow(), - backgroundColor = Color.White, - ) { - Column(modifier = Modifier - .fillMaxWidth() - .padding(start = 15.dp, top = 10.dp), - horizontalAlignment = Alignment.CenterHorizontally, - verticalArrangement = Arrangement.Center - ) { - Text( - text = "Welcome to Waste2Wealth", - color = Color.Black, - fontFamily = monteSB, - ) - Divider( - color = Color.LightGray, - thickness = 0.dp, - startIndent = 0.dp, - modifier = Modifier.padding(vertical = 10.dp) - ) - Row( - horizontalArrangement = Arrangement.SpaceBetween, - modifier = Modifier - .fillMaxWidth() - .padding(bottom = 10.dp) - ) { - Text( - text = "Points Earned", - color = Color.Black, - fontFamily = monteSB, - ) - Text( - text = tripID, - color = Color.Black, - fontFamily = monteNormal, - fontWeight = FontWeight.Bold, - modifier = Modifier.padding(end = 15.dp) - ) - - } - Divider( - color = Color.LightGray, - thickness = 0.dp, - startIndent = 0.dp, - modifier = Modifier.padding(vertical = 10.dp) - ) - Row( - horizontalArrangement = Arrangement.SpaceBetween, - modifier = Modifier - .fillMaxWidth() - .padding(bottom = 10.dp) - ) { - Text( - text = "Waste Reported", - color = Color.Black, - fontFamily = monteSB, - ) - Text( - text = hub, - color = Color.Black, - fontFamily = monteNormal, - fontWeight = FontWeight.Bold, - modifier = Modifier.padding(end = 15.dp) - ) - - } - Divider( - color = Color.LightGray, - thickness = 0.dp, - startIndent = 0.dp, - modifier = Modifier.padding(vertical = 10.dp) - ) - Row( - horizontalArrangement = Arrangement.SpaceBetween, - modifier = Modifier - .fillMaxWidth() - .padding(bottom = 10.dp) - ) { - Text( - text = "Waste Collected", - color = Color.Black, - fontFamily = monteSB, - ) - Text( - text = hub, - color = Color.Black, - fontFamily = monteNormal, - fontWeight = FontWeight.Bold, - modifier = Modifier.padding(end = 15.dp) - ) - - } - Divider( - color = Color.LightGray, - thickness = 0.dp, - startIndent = 0.dp, - modifier = Modifier.padding(vertical = 10.dp) - ) - Row( - horizontalArrangement = Arrangement.SpaceBetween, - modifier = Modifier - .fillMaxWidth() - .padding(bottom = 10.dp) - ) { - Text( - text = "Points Redeemed", - color = Color.Black, - fontFamily = monteSB, - ) - Text( - text = tasks, - color = Color.Black, - fontFamily = monteNormal, - fontWeight = FontWeight.Bold, - modifier = Modifier.padding(end = 15.dp) - ) - } - Divider( - color = Color.LightGray, - thickness = 0.dp, - startIndent = 0.dp, - modifier = Modifier.padding(vertical = 10.dp) - ) -// Row( -// horizontalArrangement = Arrangement.SpaceBetween, -// modifier = Modifier -// .fillMaxWidth() -// .padding(bottom = 10.dp) -// ) { -// Text( -// text = "V", -// color = Color.Black, -// fontFamily = monteSB, -// ) -// Text( -// text = v, -// color = Color.Black, -// fontFamily = monteNormal, -// fontWeight = FontWeight.Bold, -// modifier = Modifier.padding(end = 15.dp), -// fontSize = 14.sp -// ) -// -// } - } - } - Text(text = ls.value, color = Color.Black, modifier = Modifier.padding(start = 30.dp)) - Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.BottomCenter) { - Button(onClick = { - navHostController.navigate(Screens.TasksLists.route) - }, colors = ButtonDefaults.buttonColors( - backgroundColor = backGround - ), modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 55.dp), - shape = RoundedCornerShape(6.dp) - ) { - Text( - text = "CONTINUE", - color = Color.White, - fontFamily = monteSB, - fontSize = 13.sp - ) - } - } - } -} \ No newline at end of file diff --git a/app/src/main/java/app/waste2wealth/com/di/Module.kt b/app/src/main/java/app/waste2wealth/com/di/Module.kt index b0345b8..5ac02c0 100644 --- a/app/src/main/java/app/waste2wealth/com/di/Module.kt +++ b/app/src/main/java/app/waste2wealth/com/di/Module.kt @@ -3,8 +3,6 @@ package app.waste2wealth.com.di import android.app.Application import app.waste2wealth.com.ktorClient.repository.PlacesRepoImpl import app.waste2wealth.com.ktorClient.repository.PlacesRepository -import app.waste2wealth.com.qrcode.sensors.MeasurableSensors -import app.waste2wealth.com.qrcode.sensors.Sensors import com.google.android.gms.location.FusedLocationProviderClient import com.google.android.gms.location.LocationServices import dagger.Module @@ -24,13 +22,6 @@ import javax.inject.Singleton object Module { - @Provides - @Singleton - fun provideLightSensor(app: Application): MeasurableSensors { - return Sensors(app) - } - - @Provides @Singleton fun provideHttpClient(): HttpClient { diff --git a/app/src/main/java/app/waste2wealth/com/failuretask/TaskUndelivered.kt b/app/src/main/java/app/waste2wealth/com/failuretask/TaskUndelivered.kt deleted file mode 100644 index 879b0bf..0000000 --- a/app/src/main/java/app/waste2wealth/com/failuretask/TaskUndelivered.kt +++ /dev/null @@ -1,283 +0,0 @@ -package app.waste2wealth.com.failuretask - -import android.Manifest -import androidx.activity.compose.rememberLauncherForActivityResult -import androidx.activity.result.contract.ActivityResultContracts -import androidx.activity.result.launch -import androidx.compose.foundation.* -import androidx.compose.foundation.layout.* -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.* -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.ArrowDropDown -import androidx.compose.runtime.* -import androidx.compose.ui.Alignment -import androidx.compose.ui.ExperimentalComposeUiApi -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.ImageBitmap -import androidx.compose.ui.graphics.asImageBitmap -import androidx.compose.ui.layout.ContentScale -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import androidx.core.app.ActivityOptionsCompat -import androidx.navigation.NavHostController -import app.waste2wealth.com.R -import app.waste2wealth.com.components.TasksDetailsAppBar -import app.waste2wealth.com.components.permissions.PermissionDrawer -import app.waste2wealth.com.ui.theme.backGround -import app.waste2wealth.com.ui.theme.monteNormal -import app.waste2wealth.com.ui.theme.monteSB -import com.google.accompanist.permissions.ExperimentalPermissionsApi -import com.google.accompanist.permissions.rememberMultiplePermissionsState -import kotlinx.coroutines.launch - -@OptIn( - ExperimentalPermissionsApi::class, ExperimentalMaterialApi::class, - ExperimentalComposeUiApi::class -) -@Composable -fun TaskUndelivered( - navHostController: NavHostController, - phoneNumber: String, -) { - val ctx = LocalContext.current - val scaffoldState = rememberScaffoldState() - var reason by remember { mutableStateOf("Select Reason") } - val dropDownContent = listOf( - "Waste Not Found", - "Wrong Address", - "No Equipment to Collect Waste", - "Other" - ) - - val coroutineScope = rememberCoroutineScope() - var imageBitmap by remember { - mutableStateOf(null) - } - val launcher = rememberLauncherForActivityResult( - contract = ActivityResultContracts.TakePicturePreview(), - onResult = { - println("Bitmaps is ${it?.asImageBitmap()}") - imageBitmap = it?.asImageBitmap() - } - ) - val permissionState = rememberMultiplePermissionsState( - permissions = listOf( - Manifest.permission.CAMERA, - ) - ) - val permissionDrawerState = rememberBottomDrawerState(BottomDrawerValue.Closed) - val gesturesEnabled by remember { derivedStateOf { permissionDrawerState.isOpen } } - var isDropDownVisible by remember { mutableStateOf(false) } - Scaffold(scaffoldState = scaffoldState, topBar = { - TasksDetailsAppBar(onClick = { - }, navHostController = navHostController, text = "Task Incomplete", isCallVisible = false) - }) { - println(it) - PermissionDrawer( - drawerState = permissionDrawerState, - permissionState = permissionState, - rationaleText = "To continue, allow Waste2Wealth to access your device's camera" + - ". Tap Settings > Permission, and turn \"Access Camera On\" on.", - withoutRationaleText = "Camera permission required for this feature to be available." + - " Please grant the permission.", - model = R.drawable.camera, - gesturesEnabled = gesturesEnabled, - size = 100.dp - ) { - Box( - modifier = Modifier - .fillMaxSize() - .background(Color.White) - ) { - Column( - modifier = Modifier - .fillMaxSize() - .padding(top = 10.dp) - .verticalScroll(rememberScrollState()), - horizontalAlignment = Alignment.CenterHorizontally, - ) { - Row( - modifier = Modifier - .fillMaxWidth() - .height(50.dp) - .padding(bottom = 5.dp) - .background(Color(0xFFF3EDED)), - horizontalArrangement = Arrangement.SpaceBetween, - verticalAlignment = Alignment.CenterVertically - ) { - Text( - text = "Reason", - color = Color.Black, - fontSize = 16.sp, - fontFamily = monteSB, - modifier = Modifier.padding(start = 13.dp) - ) - } - ExposedDropdownMenuBox(expanded = isDropDownVisible, onExpandedChange = { - isDropDownVisible = true - }, modifier = Modifier.background(Color.White)) { - Card( - modifier = Modifier.fillMaxWidth(), - backgroundColor = Color.White, - elevation = 5.dp, - shape = RoundedCornerShape(7.dp) - ) { - Row( - modifier = Modifier - .fillMaxWidth() - .padding(top = 20.dp, bottom = 10.dp) - .background(Color.White) - .clickable { - isDropDownVisible = true - }, - horizontalArrangement = Arrangement.SpaceBetween, - verticalAlignment = Alignment.CenterVertically - ) { - Text( - text = reason, - color = Color.Black, - fontSize = 16.sp, - fontFamily = monteNormal, - fontWeight = FontWeight.SemiBold, - modifier = Modifier.padding(start = 16.dp) - ) - Box( - modifier = Modifier.fillMaxWidth(), - contentAlignment = Alignment.CenterEnd - ) { - Icon( - imageVector = Icons.Filled.ArrowDropDown, - contentDescription = "dropDownArrow", - tint = Color.LightGray, - modifier = Modifier.padding(end = 10.dp) - ) - - } - DropdownMenu( - expanded = isDropDownVisible, - onDismissRequest = { - isDropDownVisible = !isDropDownVisible - }, - modifier = Modifier - .background(Color.White) - .fillMaxWidth() - .padding(start = 10.dp, end = 10.dp) - ) { - dropDownContent.forEach { value -> - DropdownMenuItem(onClick = { - reason = value - isDropDownVisible = false - }) { - Text( - text = value, - color = Color.Black, - fontFamily = monteNormal, - fontSize = 15.sp - ) - } - } - } - - } - } - } - Row( - modifier = Modifier - .fillMaxWidth() - .padding(bottom = 0.dp, top = 35.dp) - .height(50.dp) - .background(Color(0xFFF3EDED)), - horizontalArrangement = Arrangement.SpaceBetween, - verticalAlignment = Alignment.CenterVertically - ) { - Text( - text = "Upload Attempt Proof", - color = Color.Black, - fontSize = 16.sp, - fontFamily = monteSB, - modifier = Modifier.padding(start = 13.dp) - ) - } - Row( - modifier = Modifier - .fillMaxWidth() - .padding(top = 7.dp, bottom = 10.dp, start = 10.dp) - .background(Color.White), - horizontalArrangement = Arrangement.Center, - verticalAlignment = Alignment.CenterVertically - ) { - if (imageBitmap == null) { - Button( - onClick = { - coroutineScope.launch { - if (!permissionState.allPermissionsGranted) { - permissionDrawerState.open() - } else { - launcher.launch( - ActivityOptionsCompat.makeBasic() - ) - } - } - }, - colors = ButtonDefaults.buttonColors( - backgroundColor = Color.Transparent - ), - elevation = ButtonDefaults.elevation(0.dp), - shape = RoundedCornerShape(7.dp), - border = BorderStroke(width = 0.dp, color = backGround) - ) { - Text( - text = "Upload Proof of Attempt", - color = backGround, - fontFamily = monteSB - ) - } - } else { - Card( - backgroundColor = Color.Transparent, - shape = RoundedCornerShape(7.dp), - modifier = Modifier - .fillMaxWidth() - .padding(start = 20.dp, end = 20.dp, bottom = 25.dp) - ) { - Image( - bitmap = imageBitmap!!, - contentDescription = "", - contentScale = ContentScale.Crop, - ) - } - } - } - - - } - Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.BottomCenter) { - Button( - onClick = { - - }, colors = ButtonDefaults.buttonColors( - backgroundColor = backGround - ), modifier = Modifier - .fillMaxWidth() - .height(45.dp) - .padding(horizontal = 65.dp), - shape = RoundedCornerShape(6.dp) - ) { - Text( - text = "FINISH TASK", - color = Color.White, - fontFamily = monteNormal, - fontSize = 15.sp - ) - - } - - } - } - } - } -} \ No newline at end of file diff --git a/app/src/main/java/app/waste2wealth/com/ktorClient/HttpCLient.kt b/app/src/main/java/app/waste2wealth/com/ktorClient/HttpCLient.kt deleted file mode 100644 index 567f563..0000000 --- a/app/src/main/java/app/waste2wealth/com/ktorClient/HttpCLient.kt +++ /dev/null @@ -1,32 +0,0 @@ -package app.waste2wealth.com.ktorClient -//import android.util.Log -//import io.ktor.client.* -//import io.ktor.client.engine.android.Android -//import io.ktor.client.engine.cio.CIO -//import io.ktor.client.features.* -//import io.ktor.client.features.json.* -//import io.ktor.client.features.json.serializer.* -//import io.ktor.client.features.logging.* -//import io.ktor.client.features.observer.* -//import io.ktor.client.request.* -//import io.ktor.http.* -//import javax.inject.Inject -// -//class TmdbHttpClient @Inject constructor() { -// -// fun getHttpClient() = HttpClient(Android) { -// -// install(JsonFeature) { -// serializer = KotlinxSerializer(kotlinx.serialization.json.Json { -// prettyPrint = true -// isLenient = true -// ignoreUnknownKeys = true -// }) -// -// } -// -// install(Logging) -// -// } -// -//} \ No newline at end of file diff --git a/app/src/main/java/app/waste2wealth/com/ktorClient/HttpRoutes.kt b/app/src/main/java/app/waste2wealth/com/ktorClient/HttpRoutes.kt deleted file mode 100644 index a786727..0000000 --- a/app/src/main/java/app/waste2wealth/com/ktorClient/HttpRoutes.kt +++ /dev/null @@ -1,7 +0,0 @@ -package app.waste2wealth.com.ktorClient - -object HttpRoutes { - - private const val Places_Base_URL = "https://maps.googleapis.com/maps/api/geocode/" - const val reverseGeocoding = "$Places_Base_URL/json" -} \ No newline at end of file diff --git a/app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/Chain.kt b/app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/Chain.kt deleted file mode 100644 index 66a9c24..0000000 --- a/app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/Chain.kt +++ /dev/null @@ -1,13 +0,0 @@ -package app.waste2wealth.com.ktorClient.imageDto - - -import com.google.gson.annotations.SerializedName - -data class Chain( - @SerializedName("image") - val image: String?, - @SerializedName("medium") - val medium: String?, - @SerializedName("thumb") - val thumb: String? -) \ No newline at end of file diff --git a/app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/ChainCode.kt b/app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/ChainCode.kt deleted file mode 100644 index cba4cd8..0000000 --- a/app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/ChainCode.kt +++ /dev/null @@ -1,13 +0,0 @@ -package app.waste2wealth.com.ktorClient.imageDto - - -import com.google.gson.annotations.SerializedName - -data class ChainCode( - @SerializedName("image") - val image: String?, - @SerializedName("medium") - val medium: String?, - @SerializedName("thumb") - val thumb: String? -) \ No newline at end of file diff --git a/app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/File.kt b/app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/File.kt deleted file mode 100644 index 98365bb..0000000 --- a/app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/File.kt +++ /dev/null @@ -1,9 +0,0 @@ -package app.waste2wealth.com.ktorClient.imageDto - - -import com.google.gson.annotations.SerializedName - -data class File( - @SerializedName("resource") - val resource: Resource? -) \ No newline at end of file diff --git a/app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/Image.kt b/app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/Image.kt deleted file mode 100644 index e8f78b7..0000000 --- a/app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/Image.kt +++ /dev/null @@ -1,99 +0,0 @@ -package app.waste2wealth.com.ktorClient.imageDto - - -import com.google.gson.annotations.SerializedName - -data class Image( - @SerializedName("access_hotlink") - val accessHotlink: Int?, - @SerializedName("access_html") - val accessHtml: Int?, - @SerializedName("adult") - val adult: Int?, - @SerializedName("cloud") - val cloud: Int?, - @SerializedName("date_fixed_peer") - val dateFixedPeer: String?, - @SerializedName("description") - val description: Any?, - @SerializedName("display_height") - val displayHeight: Int?, - @SerializedName("display_url") - val displayUrl: String?, - @SerializedName("display_width") - val displayWidth: Int?, - @SerializedName("expiration") - val expiration: Int?, - @SerializedName("extension") - val extension: String?, - @SerializedName("file") - val `file`: File?, - @SerializedName("filename") - val filename: String?, - @SerializedName("height") - val height: Int?, - @SerializedName("how_long_ago") - val howLongAgo: String?, - @SerializedName("id_encoded") - val idEncoded: String?, - @SerializedName("image") - val image: ImageX?, - @SerializedName("is_animated") - val isAnimated: Int?, - @SerializedName("is_use_loader") - val isUseLoader: Boolean?, - @SerializedName("likes") - val likes: Int?, - @SerializedName("likes_label") - val likesLabel: String?, - @SerializedName("medium") - val medium: Medium?, - @SerializedName("name") - val name: String?, - @SerializedName("nsfw") - val nsfw: Int?, - @SerializedName("original_exifdata") - val originalExifdata: Any?, - @SerializedName("original_filename") - val originalFilename: String?, - @SerializedName("ratio") - val ratio: Double?, - @SerializedName("size") - val size: Int?, - @SerializedName("size_formatted") - val sizeFormatted: String?, - @SerializedName("status") - val status: Int?, - @SerializedName("thumb") - val thumb: Thumb?, - @SerializedName("time") - val time: Int?, - @SerializedName("title") - val title: String?, - @SerializedName("title_truncated") - val titleTruncated: String?, - @SerializedName("title_truncated_html") - val titleTruncatedHtml: String?, - @SerializedName("url") - val url: String?, - @SerializedName("url_seo") - val urlSeo: String?, - @SerializedName("url_short") - val urlShort: String?, - @SerializedName("url_viewer") - val urlViewer: String?, - @SerializedName("url_viewer_preview") - val urlViewerPreview: String?, - @SerializedName("url_viewer_thumb") - val urlViewerThumb: String?, - @SerializedName("views_hotlink") - val viewsHotlink: Int?, - @SerializedName("views_html") - val viewsHtml: Int?, - @SerializedName("views_label") - val viewsLabel: String?, - @SerializedName("vision") - val vision: Int?, - @SerializedName("width") - val width: Int? -) \ No newline at end of file diff --git a/app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/ImageHost.kt b/app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/ImageHost.kt deleted file mode 100644 index f9a1dc3..0000000 --- a/app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/ImageHost.kt +++ /dev/null @@ -1,15 +0,0 @@ -package app.waste2wealth.com.ktorClient.imageDto - - -import com.google.gson.annotations.SerializedName - -data class ImageHost( - @SerializedName("image") - val image: Image?, - @SerializedName("status_code") - val statusCode: Int?, - @SerializedName("status_txt") - val statusTxt: String?, - @SerializedName("success") - val success: Success? -) \ No newline at end of file diff --git a/app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/ImageX.kt b/app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/ImageX.kt deleted file mode 100644 index d19f662..0000000 --- a/app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/ImageX.kt +++ /dev/null @@ -1,19 +0,0 @@ -package app.waste2wealth.com.ktorClient.imageDto - - -import com.google.gson.annotations.SerializedName - -data class ImageX( - @SerializedName("extension") - val extension: String?, - @SerializedName("filename") - val filename: String?, - @SerializedName("mime") - val mime: String?, - @SerializedName("name") - val name: String?, - @SerializedName("size") - val size: Int?, - @SerializedName("url") - val url: String? -) \ No newline at end of file diff --git a/app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/Medium.kt b/app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/Medium.kt deleted file mode 100644 index b997309..0000000 --- a/app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/Medium.kt +++ /dev/null @@ -1,17 +0,0 @@ -package app.waste2wealth.com.ktorClient.imageDto - - -import com.google.gson.annotations.SerializedName - -data class Medium( - @SerializedName("extension") - val extension: String?, - @SerializedName("filename") - val filename: String?, - @SerializedName("mime") - val mime: String?, - @SerializedName("name") - val name: String?, - @SerializedName("url") - val url: String? -) \ No newline at end of file diff --git a/app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/Resource.kt b/app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/Resource.kt deleted file mode 100644 index 7de2f33..0000000 --- a/app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/Resource.kt +++ /dev/null @@ -1,11 +0,0 @@ -package app.waste2wealth.com.ktorClient.imageDto - - -import com.google.gson.annotations.SerializedName - -data class Resource( - @SerializedName("chain") - val chain: Chain?, - @SerializedName("chain_code") - val chainCode: ChainCode? -) \ No newline at end of file diff --git a/app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/Success.kt b/app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/Success.kt deleted file mode 100644 index 29271bc..0000000 --- a/app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/Success.kt +++ /dev/null @@ -1,11 +0,0 @@ -package app.waste2wealth.com.ktorClient.imageDto - - -import com.google.gson.annotations.SerializedName - -data class Success( - @SerializedName("code") - val code: Int?, - @SerializedName("message") - val message: String? -) \ No newline at end of file diff --git a/app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/Thumb.kt b/app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/Thumb.kt deleted file mode 100644 index 5045297..0000000 --- a/app/src/main/java/app/waste2wealth/com/ktorClient/imageDto/Thumb.kt +++ /dev/null @@ -1,17 +0,0 @@ -package app.waste2wealth.com.ktorClient.imageDto - - -import com.google.gson.annotations.SerializedName - -data class Thumb( - @SerializedName("extension") - val extension: String?, - @SerializedName("filename") - val filename: String?, - @SerializedName("mime") - val mime: String?, - @SerializedName("name") - val name: String?, - @SerializedName("url") - val url: String? -) \ No newline at end of file diff --git a/app/src/main/java/app/waste2wealth/com/location/LocationViewModel.kt b/app/src/main/java/app/waste2wealth/com/location/LocationViewModel.kt index c453b02..ce19c58 100644 --- a/app/src/main/java/app/waste2wealth/com/location/LocationViewModel.kt +++ b/app/src/main/java/app/waste2wealth/com/location/LocationViewModel.kt @@ -13,7 +13,6 @@ import androidx.lifecycle.viewModelScope import app.waste2wealth.com.ktorClient.Resource import app.waste2wealth.com.ktorClient.UriPathFinder import app.waste2wealth.com.ktorClient.repository.PlacesRepository -import app.waste2wealth.com.qrcode.sensors.MeasurableSensors import com.google.android.gms.location.LocationServices import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableStateFlow @@ -24,7 +23,6 @@ import javax.inject.Inject @HiltViewModel class LocationViewModel @Inject constructor( application: Application, - private val lightSensors: MeasurableSensors, private val repository: PlacesRepository, private val locationTracker: LocationTracker, ) : AndroidViewModel(application) { @@ -43,26 +41,12 @@ class LocationViewModel @Inject constructor( var distance = mutableStateOf("") var time = mutableStateOf("") var wastePhoto = mutableStateOf("") - var beforeActivityPath = mutableStateOf("") - var activityTitle = mutableStateOf("") var rewardImage = mutableStateOf("") var rewardTitle = mutableStateOf("") var rewardDescription = mutableStateOf("") var rewardNoOfPoints = mutableStateOf(0) - var startActivityTime = mutableStateOf(0L) var listOfAddresses by mutableStateOf(mutableListOf(null)) - - init { - lightSensors.startListening() - lightSensors.setOnSensorValuesChangedListener { values -> - val lux = values[0] - println("The values are $lux") - isDark = lux == 0f - println("what is is Dark $isDark") - } - } - val result = MutableLiveData() @@ -103,11 +87,4 @@ class LocationViewModel @Inject constructor( } } } - - private fun changeUriToPath(uris: Uri, context: Context) = - UriPathFinder().getPath(context, uris) - - fun onFilePathsListChange(list: Uri, context: Context): String? = changeUriToPath(list, context) - - } \ No newline at end of file diff --git a/app/src/main/java/app/waste2wealth/com/navigation/NavigationController.kt b/app/src/main/java/app/waste2wealth/com/navigation/NavigationController.kt index 08d82bc..177b347 100644 --- a/app/src/main/java/app/waste2wealth/com/navigation/NavigationController.kt +++ b/app/src/main/java/app/waste2wealth/com/navigation/NavigationController.kt @@ -17,31 +17,21 @@ import androidx.navigation.NavHostController import androidx.navigation.NavType import androidx.navigation.navArgument import app.waste2wealth.com.UserDatastore -import app.waste2wealth.com.activity.AllActivities -import app.waste2wealth.com.activity.MyRecordings -import app.waste2wealth.com.activity.StopRecording -import app.waste2wealth.com.challenges.Community import app.waste2wealth.com.collectwaste.CollectWaste import app.waste2wealth.com.collectwaste.CollectWasteInfo import app.waste2wealth.com.collectwaste.SuccessfullyCollected import app.waste2wealth.com.communities.ui.CommunitiesSection import app.waste2wealth.com.dashboard.NewDashboard -import app.waste2wealth.com.failuretask.TaskUndelivered import app.waste2wealth.com.location.LocationViewModel import app.waste2wealth.com.login.CompleteProfile import app.waste2wealth.com.login.LoginPage import app.waste2wealth.com.login.onboarding.Onboarding import app.waste2wealth.com.login.onboarding.SettingUp -import app.waste2wealth.com.maps.MapScreen import app.waste2wealth.com.profile.NewProfileScreen -import app.waste2wealth.com.qrcode.ui.ScanQr import app.waste2wealth.com.reportwaste.ReportWaste import app.waste2wealth.com.rewards.ClaimedRewardsScreen import app.waste2wealth.com.rewards.NewRewardsScreen import app.waste2wealth.com.rewards.RewardDetails -import app.waste2wealth.com.successtask.DeliveryDetailsScreen -import app.waste2wealth.com.tasksDetail.TasksDetails -import app.waste2wealth.com.tasksList.TasksLists import com.google.accompanist.navigation.animation.AnimatedNavHost import com.google.accompanist.navigation.animation.composable @@ -141,9 +131,6 @@ fun NavigationController( composable(Screens.Onboarding.route) { Onboarding(navHostController = navController) } - composable(Screens.TasksLists.route) { - TasksLists(navHostController = navController) - } composable(Screens.CompleteProfile.route) { CompleteProfile(navHostController = navController) } @@ -166,7 +153,11 @@ fun NavigationController( ) } composable(Screens.CollectWasteLists.route) { - CollectWaste(navController = navController, viewModel = viewModel, paddingValues = paddingValues) + CollectWaste( + navController = navController, + viewModel = viewModel, + paddingValues = paddingValues + ) } composable(Screens.CollectWasteInfo.route) { CollectWasteInfo(navController = navController, viewModel = viewModel) @@ -179,25 +170,6 @@ fun NavigationController( pfp = profile.value ) } - composable(Screens.AllActivities.route) { - AllActivities( - navController = navController, viewModel = viewModel, - email = email.value, - name = name.value, - pfp = profile.value - ) - } - composable(Screens.MyRecordings.route) { - MyRecordings(navController = navController, viewModel = viewModel) - } - composable(Screens.StopRecording.route) { - StopRecording( - navController = navController, - viewModel = viewModel, - email = email.value, - name = name.value - ) - } composable(Screens.Rewards.route) { NewRewardsScreen( navController = navController, @@ -219,77 +191,11 @@ fun NavigationController( ClaimedRewardsScreen( navController = navController, email = email.value, - name =name.value, - pfp =profile.value, - viewModel =viewModel - ) - } - composable( - Screens.TaskDetail.route - .plus( - "?${TaskDetailsConstants.taskCode.value}={taskCode}" + - "?${TaskDetailsConstants.address.value}={address}" + - "?${TaskDetailsConstants.noOfAttempts.value}={noOfKMs}" + - "?${TaskDetailsConstants.taskPrice.value}={image}" - ), - arguments = listOf( - navArgument("taskCode") { - this.type = NavType.StringType - }, - navArgument("noOfKMs") { - this.type = NavType.StringType - }, - navArgument("address") { - this.type = NavType.StringType - }, - navArgument("image") { - this.type = NavType.StringType - }, - ), - ) { backStackEntry -> - val taskCode = backStackEntry.arguments?.getString("taskCode") ?: "" - val address = backStackEntry.arguments?.getString("address") ?: "" - val noOfKMs = backStackEntry.arguments?.getString("noOfKMs") ?: "" - val image = backStackEntry.arguments?.getString("image") ?: "" - TasksDetails( - address = address, - navHostController = navController, - taskCode = taskCode, - noOfKms = noOfKMs, - image = image - ) - } - - composable(route = Screens.SuccessTask.route.plus( - "?${TaskDetailsConstants.taskPrice.value}={taskPrice}" - ), arguments = listOf( - navArgument("taskPrice") { - this.type = NavType.StringType - } - ) - ) { backStackEntry -> - val taskPrice = backStackEntry.arguments?.getString("taskPrice") ?: "" - DeliveryDetailsScreen( - navHostController = navController, - taskPrice = taskPrice - ) - } - - composable(Screens.FailureTask.route - .plus("?${TaskDetailsConstants.phoneNumber.value}={phoneNumber}"), - arguments = listOf( - navArgument("phoneNumber") { - this.type = NavType.StringType - } + name = name.value, + pfp = profile.value, + viewModel = viewModel ) - ) { backStackEntry -> - val phoneNumber = backStackEntry.arguments?.getString("phoneNumber") ?: "" - TaskUndelivered(navHostController = navController, phoneNumber = phoneNumber) - } - composable(Screens.QrCodeScanner.route) { - ScanQr(viewModel = locationViewModel) } - composable(Screens.Splash.route) { SplashScreen(navController = navController, email = email.value) } diff --git a/app/src/main/java/app/waste2wealth/com/navigation/Screens.kt b/app/src/main/java/app/waste2wealth/com/navigation/Screens.kt index 13ab902..be23eb3 100644 --- a/app/src/main/java/app/waste2wealth/com/navigation/Screens.kt +++ b/app/src/main/java/app/waste2wealth/com/navigation/Screens.kt @@ -1,7 +1,5 @@ package app.waste2wealth.com.navigation -import androidx.navigation.NavHostController - sealed class Screens(val route: String) { @@ -22,20 +20,6 @@ sealed class Screens(val route: String) { object LoginScreen : Screens("login") object Dashboard : Screens("dashboard") object Profile : Screens("profile") - object TasksLists : Screens("tasksLists") - object TaskDetail : Screens("taskDetails") - object SuccessTask : Screens("successTask") - object FailureTask : Screens("failureTask") - object QrCodeScanner : Screens("qrCodeScanner") object Splash : Screens("splash") } - -sealed class TaskDetailsConstants(val value: String) { - object taskCode : TaskDetailsConstants("taskCode") - object taskPrice : TaskDetailsConstants("taskPrice") - object noOfAttempts : TaskDetailsConstants("noOfAttempts") - object address : TaskDetailsConstants("address") - object phoneNumber : TaskDetailsConstants("phoneNumber") -} - diff --git a/app/src/main/java/app/waste2wealth/com/profile/ProfileScreen.kt b/app/src/main/java/app/waste2wealth/com/profile/ProfileScreen.kt deleted file mode 100644 index 3d84c4c..0000000 --- a/app/src/main/java/app/waste2wealth/com/profile/ProfileScreen.kt +++ /dev/null @@ -1,187 +0,0 @@ -package app.waste2wealth.com.profile - -import androidx.compose.foundation.background -import androidx.compose.foundation.border -import androidx.compose.foundation.layout.* -import androidx.compose.foundation.shape.CircleShape -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.Divider -import androidx.compose.material.Scaffold -import androidx.compose.material.Text -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.Home -import androidx.compose.material.icons.filled.Person -import androidx.compose.material.icons.filled.QrCodeScanner -import androidx.compose.material.rememberScaffoldState -import androidx.compose.runtime.* -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.text.style.TextAlign -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import androidx.navigation.NavHostController -import app.waste2wealth.com.components.* -import app.waste2wealth.com.navigation.Screens -import app.waste2wealth.com.ui.theme.backGround -import com.google.accompanist.systemuicontroller.rememberSystemUiController -import kotlinx.coroutines.launch - -@Composable -fun ProfileScreen( - navHostController: NavHostController, - profileName: String = "Krishna Patil", - organization: String = "Robin Hood", - phoneNumber: String = "+911234567890", -) { - val scaffoldState = rememberScaffoldState() - val systemUiController = rememberSystemUiController() - systemUiController.setStatusBarColor(backGround) - systemUiController.setNavigationBarColor(Color.White) - val coroutineScope = rememberCoroutineScope() - var currentItem by remember { - mutableStateOf(Screens.Dashboard.route) - } - Scaffold( - scaffoldState = scaffoldState, - topBar = { - AppBar(currentPage = "Profile", onNavDrawer = { - coroutineScope.launch { - scaffoldState.drawerState.open() - } - }, elevation = 0.dp - ) - }, - drawerGesturesEnabled = scaffoldState.drawerState.isOpen, - drawerContent = { - DrawerHeader() - DrawerBody(items = listOf( - MenuItem( - id = Screens.Dashboard.route, - title = "Dashboard", - icon = Icons.Filled.Home, - contentDesc = "Dashboard" - ), - MenuItem( - id = Screens.Profile.route, - title = "Profile", - icon = Icons.Filled.Person, - contentDesc = "Profile" - ), - MenuItem( - id = Screens.QrCodeScanner.route, - title = "Report Waste", - icon = Icons.Filled.QrCodeScanner, - contentDesc = "Qr Code Scanner" - ) - ), onItemClick = { - currentItem = it.id - when (it.id) { - Screens.Dashboard.route -> { - navHostController.navigate(Screens.Dashboard.route) - } - Screens.Profile.route -> { - navHostController.navigate(Screens.Profile.route) - } - Screens.QrCodeScanner.route -> { - navHostController.navigate(Screens.QrCodeScanner.route) - } - } - }, currentItem = Screens.Profile.route) - Divider(color = Color.Gray, modifier = Modifier.padding( - top = 7.dp, - start = 10.dp, - end = 10.dp - )) - LogOut(navHostController = navHostController) - TnC() - PrivacyPolicy() - AppVersion() - - - }, - drawerBackgroundColor = Color.White, - drawerScrimColor = Color.White, - drawerElevation = 15.dp, - drawerShape = RoundedCornerShape(15.dp) - ) { - Column(modifier = Modifier - .fillMaxSize() - .background(Color.White)) { - println(it) - Column(modifier = Modifier - .fillMaxWidth() - .fillMaxHeight(0.20f) - .background(backGround) - .padding(top = 35.dp, start = 10.dp) - ) { - - Row(modifier = Modifier - .fillMaxWidth() - .background(backGround), - horizontalArrangement = Arrangement.SpaceBetween) { - ProfileImage( - imageUrl = app.waste2wealth.com.R.drawable.appicon, - modifier = Modifier - .size(100.dp) - .border( - width = 1.dp, - color = Color(0xFF4483D1), - shape = CircleShape - ) - .padding(3.dp) - .clip(CircleShape) - ) - Column( - horizontalAlignment = Alignment.CenterHorizontally, - verticalArrangement = Arrangement.SpaceEvenly - ) { - Text( - text = profileName, - fontSize = 31.sp, - color = Color.White, - fontWeight = FontWeight.Bold, - modifier = Modifier.padding(end = 25.dp) - ) - Text( - text = "Organization: $organization", - fontSize = 18.sp, - color = Color.White, - fontWeight = FontWeight.Bold, - textAlign = TextAlign.Justify, - modifier = Modifier.padding(top = 5.dp, end = 25.dp) - ) - } - } - } - Column(modifier = Modifier.padding(start = 15.dp, top = 15.dp)) { - Text( - text = "Personal Details", - color = Color(0xFF005F47), - fontSize = 20.sp - ) - Divider( - color = Color.LightGray, - thickness = 0.dp, - modifier = Modifier.padding(vertical = 10.dp) - ) - Row(horizontalArrangement = Arrangement.SpaceBetween, - modifier = Modifier.fillMaxWidth()) { - Text( - text = "Phone", - color = backGround, - fontWeight = FontWeight.Black - ) - Text( - text = phoneNumber, - color = Color.Black, - fontWeight = FontWeight.Black, - modifier = Modifier.padding(end = 15.dp) - ) - } - } - } - } -} \ No newline at end of file diff --git a/app/src/main/java/app/waste2wealth/com/qrcode/analyzer/QrCodeAnalyzer.kt b/app/src/main/java/app/waste2wealth/com/qrcode/analyzer/QrCodeAnalyzer.kt deleted file mode 100644 index 1f44a93..0000000 --- a/app/src/main/java/app/waste2wealth/com/qrcode/analyzer/QrCodeAnalyzer.kt +++ /dev/null @@ -1,62 +0,0 @@ -package app.waste2wealth.com.qrcode.analyzer - -import android.annotation.SuppressLint -import android.util.Log -import androidx.camera.core.ImageAnalysis -import androidx.camera.core.ImageProxy -import com.google.mlkit.vision.barcode.BarcodeScannerOptions -import com.google.mlkit.vision.barcode.BarcodeScanning -import com.google.mlkit.vision.barcode.common.Barcode -import com.google.mlkit.vision.common.InputImage -import java.util.concurrent.TimeUnit - -@SuppressLint("UnsafeOptInUsageError") -class QrCodeAnalyzer( - private val onBarcodeDetected: (barcodes: List) -> Unit, -) : ImageAnalysis.Analyzer { - private var lastAnalyzedTimeStamp = 0L - - override fun analyze(image: ImageProxy) { - val currentTimestamp = System.currentTimeMillis() - if (currentTimestamp - lastAnalyzedTimeStamp >= TimeUnit.SECONDS.toMillis(1)) { - image.image?.let { imageToAnalyze -> - val options = BarcodeScannerOptions.Builder() - .setBarcodeFormats(Barcode.FORMAT_ALL_FORMATS) - .build() - val barcodeScanner = BarcodeScanning.getClient(options) - val imageToProcess = InputImage - .fromMediaImage(imageToAnalyze, image.imageInfo.rotationDegrees) - barcodeScanner.process(imageToProcess) - .addOnSuccessListener { barcodes -> - if (barcodes.isNotEmpty()) { - onBarcodeDetected(barcodes) - } else { - Log.d("TAG", "analyze: No barcode Scanned") - } - } - .addOnFailureListener { exception -> - Log.d("TAG", "BarcodeAnalyser: Something went wrong $exception") - } - .addOnCompleteListener { - image.close() - } - } - lastAnalyzedTimeStamp = currentTimestamp - } else { - image.close() - } - } -} - -enum class BarCodeTypes { - None, - CalendarEvent, - DrivingLicense, - Email, - GeoPoint, - Phone, - SMS, - Url, - Wifi - -} diff --git a/app/src/main/java/app/waste2wealth/com/qrcode/sensors/AndroidSensor.kt b/app/src/main/java/app/waste2wealth/com/qrcode/sensors/AndroidSensor.kt deleted file mode 100644 index 85c0113..0000000 --- a/app/src/main/java/app/waste2wealth/com/qrcode/sensors/AndroidSensor.kt +++ /dev/null @@ -1,51 +0,0 @@ -package app.waste2wealth.com.qrcode.sensors - -import android.content.Context -import android.hardware.Sensor -import android.hardware.SensorEvent -import android.hardware.SensorEventListener -import android.hardware.SensorManager - -abstract class AndroidSensor( - private val context: Context, - private val sensorFeature: String, - sensorType: Int -) : MeasurableSensors(sensorType), SensorEventListener { - - override val doesSensorExist: Boolean - get() = context.packageManager.hasSystemFeature(sensorFeature) - - private lateinit var sensorManager: SensorManager - private var sensor: Sensor? = null - - override fun startListening() { - if (!doesSensorExist) { - return - } - if (!::sensorManager.isInitialized && sensor == null) { - sensorManager = context.getSystemService(Context.SENSOR_SERVICE) as SensorManager - sensor = sensorManager.getDefaultSensor(sensorType) - } - sensor?.let { - sensorManager.registerListener(this, it, SensorManager.SENSOR_DELAY_NORMAL) - } - } - - override fun stopListening() { - if (!doesSensorExist || !::sensorManager.isInitialized) { - return - } - sensorManager.unregisterListener(this) - } - - override fun onSensorChanged(event: SensorEvent?) { - if (!doesSensorExist) { - return - } - if (event?.sensor?.type == sensorType) { - onSensorValuesChanged?.invoke(event.values.toList()) - } - } - - override fun onAccuracyChanged(p0: Sensor?, p1: Int) = Unit -} \ No newline at end of file diff --git a/app/src/main/java/app/waste2wealth/com/qrcode/sensors/MeasurableSensors.kt b/app/src/main/java/app/waste2wealth/com/qrcode/sensors/MeasurableSensors.kt deleted file mode 100644 index cc4aac4..0000000 --- a/app/src/main/java/app/waste2wealth/com/qrcode/sensors/MeasurableSensors.kt +++ /dev/null @@ -1,18 +0,0 @@ -package app.waste2wealth.com.qrcode.sensors - -abstract class MeasurableSensors(protected val sensorType: Int) { - - protected var onSensorValuesChanged: ((List) -> Unit)? = null - - abstract val doesSensorExist: Boolean - - abstract fun startListening() - - abstract fun stopListening() - - fun setOnSensorValuesChangedListener(listner: (List) -> Unit) { - onSensorValuesChanged = listner - } - - -} \ No newline at end of file diff --git a/app/src/main/java/app/waste2wealth/com/qrcode/sensors/Sensors.kt b/app/src/main/java/app/waste2wealth/com/qrcode/sensors/Sensors.kt deleted file mode 100644 index cf85f3e..0000000 --- a/app/src/main/java/app/waste2wealth/com/qrcode/sensors/Sensors.kt +++ /dev/null @@ -1,11 +0,0 @@ -package app.waste2wealth.com.qrcode.sensors - -import android.content.Context -import android.content.pm.PackageManager -import android.hardware.Sensor - -class Sensors(context: Context) : AndroidSensor( - context = context, - sensorFeature = PackageManager.FEATURE_SENSOR_LIGHT, - sensorType = Sensor.TYPE_LIGHT -) \ No newline at end of file diff --git a/app/src/main/java/app/waste2wealth/com/qrcode/ui/ScanQR.kt b/app/src/main/java/app/waste2wealth/com/qrcode/ui/ScanQR.kt deleted file mode 100644 index 96448b3..0000000 --- a/app/src/main/java/app/waste2wealth/com/qrcode/ui/ScanQR.kt +++ /dev/null @@ -1,461 +0,0 @@ -package app.waste2wealth.com.qrcode.ui - -import android.Manifest -import android.content.Intent -import android.net.Uri -import android.util.Log -import android.view.ViewGroup -import androidx.camera.core.Camera -import androidx.camera.core.CameraSelector -import androidx.camera.core.ImageAnalysis -import androidx.camera.core.Preview -import androidx.camera.lifecycle.ProcessCameraProvider -import androidx.camera.view.PreviewView -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.* -import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.foundation.verticalScroll -import androidx.compose.material.* -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.* -import androidx.compose.material.icons.sharp.Cameraswitch -import androidx.compose.material.icons.sharp.FlashAuto -import androidx.compose.material.icons.sharp.FlashOff -import androidx.compose.material.icons.sharp.FlashOn -import androidx.compose.runtime.* -import androidx.compose.ui.Alignment -import androidx.compose.ui.ExperimentalComposeUiApi -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.alpha -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.vector.ImageVector -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.platform.LocalLifecycleOwner -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import androidx.compose.ui.viewinterop.AndroidView -import androidx.core.content.ContextCompat -import app.waste2wealth.com.R -import app.waste2wealth.com.components.permissions.Grapple -import app.waste2wealth.com.components.permissions.PermissionDrawer -import app.waste2wealth.com.location.LocationViewModel -import app.waste2wealth.com.qrcode.analyzer.BarCodeTypes -import app.waste2wealth.com.qrcode.analyzer.QrCodeAnalyzer -import app.waste2wealth.com.ui.theme.backGround -import app.waste2wealth.com.ui.theme.monteNormal -import app.waste2wealth.com.ui.theme.monteSB -import com.google.accompanist.permissions.ExperimentalPermissionsApi -import com.google.accompanist.permissions.rememberMultiplePermissionsState -import com.google.common.util.concurrent.ListenableFuture -import java.util.concurrent.ExecutorService -import java.util.concurrent.Executors - -@OptIn( - ExperimentalPermissionsApi::class, - ExperimentalComposeUiApi::class, - ExperimentalMaterialApi::class -) -@Composable -fun ScanQr(viewModel: LocationViewModel) { - var code by remember { - mutableStateOf("No Results Found") - } - var isFlashAuto by remember { mutableStateOf(false) } - var isChecked by remember { mutableStateOf(true) } - val context = LocalContext.current - val permissionState = rememberMultiplePermissionsState( - permissions = listOf( - Manifest.permission.CAMERA, - ) - ) - val isDark = viewModel.isDark - var barcodeType by remember { - mutableStateOf(BarCodeTypes.None) - } - var isFlashEnabled by remember { - mutableStateOf(false) - } - val cameraProviderFuture: ListenableFuture = - ProcessCameraProvider.getInstance(context) - var camera by remember { - mutableStateOf(null) - } - var lens by remember { mutableStateOf(CameraSelector.LENS_FACING_BACK) } - var preview by remember { mutableStateOf(null) } - val cameraProvider: ProcessCameraProvider = cameraProviderFuture.get() - val cameraSelector: CameraSelector = CameraSelector.Builder().requireLensFacing(lens).build() - val permissionDrawerState = rememberBottomDrawerState( - if (permissionState.allPermissionsGranted) BottomDrawerValue.Closed - else BottomDrawerValue.Open - ) - val gesturesEnabled by remember { derivedStateOf { permissionDrawerState.isOpen } } - PermissionDrawer( - drawerState = permissionDrawerState, - permissionState = permissionState, - rationaleText = "To continue, allow Waste2Wealth to access your device's camera" + - ". Tap Settings > Permission, and turn \"Access Camera On\" on.", - withoutRationaleText = "Camera permission required for this feature to be available." + - " Please grant the permission.", - model = R.drawable.camera, - gesturesEnabled = gesturesEnabled, - size = 100.dp - ) { - Column( - modifier = Modifier - .fillMaxSize() - .background(Color.White) - ) { - - val lifecycleOwner = LocalLifecycleOwner.current - val barCodeVal = remember { mutableStateOf("") } - AndroidView( - factory = { AndroidViewContext -> - PreviewView(AndroidViewContext).apply { - layoutParams = ViewGroup.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.MATCH_PARENT, - ) - implementationMode = PreviewView.ImplementationMode.COMPATIBLE - } - }, - modifier = Modifier.fillMaxSize(), - update = { previewView -> - val cameraExecutor: ExecutorService = Executors.newSingleThreadExecutor() - cameraProviderFuture.addListener({ - preview = Preview.Builder().build().also { - it.setSurfaceProvider(previewView.surfaceProvider) - } - val barcodeAnalyser = QrCodeAnalyzer { barcodes -> - barcodes.forEach { barcode -> - println() - when (barcode.valueType) { - 8 -> { - barcodeType = BarCodeTypes.Url - } - 12 -> { - barcodeType = BarCodeTypes.DrivingLicense - } - 2 -> { - barcodeType = BarCodeTypes.Email - } - 10 -> { - barcodeType = BarCodeTypes.GeoPoint - } - 6 -> { - barcodeType = BarCodeTypes.SMS - } - 9 -> { - barcodeType = BarCodeTypes.Wifi - } - 4 -> { - barcodeType = BarCodeTypes.Phone - } - 11 -> { - barcodeType = BarCodeTypes.CalendarEvent - } - } - barcode.rawValue?.let { barcodeValue -> - barCodeVal.value = barcodeValue - code = barcodeValue - if (isChecked) { - if (barcode.valueType == 8) { - try { - val urlIntent = Intent( - Intent.ACTION_VIEW, Uri.parse(code) - ) - context.startActivity(urlIntent) - } catch (e: Exception) { - e.printStackTrace() - } - } - } - } - } - } - val imageAnalysis: ImageAnalysis = ImageAnalysis.Builder() - .setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST) - .build().also { - it.setAnalyzer(cameraExecutor, barcodeAnalyser) - } - - try { - cameraProvider.unbindAll() - camera = cameraProvider.bindToLifecycle( - lifecycleOwner, cameraSelector, preview, imageAnalysis - ) - if (isFlashAuto) { - if (isDark) { - if (camera?.cameraInfo?.hasFlashUnit() == true) { - camera?.cameraControl?.enableTorch(true) - isFlashEnabled = true - } - } else { - camera?.cameraControl?.enableTorch(false) - isFlashEnabled = false - } - } - } catch (e: Exception) { - Log.d("TAG", "CameraPreview: ${e.localizedMessage}") - } - }, ContextCompat.getMainExecutor(context)) - }, - - ) - - - } - Box( - modifier = Modifier - .fillMaxSize() - .padding(top = 25.dp, start = 15.dp, end = 15.dp), - contentAlignment = Alignment.TopStart - ) { - Row( - modifier = Modifier - .fillMaxWidth() - .background(Color(0xFF353739).copy(0.55f)), - horizontalArrangement = Arrangement.SpaceBetween - ) { - IconButton(onClick = { - if (camera?.cameraInfo?.hasFlashUnit() == true) { - camera?.cameraControl?.enableTorch(!isFlashEnabled) - isFlashEnabled = !isFlashEnabled - } - }) { - if (isFlashAuto) { - Icon( - imageVector = Icons.Sharp.FlashAuto, contentDescription = "auto" - ) - } else { - if (isFlashEnabled) { - Icon( - imageVector = Icons.Sharp.FlashOn, contentDescription = "" - ) - } else { - Icon( - imageVector = Icons.Sharp.FlashOff, contentDescription = "" - ) - } - } - } - IconButton(onClick = { - isFlashAuto = !isFlashAuto - }) { - if (isFlashAuto) { - Text( - text = "Auto Flash On", - color = Color.White, - fontSize = 20.sp, - fontFamily = monteNormal - ) - } else { - Text( - text = "Auto Flash Off", - color = Color.White, - fontSize = 20.sp, - fontFamily = monteNormal - ) - } - } - IconButton(onClick = { - lens = - if (lens == CameraSelector.LENS_FACING_BACK) CameraSelector.LENS_FACING_FRONT - else CameraSelector.LENS_FACING_BACK - }) { - Icon( - imageVector = Icons.Sharp.Cameraswitch, contentDescription = "" - ) - } - - } - } - Box( - modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.BottomStart - ) { - Card( - modifier = Modifier - .fillMaxWidth() - .fillMaxHeight(0.25f), - backgroundColor = Color(0xFF353739).copy(0.55f), - shape = RoundedCornerShape(topStart = 7.dp, topEnd = 7.dp), - elevation = 0.dp - ) { - Column( - modifier = Modifier - .fillMaxWidth() - ) { - Row( - modifier = Modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.Center - ) { - Grapple( - modifier = Modifier - .padding(bottom = 0.dp) - .requiredHeight(15.dp) - .requiredWidth(55.dp) - .alpha(0.22f), color = Color.White - ) - } - Row( - modifier = Modifier - .fillMaxWidth() - .padding(top = 7.dp), - horizontalArrangement = Arrangement.SpaceAround - ) { - Text( - text = "Results", - color = Color.White, - fontSize = 25.sp, - fontFamily = monteSB, - modifier = Modifier.padding(start = 7.dp) - ) - Row( - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.End, - modifier = Modifier - .fillMaxWidth() - .padding(end = 5.dp), - ) { - Checkbox(checked = isChecked, onCheckedChange = { - isChecked = !isChecked - }, modifier = Modifier.padding(end = 0.dp)) - Text( - text = "Auto Navigate", - color = Color.White, - fontSize = 13.sp, - fontFamily = monteSB - ) - } - } - Row( - modifier = Modifier - .fillMaxWidth() - .padding( - start = 7.dp, end = 7.dp, top = 10.dp, bottom = 10.dp - ) - .verticalScroll(rememberScrollState()), - horizontalArrangement = Arrangement.Center - ) { - Text( - text = code, - color = Color.White, - fontSize = 16.sp, - fontFamily = monteNormal, - softWrap = true - ) - } - Row( - modifier = Modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.Center - ) { - when (barcodeType) { - BarCodeTypes.CalendarEvent -> { - CustomIcon( - imageVector = Icons.Filled.CalendarMonth, - desc = "Calendar Event" - ) - } - BarCodeTypes.DrivingLicense -> { - CustomIcon( - imageVector = Icons.Filled.ElectricCar, desc = "Driving License" - ) - } - BarCodeTypes.Email -> { - CustomIcon( - imageVector = Icons.Filled.Email, desc = "Email" - ) - } - BarCodeTypes.GeoPoint -> { - CustomIcon( - imageVector = Icons.Filled.Link, desc = "Geo Point" - ) - } - BarCodeTypes.SMS -> { - CustomIcon( - imageVector = Icons.Filled.Sms, desc = "SMS" - ) - } - BarCodeTypes.Wifi -> { - CustomIcon( - imageVector = Icons.Filled.Wifi, desc = "Wifi Details" - ) - } - BarCodeTypes.Phone -> { - CustomIcon( - imageVector = Icons.Filled.Phone, desc = "Contact" - ) - } - BarCodeTypes.Url -> { - CustomIcon( - imageVector = Icons.Filled.Link, desc = "Url" - ) - } - BarCodeTypes.None -> { - - } - } - } - - } - Box( - modifier = Modifier - .fillMaxSize() - .padding(end = 0.dp), - contentAlignment = Alignment.BottomCenter - ) { - Button( - onClick = { - try { - val urlIntent = Intent( - Intent.ACTION_VIEW, Uri.parse(code) - ) - context.startActivity(urlIntent) - } catch (e: Exception) { - e.printStackTrace() - } - }, - colors = ButtonDefaults.buttonColors( - backgroundColor = backGround - ), - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 55.dp), - shape = RoundedCornerShape(6.dp) - ) { - Text( - text = "Visit", - color = Color.White, - fontFamily = monteSB, - fontSize = 13.sp - ) - } - } - } - - } - } -} - -@Composable -fun CustomIcon(imageVector: ImageVector, desc: String) { - Row( - horizontalArrangement = Arrangement.Center, - modifier = Modifier - .fillMaxWidth() - .padding(top = 0.dp, bottom = 7.dp), - verticalAlignment = Alignment.CenterVertically - ) { - Icon( - imageVector = imageVector, contentDescription = desc, modifier = Modifier.size(20.dp) - ) - Text( - text = "$desc found", - color = Color.White, - modifier = Modifier.padding(start = 5.dp), - fontSize = 13.sp, - fontFamily = monteNormal - ) - } -} - diff --git a/app/src/main/java/app/waste2wealth/com/rewards/RewardsScreen.kt b/app/src/main/java/app/waste2wealth/com/rewards/RewardsScreen.kt deleted file mode 100644 index f9cd9ab..0000000 --- a/app/src/main/java/app/waste2wealth/com/rewards/RewardsScreen.kt +++ /dev/null @@ -1,342 +0,0 @@ -package app.waste2wealth.com.rewards - -import android.Manifest -import android.widget.Toast -import androidx.compose.foundation.background -import androidx.compose.foundation.border -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.PaddingValues -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.lazy.grid.GridCells -import androidx.compose.foundation.lazy.grid.LazyVerticalGrid -import androidx.compose.foundation.lazy.grid.items -import androidx.compose.foundation.shape.CircleShape -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.BottomDrawerValue -import androidx.compose.material.Button -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.Card -import androidx.compose.material.ExperimentalMaterialApi -import androidx.compose.material.Scaffold -import androidx.compose.material.Text -import androidx.compose.material.rememberBottomDrawerState -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue -import androidx.compose.ui.Alignment -import androidx.compose.ui.ExperimentalComposeUiApi -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.layout.ContentScale -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import androidx.navigation.NavHostController -import app.waste2wealth.com.bottombar.BottomBar -import app.waste2wealth.com.components.permissions.PermissionDrawer -import app.waste2wealth.com.firebase.firestore.ProfileInfo -import app.waste2wealth.com.firebase.firestore.updateInfoToFirebase -import app.waste2wealth.com.navigation.Screens -import app.waste2wealth.com.profile.ProfileImage -import app.waste2wealth.com.ui.theme.appBackground -import app.waste2wealth.com.ui.theme.monteBold -import app.waste2wealth.com.ui.theme.monteNormal -import app.waste2wealth.com.ui.theme.monteSB -import app.waste2wealth.com.ui.theme.textColor -import com.airbnb.lottie.compose.LottieAnimation -import com.airbnb.lottie.compose.LottieCompositionSpec -import com.airbnb.lottie.compose.rememberLottieComposition -import com.google.accompanist.permissions.ExperimentalPermissionsApi -import com.google.accompanist.permissions.rememberMultiplePermissionsState -import com.jet.firestore.JetFirestore -import com.jet.firestore.getListOfObjects - -@OptIn( - ExperimentalPermissionsApi::class, ExperimentalComposeUiApi::class, - ExperimentalMaterialApi::class -) -@Composable -fun RewardsScreen( - navController: NavHostController, - email: String, - name: String, - pfp: String -) { - - val permissionState = rememberMultiplePermissionsState( - permissions = listOf( - Manifest.permission.ACCESS_FINE_LOCATION, - Manifest.permission.ACCESS_COARSE_LOCATION - ) - ) - val permissionDrawerState = rememberBottomDrawerState( - if (permissionState.allPermissionsGranted) BottomDrawerValue.Closed else BottomDrawerValue.Open - ) - var profileList by remember { - mutableStateOf?>(null) - } - var userAddress by remember { - mutableStateOf("") - } - var phoneNumber by remember { - mutableStateOf("") - } - var gender by remember { - mutableStateOf("") - } - var organization by remember { - mutableStateOf("") - } - var pointsEarned by remember { - mutableStateOf(0) - } - var pointsRedeemed by remember { - mutableStateOf(0) - } - var noOfTimesReported by remember { - mutableStateOf(0) - } - var noOfTimesCollected by remember { - mutableStateOf(0) - } - var noOfTimesActivity by remember { - mutableStateOf(0) - } - JetFirestore(path = { - collection("ProfileInfo") - }, onRealtimeCollectionFetch = { value, _ -> - profileList = value?.getListOfObjects() - }) { - if (profileList != null) { - for (i in profileList!!) { - if (i.email == email) { - userAddress = i.address ?: "" - gender = i.gender ?: "" - phoneNumber = i.phoneNumber ?: "" - organization = i.organization ?: "" - pointsEarned = i.pointsEarned - pointsRedeemed = i.pointsRedeemed - noOfTimesReported = i.noOfTimesReported - noOfTimesCollected = i.noOfTimesCollected - noOfTimesActivity = i.noOfTimesActivity - } - } - } - - PermissionDrawer( - drawerState = permissionDrawerState, - permissionState = permissionState, - rationaleText = "To continue, allow Report Waste2Wealth to access your device's location" + - ". Tap Settings > Permission, and turn \"Access Location On\" on.", - withoutRationaleText = "Location permission required for functionality of this app." + - " Please grant the permission.", - ) { - Scaffold(bottomBar = { - BottomBar(navController = navController) - }) { - var isCOinVisible by remember { - mutableStateOf(false) - } - println(it) - Box(modifier = Modifier.fillMaxSize()) { - Box(modifier = Modifier.fillMaxSize()) { - Column( - modifier = Modifier - .fillMaxSize() - .background(appBackground) - ) { - Row( - modifier = Modifier - .fillMaxWidth() - .padding( - top = 35.dp, - bottom = 35.dp, - start = 20.dp, - end = 20.dp - ), - horizontalArrangement = Arrangement.SpaceBetween, - verticalAlignment = Alignment.CenterVertically - ) { - Text( - text = "Rewards", - color = textColor, - fontSize = 35.sp, - fontFamily = monteBold, - ) - ProfileImage( - imageUrl = pfp, - modifier = Modifier - .size(60.dp) - .border( - width = 1.dp, - color = appBackground, - shape = CircleShape - ) - .padding(3.dp) - .clip(CircleShape) - .clickable { - navController.navigate(Screens.Profile.route) - }, - ) - } - val context = LocalContext.current - LazyVerticalGrid( - columns = GridCells.Fixed(2), - modifier = Modifier.padding( - bottom = 50.dp, - start = 15.dp, - top = 0.dp, - end = 15.dp - ), - contentPadding = PaddingValues(bottom = 25.dp) - ) { - - items(allRewards) { item -> - RepeatingRewards( - name = item.name, - expiry = item.expiry, - points = item.points - ) { - if (pointsEarned >= item.points.toInt()) { - isCOinVisible = true - Toast.makeText( - context, - "You have earned ${item.points} points", - Toast.LENGTH_SHORT - ).show() - updateInfoToFirebase( - context, - name = name, - email = email, - phoneNumber = phoneNumber, - gender = gender, - organization = organization, - address = userAddress, - pointsEarned = pointsEarned - item.points.toInt(), - pointsRedeemed = pointsRedeemed + item.points.toInt(), - noOfTimesReported = noOfTimesReported, - noOfTimesCollected = noOfTimesCollected + 1, - noOfTimesActivity = noOfTimesActivity, - ) - - } else { - Toast.makeText( - context, - "You do not have enough points to claim this reward", - Toast.LENGTH_SHORT - ).show() - } - } - } - - } - - } - } - if (isCOinVisible) { - Box( - modifier = Modifier.fillMaxSize(), - contentAlignment = Alignment.BottomCenter - ) { - val currenanim by rememberLottieComposition( - spec = LottieCompositionSpec.Asset("coins.json") - ) - LottieAnimation( - composition = currenanim, - iterations = 1, - contentScale = ContentScale.Crop, - speed = 1f, - modifier = Modifier - .fillMaxSize() - .size(250.dp) - ) - } - - } - } - } - } - } -} - -@Composable -fun RepeatingRewards( - name: String, - expiry: String, - points: String, - onClaimClick: () -> Unit -) { - Card( - backgroundColor = Color(0xFFD5E1DA), - shape = RoundedCornerShape( - topStart = 10.dp, - topEnd = 10.dp, - bottomEnd = 10.dp, - bottomStart = 50.dp - ), - modifier = Modifier.padding(end = 10.dp, bottom = 20.dp) - ) { - Column(modifier = Modifier.padding(15.dp)) { - Row( - modifier = Modifier.fillMaxWidth(), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.SpaceBetween - ) { - Text( - text = name, - color = Color.Black, - fontSize = 20.sp, - fontFamily = monteSB, - modifier = Modifier.padding(bottom = 10.dp), - softWrap = true, - ) - } - Text( - text = expiry, - color = Color.Black, - fontSize = 16.sp, - fontFamily = monteNormal, - modifier = Modifier.padding(bottom = 10.dp) - ) - Text( - text = "Points: $points", - color = Color.Black, - fontSize = 16.sp, - fontFamily = monteNormal, - modifier = Modifier.padding(bottom = 10.dp) - ) - - Button( - onClick = { onClaimClick() }, - colors = ButtonDefaults.buttonColors( - backgroundColor = Color(0xFFFD5065), - contentColor = Color.White - ), - shape = RoundedCornerShape(35.dp), - modifier = Modifier.padding(start = 10.dp) - ) { - Text( - text = "Claim Now", - color = Color.White, - fontSize = 12.sp, - fontFamily = monteSB, - modifier = Modifier.padding(bottom = 4.dp), - maxLines = 1, - softWrap = true - ) - } - - } - - } -} \ No newline at end of file diff --git a/app/src/main/java/app/waste2wealth/com/successtask/DeliveryDetailsScreen.kt b/app/src/main/java/app/waste2wealth/com/successtask/DeliveryDetailsScreen.kt deleted file mode 100644 index 9c206c3..0000000 --- a/app/src/main/java/app/waste2wealth/com/successtask/DeliveryDetailsScreen.kt +++ /dev/null @@ -1,318 +0,0 @@ -package app.waste2wealth.com.successtask - -import android.Manifest -import androidx.activity.compose.rememberLauncherForActivityResult -import androidx.activity.result.contract.ActivityResultContracts -import androidx.activity.result.launch -import androidx.compose.foundation.* -import androidx.compose.foundation.layout.* -import androidx.compose.foundation.selection.selectable -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.* -import androidx.compose.runtime.* -import androidx.compose.ui.Alignment -import androidx.compose.ui.ExperimentalComposeUiApi -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.ImageBitmap -import androidx.compose.ui.graphics.asImageBitmap -import androidx.compose.ui.layout.ContentScale -import androidx.compose.ui.semantics.Role -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import androidx.core.app.ActivityOptionsCompat -import androidx.navigation.NavHostController -import app.waste2wealth.com.R -import app.waste2wealth.com.components.TasksDetailsAppBar -import app.waste2wealth.com.components.permissions.PermissionDrawer -import app.waste2wealth.com.ui.theme.backGround -import app.waste2wealth.com.ui.theme.monteNormal -import app.waste2wealth.com.ui.theme.monteSB -import com.google.accompanist.permissions.ExperimentalPermissionsApi -import com.google.accompanist.permissions.rememberMultiplePermissionsState -import kotlinx.coroutines.launch - -@OptIn( - ExperimentalMaterialApi::class, ExperimentalPermissionsApi::class, - ExperimentalComposeUiApi::class -) -@Composable -fun DeliveryDetailsScreen( - navHostController: NavHostController, - taskPrice: String, -) { - val scaffoldState = rememberScaffoldState() - val radioOptions = listOf("Yes", "No") - val depositedWaste = listOf("Yes", "No") - var receiver by remember { mutableStateOf(radioOptions[0]) } - val coroutineScope = rememberCoroutineScope() - var imageBitmap by remember { - mutableStateOf(null) - } - val launcher = rememberLauncherForActivityResult( - contract = ActivityResultContracts.TakePicturePreview(), - onResult = { - println("Bitmaps is ${it?.asImageBitmap()}") - imageBitmap = it?.asImageBitmap() - } - ) - val permissionState = rememberMultiplePermissionsState( - permissions = listOf( - Manifest.permission.CAMERA, - ) - ) - val permissionDrawerState = rememberBottomDrawerState(BottomDrawerValue.Closed) - val gesturesEnabled by remember { derivedStateOf { permissionDrawerState.isOpen } } - Scaffold(scaffoldState = scaffoldState, topBar = { - TasksDetailsAppBar(onClick = { - }, navHostController = navHostController, text = "Delivery Details", isCallVisible = false) - }) { - println(it) - PermissionDrawer( - drawerState = permissionDrawerState, - permissionState = permissionState, - rationaleText = "To continue, allow Waste2Wealth to access your device's camera" + - ". Tap Settings > Permission, and turn \"Access Camera On\" on.", - withoutRationaleText = "Camera permission required for this feature to be available." + - " Please grant the permission.", - model = R.drawable.camera, - gesturesEnabled = gesturesEnabled, - size = 100.dp - ) { - Box( - modifier = Modifier - .fillMaxSize() - .background(Color.White) - ) { - Column( - modifier = Modifier - .fillMaxSize() - .padding(top = 50.dp) - .verticalScroll(rememberScrollState()), - horizontalAlignment = Alignment.CenterHorizontally, - ) { - Row( - modifier = Modifier - .fillMaxWidth() - .height(50.dp) - .padding(bottom = 5.dp) - .background(Color(0xFFF3EDED)), - horizontalArrangement = Arrangement.Start, - verticalAlignment = Alignment.CenterVertically - ) { - Text( - text = "Have you Deposited the Waste", - color = Color.Black, - fontSize = 16.sp, - fontFamily = monteSB, - modifier = Modifier.padding(start = 13.dp) - ) - } - Row( - modifier = Modifier - .fillMaxWidth() - .padding(top = 0.dp, bottom = 10.dp, start = 10.dp) - .background(Color.White), - horizontalArrangement = Arrangement.spacedBy(15.dp), - verticalAlignment = Alignment.CenterVertically - ) { - depositedWaste.forEach { value -> - Row( - modifier = Modifier - .selectable( - selected = (value == receiver), - role = Role.RadioButton, - onClick = { - receiver = value - } - ) - .padding(10.dp), - verticalAlignment = Alignment.CenterVertically - ) { - Text( - text = value, - color = Color.Black, - fontFamily = monteSB - ) - RadioButton( - selected = (value == receiver), - onClick = { - receiver = value - }, - colors = RadioButtonDefaults.colors( - selectedColor = backGround, - unselectedColor = Color.Gray - ) - ) - } - } - } - Row( - modifier = Modifier - .fillMaxWidth() - .padding(bottom = 0.dp, top = 15.dp) - .height(50.dp) - .background(Color(0xFFF3EDED)), - horizontalArrangement = Arrangement.SpaceBetween, - verticalAlignment = Alignment.CenterVertically - ) { - Text( - text = "Collected All Waste ?", - color = Color.Black, - fontSize = 16.sp, - fontFamily = monteSB, - modifier = Modifier.padding(start = 13.dp) - ) - } - - Row( - modifier = Modifier - .fillMaxWidth() - .padding(top = 0.dp, bottom = 10.dp, start = 10.dp) - .background(Color.White), - horizontalArrangement = Arrangement.spacedBy(15.dp), - verticalAlignment = Alignment.CenterVertically - ) { - radioOptions.forEach { value -> - Row( - modifier = Modifier - .selectable( - selected = (value == receiver), - role = Role.RadioButton, - onClick = { - receiver = value - } - ) - .padding(10.dp), - verticalAlignment = Alignment.CenterVertically - ) { - Text( - text = value, - color = Color.Black, - fontFamily = monteSB - ) - RadioButton( - selected = (value == receiver), - onClick = { - receiver = value - }, - colors = RadioButtonDefaults.colors( - selectedColor = backGround, - unselectedColor = Color.Gray - ) - ) - } - } - } - Row( - modifier = Modifier - .fillMaxWidth() - .padding(bottom = 0.dp, top = 15.dp) - .height(50.dp) - .background(Color(0xFFF3EDED)), - horizontalArrangement = Arrangement.SpaceBetween, - verticalAlignment = Alignment.CenterVertically - ) { - Text( - text = "Proof Of Delivery", - color = Color.Black, - fontSize = 16.sp, - fontFamily = monteSB, - modifier = Modifier.padding(start = 13.dp) - ) - } - Row( - modifier = Modifier - .fillMaxWidth() - .padding(top = 7.dp, bottom = 10.dp, start = 10.dp) - .background(Color.White), - horizontalArrangement = Arrangement.Center, - verticalAlignment = Alignment.CenterVertically - ) { - if (imageBitmap == null) { - Button( - onClick = { - coroutineScope.launch { - if (!permissionState.allPermissionsGranted) { - permissionDrawerState.open() - } else { - launcher.launch( - ActivityOptionsCompat.makeBasic() - ) - } - } - }, - colors = ButtonDefaults.buttonColors( - backgroundColor = Color.Transparent - ), - elevation = ButtonDefaults.elevation(0.dp), - shape = RoundedCornerShape(7.dp), - border = BorderStroke(width = 0.dp, color = backGround) - ) { - Text( - text = "Upload Proof", - color = backGround, - fontFamily = monteSB - ) - } - } else { - Card( - backgroundColor = Color.Transparent, - shape = RoundedCornerShape(7.dp), - modifier = Modifier - .fillMaxWidth() - .padding(start = 20.dp, end = 20.dp, bottom = 25.dp) - ) { - Image( - bitmap = imageBitmap!!, - contentDescription = "", - contentScale = ContentScale.Crop, - ) - } - } - } - } - - - Box( - modifier = Modifier - .fillMaxWidth() - .background(Color(0xFFe2e2e2)), - contentAlignment = Alignment.TopStart - ) { - Text( - text = "Number of pieces: 4", - fontSize = 15.sp, - color = Color.Black, - fontFamily = monteSB, - modifier = Modifier.padding(top = 10.dp, bottom = 10.dp, start = 20.dp), - ) - } - Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.BottomCenter) { - Button( - onClick = { - - }, colors = ButtonDefaults.buttonColors( - backgroundColor = backGround - ), modifier = Modifier - .fillMaxWidth() - .height(45.dp) - .padding(horizontal = 65.dp), - shape = RoundedCornerShape(6.dp) - ) { - Text( - text = "COMPLETE TASK", - color = Color.White, - fontFamily = monteNormal, - fontSize = 15.sp - ) - - } - - } - } - } - } -} - - diff --git a/app/src/main/java/app/waste2wealth/com/tasksDetail/TaskItem.kt b/app/src/main/java/app/waste2wealth/com/tasksDetail/TaskItem.kt deleted file mode 100644 index 09fac81..0000000 --- a/app/src/main/java/app/waste2wealth/com/tasksDetail/TaskItem.kt +++ /dev/null @@ -1,39 +0,0 @@ -package app.waste2wealth.com.tasksDetail - -import app.waste2wealth.com.R - -data class TaskItem( - val locationNumber: String, - val address: String, - val noOfKMs: Int, - val image: Int -) - -data class ExpandedTaskItem( - val orderId: String, - val invoiceId: String, - val amount: Float, - val noOfAttempts: Int -) - -val list = MutableList(size = 19, init = { - TaskItem( - locationNumber = "Mukesh Patil", - address = "Shree Sai MediCare | Shop Number 2/14 Opposite Colgate Maidan, AMrut Nagar," + - " Kherwadi, Bandra East, Mumbai", - noOfKMs = 5, - image = R.drawable.appicon - ) -}) - - - -val expandedList = MutableList(size = 50, init = { - ExpandedTaskItem( - orderId = "KXVFZ", - invoiceId = "ABCDEFGH", - amount = 500.0f, - noOfAttempts = 2 - ) -}) - diff --git a/app/src/main/java/app/waste2wealth/com/tasksDetail/TasksDetailScreen.kt b/app/src/main/java/app/waste2wealth/com/tasksDetail/TasksDetailScreen.kt deleted file mode 100644 index ea57b4c..0000000 --- a/app/src/main/java/app/waste2wealth/com/tasksDetail/TasksDetailScreen.kt +++ /dev/null @@ -1,265 +0,0 @@ -package app.waste2wealth.com.tasksDetail - -import androidx.compose.foundation.Image -import androidx.compose.foundation.background -import androidx.compose.foundation.border -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.width -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.Button -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.Card -import androidx.compose.material.Scaffold -import androidx.compose.material.Text -import androidx.compose.material.rememberScaffoldState -import androidx.compose.runtime.Composable -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 -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.layout.ContentScale -import androidx.compose.ui.platform.LocalConfiguration -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import androidx.navigation.NavHostController -import app.waste2wealth.com.R -import app.waste2wealth.com.components.TasksDetailsAppBar -import app.waste2wealth.com.navigation.Screens -import app.waste2wealth.com.navigation.TaskDetailsConstants -import app.waste2wealth.com.tasksList.CustomRow -import app.waste2wealth.com.tasksList.customShadow -import app.waste2wealth.com.ui.theme.backGround -import app.waste2wealth.com.ui.theme.monteNormal -import app.waste2wealth.com.ui.theme.monteSB - -@Composable -fun TasksDetails( - taskCode: String, - taskPrice: String = "0", - noOfKms: String, - address: String, - phoneNumber: String = "123456789", - image: String, - navHostController: NavHostController, -) { - val scaffoldState = rememberScaffoldState() - val ctx = LocalContext.current - var isDialogVisible by remember { mutableStateOf(false) } - var loadProgress by remember { mutableStateOf(false) } - var isSuccessVisible by remember { mutableStateOf(false) } - val width = LocalConfiguration.current.screenWidthDp - val coroutineScope = rememberCoroutineScope() - Scaffold(scaffoldState = scaffoldState, topBar = { - TasksDetailsAppBar(onClick = { -// val u = Uri.parse("tel:$phoneNumber") -// val i = Intent(Intent.ACTION_DIAL, u) -// ctx.startActivity(i) - }, navHostController = navHostController, text = "Task Detail", isCallVisible = true) - }) { - println(it) - Box( - modifier = Modifier - .fillMaxSize() - .background(Color.White) - ) { - Column(modifier = Modifier.fillMaxWidth()) { - Card( - elevation = 15.dp, - backgroundColor = Color.White, - shape = RoundedCornerShape(7.dp), - modifier = Modifier - .padding(top = 80.dp, end = 20.dp, start = 20.dp) - .customShadow() - ) { - Column(Modifier.fillMaxWidth()) { - Spacer(modifier = Modifier.height(15.dp)) - Row( - horizontalArrangement = Arrangement.Center, - verticalAlignment = Alignment.CenterVertically, - modifier = Modifier.fillMaxWidth() - ) { - CustomRow( - imageVector = painterResource(id = R.drawable.ic_baseline_refresh_24), - textDesc = "$noOfKms Km(s)" - ) - } - Spacer(modifier = Modifier.height(15.dp)) - Row( - horizontalArrangement = Arrangement.SpaceBetween, - verticalAlignment = Alignment.CenterVertically, - modifier = Modifier.fillMaxWidth() - ) { - CustomRow( - imageVector = painterResource(id = R.drawable.locationicon), - textDesc = address, - fontSize = 15.sp - ) - } - Spacer(modifier = Modifier.height(15.dp)) - Row( - horizontalArrangement = Arrangement.Center, - verticalAlignment = Alignment.CenterVertically, - modifier = Modifier - .fillMaxWidth() - .padding(end = 10.dp, bottom = 10.dp) - ) { - Button( - onClick = { /*TODO*/ }, - colors = ButtonDefaults.buttonColors( - backgroundColor = Color.White, - ), - elevation = ButtonDefaults.elevation(0.dp), - shape = RoundedCornerShape(5.dp), - modifier = Modifier - .padding(end = 10.dp) - .border( - width = 1.dp, - color = backGround, - shape = RoundedCornerShape(5.dp) - ) - ) { - CustomRow( - imageVector = painterResource(id = R.drawable.navigation), - textDesc = "Navigate", size = 20.dp - ) - } - - - } - Spacer(modifier = Modifier.height(15.dp)) - } - - - } - Spacer(modifier = Modifier.height(15.dp)) - Card(elevation = 3.dp, - backgroundColor = Color.White, - shape = RoundedCornerShape(7.dp), - modifier = Modifier - .fillMaxWidth() - .padding(20.dp) - .customShadow()) { - Row( - modifier = Modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.Center - ) { - Image( - painter = painterResource(id = image.toInt()), - contentDescription = "", - contentScale = ContentScale.Fit - ) - } - - } - } - Box( - modifier = Modifier - .fillMaxWidth() - .background(Color(0xFFe2e2e2)), - contentAlignment = Alignment.TopStart - ) { - Text( - text = "$taskCode", - fontSize = 15.sp, - color = Color.Black, - fontFamily = monteSB, - modifier = Modifier.padding(top = 10.dp, bottom = 10.dp, start = 20.dp), - ) - } - if (isSuccessVisible) { - Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.BottomStart) { - Button( - onClick = { - navHostController.navigate( - Screens.FailureTask.route + - "?${TaskDetailsConstants.phoneNumber.value}=${phoneNumber}" - ) - - }, colors = ButtonDefaults.buttonColors( - backgroundColor = Color(0xFFfe0000) - ), modifier = Modifier - .width(width = (width / 2.5).dp) - .height(45.dp) - .padding(start = 20.dp), - shape = RoundedCornerShape(6.dp) - ) { - Text( - text = "FAIL", - color = Color.White, - fontFamily = monteNormal, - fontSize = 15.sp, - modifier = Modifier.padding(end = 0.dp) - ) - } - - } - Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.BottomEnd) { - Button( - onClick = { - navHostController.navigate( - Screens.SuccessTask.route + - "?${TaskDetailsConstants.taskPrice.value}=${taskPrice}" - ) - }, colors = ButtonDefaults.buttonColors( - backgroundColor = Color(0xFF008002) - ), modifier = Modifier - .width(width = (width / 2.0).dp) - .height(45.dp) - .padding(horizontal = 20.dp), - shape = RoundedCornerShape(6.dp) - ) { - Text( - text = "SUCCESS", - color = Color.White, - fontFamily = monteNormal, - fontSize = 15.sp, - modifier = Modifier.padding(end = 0.dp) - ) - } - - } - } else { - Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.BottomCenter) { - Button( - onClick = { - isDialogVisible = true - loadProgress = true - }, colors = ButtonDefaults.buttonColors( - backgroundColor = backGround - ), modifier = Modifier - .fillMaxWidth() - .height(45.dp) - .padding(horizontal = 65.dp), - shape = RoundedCornerShape(6.dp) - ) { - Text( - text = "I REACHED", - color = Color.White, - fontFamily = monteNormal, - fontSize = 15.sp - ) - - } - - } - } - - - } - } -} - diff --git a/app/src/main/java/app/waste2wealth/com/tasksList/TasksLists.kt b/app/src/main/java/app/waste2wealth/com/tasksList/TasksLists.kt deleted file mode 100644 index a3223f6..0000000 --- a/app/src/main/java/app/waste2wealth/com/tasksList/TasksLists.kt +++ /dev/null @@ -1,200 +0,0 @@ -package app.waste2wealth.com.tasksList - -import androidx.compose.foundation.background -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.PaddingValues -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.foundation.lazy.itemsIndexed -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.Card -import androidx.compose.material.Icon -import androidx.compose.material.Scaffold -import androidx.compose.material.Text -import androidx.compose.material.rememberScaffoldState -import androidx.compose.runtime.Composable -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.shadow -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.painter.Painter -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.unit.Dp -import androidx.compose.ui.unit.TextUnit -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import androidx.navigation.NavHostController -import app.waste2wealth.com.R -import app.waste2wealth.com.components.TasksListsAppBar -import app.waste2wealth.com.navigation.Screens -import app.waste2wealth.com.navigation.TaskDetailsConstants -import app.waste2wealth.com.tasksDetail.TaskItem -import app.waste2wealth.com.tasksDetail.list -import app.waste2wealth.com.ui.theme.backGround -import app.waste2wealth.com.ui.theme.monteSB - -@Composable -fun TasksLists( - items: List = list, - navHostController: NavHostController, -) { - val tasksList = mutableListOf() - LaunchedEffect(key1 = Unit){ - - } - val scaffoldState = rememberScaffoldState() - Scaffold(scaffoldState = scaffoldState, topBar = { - TasksListsAppBar(navHostController = navHostController) - }) { - println(it) - Box( - modifier = Modifier - .fillMaxSize() - .background(Color.White) - ) { - - Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { - Spacer(modifier = Modifier.height(50.dp)) - LazyColumn( - verticalArrangement = Arrangement.Center, - contentPadding = PaddingValues(bottom = 100.dp, top = 50.dp) - ) { - itemsIndexed(tasksList) { index, taskItem -> - Card( - elevation = 3.dp, - backgroundColor = Color.White, - shape = RoundedCornerShape(7.dp), - modifier = Modifier - .padding(20.dp) - .customShadow() - .clickable { -// isExpanded = !isExpanded - - navHostController.navigate( - Screens.TaskDetail.route + - "?${TaskDetailsConstants.taskCode.value}=${taskItem.locationNumber}" + - "?${TaskDetailsConstants.address.value}=${taskItem.address}" + - "?${TaskDetailsConstants.noOfAttempts.value}=${taskItem.noOfKMs}" + - "?${TaskDetailsConstants.taskPrice.value}=${taskItem.image}" - ) - - - } - - ) { - Column(Modifier.fillMaxWidth()) { - Row( - horizontalArrangement = Arrangement.SpaceBetween, - verticalAlignment = Alignment.CenterVertically, - modifier = Modifier.fillMaxWidth() - ) { - CustomRow( - imageVector = painterResource(id = R.drawable.name), - textDesc = taskItem.locationNumber - ) - Card( - elevation = 0.dp, - backgroundColor = Color(0xFFe9fbfb), - shape = RoundedCornerShape(100.dp), - modifier = Modifier.padding(top = 5.dp, end = 10.dp) - ) { - Text( - text = " ${taskItem.noOfKMs} Km(s)", - color = Color.Black, - fontSize = 12.sp, - fontFamily = monteSB, - modifier = Modifier.padding(10.dp) - ) - } - } - Spacer(modifier = Modifier.height(15.dp)) - - Spacer(modifier = Modifier.height(15.dp)) - Row( - horizontalArrangement = Arrangement.SpaceBetween, - verticalAlignment = Alignment.CenterVertically, - modifier = Modifier.fillMaxWidth() - ) { - CustomRow( - imageVector = painterResource(id = R.drawable.locationicon), - textDesc = taskItem.address, - fontSize = 15.sp - ) - } - Spacer(modifier = Modifier.height(18.dp)) - Spacer(modifier = Modifier.height(15.dp)) - } - } - - - } - } - - - } - Box( - modifier = Modifier - .fillMaxWidth() - .background(Color(0xFFe2e2e2)), - contentAlignment = Alignment.TopStart - ) { - Text( - text = "10 Tasks Pending", - fontSize = 15.sp, - color = Color.Black, - fontFamily = monteSB, - modifier = Modifier.padding(top = 10.dp, bottom = 10.dp, start = 20.dp), - ) - } - - } - } - -} - -@Composable -fun CustomRow( - imageVector: Painter, - textDesc: String, - size: Dp = 15.dp, - fontSize: TextUnit = 13.sp, -) { - Row( - horizontalArrangement = Arrangement.spacedBy(5.dp), - verticalAlignment = Alignment.CenterVertically - ) { - Icon( - painter = imageVector, - contentDescription = "", - tint = backGround, - modifier = Modifier - .padding(start = 10.dp) - .size(size) - ) - Text( - text = textDesc, - color = Color.Black, - fontSize = fontSize, - fontFamily = monteSB, - modifier = Modifier.padding(end = 15.dp) - ) - } -} - -fun Modifier.customShadow(): Modifier { - return shadow( - elevation = 13.dp, - shape = RoundedCornerShape(7.dp), - spotColor = Color(0xFFC7C4C4) - ) -} \ No newline at end of file From 747b6e8f50e0e5d4452ba319b758b72453eb9bb2 Mon Sep 17 00:00:00 2001 From: Kailash Sharma Date: Fri, 15 Sep 2023 04:37:35 +0530 Subject: [PATCH 2/2] Clean up build.gradle --- app/build.gradle.kts | 6 - .../com/challenges/ChallengesSection.kt | 296 ------------- .../app/waste2wealth/com/challenges/Tabs.kt | 409 ------------------ .../com/collectwaste/ListOfCollectWaste.kt | 6 - .../app/waste2wealth/com/maps/MapBoxMap.kt | 27 +- .../app/waste2wealth/com/maps/MapsScreen.kt | 59 +-- .../com/navigation/NavigationController.kt | 2 +- gradle/libs.version.toml | 2 - 8 files changed, 49 insertions(+), 758 deletions(-) delete mode 100644 app/src/main/java/app/waste2wealth/com/challenges/ChallengesSection.kt delete mode 100644 app/src/main/java/app/waste2wealth/com/challenges/Tabs.kt diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 2340f4d..7498458 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -99,7 +99,6 @@ dependencies { //Material Extended implementation(libs.material.icons.extended) - implementation("io.github.vanpra.compose-material-dialogs:core:0.9.0") //HorizontalPager implementation(libs.accompanist.pager) @@ -126,8 +125,6 @@ dependencies { implementation(libs.firebase.auth.ktx) implementation(libs.firebase.storage) - //Stacked Cards - implementation(libs.stacked.cards) //Compose ConstraintLayout implementation(libs.androidx.constraintlayout.compose) @@ -150,9 +147,6 @@ dependencies { implementation(libs.camera.core) implementation(libs.camera.camera2) - //Barcode - implementation(libs.google.mlkit) - // MapBox implementation("com.mapbox.maps:android:10.14.0") diff --git a/app/src/main/java/app/waste2wealth/com/challenges/ChallengesSection.kt b/app/src/main/java/app/waste2wealth/com/challenges/ChallengesSection.kt deleted file mode 100644 index 819e8dd..0000000 --- a/app/src/main/java/app/waste2wealth/com/challenges/ChallengesSection.kt +++ /dev/null @@ -1,296 +0,0 @@ -package app.waste2wealth.com.challenges - -import android.Manifest -import androidx.compose.foundation.ExperimentalFoundationApi -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.offset -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.material.BottomDrawerValue -import androidx.compose.material.ExperimentalMaterialApi -import androidx.compose.material.Icon -import androidx.compose.material.Scaffold -import androidx.compose.material.Tab -import androidx.compose.material.TabRow -import androidx.compose.material.TabRowDefaults -import androidx.compose.material.Text -import androidx.compose.material.rememberBottomDrawerState -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue -import androidx.compose.ui.Alignment -import androidx.compose.ui.ExperimentalComposeUiApi -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.rotate -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.layout.layout -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import androidx.navigation.NavHostController -import app.waste2wealth.com.R -import app.waste2wealth.com.bottombar.BottomBar -import app.waste2wealth.com.components.permissions.PermissionDrawer -import app.waste2wealth.com.firebase.firestore.ProfileInfo -import app.waste2wealth.com.ui.theme.appBackground -import app.waste2wealth.com.ui.theme.monteBold -import app.waste2wealth.com.ui.theme.monteNormal -import app.waste2wealth.com.ui.theme.textColor -import com.google.accompanist.permissions.ExperimentalPermissionsApi -import com.google.accompanist.permissions.rememberMultiplePermissionsState -import com.jet.firestore.JetFirestore -import com.jet.firestore.getListOfObjects - -@OptIn( - ExperimentalMaterialApi::class, ExperimentalFoundationApi::class, - ExperimentalPermissionsApi::class, ExperimentalComposeUiApi::class -) -@Composable -fun Community( - navController: NavHostController, - email: String, - name: String, - pfp: String -) { - - val cList = listOf("Challenges", "Clubs", "Posts") - var tabIndex by remember { mutableStateOf(0) } - val permissionState = rememberMultiplePermissionsState( - permissions = listOf( - Manifest.permission.ACCESS_FINE_LOCATION, - Manifest.permission.ACCESS_COARSE_LOCATION - ) - ) - val permissionDrawerState = rememberBottomDrawerState( - if (permissionState.allPermissionsGranted) BottomDrawerValue.Closed else BottomDrawerValue.Open - ) - var profileList by remember { - mutableStateOf?>(null) - } - var userAddress by remember { - mutableStateOf("") - } - var phoneNumber by remember { - mutableStateOf("") - } - var gender by remember { - mutableStateOf("") - } - var organization by remember { - mutableStateOf("") - } - var pointsEarned by remember { - mutableStateOf(0) - } - var pointsRedeemed by remember { - mutableStateOf(0) - } - var noOfTimesReported by remember { - mutableStateOf(0) - } - var noOfTimesCollected by remember { - mutableStateOf(0) - } - var noOfTimesActivity by remember { - mutableStateOf(0) - } - JetFirestore(path = { - collection("ProfileInfo") - }, onRealtimeCollectionFetch = { value, _ -> - profileList = value?.getListOfObjects() - }) { - if (profileList != null) { - for (i in profileList!!) { - if (i.email == email) { - userAddress = i.address ?: "" - gender = i.gender ?: "" - phoneNumber = i.phoneNumber ?: "" - organization = i.organization ?: "" - pointsEarned = i.pointsEarned - pointsRedeemed = i.pointsRedeemed - noOfTimesReported = i.noOfTimesReported - noOfTimesCollected = i.noOfTimesCollected - noOfTimesActivity = i.noOfTimesActivity - } - } - } - PermissionDrawer( - drawerState = permissionDrawerState, - permissionState = permissionState, - rationaleText = "To continue, allow Report Waste2Wealth to access your device's location" + - ". Tap Settings > Permission, and turn \"Access Location On\" on.", - withoutRationaleText = "Location permission required for functionality of this app." + - " Please grant the permission.", - ) { - Scaffold(bottomBar = { - BottomBar(navController = navController) - }) { - println(it) - Column( - modifier = Modifier - .fillMaxSize() - .background(appBackground) - ) { - Row( - modifier = Modifier - .fillMaxWidth() - .padding( - top = 35.dp, - bottom = 35.dp, - start = 20.dp, - end = 20.dp - ), - horizontalArrangement = Arrangement.SpaceBetween, - verticalAlignment = Alignment.CenterVertically - ) { - Text( - text = "Community", - color = textColor, - fontSize = 35.sp, - fontFamily = monteBold, - ) - Row( - modifier = Modifier - .fillMaxWidth() - .padding(top = 15.dp, end = 0.dp, start = 20.dp), - horizontalArrangement = Arrangement.End, - verticalAlignment = Alignment.CenterVertically - ) { - Row( - modifier = Modifier.padding(end = 25.dp), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.End - ) { - Icon( - painter = painterResource(id = R.drawable.coins), - contentDescription = "coins", - modifier = Modifier - .size(40.dp) - .padding(end = 5.dp), - tint = Color.Unspecified - ) - Text( - text = pointsEarned.toString(), - color = textColor, - fontSize = 15.sp, - softWrap = true, - fontFamily = monteNormal, - ) - } - - } - } - -// Column( -// modifier = Modifier -// .fillMaxWidth() -// .padding(start = 35.dp, end = 35.dp) -// ) { -// TabRow( -// selectedTabIndex = tabIndex, -// backgroundColor = appBackground, -// contentColor = textColor, -// divider = { -// TabRowDefaults.Divider( -// color = Color(0xFFF37952), -// thickness = 1.dp -// ) -// }, -// ) { -// cList.forEachIndexed { index, title -> -// Tab(text = { -// Text( -// title, -// softWrap = false, -// fontSize = 13.sp, -// ) -// }, -// selected = tabIndex == index, -// onClick = { tabIndex = index } -// ) -// } -// -// } -// } - Row( - modifier = Modifier - .offset(y = (-50).dp) - .fillMaxWidth() - .weight(1f) - .padding(20.dp), - verticalAlignment = Alignment.CenterVertically, - ) { - Column(horizontalAlignment = Alignment.CenterHorizontally) { - Icon( - painter = painterResource(id = R.drawable.kright), - contentDescription = "", - tint = Color.Unspecified, - modifier = Modifier - .rotate(180f) - .size(15.dp) - .padding(end = 0.dp) - ) - - Text( - modifier = Modifier - .vertical() - .rotate(-90f) - .background(appBackground) - .padding(end = 20.dp), - text = "Comment", - ) - - Spacer(modifier = Modifier.height(50.dp)) - Text( - modifier = Modifier - .vertical() - .rotate(-90f) - .background(appBackground) - .padding(end = 20.dp), - text = " Kudos", - ) - Icon( - painter = painterResource(id = R.drawable.kright), - contentDescription = "", - tint = Color.Unspecified, - modifier = Modifier - .size(15.dp) - .padding(end = 0.dp) - ) - - } - when (tabIndex) { - 0 -> Challenges() - 1 -> Clubs() - 2 -> Posts() - } - } - - - } - } - } - } -} - - -fun Modifier.vertical() = - layout { measurable, constraints -> - val placeable = measurable.measure(constraints) - layout(placeable.height, placeable.width) { - placeable.place( - x = -(placeable.width / 2 - placeable.height / 2), - y = -(placeable.height / 2 - placeable.width / 2) - ) - } - } - diff --git a/app/src/main/java/app/waste2wealth/com/challenges/Tabs.kt b/app/src/main/java/app/waste2wealth/com/challenges/Tabs.kt deleted file mode 100644 index e443efa..0000000 --- a/app/src/main/java/app/waste2wealth/com/challenges/Tabs.kt +++ /dev/null @@ -1,409 +0,0 @@ -package app.waste2wealth.com.challenges - -import androidx.compose.foundation.border -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.Button -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.Card -import androidx.compose.material.ExperimentalMaterialApi -import androidx.compose.material.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import app.waste2wealth.com.firebase.firestore.challengesList -import app.waste2wealth.com.profile.ProfileImage -import app.waste2wealth.com.ui.theme.appBackground -import app.waste2wealth.com.ui.theme.monteBold -import app.waste2wealth.com.ui.theme.monteSB -import app.waste2wealth.com.ui.theme.textColor -import com.omercemcicekli.cardstack.CardStack -import com.omercemcicekli.cardstack.HorizontalAlignment -import com.omercemcicekli.cardstack.HorizontalAnimationStyle -import com.omercemcicekli.cardstack.Orientation - -@OptIn(ExperimentalMaterialApi::class) -@Composable -fun Challenges() { - Row( - modifier = Modifier.fillMaxSize(), - horizontalArrangement = Arrangement.Center, - verticalAlignment = Alignment.CenterVertically - ) { - CardStack( - { index -> - Card( - backgroundColor = appBackground, - shape = RoundedCornerShape(7.dp), - modifier = Modifier - ) { - Column { - - Row( - modifier = Modifier - .fillMaxWidth(0.9f) - .padding(horizontal = 0.dp), - horizontalArrangement = Arrangement.Center - ) { - ProfileImage( - imageUrl = challengesList[index].image, - modifier = Modifier - .fillMaxWidth(0.65f) - .size(200.dp) - .border( - width = 1.dp, - color = appBackground, - shape = RoundedCornerShape(45.dp) - ) - .padding(3.dp) - .clip(RoundedCornerShape(30.dp)), - ) - } - - Spacer(modifier = Modifier.height(10.dp)) - Text( - text = challengesList[index].title, - color = textColor, - fontSize = 20.sp, - fontFamily = monteBold, - modifier = Modifier.padding(horizontal = 10.dp) - ) - Spacer(modifier = Modifier.height(10.dp)) - Text( - text = "When", - color = Color(0xFFF37952), - fontSize = 12.sp, - fontFamily = monteBold, - modifier = Modifier.padding(horizontal = 10.dp) - ) - Spacer(modifier = Modifier.height(10.dp)) - Text( - text = challengesList[index].date, - color = textColor, - fontSize = 15.sp, - fontFamily = monteBold, - modifier = Modifier.padding(horizontal = 10.dp) - ) - Spacer(modifier = Modifier.height(10.dp)) - Text( - text = "Where", - color = Color(0xFFF37952), - fontSize = 12.sp, - fontFamily = monteBold, - modifier = Modifier.padding(horizontal = 10.dp) - ) - Spacer(modifier = Modifier.height(10.dp)) - Text( - text = challengesList[index].location, - color = textColor, - fontSize = 15.sp, - fontFamily = monteBold, - modifier = Modifier.padding(horizontal = 10.dp) - ) - Spacer(modifier = Modifier.height(10.dp)) - Text( - text = "Time", - color = Color(0xFFF37952), - fontSize = 12.sp, - fontFamily = monteBold, - modifier = Modifier.padding(horizontal = 10.dp) - ) - Spacer(modifier = Modifier.height(10.dp)) - Text( - text = challengesList[index].time, - color = textColor, - fontSize = 15.sp, - fontFamily = monteBold, - modifier = Modifier.padding(horizontal = 10.dp) - ) - Spacer(modifier = Modifier.height(10.dp)) - Button( - onClick = { /*TODO*/ }, - colors = ButtonDefaults.buttonColors( - backgroundColor = Color(0xFFFD5065), - contentColor = Color.White - ), - shape = RoundedCornerShape(35.dp), - modifier = Modifier.padding(start = 10.dp) - ) { - Text( - text = "Register Now", - color = Color.White, - fontSize = 12.sp, - fontFamily = monteSB, - modifier = Modifier.padding(bottom = 4.dp), - maxLines = 1, - softWrap = true - ) - } - Spacer(modifier = Modifier.height(10.dp)) - } - - - } - }, - cardCount = challengesList.size, - paddingBetweenCards = 55.dp, - orientation = Orientation.Horizontal( - alignment = HorizontalAlignment.StartToEnd, - animationStyle = HorizontalAnimationStyle.FromTop - ) - - ) - } -} - -@OptIn(ExperimentalMaterialApi::class) -@Composable -fun Clubs() { - Row( - modifier = Modifier.fillMaxSize(), - horizontalArrangement = Arrangement.Center, - verticalAlignment = Alignment.CenterVertically - ) { - CardStack( - { index -> - Card( - backgroundColor = appBackground, - shape = RoundedCornerShape(7.dp), - modifier = Modifier - ) { - Column { - - Row( - modifier = Modifier - .fillMaxWidth(0.9f) - .padding(horizontal = 0.dp), - horizontalArrangement = Arrangement.Center - ) { - ProfileImage( - imageUrl = challengesList[index].image, - modifier = Modifier - .fillMaxWidth(0.65f) - .size(200.dp) - .border( - width = 1.dp, - color = appBackground, - shape = RoundedCornerShape(45.dp) - ) - .padding(3.dp) - .clip(RoundedCornerShape(30.dp)), - ) - } - - Spacer(modifier = Modifier.height(10.dp)) - Text( - text = challengesList[index].title, - color = textColor, - fontSize = 20.sp, - fontFamily = monteBold, - modifier = Modifier.padding(horizontal = 10.dp) - ) - Spacer(modifier = Modifier.height(10.dp)) - Text( - text = "Location", - color = Color(0xFFF37952), - fontSize = 12.sp, - fontFamily = monteBold, - modifier = Modifier.padding(horizontal = 10.dp) - ) - Spacer(modifier = Modifier.height(10.dp)) - Text( - text = challengesList[index].date, - color = textColor, - fontSize = 15.sp, - fontFamily = monteBold, - modifier = Modifier.padding(horizontal = 10.dp) - ) - Spacer(modifier = Modifier.height(10.dp)) - Text( - text = "Since", - color = Color(0xFFF37952), - fontSize = 12.sp, - fontFamily = monteBold, - modifier = Modifier.padding(horizontal = 10.dp) - ) - Spacer(modifier = Modifier.height(10.dp)) - Text( - text = challengesList[index].location, - color = textColor, - fontSize = 15.sp, - fontFamily = monteBold, - modifier = Modifier.padding(horizontal = 10.dp) - ) - Spacer(modifier = Modifier.height(10.dp)) - Text( - text = "Frequency", - color = Color(0xFFF37952), - fontSize = 12.sp, - fontFamily = monteBold, - modifier = Modifier.padding(horizontal = 10.dp) - ) - Spacer(modifier = Modifier.height(10.dp)) - Text( - text = challengesList[index].time, - color = textColor, - fontSize = 15.sp, - fontFamily = monteBold, - modifier = Modifier.padding(horizontal = 10.dp) - ) - Spacer(modifier = Modifier.height(10.dp)) - Button( - onClick = { /*TODO*/ }, - colors = ButtonDefaults.buttonColors( - backgroundColor = Color(0xFFFD5065), - contentColor = Color.White - ), - shape = RoundedCornerShape(35.dp), - modifier = Modifier.padding(start = 10.dp) - ) { - Text( - text = "Join Now", - color = Color.White, - fontSize = 12.sp, - fontFamily = monteSB, - modifier = Modifier.padding(bottom = 4.dp), - maxLines = 1, - softWrap = true - ) - } - Spacer(modifier = Modifier.height(10.dp)) - } - - - } - }, - cardCount = challengesList.size, - paddingBetweenCards = 55.dp, - orientation = Orientation.Horizontal( - alignment = HorizontalAlignment.StartToEnd, - animationStyle = HorizontalAnimationStyle.FromTop - ) - - ) - } -} - -@OptIn(ExperimentalMaterialApi::class) -@Composable -fun Posts() { - Row( - modifier = Modifier.fillMaxSize(), - horizontalArrangement = Arrangement.Center, - verticalAlignment = Alignment.CenterVertically - ) { - CardStack( - { index -> - Card( - backgroundColor = appBackground, - shape = RoundedCornerShape(7.dp), - modifier = Modifier - ) { - Column { - - Row( - modifier = Modifier - .fillMaxWidth(0.9f) - .padding(horizontal = 0.dp), - horizontalArrangement = Arrangement.Center - ) { - ProfileImage( - imageUrl = challengesList[index].image, - modifier = Modifier - .fillMaxWidth(0.65f) - .size(200.dp) - .border( - width = 1.dp, - color = appBackground, - shape = RoundedCornerShape(45.dp) - ) - .padding(3.dp) - .clip(RoundedCornerShape(30.dp)), - ) - } - - Spacer(modifier = Modifier.height(10.dp)) - Text( - text = challengesList[index].title, - color = textColor, - fontSize = 20.sp, - fontFamily = monteBold, - modifier = Modifier.padding(horizontal = 10.dp) - ) - Spacer(modifier = Modifier.height(10.dp)) - Text( - text = "Points Earned", - color = Color(0xFFF37952), - fontSize = 12.sp, - fontFamily = monteBold, - modifier = Modifier.padding(horizontal = 10.dp) - ) - Spacer(modifier = Modifier.height(10.dp)) - Text( - text = challengesList[index].date, - color = textColor, - fontSize = 15.sp, - fontFamily = monteBold, - modifier = Modifier.padding(horizontal = 10.dp) - ) - Spacer(modifier = Modifier.height(10.dp)) - Text( - text = "Time Contributed", - color = Color(0xFFF37952), - fontSize = 12.sp, - fontFamily = monteBold, - modifier = Modifier.padding(horizontal = 10.dp) - ) - Spacer(modifier = Modifier.height(10.dp)) - Text( - text = challengesList[index].location, - color = textColor, - fontSize = 15.sp, - fontFamily = monteBold, - modifier = Modifier.padding(horizontal = 10.dp) - ) - Spacer(modifier = Modifier.height(10.dp)) - Text( - text = "Upvotes", - color = Color(0xFFF37952), - fontSize = 12.sp, - fontFamily = monteBold, - modifier = Modifier.padding(horizontal = 10.dp) - ) - Spacer(modifier = Modifier.height(10.dp)) - Text( - text = challengesList[index].time, - color = textColor, - fontSize = 15.sp, - fontFamily = monteBold, - modifier = Modifier.padding(horizontal = 10.dp) - ) - Spacer(modifier = Modifier.height(10.dp)) - - } - - - } - }, - cardCount = challengesList.size, - paddingBetweenCards = 55.dp, - orientation = Orientation.Horizontal( - alignment = HorizontalAlignment.StartToEnd, - animationStyle = HorizontalAnimationStyle.FromTop - ) - - ) - } -} \ No newline at end of file diff --git a/app/src/main/java/app/waste2wealth/com/collectwaste/ListOfCollectWaste.kt b/app/src/main/java/app/waste2wealth/com/collectwaste/ListOfCollectWaste.kt index ae0bc52..81e646a 100644 --- a/app/src/main/java/app/waste2wealth/com/collectwaste/ListOfCollectWaste.kt +++ b/app/src/main/java/app/waste2wealth/com/collectwaste/ListOfCollectWaste.kt @@ -47,12 +47,6 @@ import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.navigation.NavHostController -import app.waste2wealth.com.R -import app.waste2wealth.com.bottombar.BottomBar -import app.waste2wealth.com.challenges.Challenges -import app.waste2wealth.com.challenges.Clubs -import app.waste2wealth.com.challenges.Posts -import app.waste2wealth.com.components.permissions.PermissionDrawer import app.waste2wealth.com.firebase.firestore.WasteItem import app.waste2wealth.com.location.LocationViewModel import app.waste2wealth.com.maps.MapScreen diff --git a/app/src/main/java/app/waste2wealth/com/maps/MapBoxMap.kt b/app/src/main/java/app/waste2wealth/com/maps/MapBoxMap.kt index 55454fb..ca7fad0 100644 --- a/app/src/main/java/app/waste2wealth/com/maps/MapBoxMap.kt +++ b/app/src/main/java/app/waste2wealth/com/maps/MapBoxMap.kt @@ -3,7 +3,6 @@ package app.waste2wealth.com.maps import android.content.Context import android.graphics.Bitmap import android.graphics.Canvas -import android.graphics.Color.rgb import android.graphics.drawable.BitmapDrawable import android.graphics.drawable.Drawable import android.util.Log @@ -17,9 +16,7 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.res.stringResource import androidx.compose.ui.viewinterop.AndroidView -import androidx.core.graphics.drawable.toBitmap import app.waste2wealth.com.R import com.mapbox.android.gestures.StandardScaleGestureDetector import com.mapbox.geojson.Point @@ -89,8 +86,10 @@ fun MapBoxMap( } } ) - isScalingOut(mapView) { + isScalingOut(mapView = mapView, onScaleOutClick = { isClicked.value = false + } ) { + isClicked.value = true } mapView.getMapboxMap().flyTo( cameraOptions, @@ -110,9 +109,10 @@ fun MapBoxMap( } }, update = { mapView -> - isScalingOut(mapView) { + isScalingOut(mapView = mapView, onScaleOutClick = { isClicked.value = false - isReset.value = true + } ) { + isClicked.value = true } val cameraOptions = if (isReset.value) CameraOptions.Builder() .center(currentLocation) @@ -214,24 +214,31 @@ private fun convertDrawableToBitmap(sourceDrawable: Drawable?): Bitmap? { fun isScalingOut( mapView: MapView, - onClick: () -> Unit = {} + onScaleOutClick: () -> Unit = {}, + onScaleInClick: () -> Unit = {} ) { mapView.gestures.addOnScaleListener(object : OnScaleListener { override fun onScale(detector: StandardScaleGestureDetector) { if (detector.isScalingOut) { - onClick() + onScaleOutClick() + } else { + onScaleInClick() } } override fun onScaleBegin(detector: StandardScaleGestureDetector) { if (detector.isScalingOut) { - onClick() + onScaleOutClick() + } else { + onScaleInClick() } } override fun onScaleEnd(detector: StandardScaleGestureDetector) { if (detector.isScalingOut) { - onClick() + onScaleOutClick() + } else { + onScaleInClick() } } diff --git a/app/src/main/java/app/waste2wealth/com/maps/MapsScreen.kt b/app/src/main/java/app/waste2wealth/com/maps/MapsScreen.kt index 927e6af..f6718c4 100644 --- a/app/src/main/java/app/waste2wealth/com/maps/MapsScreen.kt +++ b/app/src/main/java/app/waste2wealth/com/maps/MapsScreen.kt @@ -12,6 +12,7 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height @@ -54,6 +55,7 @@ import app.waste2wealth.com.collectwaste.getTimeAgo import app.waste2wealth.com.components.permissions.PermissionDrawer import app.waste2wealth.com.firebase.firestore.WasteItem import app.waste2wealth.com.location.LocationViewModel +import app.waste2wealth.com.profile.ProfileImage import app.waste2wealth.com.ui.theme.CardColor import app.waste2wealth.com.ui.theme.CardTextColor import app.waste2wealth.com.ui.theme.appBackground @@ -233,40 +235,41 @@ fun MapScreen(viewModel: LocationViewModel, paddingValues: PaddingValues) { } } } - } - Box( - modifier = Modifier - .fillMaxSize() - .padding(horizontal = 10.dp, vertical = 25.dp), - contentAlignment = Alignment.TopEnd - ) { - Card( + Box( modifier = Modifier - .padding(end = 10.dp), - shape = RoundedCornerShape(10.dp), - elevation = 10.dp + .fillMaxSize() + .padding(horizontal = 10.dp, vertical = 25.dp), + contentAlignment = Alignment.TopEnd ) { - Button( - onClick = { - isReset.value = true - isClicked.value = false - - }, + Card( + modifier = Modifier + .padding(end = 10.dp), shape = RoundedCornerShape(10.dp), - colors = ButtonDefaults.buttonColors( - backgroundColor = CardColor, - contentColor = CardTextColor - ) + elevation = 10.dp ) { - Text( - text = "Reset", - color = CardTextColor, - fontSize = 10.sp, - fontWeight = FontWeight.Normal - ) - } + Button( + onClick = { + isReset.value = true + isClicked.value = false + + }, + shape = RoundedCornerShape(10.dp), + colors = ButtonDefaults.buttonColors( + backgroundColor = CardColor, + contentColor = CardTextColor + ) + ) { + Text( + text = "Reset", + color = CardTextColor, + fontSize = 10.sp, + fontWeight = FontWeight.Normal + ) + } + } } } + } } diff --git a/app/src/main/java/app/waste2wealth/com/navigation/NavigationController.kt b/app/src/main/java/app/waste2wealth/com/navigation/NavigationController.kt index 177b347..5e05ec6 100644 --- a/app/src/main/java/app/waste2wealth/com/navigation/NavigationController.kt +++ b/app/src/main/java/app/waste2wealth/com/navigation/NavigationController.kt @@ -35,7 +35,7 @@ import app.waste2wealth.com.rewards.RewardDetails import com.google.accompanist.navigation.animation.AnimatedNavHost import com.google.accompanist.navigation.animation.composable -@OptIn(ExperimentalAnimationApi::class, ExperimentalMaterialApi::class) +@OptIn(ExperimentalAnimationApi::class) @Composable fun NavigationController( scaffoldState: ScaffoldState, diff --git a/gradle/libs.version.toml b/gradle/libs.version.toml index 4d4f938..87e6471 100644 --- a/gradle/libs.version.toml +++ b/gradle/libs.version.toml @@ -41,7 +41,6 @@ accompanist-pager = { module = "com.google.accompanist:accompanist-pager", versi accompanist-pager-indicators = { module = "com.google.accompanist:accompanist-pager-indicators", version.ref = "accompanist" } core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "core-ktx" } junit = { group = "junit", name = "junit", version.ref = "junit" } -stacked-cards = { group = "com.github.omercemcicekli", name = "CardStack", version = "0.0.6" } firebase-bom = { group = "com.google.firebase", name = "firebase-bom", version.ref = "firebase-bom" } firebase-jet-firestore = { group = "com.github.raipankaj", name = "JetFirestore", version.ref = "jetFirestore" } lottie = { group = "com.airbnb.android", name = "lottie-compose", version = "5.2.0" } @@ -84,7 +83,6 @@ camera-lifecycle = { group = "androidx.camera", name = "camera-lifecycle", versi camera-view = { group = "androidx.camera", name = "camera-view", version = "1.3.0-alpha07" } camera-core = { group = "androidx.camera", name = "camera-core", version.ref = "camera-core" } camera-camera2 = { group = "androidx.camera", name = "camera-camera2", version.ref = "camera-core" } -google-mlkit = { group = "com.google.mlkit", name = "barcode-scanning", version.ref = "mlkit" } pager = { group = "com.google.accompanist", name = "accompanist-pager", version.ref = "pager" }