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