-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-14 Add settings view with a possibility to change avatar url (Resolve
#14)
- Loading branch information
Showing
7 changed files
with
156 additions
and
35 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
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
80 changes: 80 additions & 0 deletions
80
pom-application/app/src/main/java/net/dzikoysk/presenceofmind/pages/settings/Settings.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,80 @@ | ||
package net.dzikoysk.presenceofmind.pages.settings | ||
|
||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material.Icon | ||
import androidx.compose.material.Text | ||
import androidx.compose.material.TextField | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import net.dzikoysk.presenceofmind.R | ||
import net.dzikoysk.presenceofmind.components.scaledSp | ||
import net.dzikoysk.presenceofmind.model.presence.InMemoryPresenceRepository | ||
import net.dzikoysk.presenceofmind.model.presence.PresenceRepository | ||
import net.dzikoysk.presenceofmind.pages.Page | ||
|
||
@Preview(showBackground = false) | ||
@Composable | ||
fun SettingsPreview() { | ||
Settings() | ||
} | ||
|
||
@Composable | ||
fun Settings( | ||
presenceRepository: PresenceRepository = InMemoryPresenceRepository(), | ||
changePage: (Page) -> Unit = {} | ||
) { | ||
val avatarUrl = remember { mutableStateOf(presenceRepository.getAvatarUrl()) } | ||
|
||
Column( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.padding(horizontal = 16.dp) | ||
) { | ||
Row( | ||
verticalAlignment = Alignment.CenterVertically, | ||
modifier = Modifier | ||
.padding(vertical = 24.dp) | ||
.clickable { | ||
presenceRepository.setAvatarUrl(avatarUrl.value) | ||
changePage(Page.DASHBOARD) | ||
} | ||
) { | ||
Icon( | ||
contentDescription = "Back to dashboard", | ||
painter = painterResource(id = R.drawable.ic_baseline_arrow_back_24), | ||
modifier = Modifier.padding(end = 8.dp) | ||
) | ||
Text( | ||
text = "Go back", | ||
fontSize = 15.scaledSp(), | ||
fontWeight = FontWeight.Bold | ||
) | ||
} | ||
|
||
Row { | ||
Column { | ||
Text( | ||
fontSize = 15.scaledSp(), | ||
text = "Avatar URL", | ||
modifier = Modifier.padding(bottom = 10.dp) | ||
) | ||
|
||
TextField( | ||
value = avatarUrl.value, | ||
onValueChange = { avatarUrl.value = it } | ||
) | ||
} | ||
} | ||
} | ||
} |