Skip to content

Commit

Permalink
add mapbox
Browse files Browse the repository at this point in the history
  • Loading branch information
thekaailashsharma committed Sep 14, 2023
1 parent 2bb0e5d commit 16e0fe0
Show file tree
Hide file tree
Showing 57 changed files with 2,152 additions and 122 deletions.
10 changes: 0 additions & 10 deletions .idea/deploymentTargetDropDown.xml

This file was deleted.

20 changes: 20 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ plugins {

android {
namespace = "app.waste2wealth.com"
compileSdk = 33
compileSdk = 34

lint {
abortOnError = false
}
defaultConfig {
applicationId = "app.waste2wealth.com"
minSdk = 27
targetSdk = 33
targetSdk = 34
versionCode = 1
versionName = "1.0"

Expand Down Expand Up @@ -132,6 +132,16 @@ dependencies {
//Compose ConstraintLayout
implementation(libs.androidx.constraintlayout.compose)

implementation("com.mapbox.maps:android:10.14.0")

// // Maps
// implementation("com.google.android.gms:play-services-location:21.0.1")
// implementation("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.6.4")
// implementation("com.mapbox.maps:android:10.14.0")
// implementation("com.mapbox.mapboxsdk:mapbox-android-gestures:0.8.0")
// implementation("com.mapbox.navigation:ui-dropin:2.14.2")
// implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.3.1")

//Ktor-Client
implementation("io.ktor:ktor-client-core:1.6.3")
implementation("io.ktor:ktor-client-cio:1.6.3")
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,37 +190,37 @@ fun Community(
}
}

// 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 }
// )
// }
//
// }
// }
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ import androidx.compose.material.Card
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.icons.Icons
import androidx.compose.material.icons.filled.ArrowBackIos
Expand All @@ -46,9 +49,13 @@ 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
import app.waste2wealth.com.navigation.Screens
import app.waste2wealth.com.ui.theme.CardColor
import app.waste2wealth.com.ui.theme.appBackground
Expand Down Expand Up @@ -143,60 +150,101 @@ fun CollectWaste(
}
}

Spacer(modifier = Modifier.height(30.dp))
if (allWastes != null) {
LazyColumn(
contentPadding = PaddingValues(
bottom = 150.dp,
top = 40.dp
)
val cList = listOf("List View", "Map View (Beta)")
var tabIndex by remember { mutableStateOf(0) }
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
)
},
) {
allWastes = allWastes?.sortedBy {
distance(
viewModel.latitude,
viewModel.longitude,
it.latitude,
it.longitude
cList.forEachIndexed { index, title ->
Tab(text = {
Text(
title,
softWrap = false,
fontSize = 13.sp,
)
},
selected = tabIndex == index,
onClick = { tabIndex = index }
)
}
itemsIndexed(allWastes ?: emptyList()) { index, wasteItem ->
WasteItemCard(
locationNo = "Location ${index + 1}",
address = wasteItem.address,
distance = "${
convertDistance(
distance(
viewModel.latitude,
viewModel.longitude,
wasteItem.latitude,
wasteItem.longitude

}

}
if (tabIndex == 0) {
Spacer(modifier = Modifier.height(30.dp))
if (allWastes != null) {
LazyColumn(
contentPadding = PaddingValues(
bottom = 150.dp,
top = 40.dp
)
) {
allWastes = allWastes?.sortedBy {
distance(
viewModel.latitude,
viewModel.longitude,
it.latitude,
it.longitude
)
}
itemsIndexed(allWastes ?: emptyList()) { index, wasteItem ->
WasteItemCard(
locationNo = "Location ${index + 1}",
address = wasteItem.address,
distance = "${
convertDistance(
distance(
viewModel.latitude,
viewModel.longitude,
wasteItem.latitude,
wasteItem.longitude
)
)
)
} away",
time = getTimeAgo(wasteItem.timeStamp),
) {
viewModel.locationNo.value = "Location ${index + 1}"
viewModel.address.value = wasteItem.address
viewModel.distance.value = "${
convertDistance(
distance(
viewModel.latitude,
viewModel.longitude,
wasteItem.latitude,
wasteItem.longitude
} away",
time = getTimeAgo(wasteItem.timeStamp),
) {
viewModel.locationNo.value = "Location ${index + 1}"
viewModel.address.value = wasteItem.address
viewModel.distance.value = "${
convertDistance(
distance(
viewModel.latitude,
viewModel.longitude,
wasteItem.latitude,
wasteItem.longitude
)
)
)
} away"
viewModel.time.value = getTimeAgo(wasteItem.timeStamp)
viewModel.wastePhoto.value = wasteItem.imagePath
viewModel.theirLatitude.value = wasteItem.latitude
viewModel.theirLongitude.value = wasteItem.longitude
println("Collected time ${viewModel.time.value}")
navController.navigate(Screens.CollectWasteInfo.route)
}
} away"
viewModel.time.value = getTimeAgo(wasteItem.timeStamp)
viewModel.wastePhoto.value = wasteItem.imagePath
viewModel.theirLatitude.value = wasteItem.latitude
viewModel.theirLongitude.value = wasteItem.longitude
println("Collected time ${viewModel.time.value}")
navController.navigate(Screens.CollectWasteInfo.route)
}

}
}
}
} else {
MapScreen(
navController = navController,
viewModel = viewModel,
)
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package app.waste2wealth.com.dashboard

import android.Manifest
import android.content.Intent
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand All @@ -26,7 +25,6 @@ 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.LocationService
import app.waste2wealth.com.location.LocationViewModel
import app.waste2wealth.com.navigation.Screens
import app.waste2wealth.com.ui.theme.backGround
Expand Down Expand Up @@ -160,12 +158,6 @@ fun DashBoardPage(
}
}
} else {
LaunchedEffect(Unit) {
Intent(context.applicationContext, LocationService::class.java).apply {
action = LocationService.ACTION_START
context.startService(this)
}
}
DashboardContent(
locationViewModel = locationViewModel,
navHostController = navHostController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package app.waste2wealth.com.location
import android.app.Application
import android.content.Context
import android.net.Uri
import android.util.Log
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
Expand Down Expand Up @@ -85,6 +86,7 @@ class LocationViewModel @Inject constructor(
}
latitude = it.latitude
longitude = it.longitude
println("New Location is ${it.longitude} & ${it.latitude}")
}
}
}
Expand Down
Loading

0 comments on commit 16e0fe0

Please sign in to comment.