Skip to content
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,68 @@
package com.baidaidai.rootless_store.components.marketScreen

import com.baidaidai.rootless_store.R
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MediumFlexibleTopAppBar
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.PreviewLightDark

object MarketScreenNecessaryComponents {

@OptIn(ExperimentalMaterial3Api::class, ExperimentalMaterial3ExpressiveApi::class)
@Composable
fun MarketScreenScreenTopAppBar(
onBackButtonClick: ()-> Unit = {},
onSearchButtonClick: ()-> Unit = {},
onFilterButtonClick: ()-> Unit = {},
sourceName: String = "Null"
){
MediumFlexibleTopAppBar(
title = {
Text(sourceName)
},
subtitle = {
Text("Total Plugin: 0 available")
},
actions = {
IconButton(
onClick = onSearchButtonClick
) {
Icon(
painterResource(R.drawable.material_symbols_search),
contentDescription = "Search"
)
}
IconButton(
onClick = onFilterButtonClick
) {
Icon(
painterResource(R.drawable.material_symbols_filter_list),
contentDescription = "Filter"
)
}
},
navigationIcon = {
IconButton(
onClick = onBackButtonClick
) {
Icon(
painterResource(R.drawable.material_symbols_arrow_back),
contentDescription = "Back"
)
}
}
)
}

}

@Composable
@PreviewLightDark
fun _MarketScreenScreenTopAppBarPreview_(){
MarketScreenNecessaryComponents.MarketScreenScreenTopAppBar()
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import com.baidaidai.rootless_store.domain.market.error.MarketError
import com.baidaidai.rootless_store.domain.market.usecase.GetRemotePluginListUseCase
import com.baidaidai.rootless_store.domain.plugin.manifest.PluginManifestRemote
import com.baidaidai.rootless_store.domain.plugin.usecase.InstallPluginFromMarketUseCase
import com.baidaidai.rootless_store.domain.source.model.PluginSourceLocal
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asSharedFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.update
Expand All @@ -38,11 +40,13 @@ class RootLessStoreMarketScreenViewModel @Inject constructor(
private var _pluginSourceUri = MutableStateFlow<String?>(null)

// Market Error Handler
val _marketEvent = MutableSharedFlow<MarketError?>()
private val _marketEvent = MutableSharedFlow<MarketError?>()

val marketEvent = _marketEvent.asSharedFlow()

private val _currentPluginSource = MutableStateFlow<PluginSourceLocal?>(null)

val currentPluginSource = _currentPluginSource.asStateFlow()

@OptIn(ExperimentalCoroutinesApi::class)
val remotePluginList = _pluginSourceUri
Expand Down Expand Up @@ -71,6 +75,15 @@ class RootLessStoreMarketScreenViewModel @Inject constructor(
}
}

fun updateCurrentPluginSource(
pluginSourceLocal: PluginSourceLocal
){
_currentPluginSource.update { old ->
if(pluginSourceLocal != old) pluginSourceLocal else old
}

}

fun installPlugin(
pluginURI: String,
pluginManifestRemote: PluginManifestRemote
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.unit.dp
import com.baidaidai.rootless_store.components.sourcesScreen.SourceScreenListItem
import com.baidaidai.rootless_store.domain.source.model.PluginSourceLocal
import com.baidaidai.rootless_store.ui.model.RootLessStoreSourceScreenViewModel
@OptIn(ExperimentalMaterial3ExpressiveApi::class)
@Composable
fun SourceScreen(
contentPadding: PaddingValues,
sourceScreenViewModel: RootLessStoreSourceScreenViewModel,
onListItemClick: (pluginSourceUri: String)-> Unit
onListItemClick: (pluginSourceLocal: PluginSourceLocal)-> Unit
){
val pluginSourceList by sourceScreenViewModel.sourceList.collectAsState()
val sourceScreenLeadingDeleteButtonStatus by sourceScreenViewModel.deleterShowStatus.collectAsState()
Expand All @@ -47,7 +48,7 @@ fun SourceScreen(
pluginSourceLocal = pluginSource,
sourceScreenViewModel
) {
onListItemClick(pluginSource.sourceRemoteEndpoint)
onListItemClick(pluginSource)
}
if (listIndex!=pluginSourceList.size-1){
Spacer(modifier = Modifier.height(2.dp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import com.baidaidai.rootless_store.ShizukuActivity
import com.baidaidai.rootless_store.components.executeScreen.executeScreenNecessaryComponents
import com.baidaidai.rootless_store.components.marketScreen.MarketScreenNecessaryComponents
import com.baidaidai.rootless_store.components.pluginsScreen.PluginScreenNecessaryComponents
import com.baidaidai.rootless_store.components.sourcesScreen.SourcesScreenNecessaryComponents
import com.baidaidai.rootless_store.components.startScreen.StartScreenErrorDialog
Expand Down Expand Up @@ -59,6 +60,7 @@ fun RootlessStoreStartScreenContainer(
val navController = rememberNavController()
val navBackStackEntry by navController.currentBackStackEntryAsState()
val currentDestination = navBackStackEntry?.destination?.route ?: "HomeScreen"
val currentPluginSource by marketScreenViewModel.currentPluginSource.collectAsState()

// Define the operation ,which after got the file's URI
val openDocumentLauncher = rememberLauncherForActivityResult(
Expand Down Expand Up @@ -130,6 +132,9 @@ fun RootlessStoreStartScreenContainer(
"ExecuteScreen" -> executeScreenNecessaryComponents.ExecuteScreenTopAppBar(
scrollBehavior = scrollBehavior
)
"MarketScreen" -> MarketScreenNecessaryComponents.MarketScreenScreenTopAppBar(
sourceName = currentPluginSource!!.sourceName
)
else -> StartScreenNecessaryComponents.StartScreenTopAppBar(scrollBehavior)
}
},
Expand Down Expand Up @@ -211,8 +216,9 @@ fun RootlessStoreStartScreenContainer(
SourceScreen(
contentPadding = contentPadding,
sourceScreenViewModel = sourceScreenViewModel
){ pluginSourceUri ->
marketScreenViewModel.updatePluginSourceUri(pluginSourceUri)
){ pluginSourceLocal ->
marketScreenViewModel.updatePluginSourceUri(pluginSourceLocal.sourceRemoteEndpoint)
marketScreenViewModel.updateCurrentPluginSource(pluginSourceLocal)
navController.navigate("MarketScreen")
}
}
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/material_symbols_search.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M784,840L532,588Q502,612 463,626Q424,640 380,640Q271,640 195.5,564.5Q120,489 120,380Q120,271 195.5,195.5Q271,120 380,120Q489,120 564.5,195.5Q640,271 640,380Q640,424 626,463Q612,502 588,532L840,784L784,840ZM380,560Q455,560 507.5,507.5Q560,455 560,380Q560,305 507.5,252.5Q455,200 380,200Q305,200 252.5,252.5Q200,305 200,380Q200,455 252.5,507.5Q305,560 380,560Z"/>
</vector>
Loading