Skip to content

Commit

Permalink
Fixed logout button
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaK2905 committed Nov 17, 2024
1 parent a1d8c35 commit def5bfb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import android.graphics.Bitmap
import android.graphics.Color
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand Down Expand Up @@ -68,16 +69,24 @@ class ProfileFragment : Fragment() {
// if not an attendee, set the layout to be the not logged in profile
if (!hasLoggedIn()) {
val view = inflater.inflate(R.layout.fragment_profile_not_logged_in, container, false)
val logoutButton = view.findViewById<Button>(R.id.logout_button)
logoutButton.setOnClickListener {
val loginButton = view.findViewById<Button>(R.id.login_button)
loginButton.setOnClickListener {
val mainActivity: MainActivity = requireActivity() as MainActivity
mainActivity.logout()
}

return view
}
if (isStaff()) {
val view = inflater.inflate(R.layout.fragment_profile_staff, container, false)
val logoutButton = view.findViewById<Button>(R.id.logout_button)
val loginButton = view.findViewById<Button>(R.id.login_button)
loginButton.setOnClickListener {
// Log.d("Staff Logout", "Attempting Logout")
val mainActivity: MainActivity = requireActivity() as MainActivity
mainActivity.logout()
}

val logoutButton = view.findViewById<ImageButton>(R.id.logoutButton)
logoutButton.setOnClickListener {
val mainActivity: MainActivity = requireActivity() as MainActivity
mainActivity.logout()
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_profile_not_logged_in.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
app:layout_constraintTop_toBottomOf="@+id/title_textview_profile" />

<com.google.android.material.button.MaterialButton
android:id="@+id/logout_button"
android:id="@+id/login_button"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_profile_staff.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
app:srcCompat="@drawable/ic_logout" />

<com.google.android.material.button.MaterialButton
android:id="@+id/logout_button"
android:id="@+id/login_button"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down

0 comments on commit def5bfb

Please sign in to comment.