Skip to content

Commit

Permalink
Merge pull request #20 from Bry-Dev/development
Browse files Browse the repository at this point in the history
Change date color of overdue shopping list
  • Loading branch information
Bry-Dev committed May 10, 2021
2 parents 3926246 + 0c4663b commit fe75ea8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import android.widget.*
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.navigation.fragment.findNavController
import com.example.homeinventory.R
import com.example.homeinventory.model.ShoppingItem
import com.example.homeinventory.ui.home.HomeViewModel
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.example.homeinventory.ui.shopping

import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.databinding.BindingAdapter
import com.example.homeinventory.R
import com.example.homeinventory.model.ShoppingForHome
import java.time.LocalDate

@BindingAdapter("shoppingItemName")
fun TextView.setShoppingName(shoppingForHome : ShoppingForHome) {
Expand All @@ -21,6 +24,9 @@ fun TextView.setShoppingQty(shoppingForHome : ShoppingForHome) {
@BindingAdapter("shoppingItemDate")
fun TextView.setShoppingDate(shoppingForHome : ShoppingForHome) {
shoppingForHome.let{
text = it.shoppingItem.itemBuyDate.toString()
val shopDate = it.shoppingItem.itemBuyDate.toString().trim()
text = shopDate
val toDate = LocalDate.now()
if (LocalDate.parse(shopDate) < toDate) setTextColor(ContextCompat.getColor(context, R.color.attention))
}
}

0 comments on commit fe75ea8

Please sign in to comment.