Compare commits
6 Commits
ddc218f4cc
...
layout
| Author | SHA1 | Date | |
|---|---|---|---|
| acb211c219 | |||
| 47e1283ba2 | |||
| 88325e8abe | |||
| ee8d259c51 | |||
| 9e54bbc978 | |||
| a355301d68 |
@@ -4,6 +4,7 @@ import java.util.Properties
|
|||||||
plugins {
|
plugins {
|
||||||
id("com.android.application")
|
id("com.android.application")
|
||||||
id("org.jetbrains.kotlin.android")
|
id("org.jetbrains.kotlin.android")
|
||||||
|
id("androidx.navigation.safeargs")
|
||||||
}
|
}
|
||||||
|
|
||||||
val mqttProperties = Properties()
|
val mqttProperties = Properties()
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
// Inflate the menu; this adds items to the action bar if it is present.
|
// Inflate the menu; this adds items to the action bar if it is present.
|
||||||
menuInflater.inflate(R.menu.main, menu)
|
menuInflater.inflate(R.menu.threedots, menu)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package de.chrissthecoder.store.adapter
|
|||||||
|
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.viewpager2.adapter.FragmentStateAdapter
|
import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||||
import de.chrissthecoder.store.ui.dashboard.tabfragment.shoppinglist.ShoplistFragment
|
import de.chrissthecoder.store.ui.dashboard.tabfragment.shoppinglist.ShoppinglistShoplistFragment
|
||||||
import de.chrissthecoder.store.ui.dashboard.tabfragment.UnderstockFragment
|
import de.chrissthecoder.store.ui.dashboard.tabfragment.UnderstockFragment
|
||||||
|
|
||||||
class DashboardFragmentPagerAdapter(fragment: Fragment) : FragmentStateAdapter(fragment) {
|
class DashboardFragmentPagerAdapter(fragment: Fragment) : FragmentStateAdapter(fragment) {
|
||||||
@@ -12,7 +12,7 @@ class DashboardFragmentPagerAdapter(fragment: Fragment) : FragmentStateAdapter(f
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun createFragment(position: Int) : Fragment {
|
override fun createFragment(position: Int) : Fragment {
|
||||||
return if(position == 0) { ShoplistFragment() }
|
return if(position == 0) { ShoppinglistShoplistFragment() }
|
||||||
else { UnderstockFragment() }
|
else { UnderstockFragment() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package de.chrissthecoder.store.adapter
|
||||||
|
|
||||||
|
import android.util.Log
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.ImageView
|
||||||
|
import android.widget.TextView
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import de.chrissthecoder.store.R
|
||||||
|
import de.chrissthecoder.store.databinding.FragmentShoppinglistShoplistItemBinding
|
||||||
|
import de.chrissthecoder.store.dataclass.ShoppinglistShoplistItem
|
||||||
|
import de.chrissthecoder.store.interfaces.ShoppinglistShoplistItemClickListener
|
||||||
|
|
||||||
|
class ShoppinglistShoplistAdapter(val shoplist: List<ShoppinglistShoplistItem>, private val listener: ShoppinglistShoplistItemClickListener) : RecyclerView.Adapter<ShoppinglistShoplistAdapter.ItemViewHolder>() {
|
||||||
|
inner class ItemViewHolder(private val binding: FragmentShoppinglistShoplistItemBinding, private val listener: ShoppinglistShoplistItemClickListener) : RecyclerView.ViewHolder(binding.root) {
|
||||||
|
fun bindItem(item: ShoppinglistShoplistItem) {
|
||||||
|
binding.shoplabel.text = item.shoplabel
|
||||||
|
binding.shoppinglistCount.text = "(" + item.shoppinglistCount + ")"
|
||||||
|
binding.cardview.setOnClickListener {
|
||||||
|
listener.onClick(item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder {
|
||||||
|
Log.d(this.javaClass.name, "Create new views (invoked by the layout manager)")
|
||||||
|
val from = LayoutInflater.from(parent.context)
|
||||||
|
val binding = FragmentShoppinglistShoplistItemBinding.inflate(from, parent, false)
|
||||||
|
return ItemViewHolder(binding, listener)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: ShoppinglistShoplistAdapter.ItemViewHolder, position: Int) {
|
||||||
|
Log.d(this.javaClass.name,"Replace the contents of a view (invoked by the layout manager)")
|
||||||
|
holder.bindItem(shoplist[position])
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemCount(): Int {
|
||||||
|
Log.d(this.javaClass.name, "Return the size of your dataset (invoked by the layout manager)")
|
||||||
|
return shoplist.size
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
package de.chrissthecoder.store.dataclass
|
||||||
|
|
||||||
|
data class ShoppinglistShoplistItem(val shopID: Int, val shoplabel: String, val iconID: Int, val shoppinglistCount: Int)
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package de.chrissthecoder.store.interfaces
|
||||||
|
|
||||||
|
import de.chrissthecoder.store.dataclass.ShoppinglistShoplistItem
|
||||||
|
|
||||||
|
interface ShoppinglistShoplistItemClickListener {
|
||||||
|
fun onClick(shopitem: ShoppinglistShoplistItem)
|
||||||
|
}
|
||||||
@@ -7,16 +7,13 @@ import android.view.View
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import de.chrissthecoder.store.R
|
import de.chrissthecoder.store.R
|
||||||
|
|
||||||
/**
|
class ShoppinglistListsFragment : Fragment() {
|
||||||
* A [Fragment] subclass to list all shops that contains assigned shoppinglists.
|
|
||||||
*/
|
|
||||||
class ShoplistFragment : Fragment() {
|
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?,
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
): View? {
|
): View? {
|
||||||
// Inflate the layout for this fragment
|
// Inflate the layout for this fragment
|
||||||
return inflater.inflate(R.layout.fragment_shoppinglist_shoplist, container, false)
|
return inflater.inflate(R.layout.fragment_shoppinglist_lists, container, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package de.chrissthecoder.store.ui.dashboard.tabfragment.shoppinglist
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.navigation.fragment.findNavController
|
||||||
|
import de.chrissthecoder.store.R
|
||||||
|
import de.chrissthecoder.store.adapter.ShoppinglistShoplistAdapter
|
||||||
|
import de.chrissthecoder.store.databinding.FragmentShoppinglistShoplistBinding
|
||||||
|
import de.chrissthecoder.store.dataclass.ShoppinglistShoplistItem
|
||||||
|
import de.chrissthecoder.store.interfaces.ShoppinglistShoplistItemClickListener
|
||||||
|
import de.chrissthecoder.store.ui.dashboard.DashboardFragmentDirections
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A [Fragment] subclass to list all shops that contains assigned shoppinglists.
|
||||||
|
*/
|
||||||
|
class ShoppinglistShoplistFragment : Fragment(), ShoppinglistShoplistItemClickListener {
|
||||||
|
|
||||||
|
private var _binding: FragmentShoppinglistShoplistBinding? = null
|
||||||
|
private val binding get() = _binding!!
|
||||||
|
|
||||||
|
private lateinit var adapter: ShoppinglistShoplistAdapter
|
||||||
|
|
||||||
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||||
|
_binding = FragmentShoppinglistShoplistBinding.inflate(inflater, container, false)
|
||||||
|
|
||||||
|
val shoplist = ArrayList<ShoppinglistShoplistItem>()
|
||||||
|
shoplist.add(ShoppinglistShoplistItem(1,"Edeka", 0, 3))
|
||||||
|
|
||||||
|
val shoplistRecyclerView = binding.shoplist
|
||||||
|
adapter = ShoppinglistShoplistAdapter(shoplist, this)
|
||||||
|
shoplistRecyclerView.adapter = adapter
|
||||||
|
|
||||||
|
return binding.root
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onClick(shopitem: ShoppinglistShoplistItem) {
|
||||||
|
val direction = DashboardFragmentDirections.actionNavDashboardToShoppinglistLists(shopitem.shopID)
|
||||||
|
findNavController().navigate(direction)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,6 +20,6 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="start"
|
android:layout_gravity="start"
|
||||||
android:fitsSystemWindows="true"
|
android:fitsSystemWindows="true"
|
||||||
app:headerLayout="@layout/nav_header_main"
|
app:headerLayout="@layout/burger_header"
|
||||||
app:menu="@menu/activity_main_drawer" />
|
app:menu="@menu/burger" />
|
||||||
</androidx.drawerlayout.widget.DrawerLayout>
|
</androidx.drawerlayout.widget.DrawerLayout>
|
||||||
@@ -16,5 +16,5 @@
|
|||||||
app:layout_constraintLeft_toLeftOf="parent"
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
app:layout_constraintRight_toRightOf="parent"
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:navGraph="@navigation/mobile_navigation" />
|
app:navGraph="@navigation/app_navigation" />
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
9
app/src/main/res/layout/fragment_shoppinglist_lists.xml
Normal file
9
app/src/main/res/layout/fragment_shoppinglist_lists.xml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".ui.dashboard.tabfragment.shoppinglist.ShoppinglistListsFragment">
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -4,16 +4,16 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".ui.dashboard.tabfragment.shoppinglist.ShoplistFragment">
|
tools:context=".ui.dashboard.tabfragment.shoppinglist.ShoppinglistShoplistFragment">
|
||||||
|
|
||||||
<TextView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/shoplist"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:text="Einkaufszettel"
|
|
||||||
android:textAlignment="center"
|
|
||||||
android:textSize="32sp"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintVertical_bias="0.5" />
|
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"/>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<androidx.cardview.widget.CardView
|
||||||
|
android:id="@+id/cardview"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="15dp"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:layout_marginEnd="15dp"
|
||||||
|
app:cardBackgroundColor="@color/cardview_background"
|
||||||
|
app:cardCornerRadius="20dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/shoplabel"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="20dp"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:textColor="@color/cardview_textcolor"
|
||||||
|
android:textSize="24sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintVertical_bias="0.5" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/shopicon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="100dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="@+id/shoppinglistCount"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintVertical_bias="0.5"
|
||||||
|
app:srcCompat="@android:drawable/toast_frame" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/shoppinglistCount"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="20dp"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:textColor="@color/cardview_textcolor"
|
||||||
|
android:textSize="24sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintVertical_bias="0.5" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -9,7 +9,11 @@
|
|||||||
android:id="@+id/nav_dashboard"
|
android:id="@+id/nav_dashboard"
|
||||||
android:name="de.chrissthecoder.store.ui.dashboard.DashboardFragment"
|
android:name="de.chrissthecoder.store.ui.dashboard.DashboardFragment"
|
||||||
android:label="@string/menu_dashboard"
|
android:label="@string/menu_dashboard"
|
||||||
tools:layout="@layout/fragment_dashboard" />
|
tools:layout="@layout/fragment_dashboard" >
|
||||||
|
<action
|
||||||
|
android:id="@+id/action_nav_dashboard_to_shoppinglistLists"
|
||||||
|
app:destination="@id/shoppinglistLists" />
|
||||||
|
</fragment>
|
||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/nav_gallery"
|
android:id="@+id/nav_gallery"
|
||||||
@@ -22,4 +26,14 @@
|
|||||||
android:name="de.chrissthecoder.store.ui.slideshow.SlideshowFragment"
|
android:name="de.chrissthecoder.store.ui.slideshow.SlideshowFragment"
|
||||||
android:label="@string/menu_slideshow"
|
android:label="@string/menu_slideshow"
|
||||||
tools:layout="@layout/fragment_slideshow" />
|
tools:layout="@layout/fragment_slideshow" />
|
||||||
|
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/shoppinglistLists"
|
||||||
|
android:name="de.chrissthecoder.store.ui.dashboard.tabfragment.shoppinglist.ShoppinglistListsFragment"
|
||||||
|
android:label="@string/nav_shoppinglist"
|
||||||
|
tools:layout="@layout/fragment_shoppinglist_lists" >
|
||||||
|
<argument
|
||||||
|
android:name="shopID"
|
||||||
|
app:argType="integer" />
|
||||||
|
</fragment>
|
||||||
</navigation>
|
</navigation>
|
||||||
@@ -7,4 +7,7 @@
|
|||||||
<color name="teal_700">#FF018786</color>
|
<color name="teal_700">#FF018786</color>
|
||||||
<color name="black">#FF000000</color>
|
<color name="black">#FF000000</color>
|
||||||
<color name="white">#FFFFFFFF</color>
|
<color name="white">#FFFFFFFF</color>
|
||||||
|
|
||||||
|
<color name="cardview_background">#444444</color>
|
||||||
|
<color name="cardview_textcolor">#FFFFFF</color>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -13,4 +13,6 @@
|
|||||||
|
|
||||||
<string name="tab_shoppinglist">Einkaufszettel</string>
|
<string name="tab_shoppinglist">Einkaufszettel</string>
|
||||||
<string name="tab_understock">Minderbestand</string>
|
<string name="tab_understock">Minderbestand</string>
|
||||||
|
|
||||||
|
<string name="nav_shoppinglist">Einkaufszettel</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -1,4 +1,12 @@
|
|||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
dependencies {
|
||||||
|
val nav_version = "2.7.7"
|
||||||
|
classpath("androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("com.android.application") version "8.3.0" apply false
|
id("com.android.application") version "8.3.0" apply false
|
||||||
id("org.jetbrains.kotlin.android") version "1.9.22" apply false
|
id("org.jetbrains.kotlin.android") version "1.9.22" apply false
|
||||||
|
|||||||
Reference in New Issue
Block a user