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

Add screen to edit feed group #504

Merged
merged 6 commits into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* Copyright 2024 Sasikanth Miriyampalli
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package dev.sasikanth.rss.reader.resources.icons

import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.PathFillType.Companion.NonZero
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.StrokeCap.Companion.Butt
import androidx.compose.ui.graphics.StrokeJoin.Companion.Miter
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.ImageVector.Builder
import androidx.compose.ui.graphics.vector.path
import androidx.compose.ui.unit.dp

val TwineIcons.UnGroup: ImageVector
get() {
if (unGroup != null) {
return unGroup!!
}
unGroup =
Builder(
name = "Ungroup",
defaultWidth = 24.0.dp,
defaultHeight = 24.0.dp,
viewportWidth = 24.0f,
viewportHeight = 24.0f
)
.apply {
path(
fill = SolidColor(Color(0xFF000000)),
stroke = null,
strokeLineWidth = 0.0f,
strokeLineCap = Butt,
strokeLineJoin = Miter,
strokeLineMiter = 4.0f,
pathFillType = NonZero
) {
moveTo(7.0f, 13.0f)
horizontalLineTo(17.0f)
verticalLineTo(11.0f)
horizontalLineTo(7.0f)
verticalLineTo(13.0f)
close()
moveTo(12.0f, 22.0f)
curveTo(10.6167f, 22.0f, 9.3167f, 21.7375f, 8.1f, 21.2125f)
curveTo(6.8833f, 20.6875f, 5.825f, 19.975f, 4.925f, 19.075f)
curveTo(4.025f, 18.175f, 3.3125f, 17.1167f, 2.7875f, 15.9f)
curveTo(2.2625f, 14.6833f, 2.0f, 13.3833f, 2.0f, 12.0f)
curveTo(2.0f, 10.6167f, 2.2625f, 9.3167f, 2.7875f, 8.1f)
curveTo(3.3125f, 6.8833f, 4.025f, 5.825f, 4.925f, 4.925f)
curveTo(5.825f, 4.025f, 6.8833f, 3.3125f, 8.1f, 2.7875f)
curveTo(9.3167f, 2.2625f, 10.6167f, 2.0f, 12.0f, 2.0f)
curveTo(13.3833f, 2.0f, 14.6833f, 2.2625f, 15.9f, 2.7875f)
curveTo(17.1167f, 3.3125f, 18.175f, 4.025f, 19.075f, 4.925f)
curveTo(19.975f, 5.825f, 20.6875f, 6.8833f, 21.2125f, 8.1f)
curveTo(21.7375f, 9.3167f, 22.0f, 10.6167f, 22.0f, 12.0f)
curveTo(22.0f, 13.3833f, 21.7375f, 14.6833f, 21.2125f, 15.9f)
curveTo(20.6875f, 17.1167f, 19.975f, 18.175f, 19.075f, 19.075f)
curveTo(18.175f, 19.975f, 17.1167f, 20.6875f, 15.9f, 21.2125f)
curveTo(14.6833f, 21.7375f, 13.3833f, 22.0f, 12.0f, 22.0f)
close()
moveTo(12.0f, 20.0f)
curveTo(14.2333f, 20.0f, 16.125f, 19.225f, 17.675f, 17.675f)
curveTo(19.225f, 16.125f, 20.0f, 14.2333f, 20.0f, 12.0f)
curveTo(20.0f, 9.7667f, 19.225f, 7.875f, 17.675f, 6.325f)
curveTo(16.125f, 4.775f, 14.2333f, 4.0f, 12.0f, 4.0f)
curveTo(9.7667f, 4.0f, 7.875f, 4.775f, 6.325f, 6.325f)
curveTo(4.775f, 7.875f, 4.0f, 9.7667f, 4.0f, 12.0f)
curveTo(4.0f, 14.2333f, 4.775f, 16.125f, 6.325f, 17.675f)
curveTo(7.875f, 19.225f, 9.7667f, 20.0f, 12.0f, 20.0f)
close()
}
}
.build()
return unGroup!!
}

