Skip to content

Commit

Permalink
Merge pull request #555 from HackIllinois/aditya/staff-page-reworking
Browse files Browse the repository at this point in the history
Android Staff Page Reworking
  • Loading branch information
AdityaK2905 authored Nov 20, 2024
2 parents ea996e4 + 9d079b0 commit 27e9e85
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 9 deletions.
7 changes: 3 additions & 4 deletions app/src/main/java/org/hackillinois/android/API.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import org.hackillinois.android.model.scanner.MentorId
import org.hackillinois.android.model.scanner.Points
import org.hackillinois.android.model.scanner.UserEventPair
import org.hackillinois.android.model.shop.ItemInstance
import org.hackillinois.android.model.shop.ItemName
import org.hackillinois.android.model.user.FavoritesResponse
import org.hackillinois.android.model.version.Version
import org.hackillinois.android.notifications.DeviceToken
Expand Down Expand Up @@ -68,7 +67,7 @@ interface API {
suspend fun shop(): List<ShopItem>

@POST("shop/item/buy/")
suspend fun buyShopItem(@Body body: ItemInstance): ItemName
suspend fun buyShopItem(@Body body: ItemInstance): ShopItem

// STAFF

Expand All @@ -89,8 +88,8 @@ interface API {
@PUT("user/follow/")
fun followEvent(@Body eventId: EventId): Call<FavoritesResponse>

@PUT("user/unfollow/")
fun unfollowEvent(@Body eventId: EventId): Call<FavoritesResponse>
@DELETE("user/unfollow/{eventId}")
fun unfollowEvent(@Path("eventId") eventId: EventId): Call<FavoritesResponse>

@GET("user/v2-qr/")
suspend fun qrCode(): QR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,25 @@ class ProfileFragment : Fragment() {
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
// if not an attendee, set the layout to be the not logged in profile
if (!hasLoggedIn() or (hasLoggedIn() and isStaff())) {
if (!hasLoggedIn()) {
val view = inflater.inflate(R.layout.fragment_profile_not_logged_in, container, false)
val logoutButton = view.findViewById<Button>(R.id.logout_button)
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 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
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ class ScannerViewModel : ViewModel() {
viewModelScope.launch {
try {
Log.d("ITEMINSTANCE", body.toString())
val itemName = App.getAPI().buyShopItem(body)
val message = "You have successfully redeemed ${itemName.itemName} from the Point Shop!"
val item = App.getAPI().buyShopItem(body)
val message = "You have successfully redeemed ${item.name} from the Point Shop!"
val scanStatus = ScanStatus(message, true)
lastScanStatus.postValue(scanStatus)
} catch (e: Exception) {
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
88 changes: 88 additions & 0 deletions app/src/main/res/layout/fragment_profile_staff.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?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"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/witchyPurple">

<ImageView
android:layout_width="0dp"
android:layout_height="0dp"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="@drawable/dark_fantasy_bg_2024"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<androidx.constraintlayout.widget.Guideline
android:id="@+id/guidelineTop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.05" />

<TextView
android:id="@+id/title_textview_profile"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="35dp"
android:fontFamily="@font/montserrat_bold"
android:gravity="start"
android:text="@string/profile"
android:textColor="@color/palePeach"
android:textSize="24sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/guidelineTop" />

<TextView
android:id="@+id/logout_textview"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="30dp"
android:fontFamily="@font/montserrat_semi_bold"
android:gravity="center"
android:text="@string/not_logged_in_message"
android:textColor="@color/white"
android:textSize="17sp"
app:layout_constraintVertical_bias="0.40"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/title_textview_profile" />

<ImageButton
android:id="@+id/logoutButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="35dp"
android:background="@android:color/transparent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/guidelineTop"
app:srcCompat="@drawable/ic_logout" />

<com.google.android.material.button.MaterialButton
android:id="@+id/login_button"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
app:cornerRadius="24dp"
app:strokeWidth="2.5dp"
app:strokeColor="@color/white"
android:fontFamily="@font/montserrat_bold"
android:paddingHorizontal="30dp"
android:text="@string/profile_login"
android:textAllCaps="false"
android:textColor="@color/white"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/logout_textview"
tools:ignore="TouchTargetSizeCheck" />

</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit 27e9e85

Please sign in to comment.