Skip to content

Redesigned the Admin page with proper functionality#49

Open
siddhigupta075 wants to merge 2 commits into
iiitl:masterfrom
siddhigupta075:feature/admin-page-redesign
Open

Redesigned the Admin page with proper functionality#49
siddhigupta075 wants to merge 2 commits into
iiitl:masterfrom
siddhigupta075:feature/admin-page-redesign

Conversation

@siddhigupta075
Copy link
Copy Markdown
Contributor

@siddhigupta075 siddhigupta075 commented Apr 12, 2026

Resolves #24

Description

This pull request enhances the Admin page UI to improve visual appeal and user experience. There were also small changes in AdminFragment.kt to improve user experience.

UI Changes:

  • Improved overall layout and spacing
  • Made the card design cleaner with better elevation
  • Fixed icon alignment in input fields
  • Improved input field design with reounded corners
  • Updated button design to look more modern

Code Changes;

  • Added basic validation for email and designation
  • Show errors if input is incorrect
  • Displayed button while adding to prevent multiple clicks
  • Added loading text while adding ("Adding")
  • Cleared input fields after success
  • Updated ViewBinding to avoid memory leaks

Screenshots:

image

If applicable, include a link or screenshots of a live demo

Checkout

  • I have read all the contributor guidelines for the repo.

Summary by CodeRabbit

  • New Features

    • Enhanced form validation for committee member addition with inline error messages for required fields
    • Improved add button feedback with "Adding..." state during submission
  • Style

    • Updated icon colors and design elements in the admin panel
    • Refined card and form input styling with improved visual hierarchy and effects

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 12, 2026

Walkthrough

This PR redesigns the Admin page with enhanced validation logic and updated UI styling. Changes include implementing proper view binding with cleanup, adding email format and designation validation, introducing new gradient drawable resources, and comprehensively updating the layout structure with refined styling for cards, form inputs, and action buttons.

Changes

