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

Add black amoled theme #112

Merged
merged 3 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .idea/deploymentTargetDropDown.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 @@ -44,11 +44,12 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Image
import androidx.compose.material.icons.filled.Search
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FilledTonalButton
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ModalBottomSheet
Expand Down Expand Up @@ -112,80 +113,80 @@ fun IconPickerDialog(
Column(
modifier = Modifier.fillMaxWidth(0.99f)
) {
Card(
Column(
modifier = Modifier.fillMaxWidth(),
colors = CardDefaults.elevatedCardColors()
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
Column(
modifier = Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {

SearchTextField(
viewModel = viewModel,
onSearchChanged = { search ->
viewModel.updateIconSearch(
context = context,
search = search
)
}
)
SearchTextField(
viewModel = viewModel,
onSearchChanged = { search ->
viewModel.updateIconSearch(
context = context,
search = search
)
}
)

Spacer(modifier = Modifier.height(18.dp))
Spacer(modifier = Modifier.height(18.dp))

IconsGirdList(
iconState = state,
onIconClick = { viewModel.updateCurrentIcon(it) }
)
IconsGirdList(
iconState = state,
onIconClick = { viewModel.updateCurrentIcon(it) }
)

Row(
modifier = Modifier
.fillMaxWidth()
.padding(10.dp)
) {
Spacer(modifier = Modifier.weight(1f))
Row(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 10.dp, horizontal = 20.dp)
) {
Spacer(modifier = Modifier.weight(1f))

// Cancel button
TextButton(onClick = {
if (viewModel.iconState.value.searchText.isNotEmpty()) {
viewModel.updateIconSearch(context = context, search = "")
} else {
coroutineScope.launch {
sheetState.hide()
delay(300)
showDialog.value = false
}
// Cancel button
TextButton(onClick = {
if (viewModel.iconState.value.searchText.isNotEmpty()) {
viewModel.updateIconSearch(context = context, search = "")
} else {
coroutineScope.launch {
sheetState.hide()
delay(300)
showDialog.value = false
}
}) {
Text(
text = stringResource(id = R.string.cancel),
fontFamily = greenstashFont
)
}
}) {
Text(
text = stringResource(id = R.string.cancel),
fontFamily = greenstashFont
)
}

Spacer(modifier = Modifier.width(10.dp))
Spacer(modifier = Modifier.width(10.dp))

// Confirm button
Button(onClick = {
// Confirm button
FilledTonalButton(
onClick = {
onIconSelected(state.currentIcon)
coroutineScope.launch {
sheetState.hide()
delay(300)
showDialog.value = false
}
}) {
Text(
text = stringResource(id = R.string.confirm),
fontFamily = greenstashFont,
)
}
}, colors = ButtonDefaults.filledTonalButtonColors(
containerColor = MaterialTheme.colorScheme.primaryContainer,
contentColor = MaterialTheme.colorScheme.onPrimaryContainer
), shape = RoundedCornerShape(16.dp)
) {
Text(
text = stringResource(id = R.string.confirm),
fontFamily = greenstashFont,
)
}

Spacer(modifier = Modifier.height(10.dp))
}

Spacer(modifier = Modifier.height(10.dp))
}
}

}
}

Expand Down Expand Up @@ -238,7 +239,7 @@ private fun IconsGirdList(
.fillMaxWidth(0.9f)
.height(180.dp),
colors = CardDefaults.cardColors(
containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(4.dp)
containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp)
),
shape = RoundedCornerShape(16.dp)
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,19 @@ class SettingsViewModel @Inject constructor(
) : ViewModel() {

private val _theme = MutableLiveData(ThemeMode.Auto)
private val _amoledTheme = MutableLiveData(false)
private val _materialYou = MutableLiveData(Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)
private val _goalCardStyle = MutableLiveData(GoalCardStyle.Classic)

val theme: LiveData<ThemeMode> = _theme
val amoledTheme: LiveData<Boolean> = _amoledTheme
val materialYou: LiveData<Boolean> = _materialYou
val goalCardStyle: LiveData<GoalCardStyle> = _goalCardStyle

// Initialize preferences --------------------------------------------
init {
_theme.value = ThemeMode.entries.toTypedArray()[getThemeValue()]
_amoledTheme.value = getAmoledThemeValue()
_materialYou.value = getMaterialYouValue()
_goalCardStyle.value = GoalCardStyle.entries.toTypedArray()[getGoalCardStyleValue()]
}
Expand All @@ -82,6 +85,11 @@ class SettingsViewModel @Inject constructor(
preferenceUtil.putInt(PreferenceUtil.APP_THEME_INT, newTheme.ordinal)
}

fun setAmoledTheme(newValue: Boolean) {
_amoledTheme.postValue(newValue)
preferenceUtil.putBoolean(PreferenceUtil.AMOLED_THEME_BOOL, newValue)
}

fun setMaterialYou(newValue: Boolean) {
_materialYou.postValue(newValue)
preferenceUtil.putBoolean(PreferenceUtil.MATERIAL_YOU_BOOL, newValue)
Expand Down Expand Up @@ -109,6 +117,10 @@ class SettingsViewModel @Inject constructor(
PreferenceUtil.APP_THEME_INT, ThemeMode.Auto.ordinal
)

fun getAmoledThemeValue() = preferenceUtil.getBoolean(
PreferenceUtil.AMOLED_THEME_BOOL, false
)

fun getMaterialYouValue() = preferenceUtil.getBoolean(
PreferenceUtil.MATERIAL_YOU_BOOL, Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
)
Expand Down
Loading
Loading