-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #496 from 07jasjeet/settings-delete-acc-button
Settings Revamp
- Loading branch information
Showing
5 changed files
with
439 additions
and
403 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
app/src/main/java/org/listenbrainz/android/ui/screens/settings/SettingsCallbacks.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,14 @@ | ||
package org.listenbrainz.android.ui.screens.settings | ||
|
||
import android.graphics.drawable.Drawable | ||
import androidx.compose.runtime.Immutable | ||
|
||
@Immutable | ||
data class SettingsCallbacks( | ||
val logout: () -> Unit, | ||
val getVersion: () -> String, | ||
val fetchLinkedServices: () -> Unit, | ||
val getPackageIcon: (String) -> Drawable?, | ||
val getPackageLabel: (String) -> String, | ||
val setWhitelist: (List<String>) -> Unit, | ||
) |
155 changes: 155 additions & 0 deletions
155
app/src/main/java/org/listenbrainz/android/ui/screens/settings/SettingsOption.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,155 @@ | ||
package org.listenbrainz.android.ui.screens.settings | ||
|
||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.layout.width | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.graphics.ColorFilter | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import org.listenbrainz.android.R | ||
import org.listenbrainz.android.ui.components.Switch | ||
import org.listenbrainz.android.ui.theme.ListenBrainzTheme | ||
|
||
@Composable | ||
fun SettingsSwitchOption( | ||
modifier: Modifier = Modifier, | ||
title: String, | ||
subtitle: String, | ||
enabled: Boolean = true, | ||
isChecked: Boolean, | ||
onCheckedChange: (Boolean) -> Unit | ||
) { | ||
Row( | ||
modifier = modifier | ||
.fillMaxWidth() | ||
.padding(horizontal = ListenBrainzTheme.paddings.settings), | ||
horizontalArrangement = Arrangement.SpaceBetween, | ||
verticalAlignment = Alignment.CenterVertically | ||
) { | ||
Column { | ||
SettingsText( | ||
title = title, | ||
subtitle = subtitle, | ||
enabled = enabled | ||
) | ||
} | ||
|
||
Switch( | ||
checked = isChecked, | ||
onCheckedChange = onCheckedChange, | ||
) | ||
} | ||
} | ||
|
||
@Composable | ||
fun SettingsHeader( | ||
modifier: Modifier = Modifier, | ||
title: String, | ||
) { | ||
Text( | ||
modifier = modifier.padding(horizontal = ListenBrainzTheme.paddings.settings), | ||
text = title, | ||
color = ListenBrainzTheme.colorScheme.lbSignature, | ||
fontWeight = FontWeight.Medium | ||
) | ||
} | ||
|
||
@Composable | ||
fun SettingsTextOption( | ||
modifier: Modifier = Modifier, | ||
title: String, | ||
subtitle: String? = null, | ||
enabled: Boolean = true, | ||
textColor: Color = ListenBrainzTheme.colorScheme.text | ||
) { | ||
SettingsText( | ||
modifier = modifier | ||
.fillMaxWidth() | ||
.padding(horizontal = ListenBrainzTheme.paddings.settings), | ||
title = title, | ||
subtitle = subtitle, | ||
enabled = enabled, | ||
textColor = textColor, | ||
) | ||
} | ||
|
||
@Composable | ||
fun SettingsHyperlink( | ||
modifier: Modifier = Modifier, | ||
title: String, | ||
subtitle: String? = null, | ||
enabled: Boolean = true, | ||
textColor: Color = ListenBrainzTheme.colorScheme.text, | ||
iconColor: Color = ListenBrainzTheme.colorScheme.hint | ||
) { | ||
Row( | ||
modifier | ||
.fillMaxWidth() | ||
.padding(horizontal = ListenBrainzTheme.paddings.settings), | ||
verticalAlignment = Alignment.CenterVertically | ||
) { | ||
SettingsText( | ||
modifier = Modifier, | ||
title = title, | ||
subtitle = subtitle, | ||
enabled = enabled, | ||
textColor = textColor, | ||
) | ||
|
||
Spacer(modifier = Modifier.width(10.dp)) | ||
|
||
Image( | ||
modifier = Modifier.size(16.dp), | ||
painter = painterResource(id = R.drawable.link_to), | ||
contentDescription = "Arrow", | ||
colorFilter = ColorFilter.tint(iconColor) | ||
) | ||
} | ||
} | ||
|
||
@Composable | ||
private fun SettingsText( | ||
modifier: Modifier = Modifier, | ||
title: String, | ||
subtitle: String?, | ||
enabled: Boolean, | ||
textColor: Color = ListenBrainzTheme.colorScheme.text, | ||
) { | ||
Column(modifier) { | ||
Text( | ||
text = title, | ||
color = if (enabled) { | ||
textColor | ||
} else { | ||
ListenBrainzTheme.colorScheme.hint | ||
} | ||
) | ||
|
||
if (subtitle != null) { | ||
Text( | ||
text = subtitle, | ||
lineHeight = 18.sp, | ||
fontSize = 12.sp, | ||
color = ListenBrainzTheme.colorScheme.hint, | ||
modifier = Modifier | ||
.padding(top = 6.dp, end = 6.dp) | ||
.fillMaxWidth(0.9f) | ||
) | ||
} | ||
} | ||
} |
Oops, something went wrong.