Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: feat: Dark theme for AMOLED screens #1178

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Niisoks
Copy link

@Niisoks Niisoks commented Feb 11, 2024

Aiming to close issue #734

What it does

Adds a Black theme to the themes menu. Also changes a parameter in the NekomeTheme composable.

Potential oversights

Im unsure if there's a way to tell if the screen is AMOLED when setting a system theme, or if a black theme is something that android is supporting as a system theme right now. So i have not done anything in regards to setting Dynamic black or getting it set when its a system default

Issues

Readability

Currently, the way we get themes is a bit strange, relying on a pair containing 2 bools. While verbose it made it hard to adapt in its current state to include more themes.
I was looking at maybe using a Triple instead of a Pair, but i believe that may end up making things more confusing, especially when it comes to the logic of checking what theme is currently being used.
I wanted to opt for an Enum, but the enum class ...flags.Theme isn't accessible from ...Compose, so i ended up using the Enums value which isn't ideal but solves the problem immediately.
So currently when themes are checked & set within NekomeTheme it doesn't use an enum, and instead just goes through the when statement checking against ints.

Colour choices

I assume that all that really needs to be changed for this theme is setting the background and surface colours to black? Not entirely sure what else would need to be changed.

Visibility

In some weird case where you decide to log out whilst in Black mode, the Nekome logo will become completely unseeable.

I added some kDoc to NekomeTheme to hopefully explain my reasoning a bit to anyone that would stumble across this in the future lol.

- Also changed previews to include theme = 2 instead of isDarkMode = true
@Niisoks Niisoks marked this pull request as draft February 11, 2024 02:31
@Chesire
Copy link
Owner

Chesire commented Feb 25, 2024

Currently, the way we get themes is a bit strange, relying on a pair containing 2 bools. While verbose it made it hard to adapt in its current state to include more themes. I was looking at maybe using a Triple instead of a Pair, but i believe that may end up making things more confusing, especially when it comes to the logic of checking what theme is currently being used. I wanted to opt for an Enum, but the enum class ...flags.Theme isn't accessible from ...Compose, so i ended up using the Enums value which isn't ideal but solves the problem immediately. So currently when themes are checked & set within NekomeTheme it doesn't use an enum, and instead just goes through the when statement checking against ints.

Yeah this isn't written the best and can be confusing.

For now a better way to handle it would be to let the core:compose module reference libraries:core, and then the NekomeTheme can take the Theme flags enum in and do a when block` off of that, which is a lot cleaner than the multiple boolean mess.

This breaks the ideal that core libraries shouldn't reference above them, but libraries:core is something that needs to be burned at some point anyway, so in this instance it should be fine 👍

Copy link
Owner

@Chesire Chesire left a comment

Choose a reason for hiding this comment

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

Nice work, left a few comments, and hopefully #1178 (comment) clears up how we could use the theme?

@@ -40,13 +40,15 @@ class MainActivity : ComponentActivity() {
/**
* Returns a [Pair] of (dark mode enabled) to (dynamic color enabled).
*/
private fun generateTheme(theme: Theme, isSystemDarkMode: Boolean): Pair<Boolean, Boolean> {
private fun generateTheme(theme: Theme, isSystemDarkMode: Boolean): Pair<Theme, Boolean> {
Copy link
Owner

Choose a reason for hiding this comment

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

Based on the PR comment previously, this could probably be removed and the whole itself passed through to the NekomeTheme object

Copy link
Author

Choose a reason for hiding this comment

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

All updated in latest commit deaa97d. No longer use generateTheme() at all, we just call
NekomeTheme( Theme.yourTheme) and the composable figures out the rest (Dynamic compatibility, system theming etc.)

@@ -10,19 +10,28 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
import com.google.accompanist.systemuicontroller.rememberSystemUiController

/**
* Used to set the theme for a given composable, defaulting to the system theme
Copy link
Owner

Choose a reason for hiding this comment

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

This is correct, but the ideal is that the theme is set for the view hierarchy once at the start, not for a single composable

Copy link
Author

Choose a reason for hiding this comment

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

Addressed in commit deaa97d, now a bit less... or more? vague.

@@ -137,6 +137,7 @@
<string name="settings_theme_light">Light</string>
<string name="settings_theme_dynamic_dark">Dynamic Dark</string>
<string name="settings_theme_dynamic_light">Dynamic Light</string>
<string name="settings_theme_black">Black</string>
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe "AMOLED Black" would be clearer for the difference with dark mode?

Copy link
Author

Choose a reason for hiding this comment

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

Addressed in commit deaa97d, changed both string resources. Wasn't sure whether to have the japanese one be
アモールド ブラックテーマ
or
AMOLED ブラックテーマ
currently using the former

Comment on lines 59 to 62
val BlackColorPalette = DarkColorPalette.copy(
background = Color(0xFF000000),
surface = Color(0xFF000000)
)
Copy link
Owner

Choose a reason for hiding this comment

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

It would be good to get the cards to also be 000000, but still retain usability, but that might be difficult. I think this is a great start to providing amoled though 👍

Copy link
Author

Choose a reason for hiding this comment

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

Will look further into this to figure out what the general consensus is for AMOLED theming

* Removed generateTheme from mainActivity
* Improved NekomeTheme to be more readable and concise
* Changed values() to entries on enums as per android studios recommendation since Kotlin 1.9.0
* Updated strings to include AMOLED. (Unsure if we wanted katakana for the word AMOLED or just the way its written in english)
** Hidden previews in credentials screen and syncingScreen
  - These things likely just need their dependencies updated as well in order to use the new theming. Will get around to it on the next commit. Might want to look at removing it though
* Made a default constructor for system default on theme for ease of preview
* Updated core:compose dependency
@Niisoks
Copy link
Author

Niisoks commented Mar 8, 2024

Changed card colour to complete black, seems to still have functionality. Maybe could add some sort of faint light shadow to the bottom of the cards or something so you can tell where they end, but that might defeat the point of an AMOLED mode.

Copy link

@P2gu P2gu left a comment

Choose a reason for hiding this comment

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

Yh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants