Skip to content

Commit

Permalink
[Feat] Admin Consent (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
Danil0v3s authored Dec 30, 2024
1 parent 91167d0 commit 6383004
Show file tree
Hide file tree
Showing 15 changed files with 237 additions and 88 deletions.
2 changes: 1 addition & 1 deletion .idea/runConfigurations/Run.xml

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

2 changes: 1 addition & 1 deletion .idea/runConfigurations/Run_Standalone.xml

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

Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,28 @@ import androidx.compose.ui.unit.sp

class Typography {

/**
* fontSize = 32.sp,
* lineHeight = 0.sp,
* fontWeight = W400,
*/
val titleXXL: TextStyle
@Composable get() = defaultTextStyle.copy(
fontSize = 32.sp,
lineHeight = 0.sp,
fontFamily = fontFamilyNormal,
)

/**
* fontSize = 16.sp,
* lineHeight = 0.sp,
* fontWeight = W500,
* fontWeight = W400,
*/
val titleM: TextStyle
@Composable get() = defaultTextStyle.copy(
fontSize = 16.sp,
lineHeight = 0.sp,
fontFamily = fontFamilyMedium,
fontFamily = fontFamilyNormal,
)

/**
Expand Down
2 changes: 1 addition & 1 deletion target/desktop/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ compose.desktop {
}
}

mainClass = "app.cleanmeter.target.desktop.ServerMainKt"
mainClass = "app.cleanmeter.target.desktop.DesktopMainKt"

buildTypes.release.proguard {
version.set("7.5.0")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package app.cleanmeter.target.desktop

import app.cleanmeter.core.common.process.singleInstance
import app.cleanmeter.core.common.reporting.ApplicationParams
import app.cleanmeter.core.os.ProcessManager
import app.cleanmeter.core.os.util.isDev
import app.cleanmeter.core.os.win32.WindowsService
import app.cleanmeter.target.desktop.data.PREFERENCE_PERMISSION_CONSENT
import app.cleanmeter.target.desktop.data.PreferencesRepository

fun main(vararg args: String) = singleInstance(args) {
if (PreferencesRepository.getPreferenceBoolean(PREFERENCE_PERMISSION_CONSENT, false)) {
WindowsService.tryElevateProcess(ApplicationParams.isAutostart)

if (isDev()) {
Runtime.getRuntime().addShutdownHook(Thread {
ProcessManager.stop()
})
} else {
KeyboardManager.registerKeyboardHook()
}

if (!ApplicationParams.isAutostart) {
ProcessManager.start()
}
}

composeApp()
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import java.util.prefs.Preferences

const val OVERLAY_SETTINGS_PREFERENCE_KEY = "OVERLAY_SETTINGS_PREFERENCE_KEY"
const val PREFERENCE_START_MINIMIZED = "PREFERENCE_START_MINIMIZED"
const val PREFERENCE_PERMISSION_CONSENT = "PREFERENCE_PERMISSION_CONSENT"

object PreferencesRepository {

Expand All @@ -24,6 +25,7 @@ object PreferencesRepository {

fun setPreference(key: String, value: String) = prefs.put(key, value)
fun setPreferenceBoolean(key: String, value: Boolean) = prefs.putBoolean(key, value)
fun clear() = prefs.clear()
}

fun PreferencesRepository.loadOverlaySettings(): OverlaySettings {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Text
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.dp
import app.cleanmeter.core.designsystem.LocalColorScheme
import app.cleanmeter.core.designsystem.LocalTypography

@Composable
internal fun ClearButton(
label: String,
textColor: Color = LocalColorScheme.current.text.inverse,
onClick: () -> Unit
) {
Button(
onClick = onClick,
colors = ButtonDefaults.textButtonColors(
containerColor = Color.Transparent,
),
contentPadding = PaddingValues(horizontal = 8.dp, vertical = 0.dp),
) {
Text(
text = label,
style = LocalTypography.current.labelLMedium,
color = textColor,
modifier = Modifier.wrapContentHeight(),
)
}
}

@Composable
internal fun FilledButton(
label: String,
containerColor: Color = LocalColorScheme.current.background.surfaceRaised,
textColor: Color = LocalColorScheme.current.text.heading,
textStyle: TextStyle = LocalTypography.current.labelLMedium,
contentPadding: PaddingValues = PaddingValues(horizontal = 8.dp, vertical = 0.dp),
onClick: () -> Unit
) {
Button(
onClick = onClick,
colors = ButtonDefaults.textButtonColors(
containerColor = containerColor,
),
contentPadding = contentPadding,
shape = RoundedCornerShape(100),
) {
Text(
text = label,
color = textColor,
style = textStyle,
modifier = Modifier.wrapContentHeight(),
)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package app.cleanmeter.target.desktop.ui.components

import ClearButton
import FilledButton
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.animateContentSize
import androidx.compose.animation.slideInVertically
Expand Down Expand Up @@ -128,42 +130,7 @@ private fun RowScope.BodyText(state: UpdateState) {
}
}

@Composable
private fun ClearButton(onClick: () -> Unit, label: String) {
Button(
onClick = onClick,
colors = ButtonDefaults.textButtonColors(
containerColor = Color.Transparent,
),
contentPadding = PaddingValues(horizontal = 8.dp, vertical = 0.dp),
) {
Text(
text = label,
style = LocalTypography.current.labelLMedium,
color = LocalColorScheme.current.text.inverse,
modifier = Modifier.wrapContentHeight(),
)
}
}

@Composable
private fun FilledButton(onClick: () -> Unit, label: String) {
Button(
onClick = onClick,
colors = ButtonDefaults.textButtonColors(
containerColor = LocalColorScheme.current.background.surfaceRaised,
),
contentPadding = PaddingValues(horizontal = 8.dp, vertical = 0.dp),
shape = RoundedCornerShape(100),
) {
Text(
text = label,
color = LocalColorScheme.current.text.heading,
style = LocalTypography.current.labelLMedium,
modifier = Modifier.wrapContentHeight(),
)
}
}

@Composable
private fun RowScope.CallToAction(
Expand Down
Loading

0 comments on commit 6383004

Please sign in to comment.