Skip to content

Commit

Permalink
Merge pull request #60 from NeoUtils/develop
Browse files Browse the repository at this point in the history
Release v2.3.0
  • Loading branch information
Irineu333 authored Nov 10, 2024
2 parents 374d405 + 0d63b6d commit f88fbb3
Show file tree
Hide file tree
Showing 37 changed files with 1,108 additions and 258 deletions.
10 changes: 10 additions & 0 deletions .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion application/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import extension.*
import extension.catalog
import extension.config
import extension.distribution
import extension.name

plugins {
alias(libs.plugins.neoutils.neoregex.android)
Expand Down
6 changes: 3 additions & 3 deletions application/installation/com.neoutils.NeoRegex.metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

<description>
<p>
Visualize the functioning of your regular expressions in real-time with a useful and intuitive tool. With support for capture groups, undo, and redo.
Visualize the functioning of your regular expressions in real-time with a useful and intuitive tool. With
support for capture groups, undo, and redo.
</p>
</description>

Expand Down Expand Up @@ -50,10 +51,9 @@
<description>
<p>Improvements in user experience.</p>
<ul>
<li>Small improvements across the application.</li>
<li>Customized window for a personalized experience.</li>
<li>Enhanced touchscreen support for better usability on touch devices.</li>
<li>Improved theme detection.</li>
<li>Small improvements.</li>
</ul>
</description>
</release>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.safeDrawingPadding
import androidx.compose.ui.Modifier
import com.neoutils.neoregex.core.common.util.UiMode
import com.neoutils.neoregex.core.common.util.resolve
import com.neoutils.neoregex.core.common.util.ColorTheme
import com.neoutils.neoregex.core.common.util.colorTheme
import com.neoutils.neoregex.core.designsystem.theme.NeoTheme

class MainActivity : ComponentActivity() {
Expand All @@ -38,6 +38,7 @@ class MainActivity : ComponentActivity() {
setupSystemBars()

setContent {

NeoTheme {
App(Modifier.safeDrawingPadding())
}
Expand All @@ -46,14 +47,14 @@ class MainActivity : ComponentActivity() {

private fun setupSystemBars() {

val style = when (UiMode.resolve(context = this)) {
UiMode.DARK -> {
val style = when (colorTheme) {
ColorTheme.DARK -> {
SystemBarStyle.dark(
Color.BLACK,
)
}

UiMode.LIGHT -> {
ColorTheme.LIGHT -> {
SystemBarStyle.light(
Color.WHITE,
Color.BLACK,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,80 +16,95 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

@file:OptIn(ExperimentalComposeUiApi::class)

package com.neoutils.neoregex

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme.colorScheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.FrameWindowScope
import androidx.compose.ui.window.application
import com.neoutils.neoregex.core.common.util.UiMode
import com.neoutils.neoregex.core.common.util.isDark
import com.neoutils.neoregex.core.common.util.resolve
import androidx.compose.ui.window.launchApplication
import com.neoutils.neoregex.core.common.util.ColorTheme
import com.neoutils.neoregex.core.common.util.rememberColorTheme
import com.neoutils.neoregex.core.designsystem.theme.NeoTheme
import com.neoutils.neoregex.core.designsystem.theme.NeoTheme.dimensions
import com.neoutils.neoregex.core.resources.Res
import com.neoutils.neoregex.core.resources.app_name
import com.neoutils.neoregex.core.resources.github
import com.neoutils.neoregex.core.sharedui.component.DefaultHeader
import com.neoutils.neoregex.core.sharedui.component.NeoHeader
import com.neoutils.neoregex.core.sharedui.component.NeoWindow
import kotlinx.coroutines.CoroutineScope
import org.jetbrains.compose.resources.painterResource
import org.jetbrains.compose.resources.stringResource
import org.jetbrains.skiko.MainUIDispatcher

fun main() = application {

val uiMode = remember { UiMode.resolve() }

NeoTheme(uiMode.isDark) {
NeoWindow(
header = {
TitleBar()
fun main() {
with(CoroutineScope(MainUIDispatcher)) {
launchApplication {
NeoTheme {
NeoWindow(
header = {
Header()
}
) {
App()
}
}
) {
App()
}
}
}

@Composable
private fun FrameWindowScope.TitleBar(
private fun FrameWindowScope.Header(
title: String = stringResource(Res.string.app_name),
uiMode: UiMode = remember { UiMode.resolve() }
) {
DefaultHeader(
title = title,
options = {
val uriHandler = LocalUriHandler.current
colorTheme: ColorTheme = rememberColorTheme()
) = NeoHeader { padding ->

Icon(
painter = painterResource(Res.drawable.github),
contentDescription = null,
tint = when (uiMode) {
UiMode.LIGHT -> colorScheme.onSurface
UiMode.DARK -> colorScheme.onSurface
},
modifier = Modifier
.clip(CircleShape)
.clickable(
onClick = {
uriHandler.openUri(
uri = "https://github.com/NeoUtils/NeoRegex"
)
}
)
.padding(dimensions.medium)
.aspectRatio(ratio = 1f)
)
}
Text(
text = title,
modifier = Modifier.align(
Alignment.Center
)
)

Row(
modifier = Modifier
.padding(padding)
.padding(horizontal = dimensions.medium)
.align(Alignment.CenterEnd)
) {
val uriHandler = LocalUriHandler.current

Icon(
painter = painterResource(Res.drawable.github),
contentDescription = null,
tint = when (colorTheme) {
ColorTheme.LIGHT -> colorScheme.onSurface
ColorTheme.DARK -> colorScheme.onSurface
},
modifier = Modifier
.clip(CircleShape)
.clickable(
onClick = {
uriHandler.openUri(
uri = "https://github.com/NeoUtils/NeoRegex"
)
}
)
.padding(dimensions.medium)
.aspectRatio(ratio = 1f)
)
}
}
4 changes: 2 additions & 2 deletions build-logic/src/main/kotlin/extension/Project.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import org.gradle.kotlin.dsl.the
val config = Config(
version = Config.Version(
major = 2,
minor = 2,
patch = 1,
minor = 3,
patch = 0,
phase = Config.Phase.RELEASE
),
android = Config.Android(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,4 @@

package com.neoutils.neoregex.core.common.platform

import com.neoutils.neoregex.core.common.platform.Platform

actual val Platform.Companion.Current: Platform
get() = Platform.ANDROID
actual val platform: Platform = Platform.Android
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,26 @@ package com.neoutils.neoregex.core.common.util
import android.content.Context
import android.content.res.Configuration.UI_MODE_NIGHT_MASK
import android.content.res.Configuration.UI_MODE_NIGHT_YES
import com.neoutils.neoregex.core.common.util.UiMode
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.runtime.Composable

fun UiMode.Companion.resolve(context: Context): UiMode {
@Composable
actual fun rememberColorTheme(): ColorTheme {

return when (context.resources.configuration.uiMode and UI_MODE_NIGHT_MASK) {
return if (isSystemInDarkTheme()) {
ColorTheme.DARK
} else {
ColorTheme.LIGHT
}
}

val Context.colorTheme
get() = when (resources.configuration.uiMode and UI_MODE_NIGHT_MASK) {
UI_MODE_NIGHT_YES -> {
UiMode.DARK
ColorTheme.DARK
}

else -> {
UiMode.LIGHT
ColorTheme.LIGHT
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@

package com.neoutils.neoregex.core.common.platform

enum class Platform {
DESKTOP,
ANDROID,
WEB;
sealed class Platform {

companion object
sealed class Desktop : Platform() {
data object Windows : Desktop()
data object Linux : Desktop()
data object MacOS : Desktop()
}

data object Android : Platform()

// Experimental
data object Web : Platform()
}

expect val Platform.Companion.Current: Platform
expect val platform: Platform
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@

package com.neoutils.neoregex.core.common.util

enum class UiMode {
import androidx.compose.runtime.Composable

enum class ColorTheme {
LIGHT,
DARK;

companion object
val isLight: Boolean
get() = this == LIGHT

val isDark: Boolean
get() = this == DARK
}

val UiMode.isDark: Boolean
get() = this == UiMode.DARK
@Composable
expect fun rememberColorTheme(): ColorTheme
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@

package com.neoutils.neoregex.core.common.platform

import com.neoutils.neoregex.core.common.platform.Platform
import org.jetbrains.skiko.OS
import org.jetbrains.skiko.hostOs

actual val Platform.Companion.Current
get() = Platform.DESKTOP
actual val platform: Platform = when (hostOs) {
OS.Linux -> Platform.Desktop.Linux
OS.Windows -> Platform.Desktop.Windows
OS.MacOS -> Platform.Desktop.MacOS
else -> error("Unsupported platform ${hostOs.name}")
}
Loading

0 comments on commit f88fbb3

Please sign in to comment.