Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ dependencies {
implementation("androidx.constraintlayout:constraintlayout:2.2.1")

implementation("androidx.room:room-ktx:2.7.1")
implementation(libs.androidx.activity)
kapt("androidx.room:room-compiler:2.7.1")

testImplementation("junit:junit:4.13.2")
Expand Down
16 changes: 10 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
android:supportsRtl="true"
android:theme="@style/Theme.Project"
tools:targetApi="31">
<activity
android:name=".Activity.AdvertisingPage"
android:exported="false" />
<activity
android:name=".Activity.MainActivity"
android:exported="true">
Expand All @@ -22,12 +25,13 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Activity.WelcomeActivity"/>
<activity android:name=".Activity.LogActivity"/>
<activity android:name=".Activity.RegActivity"/>
<activity android:name=".Activity.HomeActivity"/>
<activity android:name=".Activity.ForgetPasswordActivity"/>
<activity android:name=".Activity.FavoritesActivity"/>
<activity android:name=".Activity.WelcomeActivity" />
<activity android:name=".Activity.LogActivity" />
<activity android:name=".Activity.RegActivity" />
<activity android:name=".Activity.HomeActivity" />
<activity android:name=".Activity.ForgetPasswordActivity" />
<activity android:name=".Activity.FavoritesActivity" />
<activity android:name=".Activity.AdverstsingPageActivity" />

<meta-data
android:name="preloaded_fonts"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.example.projectfigma.Activity

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.example.projectfigma.Fragments.BottomPanelFragment
import com.example.projectfigma.R
import com.example.projectfigma.Util.StatusBar
import com.example.projectfigma.databinding.ActivityAdvertisingPageBinding
import com.example.projectfigma.databinding.ActivityFavoritesBinding

class AdverstsingPageActivity : AppCompatActivity() {
private lateinit var binding: ActivityAdvertisingPageBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

binding = ActivityAdvertisingPageBinding.inflate(layoutInflater)
setContentView(binding.root)
StatusBar.hideStatusBar(window)

supportFragmentManager.beginTransaction()
.replace(R.id.buttonPanel, BottomPanelFragment())
.commit()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.example.projectfigma.Activity

import android.graphics.Paint
import android.os.Bundle
import android.widget.TextView
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.example.projectfigma.R

class AdvertisingPage : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContentView(R.layout.activity_advertising_page)
val tv: TextView = findViewById(R.id.customtext1piska)
tv.paintFlags = tv.paintFlags or Paint.STRIKE_THRU_TEXT_FLAG

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,26 @@ import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.cardview.widget.CardView
import androidx.recyclerview.widget.RecyclerView
import com.example.projectfigma.Entites.Dishes
import com.example.projectfigma.R

class PromoAdapter(private var items: List<Dishes>) :
class PromoAdapter(
private var items: List<Dishes>,
private val onBannerClick: () -> Unit) :
RecyclerView.Adapter<PromoAdapter.VH>() {

inner class VH(view: View) : RecyclerView.ViewHolder(view) {
private val image: ImageView = view.findViewById(R.id.promo_image)
private val title: TextView = view.findViewById(R.id.title)
private val discount: TextView = view.findViewById(R.id.discount)
private val fullCard: CardView = view.findViewById(R.id.fullCard)

fun bind(item: Dishes) {
title.text = "Experience our delicious new dish"
discount.text = "${30}% OFF"
fullCard.setOnClickListener { onBannerClick() }
}
}

Expand Down
56 changes: 31 additions & 25 deletions app/src/main/java/com/example/projectfigma/Fragments/BannerFood.kt
Original file line number Diff line number Diff line change
@@ -1,85 +1,91 @@
package com.example.projectfigma.Fragments

import android.content.Intent
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 androidx.lifecycle.lifecycleScope
import androidx.viewpager2.widget.ViewPager2
import com.example.projectfigma.Activity.AdverstsingPageActivity
import com.example.projectfigma.Activity.LogActivity
import com.example.projectfigma.Adapters.PromoAdapter
import com.example.projectfigma.DataBase.DataBase
import com.example.projectfigma.R
import com.example.projectfigma.databinding.FragmentBannerFoodBinding
import com.example.projectfigma.databinding.FragmentBestSellerBinding
import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayoutMediator
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext

class BannerFood : Fragment() {
private var _binding: FragmentBannerFoodBinding? = null
private val binding get() = _binding!!
private lateinit var promoAdapter: PromoAdapter


override fun onCreate(savedInstanceState: Bundle?) {

super.onCreate(savedInstanceState)
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
_binding = FragmentBannerFoodBinding.inflate(inflater, container, false)
return binding.root
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

// 1) Инициализируем адаптер
promoAdapter = PromoAdapter(emptyList())
promoAdapter = PromoAdapter(emptyList()) {
val intent = Intent(requireContext(), AdverstsingPageActivity::class.java)
startActivity(intent)
requireActivity().finish()
}
binding.viewPager.adapter = promoAdapter

// 2) Настраиваем TabLayoutMediator, сразу задаём иконки
TabLayoutMediator(binding.tabLayout, binding.viewPager) { tab, _ ->
tab.setIcon(R.drawable.tab_indicator_unselected)
tab.setIcon(com.example.projectfigma.R.drawable.tab_indicator_unselected)
}.attach()

// 3) Подписываемся на смену вкладки, чтобы менять иконки
// 3) Слушаем смену вкладки для изменения иконки
binding.tabLayout.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener {
override fun onTabSelected(tab: TabLayout.Tab) {
tab.setIcon(R.drawable.tab_indicator_selected)
tab.setIcon(com.example.projectfigma.R.drawable.tab_indicator_selected)
}

override fun onTabUnselected(tab: TabLayout.Tab) {
tab.setIcon(R.drawable.tab_indicator_unselected)
tab.setIcon(com.example.projectfigma.R.drawable.tab_indicator_unselected)
}

override fun onTabReselected(tab: TabLayout.Tab) {}
})

// 4) Тут же можете запустить автопрокрутку, если она нужна в фрагменте
val handler = Handler(Looper.getMainLooper())
handler.postDelayed(object : Runnable {
override fun run() {
// 4) Автопрокрутка с помощью корутины
viewLifecycleOwner.lifecycleScope.launch(Dispatchers.Main) {
while (isActive) {
delay(4000)
if (promoAdapter.itemCount > 1) {
val next = (binding.viewPager.currentItem + 1) % promoAdapter.itemCount
binding.viewPager.setCurrentItem(next, true)
}
handler.postDelayed(this, 4000)
}
}, 4000)
}

// 5) А обновление списка (LiveData) можно тоже повесить здесь:
// 5) Обновление списка из БД
val dao = DataBase.getDb(requireContext()).getDishesDao()
dao.getBestSellers().observe(viewLifecycleOwner) { list ->
promoAdapter.updateList(list)
}
}

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
_binding = FragmentBannerFoodBinding.inflate(inflater, container, false)
return binding.root
}

override fun onDestroyView() {
super.onDestroyView()
_binding = null
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/drawable/bg_rating.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="#80000000"/>
<corners android:radius="8dp"/>
<solid android:color="@color/white"/>
<corners android:radius="50dp"/>
</shape>
8 changes: 8 additions & 0 deletions app/src/main/res/drawable/bg_rating_orange.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<solid android:color="@color/organe" /> <!-- Твой цвет фона -->

<corners android:radius="50dp" /> <!-- Радиус скругления -->
</shape>
4 changes: 4 additions & 0 deletions app/src/main/res/drawable/bg_skibidi_tualet.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="@color/white"/>
<corners android:radius="25dp"/>
</shape>
Binary file added app/src/main/res/drawable/ic_add_to_card.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/ic_discount_30.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/ic_heart_in_circle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/ic_heart_unborder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/ic_minus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/ic_plus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading