From 7d0721e80a3618ef6d7fda8c640a60b517b85d65 Mon Sep 17 00:00:00 2001 From: Ash Date: Fri, 22 Apr 2022 04:46:05 +0800 Subject: [PATCH] Improved interaction of option drawers --- .../java/me/ash/reader/ui/page/home/HomePage.kt | 9 ++------- .../me/ash/reader/ui/page/home/feeds/FeedItem.kt | 4 ++-- .../me/ash/reader/ui/page/home/feeds/FeedsPage.kt | 5 +++++ .../me/ash/reader/ui/page/home/feeds/GroupItem.kt | 4 ++-- .../option}/feed/DeleteFeedDialog.kt | 2 +- .../option}/feed/FeedOptionDrawer.kt | 12 ++++++++++-- .../option}/feed/FeedOptionViewModel.kt | 2 +- .../option}/group/AllAllowNotificationDialog.kt | 2 +- .../option}/group/AllMoveToGroupDialog.kt | 2 +- .../option}/group/AllParseFullContentDialog.kt | 2 +- .../option}/group/DeleteGroupDialog.kt | 2 +- .../option}/group/GroupOptionDrawer.kt | 15 +++++++++++++-- .../option}/group/GroupOptionViewModel.kt | 2 +- .../ui/page/home/feeds/subscribe/ResultView.kt | 3 +++ 14 files changed, 44 insertions(+), 22 deletions(-) rename app/src/main/java/me/ash/reader/ui/page/home/{drawer => feeds/option}/feed/DeleteFeedDialog.kt (97%) rename app/src/main/java/me/ash/reader/ui/page/home/{drawer => feeds/option}/feed/FeedOptionDrawer.kt (94%) rename app/src/main/java/me/ash/reader/ui/page/home/{drawer => feeds/option}/feed/FeedOptionViewModel.kt (99%) rename app/src/main/java/me/ash/reader/ui/page/home/{drawer => feeds/option}/group/AllAllowNotificationDialog.kt (98%) rename app/src/main/java/me/ash/reader/ui/page/home/{drawer => feeds/option}/group/AllMoveToGroupDialog.kt (98%) rename app/src/main/java/me/ash/reader/ui/page/home/{drawer => feeds/option}/group/AllParseFullContentDialog.kt (98%) rename app/src/main/java/me/ash/reader/ui/page/home/{drawer => feeds/option}/group/DeleteGroupDialog.kt (97%) rename app/src/main/java/me/ash/reader/ui/page/home/{drawer => feeds/option}/group/GroupOptionDrawer.kt (94%) rename app/src/main/java/me/ash/reader/ui/page/home/{drawer => feeds/option}/group/GroupOptionViewModel.kt (99%) diff --git a/app/src/main/java/me/ash/reader/ui/page/home/HomePage.kt b/app/src/main/java/me/ash/reader/ui/page/home/HomePage.kt index f3fbbff..76aec0d 100644 --- a/app/src/main/java/me/ash/reader/ui/page/home/HomePage.kt +++ b/app/src/main/java/me/ash/reader/ui/page/home/HomePage.kt @@ -13,10 +13,8 @@ import me.ash.reader.ui.component.ViewPager import me.ash.reader.ui.ext.collectAsStateValue import me.ash.reader.ui.ext.findActivity import me.ash.reader.ui.page.common.ExtraName -import me.ash.reader.ui.page.home.drawer.feed.FeedOptionDrawer -import me.ash.reader.ui.page.home.drawer.feed.FeedOptionViewAction -import me.ash.reader.ui.page.home.drawer.feed.FeedOptionViewModel -import me.ash.reader.ui.page.home.drawer.group.GroupOptionDrawer +import me.ash.reader.ui.page.home.feeds.option.feed.FeedOptionViewAction +import me.ash.reader.ui.page.home.feeds.option.feed.FeedOptionViewModel import me.ash.reader.ui.page.home.feeds.FeedsPage import me.ash.reader.ui.page.home.flow.FlowPage import me.ash.reader.ui.page.home.read.ReadPage @@ -150,7 +148,4 @@ fun HomePage( ), ) } - - FeedOptionDrawer() - GroupOptionDrawer() } \ No newline at end of file diff --git a/app/src/main/java/me/ash/reader/ui/page/home/feeds/FeedItem.kt b/app/src/main/java/me/ash/reader/ui/page/home/feeds/FeedItem.kt index dd04af7..db5c130 100644 --- a/app/src/main/java/me/ash/reader/ui/page/home/feeds/FeedItem.kt +++ b/app/src/main/java/me/ash/reader/ui/page/home/feeds/FeedItem.kt @@ -19,8 +19,8 @@ import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import me.ash.reader.data.entity.Feed -import me.ash.reader.ui.page.home.drawer.feed.FeedOptionViewAction -import me.ash.reader.ui.page.home.drawer.feed.FeedOptionViewModel +import me.ash.reader.ui.page.home.feeds.option.feed.FeedOptionViewAction +import me.ash.reader.ui.page.home.feeds.option.feed.FeedOptionViewModel @OptIn( androidx.compose.foundation.ExperimentalFoundationApi::class, diff --git a/app/src/main/java/me/ash/reader/ui/page/home/feeds/FeedsPage.kt b/app/src/main/java/me/ash/reader/ui/page/home/feeds/FeedsPage.kt index 3148f1a..7258899 100644 --- a/app/src/main/java/me/ash/reader/ui/page/home/feeds/FeedsPage.kt +++ b/app/src/main/java/me/ash/reader/ui/page/home/feeds/FeedsPage.kt @@ -38,6 +38,8 @@ import me.ash.reader.ui.ext.getName import me.ash.reader.ui.page.common.RouteName import me.ash.reader.ui.page.home.FilterBar import me.ash.reader.ui.page.home.FilterState +import me.ash.reader.ui.page.home.feeds.option.feed.FeedOptionDrawer +import me.ash.reader.ui.page.home.feeds.option.group.GroupOptionDrawer import me.ash.reader.ui.page.home.feeds.subscribe.SubscribeDialog import me.ash.reader.ui.page.home.feeds.subscribe.SubscribeViewAction import me.ash.reader.ui.page.home.feeds.subscribe.SubscribeViewModel @@ -239,5 +241,8 @@ fun FeedsPage( ) } ) + + FeedOptionDrawer() + GroupOptionDrawer() } diff --git a/app/src/main/java/me/ash/reader/ui/page/home/feeds/GroupItem.kt b/app/src/main/java/me/ash/reader/ui/page/home/feeds/GroupItem.kt index d906160..3f32954 100644 --- a/app/src/main/java/me/ash/reader/ui/page/home/feeds/GroupItem.kt +++ b/app/src/main/java/me/ash/reader/ui/page/home/feeds/GroupItem.kt @@ -27,8 +27,8 @@ import androidx.hilt.navigation.compose.hiltViewModel import me.ash.reader.R import me.ash.reader.data.entity.Feed import me.ash.reader.data.entity.Group -import me.ash.reader.ui.page.home.drawer.group.GroupOptionViewAction -import me.ash.reader.ui.page.home.drawer.group.GroupOptionViewModel +import me.ash.reader.ui.page.home.feeds.option.group.GroupOptionViewAction +import me.ash.reader.ui.page.home.feeds.option.group.GroupOptionViewModel @OptIn(ExperimentalMaterialApi::class, androidx.compose.foundation.ExperimentalFoundationApi::class) @Composable diff --git a/app/src/main/java/me/ash/reader/ui/page/home/drawer/feed/DeleteFeedDialog.kt b/app/src/main/java/me/ash/reader/ui/page/home/feeds/option/feed/DeleteFeedDialog.kt similarity index 97% rename from app/src/main/java/me/ash/reader/ui/page/home/drawer/feed/DeleteFeedDialog.kt rename to app/src/main/java/me/ash/reader/ui/page/home/feeds/option/feed/DeleteFeedDialog.kt index 99c3623..192ec41 100644 --- a/app/src/main/java/me/ash/reader/ui/page/home/drawer/feed/DeleteFeedDialog.kt +++ b/app/src/main/java/me/ash/reader/ui/page/home/feeds/option/feed/DeleteFeedDialog.kt @@ -1,4 +1,4 @@ -package me.ash.reader.ui.page.home.drawer.feed +package me.ash.reader.ui.page.home.feeds.option.feed import android.widget.Toast import androidx.compose.material.icons.Icons diff --git a/app/src/main/java/me/ash/reader/ui/page/home/drawer/feed/FeedOptionDrawer.kt b/app/src/main/java/me/ash/reader/ui/page/home/feeds/option/feed/FeedOptionDrawer.kt similarity index 94% rename from app/src/main/java/me/ash/reader/ui/page/home/drawer/feed/FeedOptionDrawer.kt rename to app/src/main/java/me/ash/reader/ui/page/home/feeds/option/feed/FeedOptionDrawer.kt index 5d9fe7c..3931912 100644 --- a/app/src/main/java/me/ash/reader/ui/page/home/drawer/feed/FeedOptionDrawer.kt +++ b/app/src/main/java/me/ash/reader/ui/page/home/feeds/option/feed/FeedOptionDrawer.kt @@ -1,6 +1,7 @@ -package me.ash.reader.ui.page.home.drawer.feed +package me.ash.reader.ui.page.home.feeds.option.feed import android.widget.Toast +import androidx.activity.compose.BackHandler import androidx.compose.foundation.layout.* import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.icons.Icons @@ -19,6 +20,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel +import kotlinx.coroutines.launch import me.ash.reader.R import me.ash.reader.ui.component.BottomDrawer import me.ash.reader.ui.component.TextFieldDialog @@ -39,10 +41,16 @@ fun FeedOptionDrawer( val feed = viewState.feed val toastString = stringResource(R.string.rename_toast, viewState.newName) + BackHandler(viewState.drawerState.isVisible) { + scope.launch { + viewState.drawerState.hide() + } + } + BottomDrawer( drawerState = viewState.drawerState, sheetContent = { - Column { + Column(modifier = Modifier.navigationBarsPadding()) { Column( modifier = Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally, diff --git a/app/src/main/java/me/ash/reader/ui/page/home/drawer/feed/FeedOptionViewModel.kt b/app/src/main/java/me/ash/reader/ui/page/home/feeds/option/feed/FeedOptionViewModel.kt similarity index 99% rename from app/src/main/java/me/ash/reader/ui/page/home/drawer/feed/FeedOptionViewModel.kt rename to app/src/main/java/me/ash/reader/ui/page/home/feeds/option/feed/FeedOptionViewModel.kt index 06c2096..e555cc3 100644 --- a/app/src/main/java/me/ash/reader/ui/page/home/drawer/feed/FeedOptionViewModel.kt +++ b/app/src/main/java/me/ash/reader/ui/page/home/feeds/option/feed/FeedOptionViewModel.kt @@ -1,4 +1,4 @@ -package me.ash.reader.ui.page.home.drawer.feed +package me.ash.reader.ui.page.home.feeds.option.feed import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.ModalBottomSheetState diff --git a/app/src/main/java/me/ash/reader/ui/page/home/drawer/group/AllAllowNotificationDialog.kt b/app/src/main/java/me/ash/reader/ui/page/home/feeds/option/group/AllAllowNotificationDialog.kt similarity index 98% rename from app/src/main/java/me/ash/reader/ui/page/home/drawer/group/AllAllowNotificationDialog.kt rename to app/src/main/java/me/ash/reader/ui/page/home/feeds/option/group/AllAllowNotificationDialog.kt index f4ea5d7..50757ac 100644 --- a/app/src/main/java/me/ash/reader/ui/page/home/drawer/group/AllAllowNotificationDialog.kt +++ b/app/src/main/java/me/ash/reader/ui/page/home/feeds/option/group/AllAllowNotificationDialog.kt @@ -1,4 +1,4 @@ -package me.ash.reader.ui.page.home.drawer.group +package me.ash.reader.ui.page.home.feeds.option.group import android.widget.Toast import androidx.compose.material.icons.Icons diff --git a/app/src/main/java/me/ash/reader/ui/page/home/drawer/group/AllMoveToGroupDialog.kt b/app/src/main/java/me/ash/reader/ui/page/home/feeds/option/group/AllMoveToGroupDialog.kt similarity index 98% rename from app/src/main/java/me/ash/reader/ui/page/home/drawer/group/AllMoveToGroupDialog.kt rename to app/src/main/java/me/ash/reader/ui/page/home/feeds/option/group/AllMoveToGroupDialog.kt index 4465184..b0027af 100644 --- a/app/src/main/java/me/ash/reader/ui/page/home/drawer/group/AllMoveToGroupDialog.kt +++ b/app/src/main/java/me/ash/reader/ui/page/home/feeds/option/group/AllMoveToGroupDialog.kt @@ -1,4 +1,4 @@ -package me.ash.reader.ui.page.home.drawer.group +package me.ash.reader.ui.page.home.feeds.option.group import android.widget.Toast import androidx.compose.material.icons.Icons diff --git a/app/src/main/java/me/ash/reader/ui/page/home/drawer/group/AllParseFullContentDialog.kt b/app/src/main/java/me/ash/reader/ui/page/home/feeds/option/group/AllParseFullContentDialog.kt similarity index 98% rename from app/src/main/java/me/ash/reader/ui/page/home/drawer/group/AllParseFullContentDialog.kt rename to app/src/main/java/me/ash/reader/ui/page/home/feeds/option/group/AllParseFullContentDialog.kt index b7526f9..059c0b6 100644 --- a/app/src/main/java/me/ash/reader/ui/page/home/drawer/group/AllParseFullContentDialog.kt +++ b/app/src/main/java/me/ash/reader/ui/page/home/feeds/option/group/AllParseFullContentDialog.kt @@ -1,4 +1,4 @@ -package me.ash.reader.ui.page.home.drawer.group +package me.ash.reader.ui.page.home.feeds.option.group import android.widget.Toast import androidx.compose.material.icons.Icons diff --git a/app/src/main/java/me/ash/reader/ui/page/home/drawer/group/DeleteGroupDialog.kt b/app/src/main/java/me/ash/reader/ui/page/home/feeds/option/group/DeleteGroupDialog.kt similarity index 97% rename from app/src/main/java/me/ash/reader/ui/page/home/drawer/group/DeleteGroupDialog.kt rename to app/src/main/java/me/ash/reader/ui/page/home/feeds/option/group/DeleteGroupDialog.kt index ee2652e..497aa6b 100644 --- a/app/src/main/java/me/ash/reader/ui/page/home/drawer/group/DeleteGroupDialog.kt +++ b/app/src/main/java/me/ash/reader/ui/page/home/feeds/option/group/DeleteGroupDialog.kt @@ -1,4 +1,4 @@ -package me.ash.reader.ui.page.home.drawer.group +package me.ash.reader.ui.page.home.feeds.option.group import android.widget.Toast import androidx.compose.material.icons.Icons diff --git a/app/src/main/java/me/ash/reader/ui/page/home/drawer/group/GroupOptionDrawer.kt b/app/src/main/java/me/ash/reader/ui/page/home/feeds/option/group/GroupOptionDrawer.kt similarity index 94% rename from app/src/main/java/me/ash/reader/ui/page/home/drawer/group/GroupOptionDrawer.kt rename to app/src/main/java/me/ash/reader/ui/page/home/feeds/option/group/GroupOptionDrawer.kt index e4f87a3..20099b2 100644 --- a/app/src/main/java/me/ash/reader/ui/page/home/drawer/group/GroupOptionDrawer.kt +++ b/app/src/main/java/me/ash/reader/ui/page/home/feeds/option/group/GroupOptionDrawer.kt @@ -1,7 +1,8 @@ -package me.ash.reader.ui.page.home.drawer.group +package me.ash.reader.ui.page.home.feeds.option.group import android.content.Context import android.widget.Toast +import androidx.activity.compose.BackHandler import androidx.compose.animation.animateContentSize import androidx.compose.foundation.layout.* import androidx.compose.foundation.lazy.LazyRow @@ -27,8 +28,10 @@ import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel +import com.google.accompanist.flowlayout.FlowCrossAxisAlignment import com.google.accompanist.flowlayout.FlowRow import com.google.accompanist.flowlayout.MainAxisAlignment +import kotlinx.coroutines.launch import me.ash.reader.R import me.ash.reader.data.entity.Group import me.ash.reader.ui.component.BottomDrawer @@ -53,10 +56,16 @@ fun GroupOptionDrawer( val group = viewState.group val toastString = stringResource(R.string.rename_toast, viewState.newName) + BackHandler(viewState.drawerState.isVisible) { + scope.launch { + viewState.drawerState.hide() + } + } + BottomDrawer( drawerState = viewState.drawerState, sheetContent = { - Column { + Column(modifier = Modifier.navigationBarsPadding()) { Column( modifier = Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally, @@ -153,6 +162,7 @@ private fun Preset( ) { FlowRow( mainAxisAlignment = MainAxisAlignment.Start, + crossAxisAlignment = FlowCrossAxisAlignment.Center, crossAxisSpacing = 10.dp, mainAxisSpacing = 10.dp, ) { @@ -208,6 +218,7 @@ private fun FlowRowGroups( ) { FlowRow( mainAxisAlignment = MainAxisAlignment.Start, + crossAxisAlignment = FlowCrossAxisAlignment.Center, crossAxisSpacing = 10.dp, mainAxisSpacing = 10.dp, ) { diff --git a/app/src/main/java/me/ash/reader/ui/page/home/drawer/group/GroupOptionViewModel.kt b/app/src/main/java/me/ash/reader/ui/page/home/feeds/option/group/GroupOptionViewModel.kt similarity index 99% rename from app/src/main/java/me/ash/reader/ui/page/home/drawer/group/GroupOptionViewModel.kt rename to app/src/main/java/me/ash/reader/ui/page/home/feeds/option/group/GroupOptionViewModel.kt index 7ee989e..cc7b1cb 100644 --- a/app/src/main/java/me/ash/reader/ui/page/home/drawer/group/GroupOptionViewModel.kt +++ b/app/src/main/java/me/ash/reader/ui/page/home/feeds/option/group/GroupOptionViewModel.kt @@ -1,4 +1,4 @@ -package me.ash.reader.ui.page.home.drawer.group +package me.ash.reader.ui.page.home.feeds.option.group import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.ModalBottomSheetState diff --git a/app/src/main/java/me/ash/reader/ui/page/home/feeds/subscribe/ResultView.kt b/app/src/main/java/me/ash/reader/ui/page/home/feeds/subscribe/ResultView.kt index bef743b..1f02321 100644 --- a/app/src/main/java/me/ash/reader/ui/page/home/feeds/subscribe/ResultView.kt +++ b/app/src/main/java/me/ash/reader/ui/page/home/feeds/subscribe/ResultView.kt @@ -28,6 +28,7 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp +import com.google.accompanist.flowlayout.FlowCrossAxisAlignment import com.google.accompanist.flowlayout.FlowRow import com.google.accompanist.flowlayout.MainAxisAlignment import me.ash.reader.R @@ -123,6 +124,7 @@ private fun Preset( Spacer(modifier = Modifier.height(10.dp)) FlowRow( mainAxisAlignment = MainAxisAlignment.Start, + crossAxisAlignment = FlowCrossAxisAlignment.Center, crossAxisSpacing = 10.dp, mainAxisSpacing = 10.dp, ) { @@ -200,6 +202,7 @@ private fun AddToGroup( } else { FlowRow( mainAxisAlignment = MainAxisAlignment.Start, + crossAxisAlignment = FlowCrossAxisAlignment.Center, crossAxisSpacing = 10.dp, mainAxisSpacing = 10.dp, ) {