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
Expand Up @@ -69,6 +69,8 @@
<string name="settings_adb_valid">ADB configuraton is valid</string>
<string name="settings_font_size_multiplier">Font Size Multiplier : %1$sx</string>
<string name="settings_test">Test</string>
<string name="settings_about_title">About</string>
<string name="settings_licenses">Licenses</string>
<string name="size">Size</string>
<string name="tables_empty">No Tables</string>
<string name="time">Time</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
import co.touchlab.kermit.Logger
import flocondesktop.composeapp.generated.resources.Res
import flocondesktop.composeapp.generated.resources.general_save
import flocondesktop.composeapp.generated.resources.settings_about_title
import flocondesktop.composeapp.generated.resources.settings_adb_setup_title
import flocondesktop.composeapp.generated.resources.settings_adb_valid
import flocondesktop.composeapp.generated.resources.settings_font_size_multiplier
import flocondesktop.composeapp.generated.resources.settings_licenses
import flocondesktop.composeapp.generated.resources.settings_test
import io.github.openflocon.flocondesktop.common.ui.window.FloconWindow
import io.github.openflocon.flocondesktop.common.ui.window.createFloconWindowState
import io.github.openflocon.library.designsystem.FloconTheme
import io.github.openflocon.library.designsystem.components.FloconButton
import io.github.openflocon.library.designsystem.components.FloconFeature
Expand Down Expand Up @@ -73,6 +77,8 @@ private fun SettingsScreen(
onAction: (SettingsAction) -> Unit,
modifier: Modifier = Modifier,
) {
var showLicenses by remember { mutableStateOf(false) }

FloconFeature(
modifier = modifier.fillMaxSize()
) {
Expand Down Expand Up @@ -151,6 +157,22 @@ private fun SettingsScreen(
)
}
}
FloconSection(
title = stringResource(Res.string.settings_about_title),
initialValue = true
) {
SettingsButton(
onClick = { showLicenses = true },
text = stringResource(Res.string.settings_licenses),
modifier = Modifier.padding(8.dp)
)
}
}

if (showLicenses) {
LicensesWindow(
onCloseRequest = { showLicenses = false }
)
}
}

Expand All @@ -172,6 +194,25 @@ private fun SettingsButton(
}
}

@Composable
private fun LicensesWindow(
onCloseRequest: () -> Unit
) {
FloconWindow(
title = "Licenses",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve maintainability and support for localization, it's best to use string resources instead of hardcoding text. You've already added a string resource for "Licenses", so it should be used here for the window title.

Suggested change
title = "Licenses",
title = stringResource(Res.string.settings_licenses),

state = createFloconWindowState(),
alwaysOnTop = true,
onCloseRequest = onCloseRequest,
) {
AboutScreen(
modifier = Modifier
.fillMaxSize()
.background(FloconTheme.colorPalette.primary),
)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove line break

}

@Preview
@Composable
private fun SettingsScreenPreview() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.github.openflocon.flocondesktop

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.LaunchedEffect
Expand All @@ -10,14 +8,11 @@ import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.key.Key
import androidx.compose.ui.input.key.KeyEventType
import androidx.compose.ui.input.key.key
import androidx.compose.ui.input.key.type
import androidx.compose.ui.window.ApplicationScope
import androidx.compose.ui.window.FrameWindowScope
import androidx.compose.ui.window.MenuBar
import androidx.compose.ui.window.Notification
import androidx.compose.ui.window.Tray
import androidx.compose.ui.window.Window
Expand All @@ -32,21 +27,17 @@ import flocondesktop.composeapp.generated.resources.app_icon_small
import io.github.openflocon.domain.feedback.FeedbackDisplayer
import io.github.openflocon.domain.feedback.FeedbackDisplayerHandler
import io.github.openflocon.flocondesktop.about.AboutScreen
import io.github.openflocon.flocondesktop.common.ui.window.FloconWindow
import io.github.openflocon.flocondesktop.common.ui.window.createFloconWindowState
import io.github.openflocon.flocondesktop.window.MIN_WINDOW_HEIGHT
import io.github.openflocon.flocondesktop.window.MIN_WINDOW_WIDTH
import io.github.openflocon.flocondesktop.window.WindowStateData
import io.github.openflocon.flocondesktop.window.WindowStateSaver
import io.github.openflocon.flocondesktop.window.size
import io.github.openflocon.flocondesktop.window.windowPosition
import io.github.openflocon.library.designsystem.FloconTheme
import io.github.openflocon.library.designsystem.components.escape.LocalEscapeHandlerStack
import org.jetbrains.compose.resources.painterResource
import org.koin.compose.koinInject
import java.awt.Desktop
import java.awt.Dimension
import java.util.Locale

private const val ACTIVATE_TRAY_NOTIFICATION = false

Expand Down Expand Up @@ -115,7 +106,6 @@ fun main() {
if (ACTIVATE_TRAY_NOTIFICATION) {
FloconTray()
}
FloconMenu()

if (openAbout) {
AboutScreen(
Expand All @@ -127,39 +117,6 @@ fun main() {
}
}

@Composable
private fun FrameWindowScope.FloconMenu() {
var openLicenses by remember { mutableStateOf(false) }

MenuBar {
Menu(
text = "Settings"
) {
Item(
text = "Licences",
onClick = {
openLicenses = true
}
)
}
}

if (openLicenses) {
FloconWindow(
title = "Licenses",
state = createFloconWindowState(),
alwaysOnTop = true,
onCloseRequest = { openLicenses = false },
) {
io.github.openflocon.flocondesktop.app.ui.settings.AboutScreen(
modifier = Modifier
.fillMaxSize()
.background(FloconTheme.colorPalette.primary),
)
}
}
}

@Composable
private fun ApplicationScope.FloconTray() {
val trayState = rememberTrayState()
Expand Down