Skip to content
Draft
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
7 changes: 2 additions & 5 deletions app/src/main/java/dev/dimension/flare/ui/route/Route.kt
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,7 @@ internal sealed interface Route : NavKey {
@Serializable
sealed interface Compose : Route {
@Serializable
data class New(
override val accountType: AccountType,
) : Compose,
WithAccountType
data object New : Compose

@Serializable
data class Reply(
Expand Down Expand Up @@ -503,7 +500,7 @@ internal sealed interface Route : NavKey {

is DeeplinkRoute.Login -> ServiceSelect.Selection
is DeeplinkRoute.Compose.New ->
Compose.New(accountType = deeplinkRoute.accountType)
Compose.New

is DeeplinkRoute.Compose.Quote ->
Compose.Quote(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ internal fun EntryProviderScope<NavKey>.composeEntryBuilder(
) {
entry<Route.Compose.New>(
metadata = DialogSceneStrategy.dialog()
) { args ->
) {
ComposeScreen(
onBack = onBack,
accountType = args.accountType,
accountType = null,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private fun activeAccountPresenter() =
@Composable
internal fun ComposeScreen(
onBack: () -> Unit,
accountType: AccountType,
accountType: AccountType?,
modifier: Modifier = Modifier,
status: ComposeStatus? = null,
initialText: String = "",
Expand Down Expand Up @@ -926,7 +926,7 @@ private fun PollOption(
@Composable
private fun composePresenter(
context: Context,
accountType: AccountType,
accountType: AccountType?,
status: ComposeStatus? = null,
initialText: String = "",
initialMedias: ImmutableList<Uri> = persistentListOf(),
Expand Down Expand Up @@ -1043,53 +1043,50 @@ private fun composePresenter(
}

fun send() {
state.selectedAccounts.forEach {
val data =
ComposeData(
content = textFieldState.text.toString(),
medias =
mediaState.takeSuccess()?.medias.orEmpty().map {
ComposeData.Media(
file = FileItem(context, it.uri),
altText =
it.textState.text
.toString()
.takeIf { it.isNotEmpty() },
)
},
poll =
pollState.takeSuccess()?.takeIf { it.enabled }?.let {
ComposeData.Poll(
multiple = !it.pollSingleChoice,
expiredAfter = it.expiredAt.duration.inWholeMilliseconds,
options =
it.options.map { option ->
option.text.toString()
},
)
},
sensitive = mediaState.takeSuccess()?.isMediaSensitive ?: false,
spoilerText =
contentWarningState
.takeSuccess()
?.textFieldState
?.text
?.toString(),
visibility =
state.visibilityState.takeSuccess()?.visibility
?: UiTimelineV2.Post.Visibility.Public,
account = it,
referenceStatus =
status?.let {
ComposeData.ReferenceStatus(
data = state.replyState?.takeSuccess(),
composeStatus = status,
)
},
language = languageState.takeSuccess()?.selectedLanguage.orEmpty(),
)
state.send(data)
}
val data =
ComposeData(
content = textFieldState.text.toString(),
medias =
mediaState.takeSuccess()?.medias.orEmpty().map {
ComposeData.Media(
file = FileItem(context, it.uri),
altText =
it.textState.text
.toString()
.takeIf { it.isNotEmpty() },
)
},
poll =
pollState.takeSuccess()?.takeIf { it.enabled }?.let {
ComposeData.Poll(
multiple = !it.pollSingleChoice,
expiredAfter = it.expiredAt.duration.inWholeMilliseconds,
options =
it.options.map { option ->
option.text.toString()
},
)
},
sensitive = mediaState.takeSuccess()?.isMediaSensitive ?: false,
spoilerText =
contentWarningState
.takeSuccess()
?.textFieldState
?.text
?.toString(),
visibility =
state.visibilityState.takeSuccess()?.visibility
?: UiTimelineV2.Post.Visibility.Public,
referenceStatus =
status?.let {
ComposeData.ReferenceStatus(
data = state.replyState?.takeSuccess(),
composeStatus = status,
)
},
language = languageState.takeSuccess()?.selectedLanguage.orEmpty(),
)
state.send(data)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal fun EntryProviderScope<NavKey>.homeEntryBuilder(
HomeTimelineScreen(
accountType = args.accountType,
toCompose = {
navigate(Route.Compose.New(args.accountType))
navigate(Route.Compose.New)
},
toQuickMenu = {
openDrawer.invoke()
Expand Down
36 changes: 7 additions & 29 deletions app/src/main/java/dev/dimension/flare/ui/screen/home/HomeScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ import dev.dimension.flare.ui.component.platform.isBigScreen
import dev.dimension.flare.ui.model.UiProfile
import dev.dimension.flare.ui.model.UiState
import dev.dimension.flare.ui.model.isError
import dev.dimension.flare.ui.model.isSuccess
import dev.dimension.flare.ui.model.map
import dev.dimension.flare.ui.model.onLoading
import dev.dimension.flare.ui.model.onSuccess
Expand All @@ -99,7 +98,6 @@ import dev.dimension.flare.ui.presenter.home.UserPresenter
import dev.dimension.flare.ui.presenter.invoke
import dev.dimension.flare.ui.route.Route
import dev.dimension.flare.ui.route.Router
import dev.dimension.flare.ui.route.accountTypeOr
import dev.dimension.flare.ui.screen.splash.SplashScreen
import kotlinx.coroutines.launch
import moe.tlaster.precompose.molecule.producePresenter
Expand All @@ -124,10 +122,6 @@ internal fun HomeScreen(afterInit: () -> Unit) {
) {
state.topLevelBackStack.takeSuccess()?.topLevelKey ?: getDirection(tabs.all.first())
}
val accountType = currentRoute.accountTypeOr(state.defaultAccountType)
val userState by producePresenter(key = "home_account_type_$accountType") {
userPresenter(accountType)
}
OnNewIntent(
withOnCreateIntent = true,
) {
Expand All @@ -147,11 +141,10 @@ internal fun HomeScreen(afterInit: () -> Unit) {
bottomBarAutoHideEnabled = state.navigationState.bottomBarAutoHideEnabled,
layoutType = layoutType,
showFab =
userState.isSuccess &&
accountType !is AccountType.Guest &&
state.defaultAccountType !is AccountType.Guest &&
state.topLevelBackStack.takeSuccess()?.currentKey is Route.Home,
onFabClicked = {
state.navigate(Route.Compose.New(accountType))
state.navigate(Route.Compose.New)
},
navigationSuiteColors =
NavigationSuiteDefaults.colors(
Expand All @@ -160,10 +153,8 @@ internal fun HomeScreen(afterInit: () -> Unit) {
railHeader = {
HomeRailHeader(
state.wideNavigationRailState,
userState,
state.userState,
layoutType,
currentRoute,
state.defaultAccountType,
state::navigate,
)
},
Expand Down Expand Up @@ -256,7 +247,7 @@ internal fun HomeScreen(afterInit: () -> Unit) {
}
},
footerItems = {
if (!userState.isError) {
if (!state.userState.isError) {
item(
selected = currentRoute is Route.Settings.Main,
onClick = {
Expand Down Expand Up @@ -314,8 +305,6 @@ private fun HomeRailHeader(
wideNavigationRailState: WideNavigationRailState,
userState: UiState<UiProfile>,
layoutType: NavigationSuiteType,
currentRoute: Route,
defaultAccountType: AccountType,
navigate: (Route) -> Unit,
) {
val scope = rememberCoroutineScope()
Expand Down Expand Up @@ -455,13 +444,7 @@ private fun HomeRailHeader(
WideNavigationRailValue.Collapsed ->
FloatingActionButton(
onClick = {
navigate(
Route.Compose.New(
currentRoute.accountTypeOr(
defaultAccountType,
),
),
)
navigate(Route.Compose.New)
},
elevation =
FloatingActionButtonDefaults.elevation(
Expand All @@ -483,13 +466,7 @@ private fun HomeRailHeader(
WideNavigationRailValue.Expanded ->
ExtendedFloatingActionButton(
onClick = {
navigate(
Route.Compose.New(
currentRoute.accountTypeOr(
defaultAccountType,
),
),
)
navigate(Route.Compose.New)
},
icon = {
FAIcon(
Expand Down Expand Up @@ -609,6 +586,7 @@ private fun presenter(uriHandler: UriHandler) =
val deeplinkPresenter = deeplinkPresenter
val topLevelBackStack = topLevelBackStack
val wideNavigationRailState = wideNavigationRailState
val userState = activeAccountState.user
val defaultAccountType: AccountType =
activeAccountState.user
.takeSuccess()
Expand Down
6 changes: 6 additions & 0 deletions desktopApp/src/main/composeResources/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@
<string name="settings_status_appearance_subtitle">Customize the appearance of post</string>
<string name="settings_appearance_subtitle">Customize the look and feel of Flare</string>
<string name="settings_storage_title">Storage</string>
<string name="settings_draft_box_title">Draft Box</string>
<string name="settings_draft_box_description">View sending, failed, and unsent drafts</string>
<string name="settings_storage_subtitle">Manage Flare\'s storage</string>
<string name="settings_about_title">About</string>
<string name="settings_about_subtitle">Learn more about Flare</string>
Expand Down Expand Up @@ -348,6 +350,10 @@
<string name="settings_storage_app_log_description">View the app log</string>
<string name="settings_rss_management_title">RSS Management</string>
<string name="settings_rss_management_description">Manage RSS feeds</string>
<string name="draft_box_title">Draft Box</string>
<string name="draft_box_empty">No drafts yet</string>
<string name="draft_box_retry">Retry</string>
<string name="draft_box_edit">Edit</string>

<string name="copied_to_clipboard">Copied to clipboard</string>

Expand Down
4 changes: 1 addition & 3 deletions desktopApp/src/main/kotlin/dev/dimension/flare/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@ internal fun WindowScope.FlareApp(backButtonState: NavigationBackButtonState) {
Button(
onClick = {
state.navigate(
Route.Compose.New(
accountType = AccountType.Specific(user.key),
),
Route.Compose.New,
)
},
modifier =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ internal sealed interface Route : NavKey {

data object Settings : ScreenRoute

data object DraftBox : ScreenRoute

data class Profile(
val accountType: AccountType,
val userKey: MicroBlogKey,
Expand Down Expand Up @@ -150,9 +152,7 @@ internal sealed interface Route : NavKey {
val statusKey: MicroBlogKey,
) : FloatingRoute

data class New(
val accountType: AccountType,
) : FloatingRoute
data object New : FloatingRoute

data class VVOReplyComment(
val accountKey: MicroBlogKey,
Expand Down Expand Up @@ -295,7 +295,7 @@ internal sealed interface Route : NavKey {
.toImmutableMap(),
)
is DeeplinkRoute.Login -> ServiceSelect
is DeeplinkRoute.Compose.New -> New(deeplinkRoute.accountType)
DeeplinkRoute.Compose.New -> New
is DeeplinkRoute.Compose.Quote ->
Quote(
deeplinkRoute.accountKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import dev.dimension.flare.ui.route.Route.Search
import dev.dimension.flare.ui.route.Route.Timeline
import dev.dimension.flare.ui.route.WindowSceneStrategy.Companion.window
import dev.dimension.flare.ui.screen.compose.ComposeDialog
import dev.dimension.flare.ui.screen.compose.DraftBoxScreen
import dev.dimension.flare.ui.screen.dm.DmConversationScreen
import dev.dimension.flare.ui.screen.dm.DmListScreen
import dev.dimension.flare.ui.screen.dm.UserDMConversationScreen
Expand Down Expand Up @@ -342,7 +343,7 @@ internal fun WindowScope.Router(
) {
ComposeDialog(
onBack = onBack,
accountType = args.accountType,
accountType = null,
)
}
}
Expand Down Expand Up @@ -520,6 +521,9 @@ internal fun WindowScope.Router(
toLogin = {
navigate(Route.ServiceSelect)
},
toDraftBox = {
navigate(Route.DraftBox)
},
toLocalCache = {
navigate(Route.LocalCache)
},
Expand All @@ -532,6 +536,13 @@ internal fun WindowScope.Router(
)
}

entry<Route.DraftBox> {
DraftBoxScreen(
onEdit = { _, accountKey ->
},
)
}

entry<Route.AppLogging> {
AppLoggingScreen()
}
Expand Down
Loading
Loading