Skip to content

Commit 0a85134

Browse files
authored
Merge pull request #30 from VectorVanguard/main
Updates
2 parents 3ec7588 + 490c41f commit 0a85134

12 files changed

Lines changed: 384 additions & 199 deletions

File tree

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
android:supportsRtl="true"
1414
android:theme="@style/Theme.Project"
1515
tools:targetApi="31">
16-
<activity
17-
android:name=".Activity.AdvertisingPage"
18-
android:exported="false" />
1916
<activity
2017
android:name=".Activity.MainActivity"
2118
android:exported="true">
@@ -31,6 +28,7 @@
3128
<activity android:name=".Activity.HomeActivity" />
3229
<activity android:name=".Activity.ForgetPasswordActivity" />
3330
<activity android:name=".Activity.FavoritesActivity" />
31+
<activity android:name=".Activity.BestSellerActivity" />
3432
<activity android:name=".Activity.AdverstsingPageActivity" />
3533

3634
<meta-data

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+
}

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

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

33
import android.os.Bundle
4+
import android.widget.TextView
45
import android.widget.Toast
56
import androidx.appcompat.app.AppCompatActivity
67
import androidx.core.view.GravityCompat
@@ -58,6 +59,9 @@ class HomeActivity : AppCompatActivity(),
5859
}.also { this@HomeActivity.adapter = it }
5960
}
6061

62+
63+
64+
6165
dao.getBestSellersWithLimit(4).observe(this) { list ->
6266
adapter.updateList(list)
6367
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package com.example.projectfigma.Adapters
2+
3+
import android.net.Uri
4+
import android.view.LayoutInflater
5+
import android.view.View
6+
import android.view.ViewGroup
7+
import android.widget.ImageView
8+
import android.widget.TextView
9+
import androidx.recyclerview.widget.RecyclerView
10+
import com.bumptech.glide.Glide
11+
import com.example.projectfigma.Entites.Dishes
12+
import com.example.projectfigma.R
13+
14+
class MainBestSellerAdapter (private var dishes: List<Dishes>) :
15+
RecyclerView.Adapter<MainBestSellerAdapter.DishViewHolder>() {
16+
17+
inner class DishViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
18+
val image: ImageView = itemView.findViewById(R.id.dishImage)
19+
val title: TextView = itemView.findViewById(R.id.dishTitle)
20+
val description: TextView = itemView.findViewById(R.id.dishDescription)
21+
val price: TextView = itemView.findViewById(R.id.dishPrice)
22+
val rating: TextView = itemView.findViewById(R.id.tvRating)
23+
val category: ImageView = itemView.findViewById(R.id.iconCategory)
24+
}
25+
26+
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DishViewHolder {
27+
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_dish_best_seller, parent, false)
28+
return DishViewHolder(view)
29+
}
30+
31+
override fun onBindViewHolder(holder: DishViewHolder, position: Int) {
32+
val dish = dishes[position]
33+
34+
// Используем Glide для загрузки изображения
35+
Glide.with(holder.itemView.context)
36+
.load(Uri.parse(dish.imageUri))
37+
.into(holder.image)
38+
39+
holder.category.setImageResource(dish.category.iconRes)
40+
holder.title.text = dish.name
41+
holder.description.text = dish.description
42+
holder.price.text = "$${dish.price}"
43+
holder.rating.text = "${dish.rating}"
44+
}
45+
46+
override fun getItemCount(): Int = dishes.size
47+
48+
fun updateData(newList: List<Dishes>) {
49+
dishes = newList
50+
notifyDataSetChanged()
51+
}
52+
}

app/src/main/java/com/example/projectfigma/Fragments/BestSeller.kt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
package com.example.projectfigma.Fragments
22

3+
import android.content.Intent
34
import android.os.Bundle
45
import androidx.fragment.app.Fragment
56
import android.view.LayoutInflater
67
import android.view.View
78
import android.view.ViewGroup
9+
import android.widget.TextView
10+
import com.example.projectfigma.Activity.AdverstsingPageActivity
11+
import com.example.projectfigma.Activity.BestSellerActivity
12+
import com.example.projectfigma.Activity.RegActivity
813
import com.example.projectfigma.R
914
import com.example.projectfigma.databinding.FragmentBestSellerBinding
1015
import com.example.projectfigma.databinding.FragmentDividingLineBinding
1116

