Skip to content

Commit 56793d0

Browse files
authored
Merge pull request #33 from VectorVanguard/main
Updates
2 parents 1363c9a + e247827 commit 56793d0

59 files changed

Lines changed: 2151 additions & 127 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ plugins {
22
id("com.android.application")
33
id("org.jetbrains.kotlin.android")
44
id("kotlin-kapt")
5+
id("kotlin-parcelize")
56
}
67

78
android {

app/src/main/AndroidManifest.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
android:theme="@style/Theme.Project"
1515
tools:targetApi="31">
1616
<activity
17-
android:name=".Activity.AdvertisingPage"
17+
android:name=".Activity.FoodDetailActivity"
1818
android:exported="false" />
1919
<activity
2020
android:name=".Activity.MainActivity"
@@ -25,12 +25,15 @@
2525
<category android:name="android.intent.category.LAUNCHER" />
2626
</intent-filter>
2727
</activity>
28+
<activity android:name=".Activity.RecomendationActivity" />
2829
<activity android:name=".Activity.WelcomeActivity" />
2930
<activity android:name=".Activity.LogActivity" />
3031
<activity android:name=".Activity.RegActivity" />
3132
<activity android:name=".Activity.HomeActivity" />
3233
<activity android:name=".Activity.ForgetPasswordActivity" />
3334
<activity android:name=".Activity.FavoritesActivity" />
35+
<activity android:name=".Activity.BestSellerActivity" />
36+
<activity android:name=".Activity.AdverstsingPageActivity" />
3437

3538
<meta-data
3639
android:name="preloaded_fonts"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.example.projectfigma.Activity
2+
3+
import android.os.Bundle
4+
import androidx.appcompat.app.AppCompatActivity
5+
import com.example.projectfigma.Fragments.BottomPanelFragment
6+
import com.example.projectfigma.R
7+
import com.example.projectfigma.Util.StatusBar
8+
import com.example.projectfigma.databinding.ActivityAdvertisingPageBinding
9+
import com.example.projectfigma.databinding.ActivityFavoritesBinding
10+
11+
class AdverstsingPageActivity : AppCompatActivity() {
12+
private lateinit var binding: ActivityAdvertisingPageBinding
13+
14+
override fun onCreate(savedInstanceState: Bundle?) {
15+
super.onCreate(savedInstanceState)
16+
17+
binding = ActivityAdvertisingPageBinding.inflate(layoutInflater)
18+
setContentView(binding.root)
19+
StatusBar.hideStatusBar(window)
20+
21+
supportFragmentManager.beginTransaction()
22+
.replace(R.id.buttonPanel, BottomPanelFragment())
23+
.commit()
24+
}
25+
}

app/src/main/java/com/example/projectfigma/Activity/AdvertisingPage.kt

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.example.projectfigma.Activity
2+
3+
import android.os.Bundle
4+
import androidx.appcompat.app.AppCompatActivity
5+
import com.example.projectfigma.Fragments.BottomPanelFragment
6+
import com.example.projectfigma.R
7+
import com.example.projectfigma.Util.StatusBar
8+
import com.example.projectfigma.databinding.ActivityAdvertisingPageBinding
9+
import com.example.projectfigma.databinding.ActivityBestSellerBinding
10+
11+
class BestSellerActivity : AppCompatActivity() {
12+
private lateinit var binding: ActivityBestSellerBinding
13+
14+
override fun onCreate(savedInstanceState: Bundle?) {
15+
super.onCreate(savedInstanceState)
16+
17+
binding = ActivityBestSellerBinding.inflate(layoutInflater)
18+
setContentView(binding.root)
19+
StatusBar.hideStatusBar(window)
20+
21+
supportFragmentManager.beginTransaction()
22+
.replace(R.id.buttonPanel, BottomPanelFragment())
23+
.commit()
24+
}
25+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package com.example.projectfigma.Activity
2+
3+
import android.content.Intent
4+
import android.net.Uri
5+
import android.os.Bundle
6+
import android.widget.TextView
7+
import androidx.activity.enableEdgeToEdge
8+
import androidx.appcompat.app.AppCompatActivity
9+
import androidx.core.view.ViewCompat
10+
import androidx.core.view.WindowInsetsCompat
11+
import com.bumptech.glide.Glide
12+
import com.example.projectfigma.DataBase.DataBase
13+
import com.example.projectfigma.Entites.Dishes
14+
import com.example.projectfigma.Fragments.BottomPanelFragment
15+
import com.example.projectfigma.R
16+
import com.example.projectfigma.Util.StatusBar
17+
import com.example.projectfigma.databinding.ActivityFavoritesBinding
18+
import com.example.projectfigma.databinding.ActivityFoodDetailBinding
19+
import kotlin.time.toDuration
20+
21+
class FoodDetailActivity : AppCompatActivity() {
22+
private lateinit var binding: ActivityFoodDetailBinding
23+
private lateinit var dataBase : DataBase
24+
25+
override fun onCreate(savedInstanceState: Bundle?) {
26+
super.onCreate(savedInstanceState)
27+
28+
dataBase = DataBase.getDb(this)
29+
30+
binding = ActivityFoodDetailBinding.inflate(layoutInflater)
31+
setContentView(binding.root)
32+
StatusBar.hideStatusBar(window)
33+
34+
supportFragmentManager.beginTransaction()
35+
.replace(R.id.buttonPanel, BottomPanelFragment())
36+
.commit()
37+
38+
binding.exitArrow.setOnClickListener(){
39+
startActivity(Intent(this@FoodDetailActivity,HomeActivity::class.java))
40+
}
41+
42+
val dish: Dishes? = intent.getParcelableExtra("dish")
43+
dish?.let {
44+
binding.nameDishHeader.text = it.name
45+
binding.tvRating.text = it.rating.toString()
46+
binding.textPrice.text = "$" + it.price.toString()
47+
Glide.with(binding.imgFood)
48+
.load(dish.imageUri)
49+
.into(binding.imgFood)
50+
51+
binding.dishDescription.text = it.description
52+
}
53+
}
54+
55+
private suspend fun likeDish(dish: Dishes) {
56+
57+
val user = dataBase.getSessionDao().getSession()
58+
?.let { it.userEmail?.let { it1 -> dataBase.getUserDao().getUserByEmail(it1) } }
59+
60+
val favoriteDishes:List<Int> = user?.favoriteDishesId ?: emptyList<Int>()
61+
if (favoriteDishes.contains(dish.id)) {
62+
val updatedDishes: List<Int> = favoriteDishes.filter { it != dish.id }
63+
dataBase.getUserDao().updateFavoriteDishes(user?.id!!, updatedDishes)
64+
} else {
65+
val updatedDishes = favoriteDishes + dish.id
66+
dataBase.getUserDao().updateFavoriteDishes(user?.id!!, updatedDishes)
67+
}
68+
}
69+
}

app/src/main/java/com/example/projectfigma/Activity/HomeActivity.kt

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.example.projectfigma.Activity
22

3+
import android.content.Intent
34
import android.os.Bundle
5+
import android.widget.TextView
46
import android.widget.Toast
57
import androidx.appcompat.app.AppCompatActivity
68
import androidx.core.view.GravityCompat
@@ -16,6 +18,7 @@ import com.example.projectfigma.Entites.User
1618
import com.example.projectfigma.Fragments.*
1719
import com.example.projectfigma.R
1820
import com.example.projectfigma.Util.StatusBar
21+
import com.example.projectfigma.Util.SwitchCard
1922

2023
class HomeActivity : AppCompatActivity(),
2124
HeaderButtonsFragment.Listener {
@@ -32,8 +35,6 @@ class HomeActivity : AppCompatActivity(),
3235
setContentView(R.layout.activity_home)
3336
StatusBar.hideStatusBar(window)
3437

35-
drawer = findViewById(R.id.drawer_layout)
36-
3738
val db = DataBase.getDb(this)
3839
dao = db.getDishesDao()
3940
userDao = db.getUserDao()
@@ -43,19 +44,22 @@ class HomeActivity : AppCompatActivity(),
4344
user = userDao.getUserByEmail(email)
4445
}
4546

47+
drawer = findViewById<DrawerLayout>(R.id.drawer_layout)
48+
49+
adapter = BestSellerAdapter(emptyList()) { item ->
50+
SwitchCard.switchDish(
51+
item,
52+
this,
53+
FoodDetailActivity::class.java
54+
)
55+
}
4656
val rv = findViewById<RecyclerView>(R.id.rvBestSellers).apply {
4757
layoutManager = LinearLayoutManager(
4858
this@HomeActivity,
4959
LinearLayoutManager.HORIZONTAL,
5060
false
5161
)
52-
adapter = BestSellerAdapter(emptyList()) { item: Dishes ->
53-
Toast.makeText(
54-
this@HomeActivity,
55-
"Clicked: ${item.price}",
56-
Toast.LENGTH_SHORT
57-
).show()
58-
}.also { this@HomeActivity.adapter = it }
62+
adapter = this@HomeActivity.adapter
5963
}
6064

6165
dao.getBestSellersWithLimit(4).observe(this) { list ->
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.example.projectfigma.Activity
2+
3+
import android.os.Bundle
4+
import androidx.activity.enableEdgeToEdge
5+
import androidx.appcompat.app.AppCompatActivity
6+
import androidx.core.view.ViewCompat
7+
import androidx.core.view.WindowInsetsCompat
8+
import com.example.projectfigma.Fragments.BottomPanelFragment
9+
import com.example.projectfigma.R
10+
import com.example.projectfigma.Util.StatusBar
11+
import com.example.projectfigma.databinding.ActivityAdvertisingPageBinding
12+
import com.example.projectfigma.databinding.ActivityRecomendationBinding
13+
14+
class RecomendationActivity : AppCompatActivity() {
15+
private lateinit var binding: ActivityRecomendationBinding
16+
17+
override fun onCreate(savedInstanceState: Bundle?) {
18+
super.onCreate(savedInstanceState)
19+
20+
binding = ActivityRecomendationBinding.inflate(layoutInflater)
21+
setContentView(binding.root)
22+
StatusBar.hideStatusBar(window)
23+
24+
supportFragmentManager.beginTransaction()
25+
.replace(R.id.buttonPanel, BottomPanelFragment())
26+
.commit()
27+
}
28+
}

app/src/main/java/com/example/projectfigma/Adapters/BestSellerAdapter.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import com.example.projectfigma.R
1212

1313
class BestSellerAdapter(
1414
private var items: List<Dishes>,
15-
private val onClick: (Dishes) -> Unit
15+
private val switchToSelfPage: (Dishes) -> Unit
1616
) : RecyclerView.Adapter<BestSellerAdapter.VH>() {
1717

1818
inner class VH(view: View) : RecyclerView.ViewHolder(view) {
@@ -26,7 +26,7 @@ class BestSellerAdapter(
2626
.centerCrop()
2727
.into(ivFood)
2828

29-
itemView.setOnClickListener { onClick(item) }
29+
itemView.setOnClickListener { switchToSelfPage(item) }
3030
}
3131
}
3232

app/src/main/java/com/example/projectfigma/Adapters/FavoriteDishesAdapter.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import kotlin.coroutines.coroutineContext
1515

1616
class FavoriteFoodAdapter(
1717
private val items: MutableList<Dishes>,
18-
private val onFavoriteClick: (dish: Dishes) -> Unit
18+
private val onFavoriteClick: (dish: Dishes) -> Unit,
19+
private val switchToSelfPage: (Dishes) -> Unit
1920
) : RecyclerView.Adapter<FavoriteFoodAdapter.VH>() {
2021

2122
inner class VH(view: View) : RecyclerView.ViewHolder(view) {
@@ -46,6 +47,8 @@ class FavoriteFoodAdapter(
4647

4748
holder.imgFavorite.setImageResource(R.drawable.ic_heart_border)
4849
holder.imgFavorite.setOnClickListener { onFavoriteClick(dish) }
50+
51+
holder.itemView.setOnClickListener { switchToSelfPage(dish) }
4952
}
5053

5154
override fun getItemCount(): Int = items.size

0 commit comments

Comments
 (0)