Skip to content

Commit

Permalink
feat: requests page
Browse files Browse the repository at this point in the history
  • Loading branch information
iamyajat committed Feb 4, 2023
1 parent 6f1cb31 commit 69a6694
Show file tree
Hide file tree
Showing 12 changed files with 515 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
package com.dscvit.vitty.ui.community

import android.content.SharedPreferences
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
import androidx.navigation.findNavController
import com.dscvit.vitty.R
import com.dscvit.vitty.databinding.FragmentCommunityBinding
import com.dscvit.vitty.util.Constants

class CommunityFragment : Fragment() {

private var _binding: FragmentCommunityBinding? = null
private lateinit var prefs: SharedPreferences


// This property is only valid between onCreateView and
// onDestroyView.
Expand All @@ -27,6 +33,33 @@ class CommunityFragment : Fragment() {
_binding = FragmentCommunityBinding.inflate(inflater, container, false)
val root: View = binding.root

prefs = requireContext().getSharedPreferences(Constants.USER_INFO, 0)

binding.communityToolbar.setOnMenuItemClickListener { menuItem ->
when (menuItem.itemId) {
R.id.requests -> {
requireView().findNavController()
.navigate(R.id.action_navigation_community_to_navigation_requests)
true
}
else -> {
false
}
}
}

if (!prefs.getBoolean("KRISH", false)) {
binding.krish.visibility = View.GONE
} else {
binding.krish.visibility = View.VISIBLE
}

binding.krish.setOnLongClickListener {
prefs.edit().putBoolean("KRISH", false).apply()
binding.krish.visibility = View.GONE
true
}

return root
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.dscvit.vitty.ui.community

import android.content.SharedPreferences
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
import com.dscvit.vitty.R
import com.dscvit.vitty.databinding.FragmentRequestsBinding
import com.dscvit.vitty.util.Constants

class RequestsFragment : Fragment() {

private var _binding: FragmentRequestsBinding? = null

// This property is only valid between onCreateView and
// onDestroyView.
private val binding get() = _binding!!
private lateinit var prefs: SharedPreferences


override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
val communityViewModel =
ViewModelProvider(this)[CommunityViewModel::class.java]

_binding = FragmentRequestsBinding.inflate(inflater, container, false)
val root: View = binding.root

prefs = requireContext().getSharedPreferences(Constants.USER_INFO, 0)

binding.scheduleToolbar.setOnMenuItemClickListener { menuItem ->
when (menuItem.itemId) {
R.id.close -> {
requireActivity().onBackPressed()
true
}
else -> {
false
}
}
}

binding.logout.setOnClickListener {
prefs.edit().putBoolean("KRISH", true).apply()
binding.reqKrish.visibility = View.GONE
}

if (prefs.getBoolean("KRISH", false)) {
binding.reqKrish.visibility = View.GONE
} else {
binding.reqKrish.visibility = View.VISIBLE
}

return root
}

override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
}
6 changes: 6 additions & 0 deletions app/src/main/java/com/dscvit/vitty/util/APIConstants.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.dscvit.vitty.util

object APIConstants {
const val BASE_URL = "https://shielded-beyond-17845.herokuapp.com"
const val TIMEOUT = 10
}
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_requests.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M13,8c0,-2.21 -1.79,-4 -4,-4S5,5.79 5,8s1.79,4 4,4S13,10.21 13,8zM15,10v2h3v3h2v-3h3v-2h-3V7h-2v3H15zM1,18v2h16v-2c0,-2.66 -5.33,-4 -8,-4S1,15.34 1,18z"/>
</vector>
6 changes: 6 additions & 0 deletions app/src/main/res/drawable/nav_color.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:color="@android:color/white" />
<item android:state_pressed="true" android:state_enabled="true" android:color="@color/translucent_head" />
<item android:color="@color/translucent_imp" />
</selector>
5 changes: 3 additions & 2 deletions app/src/main/res/layout/activity_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:background="@color/tab_back"
app:itemIconTint="@color/white"
app:itemTextColor="@color/white"
app:itemIconTint="@drawable/nav_color"
app:itemTextColor="@drawable/nav_color"
app:itemRippleColor="@color/translucent_ripple"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
Expand Down
Loading

0 comments on commit 69a6694

Please sign in to comment.