private var unGroup: ImageVector? = null
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ val DeTwineStrings =
actionDelete = "Löschen",
actionAddTo = "Hinzufügen zu",
actionMoveTo = "Ziehen nach",
actionUngroup = "Ungroup",
createGroup = "Gruppe erstellen",
createFeed = "Feed hinzufügen",
groupNameHint = "Name",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ val EnTwineStrings =
actionDelete = "Delete",
actionAddTo = "Add to",
actionMoveTo = "Move to",
actionUngroup = "Ungroup",
createGroup = "Create group",
createFeed = "Add feed",
groupNameHint = "Name",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ val TrTwineStrings =
actionAddTo = "a ekle",
actionMoveTo = "Taşınmak",
actionDelete = "Sil",
actionUngroup = "Ungroup",
createGroup = "Grup oluştur",
createFeed = "İçerik ekle",
groupNameHint = "İsim",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ data class TwineStrings(
val actionDelete: String,
val actionAddTo: String,
val actionMoveTo: String,
val actionUngroup: String,
val createGroup: String,
val createFeed: String,
val groupNameHint: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import dev.sasikanth.rss.reader.components.DynamicContentTheme
import dev.sasikanth.rss.reader.components.LocalDynamicColorState
import dev.sasikanth.rss.reader.components.rememberDynamicColorState
import dev.sasikanth.rss.reader.feed.ui.FeedInfoBottomSheet
import dev.sasikanth.rss.reader.group.ui.GroupScreen
import dev.sasikanth.rss.reader.groupselection.ui.GroupSelectionSheet
import dev.sasikanth.rss.reader.home.ui.HomeScreen
import dev.sasikanth.rss.reader.platform.LinkHandler
Expand Down Expand Up @@ -109,6 +110,9 @@ fun App(
is Screen.AddFeed -> {
AddFeedScreen(presenter = screen.presenter, modifier = fillMaxSizeModifier)
}
is Screen.GroupDetails -> {
GroupScreen(presenter = screen.presenter, modifier = fillMaxSizeModifier)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ import dev.sasikanth.rss.reader.core.model.local.PostWithMetadata
import dev.sasikanth.rss.reader.di.scopes.ActivityScope
import dev.sasikanth.rss.reader.feed.FeedPresenterFactory
import dev.sasikanth.rss.reader.feeds.FeedsEvent
import dev.sasikanth.rss.reader.group.GroupEvent
import dev.sasikanth.rss.reader.group.GroupPresenterFactory
import dev.sasikanth.rss.reader.groupselection.GroupSelectionPresenterFactory
import dev.sasikanth.rss.reader.home.HomePresenterFactory
import dev.sasikanth.rss.reader.platform.LinkHandler
Expand Down Expand Up @@ -73,6 +75,7 @@ class AppPresenter(
private val feedPresenter: FeedPresenterFactory,
private val groupSelectionPresenter: GroupSelectionPresenterFactory,
private val addFeedPresenter: AddFeedPresenterFactory,
private val groupPresenter: GroupPresenterFactory,
private val lastUpdatedAt: LastUpdatedAt,
private val rssRepository: RssRepository,
private val settingsRepository: SettingsRepository,
Expand Down Expand Up @@ -144,6 +147,11 @@ class AppPresenter(
AddFeedEvent.OnGroupsSelected(selectedGroupIds)
)
}
is Screen.GroupDetails -> {
activeInstance.presenter.dispatch(
GroupEvent.OnGroupsSelected(selectedGroupIds)
)
}
else -> {
throw IllegalArgumentException("Unhandled active instance: $activeInstance")
}
Expand All @@ -169,7 +177,8 @@ class AppPresenter(
{ openPost(it) },
{ modalNavigation.activate(ModalConfig.GroupSelection) },
{ modalNavigation.activate(ModalConfig.FeedInfo(it)) },
{ navigation.push(Config.AddFeed) }
{ navigation.push(Config.AddFeed) },
{ navigation.push(Config.GroupDetails(it)) }
)
)
}
Expand Down Expand Up @@ -211,6 +220,17 @@ class AppPresenter(
)
)
}
is Config.GroupDetails -> {
Screen.GroupDetails(
presenter =
groupPresenter(
config.groupId,
componentContext,
{ navigation.pop() },
{ modalNavigation.activate(ModalConfig.GroupSelection) }
)
)
}
}