1217
class BestSeller : Fragment() {
1318

1419
private var _binding: FragmentBestSellerBinding? = null
15-
private val binding get() = _binding!!
20+
private val binding get() = _binding
1621

1722
override fun onCreate(savedInstanceState: Bundle?) {
1823
super.onCreate(savedInstanceState)
@@ -24,6 +29,13 @@ class BestSeller : Fragment() {
2429
savedInstanceState: Bundle?
2530
): View {
2631
_binding = FragmentBestSellerBinding.inflate(inflater, container, false)
27-
return binding.root
32+
33+
binding?.tvViewAll?.setOnClickListener{
34+
val intent = Intent(requireContext(), BestSellerActivity::class.java)
35+
startActivity(intent)
36+
requireActivity().finish()
37+
}
38+
39+
return binding!!.root
2840
}
2941
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.example.projectfigma.Fragments
2+
3+
import android.os.Bundle
4+
import androidx.fragment.app.Fragment
5+
import android.view.LayoutInflater
6+
import android.view.View
7+
import android.view.ViewGroup
8+
import androidx.recyclerview.widget.GridLayoutManager
9+
import androidx.recyclerview.widget.RecyclerView
10+
import com.example.projectfigma.Adapters.MainBestSellerAdapter
11+
import com.example.projectfigma.DAO.DishesDao
12+
import com.example.projectfigma.DataBase.DataBase
13+
import com.example.projectfigma.Entites.Dishes
14+
import com.example.projectfigma.R
15+
16+
class MainBestSeller : Fragment(R.layout.fragment_main_best_seller) {
17+
18+
private lateinit var recyclerView: RecyclerView
19+
private lateinit var adapter: MainBestSellerAdapter
20+
private lateinit var database: DataBase
21+
private lateinit var dishesDao: DishesDao
22+
23+
override fun onCreate(savedInstanceState: Bundle?) {
24+
super.onCreate(savedInstanceState)
25+
}
26+
27+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
28+
super.onViewCreated(view, savedInstanceState)
29+
30+
recyclerView = view.findViewById(R.id.popularRecyclerView)
31+
recyclerView.layoutManager = GridLayoutManager(context, 2)
32+
33+
database = DataBase.getDb(requireContext())
34+
dishesDao = database.getDishesDao()
35+
36+
dishesDao.getBestSellers().observe(viewLifecycleOwner) { dishList ->
37+
adapter = MainBestSellerAdapter(dishList)
38+
recyclerView.adapter = adapter
39+
}
40+
}
41+
}

app/src/main/res/layout/activity_best_seller.xml

Lines changed: 28 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
xmlns:tools="http://schemas.android.com/tools"
55
android:layout_width="match_parent"
66
android:layout_height="match_parent"
7-
android:background="@drawable/background"
8-
tools:context=".BestSellerActivity">
7+
android:background="@drawable/background">
98

109
<!-- Заголовок -->
1110
<androidx.constraintlayout.widget.ConstraintLayout
@@ -22,76 +21,49 @@
2221
android:textColor="@android:color/white"
2322
android:textSize="28sp"
2423
android:textStyle="bold"
25-
app:layout_constraintTop_toTopOf="parent"
2624
app:layout_constraintBottom_toBottomOf="parent"
25+
app:layout_constraintEnd_toEndOf="parent"
26+
app:layout_constraintHorizontal_bias="0.498"
2727
app:layout_constraintStart_toStartOf="parent"
28-
app:layout_constraintEnd_toEndOf="parent" />
28+
app:layout_constraintTop_toTopOf="parent"
29+
app:layout_constraintVertical_bias="0.656" />
2930

3031
<ImageView
3132
android:id="@+id/exitArrow"
32-
android:layout_width="24dp"
33-
android:layout_height="24dp"
34-
android:src="@drawable/exit_arrow"
33+
android:layout_width="15dp"
34+
android:layout_height="15dp"
3535
android:layout_marginStart="16dp"
36+
android:src="@drawable/exit_arrow"
37+
app:layout_constraintBottom_toBottomOf="parent"
38+
app:layout_constraintEnd_toStartOf="@+id/loginHeader"
39+
app:layout_constraintHorizontal_bias="0.0"
3640
app:layout_constraintStart_toStartOf="parent"
3741
app:layout_constraintTop_toTopOf="parent"
38-
app:layout_constraintBottom_toBottomOf="parent" />
42+
app:layout_constraintVertical_bias="0.632" />
3943
</androidx.constraintlayout.widget.ConstraintLayout>
4044

41-
<!-- Основной контент -->
42-
<ScrollView
43-
android:layout_width="0dp"
44-
android:layout_height="0dp"
45-
android:fillViewport="true"
46-
app:layout_constraintTop_toBottomOf="@id/headerLayout"
47-
app:layout_constraintBottom_toTopOf="@+id/bottomPanel"
45+
<!-- Нижняя панель -->
46+
47+
<FrameLayout
48+
android:layout_width="match_parent"
49+
android:layout_height="654dp"
50+
app:layout_constraintEnd_toEndOf="parent"
4851
app:layout_constraintStart_toStartOf="parent"
49-
app:layout_constraintEnd_toEndOf="parent">
52+
app:layout_constraintTop_toBottomOf="@+id/headerLayout">
5053

51-
<LinearLayout
54+
<fragment
55+
android:id="@+id/food_favorite_fragment"
56+
android:name="com.example.projectfigma.Fragments.MainBestSeller"
5257
android:layout_width="match_parent"
53-
android:layout_height="wrap_content"
54-
android:orientation="vertical"
55-
android:background="@drawable/white_top_rounded"
56-
android:padding="16dp">
57-
58-
<!-- Подзаголовок -->
59-
<TextView
60-
android:id="@+id/text"
61-
android:layout_width="wrap_content"
62-
android:layout_height="wrap_content"
63-
android:text="Discover our most popular dishes!"
64-
android:textColor="@android:color/holo_orange_dark"
65-
android:textSize="18sp"
66-
android:textStyle="bold"
67-
android:layout_gravity="center_horizontal"
68-
android:layout_marginBottom="16dp" />
58+
android:layout_height="match_parent"
59+
tools:layout="@layout/fragment_main_best_seller" />
6960

70-
<!-- Grid из карточек -->
71-
<GridLayout
72-
android:id="@+id/gridLayout"
73-
android:layout_width="match_parent"
74-
android:layout_height="wrap_content"
75-
android:columnCount="2"
76-
android:rowCount="3"
77-
android:alignmentMode="alignMargins"
78-
android:useDefaultMargins="true">
61+
</FrameLayout>
7962

80-
<include layout="@layout/item_dish_best_seller" />
81-
<include layout="@layout/item_dish_best_seller" />
82-
<include layout="@layout/item_dish_best_seller" />
83-
<include layout="@layout/item_dish_best_seller" />
84-
<include layout="@layout/item_dish_best_seller" />
85-
<include layout="@layout/item_dish_best_seller" />
86-
</GridLayout>
87-
</LinearLayout>
88-
</ScrollView>
89-
90-
<!-- Нижняя панель -->
9163
<include
92-
android:id="@+id/bottomPanel"
9364
layout="@layout/fragment_bottom_panel"
94-
android:layout_width="match_parent"
65+
android:layout_width="wrap_content"
9566
android:layout_height="55dp"
96-
app:layout_constraintBottom_toBottomOf="parent" />
67+
app:layout_constraintBottom_toBottomOf="parent"
68+
app:layout_constraintEnd_toEndOf="parent" />
9769
</androidx.constraintlayout.widget.ConstraintLayout>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:app="http://schemas.android.com/apk/res-auto"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent">
7+
8+
<TextView
9+
android:id="@+id/titleText"
10+
android:layout_width="0dp"
11+
android:layout_height="wrap_content"
12+
android:text="Discover our most popular dishes!"
13+
android:textAppearance="@style/TextAppearance.AppCompat.Large"
14+
android:textColor="#FF5722"
15+
android:textAlignment="center"
16+
android:paddingStart="10dp"
17+
android:textSize="20dp"
18+
android:paddingEnd="10dp"
19+
app:layout_constraintTop_toTopOf="parent"
20+
app:layout_constraintStart_toStartOf="parent"
21+
app:layout_constraintEnd_toEndOf="parent"
22+
android:layout_marginTop="16dp"/>
23+
24+
<androidx.recyclerview.widget.RecyclerView
25+
android:id="@+id/popularRecyclerView"
26+
android:layout_width="0dp"
27+
android:layout_height="0dp"
28+
android:padding="8dp"
29+
app:layout_constraintBottom_toBottomOf="parent"
30+
app:layout_constraintEnd_toEndOf="parent"
31+
app:layout_constraintHorizontal_bias="0.0"
32+
app:layout_constraintStart_toStartOf="parent"
33+
app:layout_constraintTop_toBottomOf="@id/titleText"
34+
app:layout_constraintVertical_bias="0.0" />
35+
36+
</androidx.constraintlayout.widget.ConstraintLayout>

0 commit comments

Comments
 (0)