Cohort / File(s) Summary
Fragment Logic & View Binding
app/src/main/java/com/theayushyadav11/MessEase/ui/NavigationDrawers/Fragments/AdminFragment.kt
Implemented nullable view binding with cleanup in onDestroyView(). Replaced add() with validateAndAdd() method that validates email (required, EMAIL_ADDRESS pattern) and designation (required) fields, setting inline errors on TextInputLayouts. Enhanced button state management: disables button, updates text to "Adding...", and shows progress dialog during submission. Simplified adapter setup by removing local variables.
Drawable Resources
app/src/main/res/drawable/baseline_attach_email_24.xml, app/src/main/res/drawable/baseline_person_24.xml, app/src/main/res/drawable/bg_card_glass_inner.xml, app/src/main/res/drawable/bg_gradient_full.xml, app/src/main/res/drawable/bg_icon_soft.xml
Updated icon drawables to reference @color/food resource instead of hardcoded hex color. Added three new gradient/shape drawables: bg_card_glass_inner.xml (vertical white-to-light-gray gradient with rounded corners), bg_gradient_full.xml (orange gradient #FF6F00#FFB74D), and bg_icon_soft.xml (semi-transparent white shape with pill-shaped corners).
Layout Redesign
app/src/main/res/layout/fragment_admin.xml
Removed root ID and restructured header section with added subtitle TextView and adjusted divider positioning. Reworked MaterialCardView: updated corner radius, elevation, stroke properties, and applied new glass inner background drawable. Enhanced form inputs (email and designation) with rounded corners, adjusted stroke widths, drawableStart icons, padding, and text styling. Updated action button with increased margin, letterSpacing, corner radius, and elevation.

Sequence Diagram

sequenceDiagram
    actor User
    participant Fragment as AdminFragment
    participant UI as UI Elements
    participant ViewModel as ViewModel
    participant Backend as Backend/Database

    User->>Fragment: Click Add Button
    Fragment->>Fragment: validateAndAdd()
    Fragment->>UI: Check email field
    UI-->>Fragment: Email value
    Fragment->>UI: Check designation field
    UI-->>Fragment: Designation value
    
    alt Validation Fails
        Fragment->>UI: Set error on email/designation
        UI-->>Fragment: Error displayed
    else Validation Passes
        Fragment->>UI: Disable Add button
        Fragment->>UI: Update button text to "Adding..."
        Fragment->>UI: Show progress dialog
        Fragment->>ViewModel: addToMessCommittee(email, designation)
        ViewModel->>Backend: Submit data
        Backend-->>ViewModel: Success/Response
        ViewModel-->>Fragment: Result
        Fragment->>UI: Dismiss progress dialog
        Fragment->>UI: Re-enable Add button
        Fragment->>UI: Restore button text
        Fragment->>UI: Show success toast
        Fragment->>UI: Clear email input
        Fragment->>UI: Clear designation input
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: redesigning the Admin page UI and implementing proper validation/functionality, which matches the changeset across AdminFragment.kt and fragment_admin.xml.
Linked Issues check ✅ Passed The pull request fully implements the objectives from issue #24: redesigns fragment_admin.xml, adds input validation (email format and required fields), implements button state management, clears inputs after success, and updates ViewBinding to avoid memory leaks.
Out of Scope Changes check ✅ Passed The additional drawable resource files (bg_card_glass_inner.xml, bg_gradient_full.xml, bg_icon_soft.xml, and icon tint updates) support the UI redesign and are directly related to the Admin page visual improvements, thus remaining in scope.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
app/src/main/res/drawable/baseline_attach_email_24.xml (1)

2-2: Remove app:tint from <path> element; tinting is only supported on the <vector> root.

The app:tint attribute on individual <path> elements is not part of the VectorDrawable specification and will have no effect. VectorDrawable only supports tinting via android:tint on the <vector> root element. Path elements should use android:fillColor or android:strokeColor instead. Removing the unused namespace and attribute clarifies intent and reduces confusion.

Proposed cleanup
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
     android:width="24dp"
     android:height="24dp"
     android:tint="@color/food"
     android:viewportWidth="24"
     android:viewportHeight="24">
@@
     <path
         android:fillColor="@android:color/white"
-        app:tint="@color/food"
         android:pathData="M21,14v4c0,1.1 -0.9,2 -2,2s-2,-0.9 -2,-2v-4.5c0,-0.28 0.22,-0.5 0.5,-0.5s0.5,0.22 0.5,0.5V18h2v-4.5c0,-1.38 -1.12,-2.5 -2.5,-2.5S15,12.12 15,13.5V18c0,2.21 1.79,4 4,4s4,-1.79 4,-4v-4H21z" />
 </vector>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/src/main/res/drawable/baseline_attach_email_24.xml` at line 2, The XML
has an invalid app:tint on a <path> element and an unnecessary xmlns:app
declaration; remove the app:tint attribute from the path(s) and delete the
unused xmlns:app namespace on the root <vector> (tinting is only supported via
android:tint on the <vector> root). If you intended to change path color, set
android:fillColor or android:strokeColor on the affected <path> elements
instead, or move any global tint to the <vector> root using android:tint.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@app/src/main/java/com/theayushyadav11/MessEase/ui/NavigationDrawers/Fragments/AdminFragment.kt`:
- Around line 78-89: The async callbacks passed to viewModel.addToMessCommittee
(and the similar callback at lines 94-100) access binding and requireContext()
after async work, which can crash if the Fragment view is destroyed; update the
callback bodies to first check the Fragment/view lifecycle (e.g.,
viewLifecycleOwner.lifecycle.currentState.isAtLeast(Lifecycle.State.STARTED) or
isAdded() && view != null) before touching binding or calling requireContext(),
and bail out silently if the view is gone—ensure all UI updates
(mess.pbDismiss(), binding.btnAdd.*, mess.toast(...), clearing fields) are
guarded by that check or run via view?.let { ... } so no UI is accessed after
destruction.
- Around line 50-61: Before running the validation when-block in AdminFragment
(the block checking email and designation using android.util.Patterns), clear
any existing error messages on the involved TextInputLayouts first; e.g., set
binding.tilEmail.error = null and binding.tilspin.error = null (and any other
tilX used for inputs) immediately before the when { ... } so stale errors are
removed and only current validation failures are shown.

In `@app/src/main/res/layout/fragment_admin.xml`:
- Around line 23-34: The ImageView with id ivHeaderIcon is missing accessibility
semantics; update the element for accessibility by adding an appropriate
android:contentDescription—use a meaningful string resource (e.g.,
`@string/header_icon_description`) if the icon conveys information, or set
android:contentDescription="@null" (and optionally
android:importantForAccessibility="no") if it's purely decorative; ensure you
edit the ImageView with id ivHeaderIcon to include this attribute.

---

Nitpick comments:
In `@app/src/main/res/drawable/baseline_attach_email_24.xml`:
- Line 2: The XML has an invalid app:tint on a <path> element and an unnecessary
xmlns:app declaration; remove the app:tint attribute from the path(s) and delete
the unused xmlns:app namespace on the root <vector> (tinting is only supported
via android:tint on the <vector> root). If you intended to change path color,
set android:fillColor or android:strokeColor on the affected <path> elements
instead, or move any global tint to the <vector> root using android:tint.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9e8999f5-513f-4715-811e-4b0dc9c7f54d

📥 Commits

Reviewing files that changed from the base of the PR and between b8a8e9f and 99d8447.

📒 Files selected for processing (7)
  • app/src/main/java/com/theayushyadav11/MessEase/ui/NavigationDrawers/Fragments/AdminFragment.kt
  • app/src/main/res/drawable/baseline_attach_email_24.xml
  • app/src/main/res/drawable/baseline_person_24.xml
  • app/src/main/res/drawable/bg_card_glass_inner.xml
  • app/src/main/res/drawable/bg_gradient_full.xml
  • app/src/main/res/drawable/bg_icon_soft.xml
  • app/src/main/res/layout/fragment_admin.xml

Comment on lines +50 to +61
when {
email.isEmpty() -> {
binding.tilEmail.error = "Email required"
}

fun add() {
if (binding.etEmail.text.toString().isNotEmpty()) {
mess.addPb("Adding to Mess Committee")
viewModel.addToMessCommittee(
binding.etEmail.text.toString(),
binding.spinnerAutoComplete.text.toString()
)
{
mess.pbDismiss()
mess.toast(it)
!android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches() -> {
binding.tilEmail.error = "Invalid email"
}
} else {
mess.toast("Please enter email")

designation.isEmpty() -> {
binding.tilspin.error = "Select designation"
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Clear field errors before validation branches to avoid stale messages.

If one field becomes valid and another fails, the old error can remain visible.

Small validation cleanup
 private fun validateAndAdd() {
     val email = binding.etEmail.text.toString().trim()
     val designation = binding.spinnerAutoComplete.text.toString().trim()

+    binding.tilEmail.error = null
+    binding.tilspin.error = null
+
     when {
         email.isEmpty() -> {
             binding.tilEmail.error = "Email required"
         }
         !android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches() -> {
             binding.tilEmail.error = "Invalid email"
         }
         designation.isEmpty() -> {
             binding.tilspin.error = "Select designation"
         }
         else -> {
-            binding.tilEmail.error = null
-            binding.tilspin.error = null
             add(email, designation)
         }
     }
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@app/src/main/java/com/theayushyadav11/MessEase/ui/NavigationDrawers/Fragments/AdminFragment.kt`
around lines 50 - 61, Before running the validation when-block in AdminFragment
(the block checking email and designation using android.util.Patterns), clear
any existing error messages on the involved TextInputLayouts first; e.g., set
binding.tilEmail.error = null and binding.tilspin.error = null (and any other
tilX used for inputs) immediately before the when { ... } so stale errors are
removed and only current validation failures are shown.

Comment on lines +78 to 89
viewModel.addToMessCommittee(email, designation) {
mess.pbDismiss()

binding.btnAdd.isEnabled = true
binding.btnAdd.text = "Add to Committee"

mess.toast(it)

// Clear fields after success
binding.etEmail.text?.clear()
binding.spinnerAutoComplete.text?.clear()
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Guard async callbacks against Fragment view destruction.

These callbacks use binding/requireContext() after async work. If the view is destroyed first, this can crash.

Safer callback handling
 private fun add(email: String, designation: String) {
     binding.btnAdd.isEnabled = false
     binding.btnAdd.text = "Adding..."
     mess.addPb("Adding to Mess Committee")

     viewModel.addToMessCommittee(email, designation) {
+        val b = _binding ?: return@addToMessCommittee
         mess.pbDismiss()
-        binding.btnAdd.isEnabled = true
-        binding.btnAdd.text = "Add to Committee"
+        b.btnAdd.isEnabled = true
+        b.btnAdd.text = "Add to Committee"
         mess.toast(it)
-        binding.etEmail.text?.clear()
-        binding.spinnerAutoComplete.text?.clear()
+        b.etEmail.text?.clear()
+        b.spinnerAutoComplete.text?.clear()
     }
 }

 private fun setAdapter() {
     mess.getLists("${DESIGNATION}s") {
+        val b = _binding ?: return@getLists
+        val ctx = context ?: return@getLists
         val adapter = ArrayAdapter(
-            requireContext(),
+            ctx,
             android.R.layout.simple_dropdown_item_1line,
             it
         )
-        binding.spinnerAutoComplete.setAdapter(adapter)
+        b.spinnerAutoComplete.setAdapter(adapter)
     }
 }

Also applies to: 94-100

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@app/src/main/java/com/theayushyadav11/MessEase/ui/NavigationDrawers/Fragments/AdminFragment.kt`
around lines 78 - 89, The async callbacks passed to viewModel.addToMessCommittee
(and the similar callback at lines 94-100) access binding and requireContext()
after async work, which can crash if the Fragment view is destroyed; update the
callback bodies to first check the Fragment/view lifecycle (e.g.,
viewLifecycleOwner.lifecycle.currentState.isAtLeast(Lifecycle.State.STARTED) or
isAdded() && view != null) before touching binding or calling requireContext(),
and bail out silently if the view is gone—ensure all UI updates
(mess.pbDismiss(), binding.btnAdd.*, mess.toast(...), clearing fields) are
guarded by that check or run via view?.let { ... } so no UI is accessed after
destruction.

Comment on lines 23 to +34
<ImageView
android:id="@+id/ivHeaderIcon"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginStart="25dp"
android:layout_marginTop="32dp"
android:src="@drawable/logo"
android:contentDescription="Mess committee icon"
app:tint="@color/food"
android:background="@drawable/bg_icon_soft"
android:padding="14dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tint="@color/food" />
app:layout_constraintTop_toTopOf="parent"/>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add explicit accessibility semantics for the header icon.

The ImageView lacks contentDescription. If decorative, set android:contentDescription="@null" (and optionally importantForAccessibility="no"); otherwise provide a meaningful string resource.

Suggested fix
 <ImageView
     android:id="@+id/ivHeaderIcon"
     android:layout_width="60dp"
     android:layout_height="60dp"
@@
     android:src="@drawable/logo"
+    android:contentDescription="@null"
     app:tint="@color/food"
     android:background="@drawable/bg_icon_soft"
     android:padding="14dp"
     app:layout_constraintStart_toStartOf="parent"
     app:layout_constraintTop_toTopOf="parent"/>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/src/main/res/layout/fragment_admin.xml` around lines 23 - 34, The
ImageView with id ivHeaderIcon is missing accessibility semantics; update the
element for accessibility by adding an appropriate
android:contentDescription—use a meaningful string resource (e.g.,
`@string/header_icon_description`) if the icon conveys information, or set
android:contentDescription="@null" (and optionally
android:importantForAccessibility="no") if it's purely decorative; ensure you
edit the ImageView with id ivHeaderIcon to include this attribute.

@namanhere23
Copy link
Copy Markdown
Collaborator

@siddhigupta075 Please make the required changes

1. Unsafe binding Access Inside Async Callback

File: app/src/main/java/.../AdminFragment.kt

The callback supplied to viewModel.addToMessCommittee(...) references binding and its child views after an asynchronous operation. If the user navigates away from the fragment before the callback is invoked, the view will have already been destroyed and _binding will be null, resulting in a NullPointerException at runtime.


2. Validation Errors Not Reset Between Submissions

File: app/src/main/java/.../AdminFragment.kt

The current when block only assigns an error to the first field that fails validation. On subsequent submissions, previously set errors on other fields are not cleared, which may leave stale error messages visible to the user even after they have corrected the input.


@mini-walkerx
Copy link
Copy Markdown

mini-walkerx Bot commented Apr 13, 2026

🔗 @siddhigupta075 opened PR #50 for this issue and has been auto-assigned.

@mini-walkerx
Copy link
Copy Markdown

mini-walkerx Bot commented Apr 13, 2026

🔗 PR #51 by @siddhigupta075 is now linked to this assignment. The deadline timer is paused while the PR is open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Redesign Admin page with proper functionality.

2 participants