private fun openPost(post: PostWithMetadata) {
Expand Down Expand Up @@ -265,6 +285,8 @@ class AppPresenter(
@Serializable data class Reader(val postId: String) : Config

@Serializable data object AddFeed : Config

@Serializable data class GroupDetails(val groupId: String) : Config
}

@Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package dev.sasikanth.rss.reader.app
import dev.sasikanth.rss.reader.about.AboutPresenter
import dev.sasikanth.rss.reader.addfeed.AddFeedPresenter
import dev.sasikanth.rss.reader.bookmarks.BookmarksPresenter
import dev.sasikanth.rss.reader.group.GroupPresenter
import dev.sasikanth.rss.reader.home.HomePresenter
import dev.sasikanth.rss.reader.reader.ReaderPresenter
import dev.sasikanth.rss.reader.search.SearchPresenter
Expand All @@ -37,4 +38,6 @@ internal sealed interface Screen {
class Reader(val presenter: ReaderPresenter) : Screen

class AddFeed(val presenter: AddFeedPresenter) : Screen

class GroupDetails(val presenter: GroupPresenter) : Screen
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class FeedsPresenter(
@Assisted private val openGroupSelectionSheet: () -> Unit,
@Assisted private val openFeedInfoSheet: (feedId: String) -> Unit,
@Assisted private val openAddFeedScreen: () -> Unit,
@Assisted private val openGroupScreen: (groupId: String) -> Unit,
) : ComponentContext by componentContext {

private val presenterInstance =
Expand Down Expand Up @@ -109,9 +110,7 @@ class FeedsPresenter(
is FeedsEvent.OnEditSourceClicked -> {
when (val source = event.source) {
is Feed -> openFeedInfoSheet(source.id)
is FeedGroup -> {
// TODO: Open edit feed group screen
}
is FeedGroup -> openGroupScreen(source.id)
else -> {
throw IllegalArgumentException("Unknown source: $source")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,15 @@ internal fun LazyGridScope.allSources(
}

@Composable
private fun AllFeedsHeader(
internal fun AllFeedsHeader(
feedsCount: Int,
feedsSortOrder: FeedsOrderBy,
onFeedsSortChanged: (FeedsOrderBy) -> Unit,
modifier: Modifier = Modifier
) {
Row(
modifier =
Modifier.padding(start = 32.dp, end = 20.dp).padding(vertical = 12.dp).then(modifier),
Modifier.then(modifier).padding(start = 32.dp, end = 20.dp).padding(vertical = 12.dp),
verticalAlignment = Alignment.CenterVertically
) {
var showSortDropdown by remember { mutableStateOf(false) }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright 2024 Sasikanth Miriyampalli
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package dev.sasikanth.rss.reader.group

import dev.sasikanth.rss.reader.core.model.local.Feed
import dev.sasikanth.rss.reader.repository.FeedsOrderBy

sealed interface GroupEvent {

data object Init : GroupEvent

data class OnGroupNameChanged(val name: String) : GroupEvent

data class OnGroupsSelected(val groupIds: Set<String>) : GroupEvent

data object OnUngroupClicked : GroupEvent

data class OnFeedsSortOrderChanged(val feedsOrderBy: FeedsOrderBy) : GroupEvent

data object OnCancelSelectionClicked : GroupEvent

data class OnFeedClicked(val feed: Feed) : GroupEvent

data object OnMoveFeedsToClicked : GroupEvent

data object OnBackClicked : GroupEvent
}
Loading