EdricChan03 / EdricChan03/studybuddy-android
[Refactor] Add app-bar logic to controller utility class/ViewModel
- Dominant language
- Kotlin
- Stars
- 23
- Forks
- 9
- Avg merge
- 9h 1m
- Merged PRs (30d)
- 1
Description
There is no easy way of specifying a custom app bar (navigation button, title, actions) per screen without either specifying a Scaffold per screen (which can lead to visual UI jank if not animated correctly) or having some form of architecture that supports specifying the app-bar from anywhere
Having a shared controller class would make it easier for a screen to specify what should be shown for the app-bar
```kotlin
interface AppBarController {
var navBtn: NavBtn
var title: String?
var menu: Menu
}
```
The menu interface could look something like:
```kotlin
data class Menu(
val items: ItemComponent
)
sealed interface ItemComponent {
data class MenuItem(val icon: ImageVector?, val text: String, val trailingText: String? /* this could be for the action shortcut */) : ItemComponent // Or consider setting a action shortcut param and implicitly show it on the UI as well as handle the key shortcut
data class MenuGroup(val items: List, val checkableBehavior: ...) : ItemComponent
data object Divider : ItemComponent
}
```
There could also be convenience methods for say entering/exiting selection mode, where contextual actions could be shown:
```kotlin
fun AppBarController.setSelectionBar(
selectedItemsCount: Int,
title: String = ...,
onExitSelection: () -> Unit
)
fun AppBarController.clearSelectionBar() // Should we remember the previous state?
```
And methods to update the data:
```kotlin
fun AppBarController.updateNavBtn(...)
fun AppBarController.updateTitle(...)
fun AppBarController.updateMenu(...)
```
There should also be a way of listening to events emitted from the nav button and menu actions
Contributor guide
No contributing guide indexed for this repository
Research direction
No files, tests, or entry points are named. Start by locating the screens that define Scaffold and app-bar UI, then review how screen state is currently shared. Done would require an agreed controller/ViewModel design, event handling for navigation and menu actions, and a clear integration plan.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- mobile-dev
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100