mirror of
https://github.com/fromchat-messenger/app.git
synced 2026-09-22 11:05:04 +03:00
Fix plugin settings UI toggles and debug desktop auto-enable
Use SwitchListItem for visible engine/plugin switches, add Plugins to pre-auth overflow menu, auto-enable hello_world in debug desktop builds. Co-authored-by: denis0001-dev <denis0001.dev@ya.ru>
This commit is contained in:
@@ -12,6 +12,7 @@ import androidx.compose.foundation.layout.union
|
||||
import androidx.compose.foundation.layout.widthIn
|
||||
import androidx.compose.foundation.layout.windowInsetsPadding
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Extension
|
||||
import androidx.compose.material.icons.filled.Info
|
||||
import androidx.compose.material.icons.filled.MoreVert
|
||||
import androidx.compose.material.icons.outlined.BugReport
|
||||
@@ -36,6 +37,7 @@ import ru.fromchat.more
|
||||
import ru.fromchat.ui.LocalNavController
|
||||
import ru.fromchat.ui.components.Text
|
||||
import ru.fromchat.ui.extraStatusBars
|
||||
import ru.fromchat.plugins_title
|
||||
import ru.fromchat.ui.main.settings.SettingsRoutes
|
||||
|
||||
/** Margin between the window edge and the wide [AuthContentFrame] panel. */
|
||||
@@ -105,6 +107,16 @@ fun PreAuthOverflowMenu() {
|
||||
navController.navigate(SettingsRoutes.About)
|
||||
},
|
||||
)
|
||||
DropdownMenuItem(
|
||||
text = { Text(stringResource(Res.string.plugins_title)) },
|
||||
leadingIcon = {
|
||||
Icon(Icons.Default.Extension, contentDescription = null)
|
||||
},
|
||||
onClick = {
|
||||
menuExpanded = false
|
||||
navController.navigate(SettingsRoutes.Plugins)
|
||||
},
|
||||
)
|
||||
DropdownMenuItem(
|
||||
text = { Text(stringResource(Res.string.logs_title)) },
|
||||
leadingIcon = {
|
||||
|
||||
@@ -10,7 +10,6 @@ import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MediumTopAppBar
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.material3.rememberTopAppBarState
|
||||
import androidx.compose.runtime.Composable
|
||||
@@ -25,6 +24,7 @@ import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.pr0gramm3r101.components.Category
|
||||
import com.pr0gramm3r101.components.ListItem
|
||||
import com.pr0gramm3r101.components.SwitchListItem
|
||||
import com.pr0gramm3r101.utils.verticalScroll
|
||||
import org.jetbrains.compose.resources.stringResource
|
||||
import ru.fromchat.Res
|
||||
@@ -68,23 +68,19 @@ fun PluginsScreen() {
|
||||
.padding(innerPadding),
|
||||
) {
|
||||
Category(Modifier.padding(top = 16.dp)) {
|
||||
ListItem(
|
||||
SwitchListItem(
|
||||
headline = stringResource(Res.string.plugins_engine),
|
||||
supportingText = stringResource(Res.string.plugins_engine_d),
|
||||
trailingContent = {
|
||||
Switch(checked = engineEnabled, onCheckedChange = PluginEngine::setEngineEnabled)
|
||||
},
|
||||
checked = engineEnabled,
|
||||
onCheckedChange = PluginEngine::setEngineEnabled,
|
||||
divider = true,
|
||||
)
|
||||
ListItem(
|
||||
SwitchListItem(
|
||||
headline = stringResource(Res.string.plugins_developer_mode),
|
||||
supportingText = stringResource(Res.string.plugins_developer_mode_d),
|
||||
trailingContent = {
|
||||
Switch(
|
||||
checked = developerMode,
|
||||
onCheckedChange = PluginEngine::setDeveloperMode,
|
||||
enabled = engineEnabled,
|
||||
)
|
||||
},
|
||||
checked = developerMode,
|
||||
onCheckedChange = PluginEngine::setDeveloperMode,
|
||||
enabled = engineEnabled,
|
||||
)
|
||||
}
|
||||
Category(Modifier.padding(top = 8.dp)) {
|
||||
@@ -98,21 +94,20 @@ fun PluginsScreen() {
|
||||
leadingContent = { Icon(Icons.Default.Extension, contentDescription = null) },
|
||||
)
|
||||
} else {
|
||||
installed.forEach { manifest ->
|
||||
ListItem(
|
||||
installed.forEachIndexed { index, manifest ->
|
||||
SwitchListItem(
|
||||
headline = manifest.name,
|
||||
supportingText = manifest.description.ifBlank { manifest.id },
|
||||
leadingContent = { Icon(Icons.Default.Extension, contentDescription = null) },
|
||||
trailingContent = {
|
||||
Switch(
|
||||
checked = PluginEngine.isPluginEnabled(manifest.id),
|
||||
onCheckedChange = { enabled ->
|
||||
PluginEngine.setPluginEnabled(manifest.id, enabled)
|
||||
},
|
||||
enabled = engineEnabled,
|
||||
)
|
||||
checked = PluginEngine.isPluginEnabled(manifest.id),
|
||||
onCheckedChange = { enabled ->
|
||||
PluginEngine.setPluginEnabled(manifest.id, enabled)
|
||||
},
|
||||
enabled = engineEnabled,
|
||||
divider = index < installed.lastIndex,
|
||||
listItemOnClick = {
|
||||
navController.navigate(SettingsRoutes.pluginDetail(manifest.id))
|
||||
},
|
||||
onClick = { navController.navigate(SettingsRoutes.pluginDetail(manifest.id)) },
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -174,17 +169,13 @@ fun PluginDetailScreen(pluginId: String) {
|
||||
PluginEngine.getPluginSettingBoolean(pluginId, setting.key, setting.default),
|
||||
)
|
||||
}
|
||||
ListItem(
|
||||
SwitchListItem(
|
||||
headline = setting.text,
|
||||
supportingText = setting.subtext,
|
||||
trailingContent = {
|
||||
Switch(
|
||||
checked = checked,
|
||||
onCheckedChange = { value ->
|
||||
checked = value
|
||||
PluginEngine.setPluginSetting(pluginId, setting.key, value.toString())
|
||||
},
|
||||
)
|
||||
checked = checked,
|
||||
onCheckedChange = { value ->
|
||||
checked = value
|
||||
PluginEngine.setPluginSetting(pluginId, setting.key, value.toString())
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
+4
@@ -17,6 +17,10 @@ object DesktopPluginBootstrap {
|
||||
PluginEngine.appVersionProvider = { ru.fromchat.AppBuildInfo.version }
|
||||
installBundledPlugin(classLoader)
|
||||
PluginEngine.init()
|
||||
if (ru.fromchat.AppBuildInfo.isDebug) {
|
||||
PluginEngine.setEngineEnabled(true)
|
||||
PluginEngine.setPluginEnabled("hello_world", true)
|
||||
}
|
||||
PluginEngine.dispatchAppEvent(AppEvent.START)
|
||||
FeatureGate.registerDefault("calls") { ru.fromchat.config.ServerConfig.callsEnabled }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user