Skip to content

Commit

Permalink
06/07/2024.
Browse files Browse the repository at this point in the history
  • Loading branch information
youndon committed Jul 6, 2024
1 parent 4b3eb00 commit c0bad57
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ val repositoryKoinModule = module {
factoryOf(NoteUseCase::GetAllRemindingNotes)
factoryOf(NoteUseCase::GetAllNotesByOldest)
factoryOf(NoteUseCase::GetAllNotesByPriority)
factoryOf(NoteUseCase::GetAllTrashedNotes)
factoryOf(NoteUseCase::GetAllRemovedNotes)

factoryOf(TagUseCase::AddTag)
factoryOf(TagUseCase::DeleteTag)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class NoteRepositoryImpl(
override val getAllNotesByOldest: Flow<List<OutNote>>
get() = dataSource.getAllNotesByOldest.map { notes -> mapper.toDomain(notes) }

override val getAllTrashedNotes: Flow<List<OutNote>>
override val getAllRemovedNotes: Flow<List<OutNote>>
get() = dataSource.getAllTrashedNotes.map { notes -> mapper.toDomain(notes) }

override val allNotesByPriority: Flow<List<OutNote>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface NoteRepository {

val getAllNotesByOldest: Flow<List<OutNote>>

val getAllTrashedNotes: Flow<List<OutNote>>
val getAllRemovedNotes: Flow<List<OutNote>>

val allNotesByPriority: Flow<List<OutNote>>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ sealed class NoteUseCase {
operator fun invoke() = repository.getAllNotesByOldest
}

class GetAllTrashedNotes(
class GetAllRemovedNotes(
private val repository: NoteRepository
): NoteUseCase() {
operator fun invoke() = repository.getAllTrashedNotes
operator fun invoke() = repository.getAllRemovedNotes
}

class GetAllNotesByPriority(
Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[versions]
agp = "8.2.1"
kotlin = "1.9.22"
kotlin = "1.9.24"
compilesdk-v = "34"
minsdk-v = "26"
targetsdk-v = "34"
code-v = "591"
name-v = "5.9.1"
compose-v = "1.5.10"
compose-v = "1.5.14"

#Android.
core-ktx = "1.13.1"
Expand All @@ -29,7 +29,7 @@ navigation-compose = "2.7.7"
compose-constraintlayout = "1.1.0-alpha13"

#Plugins.
ksp = "1.9.23-1.0.20"
ksp = "1.9.24-1.0.20"
dependencyanalysis = "1.32.0"

#KotlinX.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,28 @@ import cafe.adriel.voyager.koin.getScreenModel
import city.zouitel.media.model.NoteAndMedia
import coil.compose.AsyncImage
import coil.request.ImageRequest
import coil.size.Scale

data class MediaScreen(val id: String = "", val backgroundColor: Int = 0): Screen {
@SuppressLint("UnusedMaterial3ScaffoldPaddingParameter")
@OptIn(ExperimentalFoundationApi::class)
@Composable
override fun Content() {

Media(
mediaModel = getScreenModel<MediaScreenModel>(),
noteAndMediaModel = getScreenModel<NoteAndMediaScreenModel>()
)
}

@OptIn(ExperimentalFoundationApi::class)
@Composable
private fun Media(
mediaModel: MediaScreenModel,
noteAndMediaModel: NoteAndMediaScreenModel
) {
val context = LocalContext.current
val vibe = LocalHapticFeedback.current

val mediaModel = getScreenModel<MediaScreenModel>()
val noteAndMediaModel = getScreenModel<NoteAndMediaScreenModel>()
val observeMedias by remember(mediaModel, mediaModel::allMedias).collectAsState()
val observeNotesAndMedia by remember(
noteAndMediaModel,
Expand Down Expand Up @@ -92,7 +102,6 @@ data class MediaScreen(val id: String = "", val backgroundColor: Int = 0): Scree
) {
runCatching {
AsyncImage(
modifier = Modifier.fillMaxWidth(),
model = ImageRequest.Builder(context)
.data(filteredMedias[index].path)
.build(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ import city.zouitel.screens.navigation_drawer.NavigationDrawer
import city.zouitel.screens.note_card.NoteCard
import city.zouitel.screens.sound
import city.zouitel.systemDesign.CommonConstants
import city.zouitel.systemDesign.CommonConstants.BY_NAME
import city.zouitel.systemDesign.CommonConstants.ORDER_BY_NEWEST
import city.zouitel.systemDesign.CommonConstants.ORDER_BY_OLDEST
import city.zouitel.systemDesign.CommonConstants.ORDER_BY_PRIORITY
import city.zouitel.systemDesign.CommonConstants.ORDER_BY_REMINDER
import city.zouitel.systemDesign.DataStoreScreenModel
import city.zouitel.systemDesign.CommonIcons
import city.zouitel.tags.ui.NoteAndTagScreenModel
Expand Down Expand Up @@ -132,15 +137,15 @@ data class MainScreen(val isHome: Boolean): Screen {
when (
remember(datastoreModel, datastoreModel::getOrdination).collectAsState().value
) {
CommonConstants.BY_NAME -> mainModel.allNotesByName.collectAsState()
CommonConstants.ORDER_BY_OLDEST -> remember(mainModel, mainModel::allNotesByOldest).collectAsState()
CommonConstants.ORDER_BY_NEWEST -> mainModel.allNotesByNewest.collectAsState()
CommonConstants.ORDER_BY_PRIORITY -> mainModel.allNotesByPriority.collectAsState()
CommonConstants.ORDER_BY_REMINDER -> mainModel.allRemindingNotes.collectAsState()
BY_NAME -> mainModel.allNotesByName.collectAsState()
ORDER_BY_OLDEST -> mainModel.allNotesByOldest.collectAsState()
ORDER_BY_NEWEST -> mainModel.allNotesByNewest.collectAsState()
ORDER_BY_PRIORITY -> mainModel.allNotesByPriority.collectAsState()
ORDER_BY_REMINDER -> mainModel.allRemindingNotes.collectAsState()
else -> mainModel.allNotesById.collectAsState()
}
} else {
remember(mainModel, mainModel::allTrashedNotes).collectAsState()
mainModel.allTrashedNotes.collectAsState()
}

val observerRemovedNotes = remember(mainModel, mainModel::allTrashedNotes).collectAsState()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class MainScreenModel(
private val getAllByOldest: NoteUseCase.GetAllNotesByOldest,
private val getAllByNewest: NoteUseCase.GetAllNotesByNewest,
private val getAllByName: NoteUseCase.GetAllNotesByName,
private val getAllTrashed: NoteUseCase.GetAllTrashedNotes,
private val getAllRemoved: NoteUseCase.GetAllRemovedNotes,
private val getAllByPriority: NoteUseCase.GetAllNotesByPriority,
private val getAllReminding: NoteUseCase.GetAllRemindingNotes,
private val mapper: NoteMapper
Expand Down Expand Up @@ -65,22 +65,22 @@ class MainScreenModel(
getAllById.invoke().collect { notes -> _allNotesById.value = mapper.fromDomain(notes) }
}
launch(Dispatchers.IO) {
getAllByName.invoke().collect { notes -> _allNotesById.value = mapper.fromDomain(notes) }
getAllByName.invoke().collect { notes -> _allNotesByName.value = mapper.fromDomain(notes) }
}
launch(Dispatchers.IO) {
getAllByNewest.invoke().collect { notes -> _allNotesById.value = mapper.fromDomain(notes) }
getAllByNewest.invoke().collect { notes -> _allNotesByNewest.value = mapper.fromDomain(notes) }
}
launch(Dispatchers.IO) {
getAllByOldest.invoke().collect { notes -> _allNotesById.value = mapper.fromDomain(notes) }
getAllByOldest.invoke().collect { notes -> _allNotesByOldest.value = mapper.fromDomain(notes) }
}
launch(Dispatchers.IO) {
getAllTrashed.invoke().collect { notes -> _allNotesById.value = mapper.fromDomain(notes) }
getAllRemoved.invoke().collect { notes -> _allTrashedNotes.value = mapper.fromDomain(notes) }
}
launch(Dispatchers.IO) {
getAllByPriority.invoke().collect { notes -> _allNotesById.value = mapper.fromDomain(notes) }
getAllByPriority.invoke().collect { notes -> _allNotesByPriority.value = mapper.fromDomain(notes) }
}
launch(Dispatchers.IO) {
getAllReminding.invoke().collect { notes -> _allNotesById.value = mapper.fromDomain(notes) }
getAllReminding.invoke().collect { notes -> _allRemindingNotes.value = mapper.fromDomain(notes) }
}
}
}
Expand Down

0 comments on commit c0bad57

Please sign in to comment.