Skip to content

Commit

Permalink
points shop without api logic
Browse files Browse the repository at this point in the history
  • Loading branch information
sneh-saraff committed Feb 13, 2025
1 parent d075a75 commit 985b43c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ class ShopAdapter(private var itemList: List<ShopItem>) :
App.getAPI().addItemCart(item.itemId)
}

}

}

}

fun updateShop(shopItem: List<ShopItem>) {
this.itemList = shopItem
notifyDataSetChanged()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ class ShopFragment : Fragment() {
}
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val view = inflater.inflate(R.layout.fragment_point_shop, container, false)

merchButton = view.findViewById(R.id.merchButton)
Expand Down Expand Up @@ -119,12 +123,9 @@ class ShopFragment : Fragment() {
transaction.addToBackStack(null) // Optional, for back navigation
transaction.commit()
}

return view
}



// Called in onCreateView within shopLiveData.observe
private fun updateShopItems(newShop: List<ShopItem>) {
// Split the shop items into Merch and Raffle items
Expand All @@ -145,9 +146,19 @@ class ShopFragment : Fragment() {
private val merchClickListener = View.OnClickListener {
if (!merchButton.isSelected) {
merchButton.isSelected = true
merchButton.background = this.context?.let { it1 -> ContextCompat.getDrawable(it1, R.drawable.point_shop_selected_background) }
merchButton.background = this.context?.let { it1 ->
ContextCompat.getDrawable(
it1,
R.drawable.point_shop_selected_background
)
}
raffleButton.isSelected = false
raffleButton.background = this.context?.let { it1 -> ContextCompat.getDrawable(it1, R.drawable.point_shop_unselected_background) }
raffleButton.background = this.context?.let { it1 ->
ContextCompat.getDrawable(
it1,
R.drawable.point_shop_unselected_background
)
}
showingMerch = true
updateShopUI()
}
Expand All @@ -157,9 +168,19 @@ class ShopFragment : Fragment() {
private val raffleClickListener = View.OnClickListener {
if (!raffleButton.isSelected) {
raffleButton.isSelected = true
raffleButton.background = this.context?.let { it1 -> ContextCompat.getDrawable(it1, R.drawable.point_shop_selected_background) }
raffleButton.background = this.context?.let { it1 ->
ContextCompat.getDrawable(
it1,
R.drawable.point_shop_selected_background
)
}
merchButton.isSelected = false
merchButton.background = this.context?.let { it1 -> ContextCompat.getDrawable(it1, R.drawable.point_shop_unselected_background) }
merchButton.background = this.context?.let { it1 ->
ContextCompat.getDrawable(
it1,
R.drawable.point_shop_unselected_background
)
}
showingMerch = false
updateShopUI()
}
Expand All @@ -179,6 +200,7 @@ class ShopFragment : Fragment() {
private fun isAttendee(): Boolean {
val context = requireActivity().applicationContext
val prefString = context.getString(R.string.authorization_pref_file_key)
return context.getSharedPreferences(prefString, Context.MODE_PRIVATE).getString("provider", "") ?: "" == "github"
return context.getSharedPreferences(prefString, Context.MODE_PRIVATE)
.getString("provider", "") ?: "" == "github"
}
}

0 comments on commit 985b43c

Please sign in to comment.