-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR moves Project Gen Compose app to Skate so it can be called directly from the IDE. I made some modifications, including: * Add a new `ProjectGenWindow` that extends `DialogWrapper` to wrap around the Compose app * Create `projectgenlock` on the fly and delete it when dialog is dismissed * Add an Alert dialog on file path errors * Grab the `DarkMode` status from the IDE Theme using `JBColors.isBright` * Make the `Quit` button to exit the dialog. It was exiting the application before * Remove the old `TerminalWrapper` code Remaining work I haven't been able to port over. Running into some issues that might take more time * Updating the `Font` to `Lato` * Adding the icon of the app Test: Light mode https://github.com/slackhq/slack-gradle-plugin/assets/12748234/69b35521-a0b6-411a-a9fc-f8d1c7a8077a Dark mode https://github.com/slackhq/slack-gradle-plugin/assets/12748234/32e1a53c-a768-4bd2-afd5-c447b1114dcd <!-- ⬆ Put your description above this! ⬆ Please be descriptive and detailed. Please read our [Contributing Guidelines](https://github.com/tinyspeck/slack-gradle-plugin/blob/main/.github/CONTRIBUTING.md) and [Code of Conduct](https://slackhq.github.io/code-of-conduct). Don't worry about deleting this, it's not visible in the PR! -->
- Loading branch information
Showing
18 changed files
with
1,221 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
153 changes: 153 additions & 0 deletions
153
skate-plugin/src/main/kotlin/com/slack/sgp/intellij/projectgen/DesktopColors.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
/* | ||
* Copyright (C) 2024 Slack Technologies, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
@file:Suppress("MagicNumber") | ||
|
||
package com.slack.sgp.intellij.projectgen | ||
|
||
import androidx.compose.material3.darkColorScheme | ||
import androidx.compose.material3.lightColorScheme | ||
import androidx.compose.ui.graphics.Color | ||
|
||
/** Borrowed from `MaterialColors` in SKColors.kt. */ | ||
internal object DesktopColors { | ||
private val mdThemeLightPrimary = Color(0xFF1264A3) | ||
private val mdThemeLightOnPrimary = Color(0xFFFFFFFF) | ||
private val mdThemeLightInversePrimary = mdThemeLightOnPrimary | ||
private val mdThemeLightPrimaryContainer = Color(0xFF9ED6FA) // On Inverse Highlight 1 | ||
private val mdThemeLightOnPrimaryContainer = Color(0xFF1D1C1D) // On Inverse Highlight 1 | ||
private val mdThemeLightSecondary = Color(0xFF1264A3) | ||
private val mdThemeLightOnSecondary = Color(0xFFFFFFFF) | ||
private val mdThemeLightSecondaryContainer = Color(0xFF9ED6FA) // Highlight 3, Jade 0 | ||
private val mdThemeLightOnSecondaryContainer = Color(0xFF1D1C1D) // Highlight 3, Jade 0 | ||
private val mdThemeLightTertiary = Color(0xFF007A5A) | ||
private val mdThemeLightOnTertiary = Color(0xFFFFFFFF) | ||
private val mdThemeLightTertiaryContainer = Color(0xFFE3FFF3) // Highlight 3, Jade 0 | ||
private val mdThemeLightOnTertiaryContainer = Color(0xFF1D1C1D) // Highlight 3, Jade 0 | ||
private val mdThemeLightError = Color(0xFFE01E5A) | ||
private val mdThemeLightOnError = Color(0xFFFFFFFF) | ||
private val mdThemeLightErrorContainer = Color(0xFFFFE8EF) // Destructive, Flamingo 0 | ||
private val mdThemeLightOnErrorContainer = Color(0xFF1D1C1D) // Destructive, Flamingo 0 | ||
private val mdThemeLightBackground = Color(0xFFFFFFFF) | ||
private val mdThemeLightOnBackground = Color(0xFF1D1C1D) | ||
private val mdThemeLightSurface = Color(0xFFFFFFFF) | ||
private val mdThemeLightOnSurface = Color(0xFF1D1C1D) | ||
private val mdThemeLightInverseSurface = Color(0xFF1D1C1D) // Inverse of surface | ||
private val mdThemeLightInverseOnSurface = Color(0xFFFFFFFF) // Inverse of onSurface | ||
private val mdThemeLightSurfaceVariant = Color(0xFFEAEAEA) // On Inverse Variant 1 | ||
private val mdThemeLightOnSurfaceVariant = Color(0xFF1D1C1D) // On Inverse Variant 1 | ||
// We don't want m3's tonal tinting for this so we just reuse the surface value | ||
private val mdThemeLightSurfaceTint = mdThemeLightSurface | ||
private val mdThemeLightOutline = Color(0xFF5E5D60) // Outline Primary | ||
private val mdThemeLightShadow = Color(0xB31D1C1D) // Background / Modal | ||
|
||
// We reuse the same values for primary/secondary/tertiary in both light and dark | ||
private val mdThemeDarkPrimary = mdThemeLightPrimary | ||
private val mdThemeDarkOnPrimary = mdThemeLightOnPrimary | ||
private val mdThemeDarkInversePrimary = mdThemeDarkOnPrimary | ||
private val mdThemeDarkPrimaryContainer = mdThemeLightPrimaryContainer | ||
private val mdThemeDarkOnPrimaryContainer = mdThemeLightOnPrimaryContainer | ||
private val mdThemeDarkSecondary = mdThemeLightSecondary | ||
private val mdThemeDarkOnSecondary = mdThemeLightOnSecondary | ||
private val mdThemeDarkSecondaryContainer = mdThemeLightSecondaryContainer | ||
private val mdThemeDarkOnSecondaryContainer = mdThemeLightOnSecondaryContainer | ||
private val mdThemeDarkTertiary = mdThemeLightTertiary | ||
private val mdThemeDarkOnTertiary = mdThemeLightOnTertiary | ||
private val mdThemeDarkTertiaryContainer = mdThemeLightTertiaryContainer | ||
private val mdThemeDarkOnTertiaryContainer = mdThemeLightOnTertiaryContainer | ||
private val mdThemeDarkError = mdThemeLightError | ||
private val mdThemeDarkOnError = mdThemeLightOnError | ||
private val mdThemeDarkErrorContainer = Color(0xFF93000A) // Destructive, Flamingo 0 | ||
private val mdThemeDarkOnErrorContainer = Color(0xFFFFDAD6) // Destructive, Flamingo 0 | ||
private val mdThemeDarkBackground = Color(0xFF1A1D21) | ||
private val mdThemeDarkOnBackground = Color(0xFFD1D2D3) | ||
private val mdThemeDarkSurface = Color(0xFF1A1D21) | ||
private val mdThemeDarkOnSurface = Color(0xFFD1D2D3) | ||
private val mdThemeDarkInverseSurface = Color(0xFFE4E2E6) // Inverse of surface | ||
private val mdThemeDarkInverseOnSurface = Color(0xFF1B1B1F) // Inverse of onSurface | ||
private val mdThemeDarkSurfaceVariant = Color(0xFF252425) // Container Gray 10 | ||
private val mdThemeDarkOnSurfaceVariant = Color(0xFFC5C6D0) // On Inverse Variant 1 | ||
/** | ||
* We don't want tonal tinting but we _do_ want to lighten the surface color when elevated. The | ||
* metaphor is that it's closer to the light source, so we just lighten with white. | ||
*/ | ||
private val mdThemeDarkSurfaceTint = Color(0xFFFFFFFF) | ||
private val mdThemeDarkOutline = Color(0xFF8F9099) // Outline Primary | ||
private val mdThemeDarkShadow = Color(0xFF000000) // Background / Modal | ||
|
||
val LightTheme = | ||
lightColorScheme( | ||
primary = mdThemeLightPrimary, | ||
onPrimary = mdThemeLightOnPrimary, | ||
primaryContainer = mdThemeLightPrimaryContainer, | ||
onPrimaryContainer = mdThemeLightOnPrimaryContainer, | ||
secondary = mdThemeLightSecondary, | ||
onSecondary = mdThemeLightOnSecondary, | ||
secondaryContainer = mdThemeLightSecondaryContainer, | ||
onSecondaryContainer = mdThemeLightOnSecondaryContainer, | ||
tertiary = mdThemeLightTertiary, | ||
onTertiary = mdThemeLightOnTertiary, | ||
tertiaryContainer = mdThemeLightTertiaryContainer, | ||
onTertiaryContainer = mdThemeLightOnTertiaryContainer, | ||
error = mdThemeLightError, | ||
errorContainer = mdThemeLightErrorContainer, | ||
onError = mdThemeLightOnError, | ||
onErrorContainer = mdThemeLightOnErrorContainer, | ||
background = mdThemeLightBackground, | ||
onBackground = mdThemeLightOnBackground, | ||
surface = mdThemeLightSurface, | ||
onSurface = mdThemeLightOnSurface, | ||
surfaceVariant = mdThemeLightSurfaceVariant, | ||
onSurfaceVariant = mdThemeLightOnSurfaceVariant, | ||
outline = mdThemeLightOutline, | ||
inverseOnSurface = mdThemeLightInverseOnSurface, | ||
inverseSurface = mdThemeLightInverseSurface, | ||
inversePrimary = mdThemeLightInversePrimary, | ||
surfaceTint = mdThemeLightSurfaceTint, | ||
scrim = mdThemeLightShadow, | ||
) | ||
|
||
val DarkTheme = | ||
darkColorScheme( | ||
primary = mdThemeDarkPrimary, | ||
onPrimary = mdThemeDarkOnPrimary, | ||
primaryContainer = mdThemeDarkPrimaryContainer, | ||
onPrimaryContainer = mdThemeDarkOnPrimaryContainer, | ||
secondary = mdThemeDarkSecondary, | ||
onSecondary = mdThemeDarkOnSecondary, | ||
secondaryContainer = mdThemeDarkSecondaryContainer, | ||
onSecondaryContainer = mdThemeDarkOnSecondaryContainer, | ||
tertiary = mdThemeDarkTertiary, | ||
onTertiary = mdThemeDarkOnTertiary, | ||
tertiaryContainer = mdThemeDarkTertiaryContainer, | ||
onTertiaryContainer = mdThemeDarkOnTertiaryContainer, | ||
error = mdThemeDarkError, | ||
errorContainer = mdThemeDarkErrorContainer, | ||
onError = mdThemeDarkOnError, | ||
onErrorContainer = mdThemeDarkOnErrorContainer, | ||
background = mdThemeDarkBackground, | ||
onBackground = mdThemeDarkOnBackground, | ||
surface = mdThemeDarkSurface, | ||
onSurface = mdThemeDarkOnSurface, | ||
surfaceVariant = mdThemeDarkSurfaceVariant, | ||
onSurfaceVariant = mdThemeDarkOnSurfaceVariant, | ||
outline = mdThemeDarkOutline, | ||
inverseOnSurface = mdThemeDarkInverseOnSurface, | ||
inverseSurface = mdThemeDarkInverseSurface, | ||
inversePrimary = mdThemeDarkInversePrimary, | ||
surfaceTint = mdThemeDarkSurfaceTint, | ||
scrim = mdThemeDarkShadow, | ||
) | ||
} |
47 changes: 47 additions & 0 deletions
47
skate-plugin/src/main/kotlin/com/slack/sgp/intellij/projectgen/PrefixTransformation.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (C) 2024 Slack Technologies, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.slack.sgp.intellij.projectgen | ||
|
||
import androidx.compose.ui.text.AnnotatedString | ||
import androidx.compose.ui.text.input.OffsetMapping | ||
import androidx.compose.ui.text.input.TransformedText | ||
import androidx.compose.ui.text.input.VisualTransformation | ||
|
||
class PrefixTransformation(val prefix: String) : VisualTransformation { | ||
override fun filter(text: AnnotatedString): TransformedText { | ||
return prefixFilter(text, prefix) | ||
} | ||
} | ||
|
||
private fun prefixFilter(number: AnnotatedString, prefix: String): TransformedText { | ||
|
||
val out = prefix + number.text | ||
val prefixOffset = prefix.length | ||
|
||
val numberOffsetTranslator = | ||
object : OffsetMapping { | ||
override fun originalToTransformed(offset: Int): Int { | ||
return offset + prefixOffset | ||
} | ||
|
||
override fun transformedToOriginal(offset: Int): Int { | ||
if (offset <= prefixOffset - 1) return prefixOffset | ||
return offset - prefixOffset | ||
} | ||
} | ||
|
||
return TransformedText(AnnotatedString(out), numberOffsetTranslator) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.