Skip to content

Commit

Permalink
Merge pull request #20 from MDalfre/develop
Browse files Browse the repository at this point in the history
Major update:
  • Loading branch information
MDalfre authored Jan 19, 2024
2 parents 2503c8b + ede02de commit a0ee59f
Show file tree
Hide file tree
Showing 17 changed files with 101 additions and 176 deletions.
23 changes: 16 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import org.jetbrains.compose.compose
import io.gitlab.arturbosch.detekt.Detekt
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import io.gitlab.arturbosch.detekt.Detekt


plugins {
kotlin("jvm") version "1.6.10"
id("org.jetbrains.compose") version "1.1.1"
kotlin("jvm") version "1.9.0"
id("org.jetbrains.compose") version "1.5.11"
id("io.gitlab.arturbosch.detekt").version("1.18.0-RC3")
}

var lastAppVersion = "2.1.4"
var lastAppVersion = "3.0.0"

group = "ma.dalfre"
version = lastAppVersion
Expand All @@ -27,8 +27,8 @@ dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
}

tasks.withType<KotlinCompile>() {
kotlinOptions.jvmTarget = "15"
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "11"
}
tasks.withType<Detekt>().configureEach {
jvmTarget = "1.8"
Expand All @@ -47,6 +47,9 @@ compose.desktop {
modules(
"java.instrument",
"java.management",
"java.naming",
"java.security.jgss",
"java.sql",
"jdk.unsupported"
)
iconFile.set(project.file("src/main/resources/icon.ico"))
Expand All @@ -55,6 +58,9 @@ compose.desktop {
modules(
"java.instrument",
"java.management",
"java.naming",
"java.security.jgss",
"java.sql",
"jdk.unsupported"
)
iconFile.set(project.file("src/main/resources/sr-sqs-icon.png"))
Expand All @@ -63,6 +69,9 @@ compose.desktop {
modules(
"java.instrument",
"java.management",
"java.naming",
"java.security.jgss",
"java.sql",
"jdk.unsupported"
)
iconFile.set(project.file("src/main/resources/sr-sqs-icon.png"))
Expand Down
51 changes: 25 additions & 26 deletions src/main/kotlin/Main.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// Copyright 2000-2021 JetBrains s.r.o. and contributors.
// Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
import androidx.compose.desktop.ui.tooling.preview.Preview
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
Expand All @@ -19,19 +21,39 @@ import commons.DefaultColors.backgroundColor
import commons.Util.appIcon
import components.mainView
import components.topBar
import components.versionCheckDialog
import model.ui.Theme
import service.CommunicationService
import service.ConnectionService
import service.VariableStore
import service.VersionCheckService

const val DEFAULT_WIDTH = 1280
const val DEFAULT_HEIGHT = 790
val communicationService: CommunicationService = CommunicationService()
var connectionService: ConnectionService? = null
val variableStore = VariableStore()

@Composable
@Preview
fun app() {
val theme = Theme(
buttonModifier = Modifier.padding(10.dp),
defaultButtonColor = ButtonDefaults.buttonColors(
backgroundColor = DefaultColors.buttonColor,
contentColor = Color.Black
)
)
MaterialTheme {
Row(
Modifier.background(backgroundColor)
) {
mainView(communicationService, variableStore, theme)
}
Column {
topBar(communicationService, variableStore)
}
}
}

fun main() = application {
Window(
onCloseRequest = ::exitApplication,
Expand All @@ -44,29 +66,6 @@ fun main() = application {
Alignment.Center
)
)
) {
val theme = Theme(
buttonModifier = Modifier.padding(10.dp),
defaultButtonColor = ButtonDefaults.buttonColors(
backgroundColor = DefaultColors.buttonColor,
contentColor = Color.Black
)
)
Thread { variableStore.versionDialogOpen = VersionCheckService().checkVersion(variableStore.version) }.start()
MaterialTheme {
Row(
Modifier.background(backgroundColor)
) {
mainView(communicationService, variableStore, theme)
}
Column {
topBar(communicationService, variableStore)
}
if (!variableStore.versionDialogOpen) {
versionCheckDialog(variableStore, theme)
}
}
}

) { app() }
}

12 changes: 6 additions & 6 deletions src/main/kotlin/commons/DefaultColors.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import androidx.compose.ui.graphics.Color

@Suppress("MagicNumber")
object DefaultColors {
val backgroundColor = Color(0xFF131520)
val secondaryColor = Color(0xFF269d66)
val tintColor = Color(0xFF7d47ba)
val buttonColor = Color(0xFFD7840E)
}

val backgroundColor = Color(0xFF1E1E1E)
val secondaryColor = Color(0xFF424242)
val tintColor = Color(0xFF64B5F6)
val buttonColor = Color(0xFF757575)
val dropDownColor = Color.Gray
}
3 changes: 2 additions & 1 deletion src/main/kotlin/components/AlertDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Modifier
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogWindow
import commons.DefaultColors.backgroundColor


Expand All @@ -18,7 +19,7 @@ fun defaultDialog(
title: String,
body: String
) {
Dialog(
DialogWindow(
onCloseRequest = {},
content = {
Column(
Expand Down
11 changes: 9 additions & 2 deletions src/main/kotlin/components/ConnectionForm.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package components

import androidx.compose.desktop.ui.tooling.preview.Preview
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
Expand All @@ -12,10 +14,12 @@ import androidx.compose.material.DropdownMenuItem
import androidx.compose.material.Text
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 androidx.compose.ui.unit.sp
import com.amazonaws.regions.Regions
import commons.DefaultColors.dropDownColor
import connectionService
import model.ConnectionSettings
import model.CredentialType
Expand All @@ -28,6 +32,7 @@ import service.VariableStore

@Suppress("LongMethod", "ComplexMethod")
@Composable
@Preview
fun connectionForm(
variableStore: VariableStore,
communicationService: CommunicationService,
Expand All @@ -42,10 +47,11 @@ fun connectionForm(
onValueChange = { variableStore.selectedCredential = it }
)
DropdownMenu(
modifier = Modifier.background(dropDownColor),
expanded = variableStore.expandedCredential,
onDismissRequest = { variableStore.expandedCredential = !variableStore.expandedCredential }
) {
CredentialType.values().forEach {
CredentialType.entries.forEach {
DropdownMenuItem(
modifier = Modifier.padding(5.dp).height(15.dp),
onClick = {
Expand Down Expand Up @@ -88,10 +94,11 @@ fun connectionForm(
onValueChange = { variableStore.selectedRegion = it }
)
DropdownMenu(
modifier = Modifier.background(dropDownColor),
expanded = variableStore.expandedRegion,
onDismissRequest = { variableStore.expandedRegion = !variableStore.expandedRegion }
) {
Regions.values().forEach {
Regions.entries.forEach {
DropdownMenuItem(
modifier = Modifier.padding(5.dp).height(15.dp),
onClick = {
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/components/DefaultTextField.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fun defaultTextField(
enabled: Boolean = true
) {
Column(
modifier = Modifier.padding(top = 10.dp)
modifier = Modifier.padding(top = 10.dp, )
) {
Text(
text = text,
Expand All @@ -37,7 +37,7 @@ fun defaultTextField(
BasicTextField(
value = value,
enabled = enabled,
textStyle = TextStyle(color = Color.White),
textStyle = TextStyle.Default.copy(color = Color.Gray),
cursorBrush = SolidColor(Color.Gray),
singleLine = false,
onValueChange = onValueChange,
Expand Down
5 changes: 3 additions & 2 deletions src/main/kotlin/components/DlqReprocess.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import commons.Constants.ZERO
import commons.DefaultColors.backgroundColor
import commons.DefaultColors.secondaryColor
import commons.DefaultColors.buttonColor
import commons.DefaultColors.dropDownColor
import commons.Util.toPercentage
import model.ProcessStatusEnum
import model.Queue
Expand Down Expand Up @@ -88,7 +89,7 @@ fun dlqReprocess(connectionService: ConnectionService, communicationService: Com
onValueChange = { selectedSourceQueue = it }
)
DropdownMenu(
modifier = Modifier.width(450.dp).height(100.dp),
modifier = Modifier.width(450.dp).height(100.dp).background(dropDownColor),
expanded = expandedSourceDropbox,
onDismissRequest = { expandedSourceDropbox = false },
) {
Expand Down Expand Up @@ -141,7 +142,7 @@ fun dlqReprocess(connectionService: ConnectionService, communicationService: Com
)
}
DropdownMenu(
modifier = Modifier.width(450.dp).height(100.dp),
modifier = Modifier.width(450.dp).height(100.dp).background(dropDownColor),
expanded = expandedTargetDropbox,
onDismissRequest = { expandedTargetDropbox = false },
) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/components/MainView.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package components

import androidx.compose.desktop.ui.tooling.preview.Preview
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
Expand All @@ -13,10 +14,9 @@ import service.VariableStore
const val ALERT_WIDTH = 700
const val ALERT_HEIGHT = 500
const val ALERT_SMALL_HEIGHT = 250
const val ALERT_SMALL_WIDTH = 500
const val ALERT_CHECK_VERSION_HEIGHT = 200

@Composable
@Preview
fun mainView(
communicationService: CommunicationService,
variableStore: VariableStore,
Expand Down
6 changes: 4 additions & 2 deletions src/main/kotlin/components/MockMode.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package components

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
Expand Down Expand Up @@ -36,6 +37,7 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import commons.Constants
import commons.DefaultColors
import commons.DefaultColors.dropDownColor
import connectionService
import model.SqsMock
import model.ui.Theme
Expand Down Expand Up @@ -128,7 +130,7 @@ fun mockMode(variableStore: VariableStore, communicationService: CommunicationSe
onValueChange = { variableStore.selectedMockQueueSource = it }
)
DropdownMenu(
modifier = Modifier.width(420.dp).heightIn(10.dp, 200.dp),
modifier = Modifier.width(420.dp).heightIn(10.dp, 200.dp).background(dropDownColor),
expanded = variableStore.expandedMockSource,
onDismissRequest = { variableStore.expandedMockSource = false },
) {
Expand Down Expand Up @@ -163,7 +165,7 @@ fun mockMode(variableStore: VariableStore, communicationService: CommunicationSe
onValueChange = { variableStore.selectedMockQueueTarget = it }
)
DropdownMenu(
modifier = Modifier.width(420.dp).heightIn(10.dp, 200.dp),
modifier = Modifier.width(420.dp).heightIn(10.dp, 200.dp).background(dropDownColor),
expanded = variableStore.expandedMockTarget,
onDismissRequest = { variableStore.expandedMockTarget = false },
) {
Expand Down
8 changes: 5 additions & 3 deletions src/main/kotlin/components/ReceiveMessageForm.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogWindow
import androidx.compose.ui.window.rememberDialogState
import commons.Constants.DEFAULT_MAX_CHARACTER
import commons.DefaultColors
import commons.DefaultColors.dropDownColor
import commons.Util
import commons.prettyJson
import connectionService
Expand Down Expand Up @@ -76,7 +78,7 @@ fun receiveMessageForm(variableStore: VariableStore, communicationService: Commu
onValueChange = { variableStore.selectedQueueToReceive = it }
)
DropdownMenu(
modifier = Modifier.width(450.dp).heightIn(10.dp, 200.dp),
modifier = Modifier.width(450.dp).heightIn(10.dp, 200.dp).background(dropDownColor),
expanded = variableStore.expandedToReceive,
onDismissRequest = { variableStore.expandedToReceive = false },
) {
Expand Down Expand Up @@ -138,7 +140,7 @@ fun receiveMessageForm(variableStore: VariableStore, communicationService: Commu
}
}
if (showAlert) {
Dialog(
DialogWindow(
onCloseRequest = { showAlert = !showAlert },
title = "MessageId: $titleAlert",
state = rememberDialogState(size = DpSize(ALERT_WIDTH.dp, ALERT_HEIGHT.dp)),
Expand Down
4 changes: 3 additions & 1 deletion src/main/kotlin/components/SendMessageForm.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package components

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
Expand All @@ -18,6 +19,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import commons.DefaultColors.dropDownColor
import connectionService
import model.ui.Theme
import service.CommunicationService
Expand Down Expand Up @@ -49,7 +51,7 @@ fun sendMessageFrom(
onValueChange = { variableStore.selectedQueueToSend = it }
)
DropdownMenu(
modifier = Modifier.width(450.dp).heightIn(10.dp, 200.dp),
modifier = Modifier.width(450.dp).heightIn(10.dp, 200.dp).background(dropDownColor),
expanded = variableStore.expandedToSend,
onDismissRequest = { variableStore.expandedToSend = false },
) {
Expand Down
Loading

0 comments on commit a0ee59f

Please sign in to comment.