Skip to content

Commit

Permalink
Convert gallery from mvp to mvvm (#443)
Browse files Browse the repository at this point in the history
* Add inject method

* Create fragment

* Add view model

* Extract flows

* Move logic down to viewmodel

* Update proper data structure

* Observe data change

* Collect state ad update method call

* Create new view adapters version

* Extract states, collect them in view

* Add argument names

* Provide view models

* Navigate to new uplift gallery screen

* Provide layout file

* Set value when navigate

* Handle state change

* Handle state change

* Improve coding style

* Extract classes & refactor code usage

* Update method modifiers

* Update method modifiers

* Reorder properties

* Use backing field

* Create state and side effect

* Extract state to side effect

* Remove unused state, update state param

* Temporarily replace flow by side effect

* Trigger side effect

* Extract side effect

* Extract side effect

* Fix klihnt check

* Fix klihnt check

* Fix klihnt check

* Fix klihnt check

* Fix klihnt check

* Improve default value

* Init state, simplify code flow

* Rename method

* Reformat code

* Fix wrong order of method call, simplify post effect call by reducing intent block

* Remove space

* Fix score widget not shown

* Remove unused class

* Extract state of progress

* Use new progress state

* Use new progress state

* Extract strings

* Fix klint code format

* Fix klint code format

* Fix klint code format

* Move controlsVisible to state

* Move rootAndFav to state

* call initStorages from viewmodel init

* Handle startPos in viewModel

* update pager items in render, move gallery items to state

* Add path to GalleryItem, replace GalleryPresenter.GalleryItem

* dont bind viewholders in viewmodel

* disable StrictMode

* refactor onRemoveFabClick

* make GalleryState.currentItem as property

* Use currentItem from state not from viewmodel property

* remove updateAdapter sideEffect and diffResult from viewmodel

* use state gallery items instead of viewmodel property

* Refactor side effects and domain models

* Refactor selecting and move selectedResources to state

* Move progress state to screen state

* Move tags to state

* Handle setupPreview in render

* Optimize render

* Move rootAndFav to state

* Move resourcesIds to state

* minor

* ktlint formatting

* Remove old gallery screen

---------

Co-authored-by: mdrlzy <[email protected]>
  • Loading branch information
hieuwu and mdrlzy authored Oct 20, 2024
1 parent c79c1b7 commit 773409b
Show file tree
Hide file tree
Showing 17 changed files with 1,102 additions and 898 deletions.
11 changes: 4 additions & 7 deletions app/src/main/java/dev/arkbuilders/navigator/di/AppComponent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ package dev.arkbuilders.navigator.di
import android.content.Context
import dagger.BindsInstance
import dagger.Component
import dev.arkbuilders.arkfilepicker.folders.FoldersRepo
import dev.arkbuilders.navigator.analytics.AnalyticsModule
import dev.arkbuilders.navigator.data.StorageBackup
import dev.arkbuilders.navigator.data.preferences.Preferences
import dev.arkbuilders.navigator.di.modules.AppModule
import dev.arkbuilders.navigator.di.modules.CiceroneModule
import dev.arkbuilders.navigator.di.modules.DispatcherModule
import dev.arkbuilders.navigator.di.modules.RepoModule
import dev.arkbuilders.navigator.presentation.App
import dev.arkbuilders.navigator.presentation.dialog.ExplainPermsDialog
Expand All @@ -17,17 +20,12 @@ import dev.arkbuilders.navigator.presentation.dialog.sort.SortDialogPresenter
import dev.arkbuilders.navigator.presentation.dialog.tagssort.TagsSortDialogFragment
import dev.arkbuilders.navigator.presentation.screen.folders.FoldersFragment
import dev.arkbuilders.navigator.presentation.screen.gallery.GalleryFragment
import dev.arkbuilders.navigator.presentation.screen.gallery.GalleryPresenter
import dev.arkbuilders.navigator.presentation.screen.gallery.previewpager.PreviewImageViewHolder
import dev.arkbuilders.navigator.presentation.screen.main.MainActivity
import dev.arkbuilders.navigator.presentation.screen.resources.ResourcesFragment
import dev.arkbuilders.navigator.presentation.screen.resources.ResourcesPresenter
import dev.arkbuilders.navigator.presentation.screen.resources.adapter.FileItemViewHolder
import dev.arkbuilders.navigator.presentation.screen.resources.adapter.ResourcesGridPresenter
import dev.arkbuilders.navigator.presentation.screen.settings.SettingsFragment
import dev.arkbuilders.arkfilepicker.folders.FoldersRepo
import dev.arkbuilders.navigator.analytics.AnalyticsModule
import dev.arkbuilders.navigator.di.modules.DispatcherModule
import javax.inject.Singleton

@Singleton
Expand All @@ -48,13 +46,12 @@ interface AppComponent {
fun inject(foldersFragment: FoldersFragment)
fun inject(resourcesPresenter: ResourcesPresenter)
fun inject(resourcesFragment: ResourcesFragment)
fun inject(galleryPresenter: GalleryPresenter)
fun inject(galleryFragment: GalleryFragment)

fun inject(settingsFragment: SettingsFragment)
fun inject(resourcesGridPresenter: ResourcesGridPresenter)
fun inject(editTagsDialogPresenter: EditTagsDialogPresenter)
fun inject(fileItemViewHolder: FileItemViewHolder)
fun inject(previewImageViewHolder: PreviewImageViewHolder)
fun inject(sortDialogPresenter: SortDialogPresenter)
fun inject(tagsSortDialogFragment: TagsSortDialogFragment)
fun inject(rootPickerDialogFragment: RootPickerDialogFragment)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package dev.arkbuilders.navigator.presentation

import android.app.Application
import android.os.StrictMode
import dev.arkbuilders.arkfilepicker.folders.FoldersRepo
import dev.arkbuilders.arklib.initArkLib
import dev.arkbuilders.arklib.initRustLogger
Expand Down Expand Up @@ -30,9 +29,9 @@ class App : Application() {
private set

init {
if (BuildConfig.DEBUG) {
StrictMode.enableDefaults()
}
// if (BuildConfig.DEBUG) {
// StrictMode.enableDefaults()
// }
}

override fun onCreate() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package dev.arkbuilders.navigator.presentation.navigation

import ru.terrakok.cicerone.android.support.SupportAppScreen
import dev.arkbuilders.arkfilepicker.folders.RootAndFav
import dev.arkbuilders.arklib.ResourceId
import dev.arkbuilders.arklib.user.tags.Tag
import dev.arkbuilders.navigator.presentation.screen.folders.FoldersFragment
import dev.arkbuilders.navigator.presentation.screen.gallery.GalleryFragment
import dev.arkbuilders.navigator.presentation.screen.resources.ResourcesFragment
import dev.arkbuilders.navigator.presentation.screen.settings.SettingsFragment
import dev.arkbuilders.arklib.user.tags.Tag
import ru.terrakok.cicerone.android.support.SupportAppScreen

class Screens {
class FoldersScreen : SupportAppScreen() {
Expand Down
Loading

0 comments on commit 773409b

Please sign in to comment.