Refactor: Extract RootScreen from MainActivity and fix reply message user
This commit refactors the UI composition logic by extracting it from `MainActivity` into a new, dedicated `RootScreen` composable. This improves the separation of concerns and simplifies `MainActivity`. Additionally, a bug has been fixed where a replied-to message would incorrectly display the author of the parent message instead of its own author. Key changes: - Moved theme setup, permission handling, Long-Poll/Online service management, and navigation graph hosting into the new `RootScreen.kt`. - `MainActivity` is now significantly simplified, delegating its UI composition to `RootScreen`. - Corrected the user and group assignment for `replyMessage` in `MessagesRepositoryImpl` to ensure the correct author is displayed. - Introduced `OnlineFriendsViewModel` to the `FriendsRoute` to separate the logic for online friends. - Replaced `List` with a custom `ImmutableList` for `photoViewerInfo` state to improve Compose stability.
This commit is contained in:
+3
-4
@@ -1,6 +1,5 @@
|
||||
package dev.meloda.fast.photoviewer.presentation
|
||||
|
||||
import android.content.Intent
|
||||
import android.widget.Toast
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.core.Animatable
|
||||
@@ -59,9 +58,9 @@ import dev.meloda.fast.photoviewer.model.PhotoViewScreenState
|
||||
import dev.meloda.fast.ui.R
|
||||
import dev.meloda.fast.ui.components.FullScreenDialog
|
||||
import dev.meloda.fast.ui.components.Loader
|
||||
import dev.meloda.fast.ui.util.ImmutableList
|
||||
import dev.meloda.fast.ui.util.getImage
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
import kotlinx.coroutines.launch
|
||||
import org.koin.androidx.compose.koinViewModel
|
||||
import java.net.URLEncoder
|
||||
@@ -69,7 +68,7 @@ import kotlin.math.abs
|
||||
|
||||
@Composable
|
||||
fun PhotoViewDialog(
|
||||
photoViewerInfo: Pair<List<String>, Int?>?,
|
||||
photoViewerInfo: Pair<ImmutableList<String>, Int?>?,
|
||||
modifier: Modifier = Modifier,
|
||||
onDismiss: () -> Unit
|
||||
) {
|
||||
@@ -85,7 +84,7 @@ fun PhotoViewDialog(
|
||||
arguments = PhotoViewArguments(
|
||||
imageUrls = photoViewerInfo.first.map {
|
||||
URLEncoder.encode(it, "utf-8")
|
||||
},
|
||||
}.toList(),
|
||||
selectedIndex = photoViewerInfo.second
|
||||
),
|
||||
applicationContext = applicationContext
|
||||
|
||||
Reference in New Issue
Block a user