Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drawer menu visible by default: Add functionality to hide on startup and open via icon or swipe #4813

Open
2 tasks done
Avinash-Codes opened this issue Nov 27, 2024 · 2 comments

Comments

@Avinash-Codes
Copy link
Member

Avinash-Codes commented Nov 27, 2024

Issue: Drawer Menu Visibility and Interaction

Verification Checklist

  • This issue is related to the Mobile Interns First Steps document.
  • Searched for relevant keywords in recent open and closed issues to avoid duplicates.

Problem Description

The drawer menu is currently visible by default when the app starts, which is not the desired user experience.

Current Behavior

  • Drawer menu opens automatically when the app launches
  • No direct way to hide the drawer on startup

Desired Behavior

  • Drawer menu should be hidden by default when the app starts
  • Drawer should open only when:
    1. User clicks on a menu icon
    2. User swipes right on the screen

Technical Changes Made

XML Layout Changes

Modified activity_dashboard.xml:

  • Added DrawerLayout as the root layout
  • Wrapped existing CoordinatorLayout inside DrawerLayout
  • Included material_drawer_slider layout

Kotlin Activity Changes in DashboardActivity.kt

// Initialize DrawerLayout
dl = findViewById(R.id.drawer_layout)

// Close the drawer by default
dl?.closeDrawer(GravityCompat.START)

// Set up toolbar with navigation icon
toolbar = activityDashboardBinding.myToolbar
setSupportActionBar(toolbar)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_menu)

// Toggle drawer on toolbar navigation icon click
toolbar!!.setNavigationOnClickListener {
    if (dl!!.isDrawerOpen(GravityCompat.START)) {
        dl!!.closeDrawer(GravityCompat.START)
    } else {
        dl!!.openDrawer(GravityCompat.START)
    }
}

// Modify back press handling
handleOnBackPressed() {
    if (dl!!.isDrawerOpen(GravityCompat.START)) {
        dl!!.closeDrawer(GravityCompat.START)
    }
    // ... rest of the existing back press logic
}

Steps to Reproduce

  1. Build and launch the app
  2. Observe the drawer menu state on app startup

Expected Result

  • Drawer menu remains closed when the app is first launched
  • Drawer can be opened by:
    • Clicking the menu icon in the toolbar
    • Swiping right from the left edge of the screen

Proposed Solution

Implement the changes as described in the "Technical Changes Made" section to control drawer visibility and interaction.

@xyb994
Copy link
Member

xyb994 commented Nov 27, 2024

Please note that we ask you to work on issues related to the first steps markdown document in https://github.com/open-learning-exchange/open-learning-exchange.github.io/ while you are on the First Steps.

Regarding this issue, I believe the rationale is to highlight the existence of a left drawer menu and make it easier to access all the app's features. Perhaps introducing this as a one-time onboarding step could work. However, it all depends on whether we want to place greater emphasis on the dashboard or the app's full feature upon user login.

@Avinash-Codes
Copy link
Member Author

Understood

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

No branches or pull requests

2 participants