diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index b589d56..b86273d 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml
index bd67f56..8655cc3 100644
--- a/.idea/deploymentTargetDropDown.xml
+++ b/.idea/deploymentTargetDropDown.xml
@@ -5,6 +5,9 @@
+
+
+
\ No newline at end of file
diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
index fdf8d99..8d81632 100644
--- a/.idea/kotlinc.xml
+++ b/.idea/kotlinc.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 8978d23..2b2f1af 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,6 +1,6 @@
-
+
diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index b519164..1f50fac 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -29,9 +29,6 @@ android {
}
// View Binding
- buildFeatures {
- viewBinding = true
- }
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
@@ -51,7 +48,7 @@ dependencies {
implementation("com.google.android.material:material:1.11.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("com.google.firebase:firebase-auth:22.3.1")
- implementation("com.google.firebase:firebase-database:20.3.0")
+ implementation("com.google.firebase:firebase-database:20.3.1")
implementation("com.google.firebase:firebase-auth-ktx:22.3.1")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
@@ -61,13 +58,20 @@ dependencies {
// Card View
implementation("androidx.cardview:cardview:1.0.0")
+
// Glide
- implementation ("com.github.bumptech.glide:glide:4.16.0")
+ implementation("com.github.bumptech.glide:glide:4.16.0")
+ annotationProcessor("com.github.bumptech.glide:compiler:4.11.0")
+
// Coil
implementation("io.coil-kt:coil:2.5.0")
implementation("com.airbnb.android:lottie:6.0.0")
-
+
+ //Navigation dependency
val nav_version = "2.7.6"
+ //noinspection GradleDependency
implementation("androidx.navigation:navigation-fragment-ktx:$nav_version")
+ //noinspection GradleDependency
implementation("androidx.navigation:navigation-ui-ktx:$nav_version")
+
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/deliveryapp/Fragments/AccessLocation.kt b/app/src/main/java/com/example/deliveryapp/Fragments/AccessLocation.kt
index a1ecadd..7719044 100644
--- a/app/src/main/java/com/example/deliveryapp/Fragments/AccessLocation.kt
+++ b/app/src/main/java/com/example/deliveryapp/Fragments/AccessLocation.kt
@@ -1,27 +1,31 @@
package com.example.deliveryapp.Fragments
+import android.Manifest
+import android.app.AlertDialog
+import android.content.pm.PackageManager
+import android.os.Build
import android.os.Bundle
-import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.activity.OnBackPressedCallback
+import androidx.core.app.ActivityCompat
+import androidx.core.content.ContextCompat
+import androidx.fragment.app.Fragment
import androidx.navigation.NavController
import androidx.navigation.Navigation
import com.example.deliveryapp.R
import com.example.deliveryapp.databinding.FragmentAccessLocationBinding
-
class AccessLocation : Fragment() {
-
private lateinit var binding: FragmentAccessLocationBinding
private lateinit var navController: NavController
+
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
- ): View? {
- // Inflate the layout for this fragment
+ ): View {
binding = FragmentAccessLocationBinding.inflate(inflater, container, false)
return binding.root
}
@@ -29,22 +33,69 @@ class AccessLocation : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
- navController= Navigation.findNavController(view)
-
+ navController = Navigation.findNavController(view)
binding.btnAccessLocation.setOnClickListener {
- navController.navigate(R.id.action_accessLocation_to_animatedScreen)
-
+ if (checkLocationPermission()) {
+ // Permission granted, navigate to the next screen
+ navController.navigate(R.id.animatedScreen)
+ }
}
+
val callback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
- // Log.d("TAG", "Pressed...")
+ // Do nothing or handle as needed
}
}
-
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, callback)
+ // Check for permission on fragment start
+ }
+ private fun checkLocationPermission(): Boolean {
+ val context = requireContext()
+ if (ContextCompat.checkSelfPermission(
+ context,
+ Manifest.permission.ACCESS_FINE_LOCATION
+ ) != PackageManager.PERMISSION_GRANTED
+ ) {
+ // Permission not granted, request it
+ if (ActivityCompat.shouldShowRequestPermissionRationale(
+ requireActivity(),
+ Manifest.permission.ACCESS_FINE_LOCATION
+ )
+ ) {
+ // Show an explanation to the user if they have denied permission previously
+ AlertDialog.Builder(context)
+ .setTitle("Location Permission Needed")
+ .setMessage("This app needs the Location permission to function properly. Please allow.")
+ .setPositiveButton("OK") { _, _ ->
+ requestLocationPermission()
+ }
+ .setNegativeButton("Cancel") { dialog, _ ->
+ dialog.dismiss()
+ }
+ .create()
+ .show()
+ } else {
+ // No explanation needed, request the permission
+ requestLocationPermission()
+ }
+ return false
+ }
+ // Permission already granted
+ return true
}
+ private fun requestLocationPermission() {
+ ActivityCompat.requestPermissions(
+ requireActivity(),
+ arrayOf(Manifest.permission.ACCESS_FINE_LOCATION),
+ LOCATION_PERMISSION_REQUEST_CODE
+ )
+ }
-}
\ No newline at end of file
+ companion object {
+ private const val LOCATION_PERMISSION_REQUEST_CODE = 1001
+ }
+
+}
diff --git a/app/src/main/java/com/example/deliveryapp/Fragments/LocationFragment.kt b/app/src/main/java/com/example/deliveryapp/Fragments/LocationFragment.kt
new file mode 100644
index 0000000..a6ff2b7
--- /dev/null
+++ b/app/src/main/java/com/example/deliveryapp/Fragments/LocationFragment.kt
@@ -0,0 +1,47 @@
+package com.example.deliveryapp.Fragments
+
+import android.os.Bundle
+import androidx.fragment.app.Fragment
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import androidx.activity.OnBackPressedCallback
+import androidx.navigation.NavController
+import androidx.navigation.Navigation
+import com.example.deliveryapp.R
+import com.example.deliveryapp.databinding.FragmentLocationBinding
+
+class LocationFragment : Fragment() {
+
+ private lateinit var navController: NavController
+ private lateinit var binding:FragmentLocationBinding
+ override fun onCreateView(
+ inflater: LayoutInflater, container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
+ // Inflate the layout for this fragment
+ binding=FragmentLocationBinding.inflate(inflater,container,false)
+ return binding.root
+
+ }
+
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ super.onViewCreated(view, savedInstanceState)
+ navController=Navigation.findNavController(view)
+
+
+
+ binding.btnAddLocation.setOnClickListener {
+ navController.navigate(R.id.action_locationFragment_to_addressFragment)
+ }
+
+ val callback = object : OnBackPressedCallback(true) {
+ override fun handleOnBackPressed() {
+ // Log.d("TAG", "Pressed...")
+ }
+ }
+
+ requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, callback)
+
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/deliveryapp/Fragments/LoginPage.kt b/app/src/main/java/com/example/deliveryapp/Fragments/LoginPage.kt
index 331c124..58e6d88 100644
--- a/app/src/main/java/com/example/deliveryapp/Fragments/LoginPage.kt
+++ b/app/src/main/java/com/example/deliveryapp/Fragments/LoginPage.kt
@@ -1,18 +1,21 @@
package com.example.deliveryapp.Fragments
+import android.content.Intent
import android.os.Bundle
-import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.activity.OnBackPressedCallback
+import androidx.fragment.app.Fragment
import androidx.navigation.NavController
import androidx.navigation.Navigation
+import androidx.navigation.fragment.findNavController
import com.example.deliveryapp.R
import com.example.deliveryapp.databinding.FragmentLoginPageBinding
-import com.google.android.gms.tasks.OnCompleteListener
import com.google.firebase.auth.FirebaseAuth
+import com.google.firebase.database.DatabaseReference
+import com.google.firebase.database.FirebaseDatabase
class LoginPage : Fragment() {
@@ -20,6 +23,7 @@ class LoginPage : Fragment() {
private lateinit var auth: FirebaseAuth
private lateinit var binding: FragmentLoginPageBinding
private lateinit var navController: NavController
+ private lateinit var databaseRef: DatabaseReference
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
@@ -51,6 +55,10 @@ class LoginPage : Fragment() {
navController=Navigation.findNavController(view)
auth=FirebaseAuth.getInstance()
+ databaseRef=FirebaseDatabase.getInstance()
+ .reference.child("Users")
+ .child(auth.currentUser?.uid.toString())
+
}
private fun registerEvents() {
@@ -68,19 +76,31 @@ class LoginPage : Fragment() {
val pattern=Regex("nits.ac.in")
val check=pattern.containsMatchIn(email)
- if ( email.isNotEmpty() && pass.isNotEmpty() && check==true){
-
- auth.signInWithEmailAndPassword(email,pass).addOnCompleteListener(
- OnCompleteListener {
- if (it.isSuccessful){
- Toast.makeText(context,"Login Successfully", Toast.LENGTH_SHORT).show()
- navController.navigate(R.id.action_loginPage_to_emptyActivity)
-
- }else{
- Toast.makeText(context,it.exception?.message, Toast.LENGTH_SHORT).show()
+ if (email.isNotEmpty() && pass.isNotEmpty() && check){
+
+ auth.signInWithEmailAndPassword(email,pass)
+ .addOnCompleteListener {
+ if (it.isSuccessful) {
+ val verification = auth.currentUser?.isEmailVerified
+ when(verification){
+ true -> {
+ Toast.makeText(context, "Login Successfully", Toast.LENGTH_SHORT).show()
+ findNavController().navigate(R.id.action_loginPage_to_locationFragment)
+ }
+ else -> Toast.makeText(requireContext(), "Please Verify Your Email", Toast.LENGTH_SHORT).show()
+ }
+ } else {
+ Toast.makeText(
+ context,
+ "Kindly Sign Up By Clicking SignUp button",
+ Toast.LENGTH_SHORT
+ ).show()
}
}
- )
+
+ }else{
+
+ Toast.makeText(context,"Please fill up all the necessary details",Toast.LENGTH_SHORT).show()
}
diff --git a/app/src/main/java/com/example/deliveryapp/Fragments/SignIn.kt b/app/src/main/java/com/example/deliveryapp/Fragments/SignIn.kt
index 8618586..3d41497 100644
--- a/app/src/main/java/com/example/deliveryapp/Fragments/SignIn.kt
+++ b/app/src/main/java/com/example/deliveryapp/Fragments/SignIn.kt
@@ -1,7 +1,7 @@
package com.example.deliveryapp.Fragments
-import android.os.Bundle
import androidx.fragment.app.Fragment
+import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@@ -34,15 +34,15 @@ class SignIn : Fragment() {
binding.btnSignUp.setOnClickListener {
navController.navigate(R.id.action_signIn_to_signUpPage)
}
+
+
val callback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
// Log.d("TAG", "Pressed...")
}
}
-
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, callback)
-
}
diff --git a/app/src/main/java/com/example/deliveryapp/Fragments/SignUpPage.kt b/app/src/main/java/com/example/deliveryapp/Fragments/SignUpPage.kt
index 8cc6ee9..4851ffc 100644
--- a/app/src/main/java/com/example/deliveryapp/Fragments/SignUpPage.kt
+++ b/app/src/main/java/com/example/deliveryapp/Fragments/SignUpPage.kt
@@ -1,20 +1,24 @@
package com.example.deliveryapp.Fragments
+import android.annotation.SuppressLint
import android.os.Bundle
-import androidx.fragment.app.Fragment
+import android.os.Handler
+import android.os.Looper
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.activity.OnBackPressedCallback
+import androidx.fragment.app.Fragment
import androidx.navigation.NavController
import androidx.navigation.Navigation
+import androidx.navigation.fragment.findNavController
import com.example.deliveryapp.R
import com.example.deliveryapp.databinding.FragmentSignUpPageBinding
-import com.google.android.gms.tasks.OnCompleteListener
-import com.google.firebase.Firebase
+import com.example.deliveryapp.utils.User
import com.google.firebase.auth.FirebaseAuth
-import com.google.firebase.auth.FirebaseAuthException
+import com.google.firebase.database.DatabaseReference
+import com.google.firebase.database.FirebaseDatabase
class SignUpPage : Fragment() {
@@ -22,12 +26,12 @@ class SignUpPage : Fragment() {
private lateinit var auth: FirebaseAuth
private lateinit var binding: FragmentSignUpPageBinding
private lateinit var navController: NavController
+ private lateinit var databaseRef: DatabaseReference
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
- // Inflate the layout for this fragment
binding = FragmentSignUpPageBinding.inflate(inflater, container, false)
return binding.root
}
@@ -40,42 +44,73 @@ class SignUpPage : Fragment() {
}
+ private fun init(view: View) {
+ navController = Navigation.findNavController(view)
+ auth = FirebaseAuth.getInstance()
+ databaseRef = FirebaseDatabase.getInstance()
+ .reference.child("Users")
- private fun init(view: View) {
- navController=Navigation.findNavController(view)
- auth=FirebaseAuth.getInstance()
}
+
+ @SuppressLint("SuspiciousIndentation")
private fun registerEvents() {
binding.backBtnSignUpPage.setOnClickListener {
navController.navigate(R.id.action_signUpPage_to_signIn)
}
+
binding.btnSignUp.setOnClickListener {
- val name=binding.etNameSignUpPage.text.toString().trim()
- val email=binding.etEmailSignUpPage.text.toString().trim()
- val pass=binding.etPassSignUpPage.text.toString().trim()
- val repass=binding.etRePassSignUpPage.text.toString().trim()
-
- val pattern=Regex("nits.ac.in")
- val check=pattern.containsMatchIn(email)
-
- if (name.isNotEmpty() && email.isNotEmpty() && pass.isNotEmpty() && repass.isNotEmpty() && check==true){
- if (pass==repass){
- auth.createUserWithEmailAndPassword(email,pass).addOnCompleteListener(
- OnCompleteListener {
- if (it.isSuccessful){
- Toast.makeText(context,"Registered Successfully",Toast.LENGTH_SHORT).show()
- navController.navigate(R.id.action_signUpPage_to_emptyActivity)
-
- }else{
- Toast.makeText(context,it.exception?.message,Toast.LENGTH_SHORT).show()
+ val name = binding.etNameSignUpPage.text.toString().trim()
+ val email = binding.etEmailSignUpPage.text.toString().trim()
+ val pass = binding.etPassSignUpPage.text.toString().trim()
+ val repass = binding.etRePassSignUpPage.text.toString().trim()
+
+ val pattern = Regex("nits.ac.in")
+ val check = pattern.containsMatchIn(email)
+
+ if (name.isNotEmpty() && email.isNotEmpty() && pass.isNotEmpty() && repass.isNotEmpty() && check) {
+ if (pass == repass) {
+
+ auth.createUserWithEmailAndPassword(email, pass).addOnCompleteListener { authTask ->
+ if (authTask.isSuccessful) {
+ val currentUser = auth.currentUser
+ val userId = currentUser?.uid
+
+ val userModel = User(name, email)
+ userId?.let {
+ databaseRef.child(it).setValue(userModel)
+ .addOnCompleteListener { dbTask ->
+ if (dbTask.isSuccessful) {
+ auth.currentUser?.sendEmailVerification()?.addOnSuccessListener {
+ Toast.makeText(requireContext(), "Please Verify Your Email", Toast.LENGTH_SHORT).show()
+ }
+ ?.addOnFailureListener {
+ Toast.makeText(requireContext(), it.toString(), Toast.LENGTH_SHORT).show()
+ }
+ Handler(Looper.getMainLooper()).postDelayed({
+ navController.navigate(R.id.action_signUpPage_to_loginPage)
+ }, 1000)
+ } else {
+ Toast.makeText(context, "User could not be added", Toast.LENGTH_SHORT).show()
+ }
+ }
}
+ } else {
+ val verification = auth.currentUser?.isEmailVerified
+ if(verification == false)
+ Toast.makeText(requireContext(), "Please Verify Your Email", Toast.LENGTH_SHORT).show()
+ else
+ Toast.makeText(context, authTask.exception?.message, Toast.LENGTH_SHORT).show()
}
- )
+ }
+ } else {
+ Toast.makeText(context, "Passwords do not match", Toast.LENGTH_SHORT).show()
}
+ } else {
+ Toast.makeText(context, "Please fill up all the necessary details", Toast.LENGTH_SHORT).show()
}
-
}
+
val callback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
// Log.d("TAG", "Pressed...")
@@ -84,5 +119,4 @@ class SignUpPage : Fragment() {
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, callback)
}
-
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/com/example/deliveryapp/Fragments/SplashScreen.kt b/app/src/main/java/com/example/deliveryapp/Fragments/SplashScreen.kt
index 220c942..4a4f6d5 100644
--- a/app/src/main/java/com/example/deliveryapp/Fragments/SplashScreen.kt
+++ b/app/src/main/java/com/example/deliveryapp/Fragments/SplashScreen.kt
@@ -1,12 +1,14 @@
package com.example.deliveryapp.Fragments
+import androidx.fragment.app.Fragment
import android.os.Bundle
import android.os.Handler
import android.os.Looper
-import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import android.view.animation.AnimationUtils
+import android.widget.Toast
import androidx.activity.OnBackPressedCallback
import androidx.navigation.NavController
import androidx.navigation.Navigation
@@ -34,28 +36,31 @@ class SplashScreen : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
- val sideAnimation=android.view.animation.AnimationUtils.loadAnimation(parentFragment?.context,R.anim.slide)
+ val sideAnimation= AnimationUtils.loadAnimation(parentFragment?.context,R.anim.slide)
binding.ivIcon.startAnimation(sideAnimation)
auth=FirebaseAuth.getInstance()
navController = Navigation.findNavController(view)
-
- Handler(Looper.myLooper()!!).postDelayed(Runnable{
- if (auth.currentUser!=null){
- navController.navigate(R.id.action_splashScreen_to_emptyActivity)
- }else{
- navController.navigate(R.id.action_splashScreen_to_accessLocation)
+ val verification = auth.currentUser?.isEmailVerified
+ Handler(Looper.myLooper()!!).postDelayed({
+ if (auth.currentUser!=null && verification == true){
+ navController.navigate(R.id.action_splashScreen_to_homeActivity)
+ }else if(auth.currentUser != null && verification == false){
+ Toast.makeText(requireContext(), "Please Verify Your email", Toast.LENGTH_SHORT).show()
+ navController.navigate(R.id.action_splashScreen_to_signIn)
}
+ else navController.navigate(R.id.action_splashScreen_to_accessLocation)
+
},3000)
+
+
val callback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
- // Log.d("TAG", "Pressed...")
+ // Do nothing or handle as needed
}
}
-
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, callback)
-
}
diff --git a/app/src/main/java/com/example/deliveryapp/HomeActivity.kt b/app/src/main/java/com/example/deliveryapp/HomeActivity.kt
index cbb6d53..34151fa 100644
--- a/app/src/main/java/com/example/deliveryapp/HomeActivity.kt
+++ b/app/src/main/java/com/example/deliveryapp/HomeActivity.kt
@@ -5,17 +5,18 @@ import android.os.Bundle
import androidx.fragment.app.Fragment
import com.example.deliveryapp.homepage_fragments.CartFragment
import com.example.deliveryapp.homepage_fragments.HomeFragment
+import com.example.deliveryapp.homepage_fragments.HomepageNavigation
import com.example.deliveryapp.homepage_fragments.ProfileFragment
import com.example.deliveryapp.homepage_fragments.SearchFragment
+import com.example.deliveryapp.userprofile.ProfileListFragment
import com.google.android.material.bottomnavigation.BottomNavigationView
-
-class HomeActivity : AppCompatActivity() {
+class HomeActivity : AppCompatActivity(), HomepageNavigation {
private lateinit var bottomNavigationView: BottomNavigationView
+
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.homepage)
-
bottomNavigationView = findViewById(R.id.bottom_navigation)
bottomNavigationView.setOnItemSelectedListener { menuItem ->
when (menuItem.itemId) {
@@ -25,27 +26,27 @@ class HomeActivity : AppCompatActivity() {
true
}
R.id.bottom_cart -> {
- // Replace fragment with HomeFragment
+ // Replace fragment with CartFragment
replaceFragment(CartFragment())
true
}
R.id.bottom_search -> {
- // Replace fragment with HomeFragment
+ // Replace fragment with SearchFragment
replaceFragment(SearchFragment())
true
}
R.id.bottom_profile -> {
- // Replace fragment with HomeFragment
- replaceFragment(ProfileFragment())
+ // Replace fragment with ProfileFragment
+ replaceFragment(ProfileListFragment())
true
}
else -> false
}
}
replaceFragment(HomeFragment())
-
}
- private fun replaceFragment(fragment: Fragment) {
+
+ override fun replaceFragment(fragment: Fragment) {
supportFragmentManager.beginTransaction().replace(R.id.frame_container, fragment).commit()
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/com/example/deliveryapp/MainActivity.kt b/app/src/main/java/com/example/deliveryapp/MainActivity.kt
index 5801673..fb46b29 100644
--- a/app/src/main/java/com/example/deliveryapp/MainActivity.kt
+++ b/app/src/main/java/com/example/deliveryapp/MainActivity.kt
@@ -12,9 +12,44 @@ import com.google.android.material.bottomnavigation.BottomNavigationView
class MainActivity : AppCompatActivity() {
+ private lateinit var binding: ActivityMainBinding
private lateinit var bottomNavigationView: BottomNavigationView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
- setContentView(R.layout.activity_main)
+ binding = ActivityMainBinding.inflate(layoutInflater)
+ setContentView(binding.root)
+
+// bottomNavigationView = findViewById(R.id.bottom_navigation)
+
+// bottomNavigationView.setOnItemSelectedListener { menuItem ->
+// when (menuItem.itemId) {
+// R.id.bottom_home -> {
+// // Replace fragment with HomeFragment
+// replaceFragment(HomeFragment())
+// true
+// }
+// R.id.bottom_cart -> {
+// // Replace fragment with HomeFragment
+// replaceFragment(CartFragment())
+// true
+// }
+// R.id.bottom_search -> {
+// // Replace fragment with HomeFragment
+// replaceFragment(SearchFragment())
+// true
+// }
+// R.id.bottom_profile -> {
+// // Replace fragment with HomeFragment
+// replaceFragment(ProfileFragment())
+// true
+// }
+// else -> false
+// }
+// }
+// replaceFragment(HomeFragment())
+
+ }
+ private fun replaceFragment(fragment: Fragment) {
+ supportFragmentManager.beginTransaction().replace(R.id.frame_container, fragment).commit()
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/deliveryapp/UserProfileActivity.kt b/app/src/main/java/com/example/deliveryapp/UserProfileActivity.kt
new file mode 100644
index 0000000..5a4f0ba
--- /dev/null
+++ b/app/src/main/java/com/example/deliveryapp/UserProfileActivity.kt
@@ -0,0 +1,18 @@
+package com.example.deliveryapp
+
+import android.os.Bundle
+import androidx.appcompat.app.AppCompatActivity
+import androidx.fragment.app.FragmentManager
+import androidx.fragment.app.FragmentTransaction
+import com.example.deliveryapp.userprofile.ProfileListFragment
+
+class UserProfileActivity : AppCompatActivity() {
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_user_profile)
+ val fragmentManager: FragmentManager = supportFragmentManager
+ val fragmentTransaction: FragmentTransaction = fragmentManager.beginTransaction()
+ fragmentTransaction.replace(R.id.fvFragment, ProfileListFragment())
+ fragmentTransaction.commit()
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/deliveryapp/adapters/NestedRecyclerFoodAdapter.kt b/app/src/main/java/com/example/deliveryapp/adapters/NestedRecyclerFoodAdapter.kt
index 3d6235e..73b4e12 100644
--- a/app/src/main/java/com/example/deliveryapp/adapters/NestedRecyclerFoodAdapter.kt
+++ b/app/src/main/java/com/example/deliveryapp/adapters/NestedRecyclerFoodAdapter.kt
@@ -3,6 +3,8 @@ package com.example.deliveryapp.adapters
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import android.widget.Toast
+import androidx.navigation.Navigation
import androidx.recyclerview.widget.RecyclerView
import coil.load
import com.example.deliveryapp.models.NestedRecyclerModelFood
@@ -25,6 +27,10 @@ class NestedRecyclerFoodAdapter (private val movieModel: List(R.id.imageRV)
@@ -59,8 +75,22 @@ class HomeFragment : Fragment() {
val rvMain = rootView.findViewById(R.id.rvMain)
rvMain.adapter = nestedRecyclerAdapter
+ // set onClick to profile
+ val cardView = rootView.findViewById(R.id.home_profile)
+ cardView.setOnClickListener {
+ // Your onClick logic here
+ Toast.makeText(context, "Card clicked", Toast.LENGTH_SHORT).show()
+ fragmentNavigation?.replaceFragment(ProfileListFragment())
+ bottomNavigationView.selectedItemId = R.id.bottom_profile
+ }
+
+
return rootView
}
+ override fun onDetach() {
+ super.onDetach()
+ fragmentNavigation = null
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/deliveryapp/homepage_fragments/HomepageNavigation.kt b/app/src/main/java/com/example/deliveryapp/homepage_fragments/HomepageNavigation.kt
new file mode 100644
index 0000000..ab9c942
--- /dev/null
+++ b/app/src/main/java/com/example/deliveryapp/homepage_fragments/HomepageNavigation.kt
@@ -0,0 +1,7 @@
+package com.example.deliveryapp.homepage_fragments
+
+import androidx.fragment.app.Fragment
+
+interface HomepageNavigation {
+ fun replaceFragment(fragment: Fragment)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/deliveryapp/userprofile/AddressData.kt b/app/src/main/java/com/example/deliveryapp/userprofile/AddressData.kt
new file mode 100644
index 0000000..ba75366
--- /dev/null
+++ b/app/src/main/java/com/example/deliveryapp/userprofile/AddressData.kt
@@ -0,0 +1,9 @@
+package com.example.deliveryapp.userprofile
+
+data class AddressData(
+ val hostel : String = "",
+ val city : String = "",
+ val state : String = "",
+ val country : String = "",
+ val pinCode : String = ""
+)
diff --git a/app/src/main/java/com/example/deliveryapp/userprofile/AddressFragment.kt b/app/src/main/java/com/example/deliveryapp/userprofile/AddressFragment.kt
new file mode 100644
index 0000000..b712d26
--- /dev/null
+++ b/app/src/main/java/com/example/deliveryapp/userprofile/AddressFragment.kt
@@ -0,0 +1,76 @@
+package com.example.deliveryapp.userprofile
+
+import android.os.Bundle
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.Button
+import android.widget.Toast
+import androidx.activity.OnBackPressedCallback
+import androidx.fragment.app.Fragment
+import androidx.navigation.NavController
+import androidx.navigation.Navigation
+import com.example.deliveryapp.R
+import com.example.deliveryapp.databinding.FragmentAddressBinding
+import com.google.android.material.textfield.TextInputEditText
+import com.google.firebase.auth.FirebaseAuth
+
+class AddressFragment : Fragment() {
+
+ private lateinit var binding: FragmentAddressBinding
+ private lateinit var navController: NavController
+ override fun onCreateView(
+ inflater: LayoutInflater, container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
+ // Inflate the layout for this fragment
+ binding= FragmentAddressBinding.inflate(inflater, container, false)
+ return binding.root
+ }
+
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ super.onViewCreated(view, savedInstanceState)
+
+ navController= Navigation.findNavController(view)
+ binding.backBtnAddressPage.setOnClickListener {
+ navController.navigate(R.id.action_addressFragment_to_locationFragment)
+ }
+
+ var etHostel = view.findViewById(R.id.etHostelNameAddressPage)
+ var etCity = view.findViewById(R.id.etCityAddressPage)
+ var etState = view.findViewById(R.id.etStateNameAddressPage)
+ var etCountry = view.findViewById(R.id.etCountryNameAddressPage)
+ var etPinCode = view.findViewById(R.id.etPostalCodeAddressPage)
+
+ var address = AddressData(
+ etHostel.text.toString(), etCity.text.toString(), etState.text.toString(),
+ etCountry.text.toString(), etPinCode.text.toString()
+ )
+
+ val btnSave=view.findViewById