Skip to content

Commit

Permalink
Version 1.5.2 (#40)
Browse files Browse the repository at this point in the history
* Group the list of repos by group
  • Loading branch information
walter-juan authored Jun 16, 2024
1 parent a42da8b commit 3a6075d
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 20 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
### Security

## [1.5.2]
### Added
- Group the list of repos by group

## [1.5.1]
### Changed
- Use multiplatform setting library
Expand Down Expand Up @@ -196,7 +200,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [1.0.0]
_First version_

[unreleased]: https://github.com/walter-juan/ghd/compare/v1.5.1...dev
[unreleased]: https://github.com/walter-juan/ghd/compare/v1.5.2...dev
[1.5.2]: https://github.com/walter-juan/ghd/releases/tag/v1.5.2
[1.5.1]: https://github.com/walter-juan/ghd/releases/tag/v1.5.1
[1.5.0]: https://github.com/walter-juan/ghd/releases/tag/v1.5.0
[1.4.2]: https://github.com/walter-juan/ghd/releases/tag/v1.4.2
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ plugins {
}

group = "com.woowla"
version = "1.5.1"
version = "1.5.2"
val debug = (extra["debugConfig"] as String).toBoolean()
val debugAppFolder = "ghd-debug"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
package com.woowla.ghd.presentation.screens

import androidx.compose.foundation.layout.*
import androidx.compose.material3.Button
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.withStyle
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import com.woowla.compose.tabler.OutlineFileDownload
Expand Down Expand Up @@ -125,19 +128,47 @@ object RepoToCheckScreen {
SectionCategory(i18n.screen_repos_to_check_repositories_section) {
SectionItem(
title = i18n.screen_app_settings_repositories_item,
description = i18n.screen_app_settings_repositories_item_description(lockedState.reposToCheck.size),
description = i18n.screen_app_settings_repositories_item_description(lockedState.size),
) {
lockedState.reposToCheck.forEach { repoToCheck ->
RepoToCheckCard(
repoToCheck = repoToCheck,
onEditClick = { repoToEdit ->
onEditRepoClick.invoke(repoToEdit)
},
onDeleteClick = { repoToDelete ->
viewModel.deleteRepo(repoToDelete)
},
)
Spacer(modifier = Modifier.padding(5.dp))
Column(
verticalArrangement = Arrangement.spacedBy(10.dp),
) {
lockedState.groupedReposToCheck.forEachIndexed { index, (groupName, reposToCheck) ->
if (groupName != null) {
Row(
horizontalArrangement = Arrangement.spacedBy(10.dp, Alignment.Start),
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.width(AppDimens.contentWidthDp)
) {
Text(
text = buildAnnotatedString {
if(groupName.isBlank()) {
withStyle(SpanStyle(fontStyle = FontStyle.Italic)) {
append(i18n.screen_edit_repo_to_no_group)
}
} else {
append(groupName)
}
},
style = MaterialTheme.typography.titleMedium,
)
}
}
reposToCheck.forEach { repoToCheck ->
RepoToCheckCard(
repoToCheck = repoToCheck,
onEditClick = { repoToEdit ->
onEditRepoClick.invoke(repoToEdit)
},
onDeleteClick = { repoToDelete ->
viewModel.deleteRepo(repoToDelete)
},
)
}
if (index < lockedState.groupedReposToCheck.size - 1) {
Divider(modifier = Modifier.padding(vertical = 10.dp).width(AppDimens.contentWidthDp))
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,13 @@ class ReposToCheckViewModel(
val appSettings = appSettingsService.get().getOrNull()

repoToCheckService.getAll().fold(
onSuccess = {
_state.value = State.Success(reposToCheck = it, appSettings = appSettings)
onSuccess = { repoToCheckList ->
val groupedReposToCheck = repoToCheckList
.sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER, { it.name }))
.groupBy { it.groupName }
.toList()
.sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER, { it.first ?: "" }))
_state.value = State.Success(size = repoToCheckList.size, groupedReposToCheck = groupedReposToCheck, appSettings = appSettings)
},
onFailure = {
_state.value = State.Error(throwable = it)
Expand All @@ -79,7 +84,7 @@ class ReposToCheckViewModel(

sealed class State {
object Initializing: State()
data class Success(val reposToCheck: List<RepoToCheck>, val appSettings: AppSettings?): State()
data class Success(val size: Int, val groupedReposToCheck: List<Pair<String?, List<RepoToCheck>>>, val appSettings: AppSettings?): State()
data class Error(val throwable: Throwable): State()
}
}

0 comments on commit 3a6075d

Please sign in to comment.