forked from vfsfitvnm/ViMusic
-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
- Loading branch information
Showing
9 changed files
with
505 additions
and
130 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
61 changes: 61 additions & 0 deletions
61
composeApp/src/androidMain/kotlin/me/knighthat/ui/screens/settings/about/DevBoard.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,61 @@ | ||
package me.knighthat.ui.screens.settings.about | ||
|
||
import android.content.Context | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.layout.width | ||
import androidx.compose.foundation.lazy.LazyColumn | ||
import androidx.compose.foundation.lazy.items | ||
import androidx.compose.material3.HorizontalDivider | ||
import androidx.compose.material3.VerticalDivider | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
import com.google.gson.Gson | ||
import com.google.gson.JsonArray | ||
import it.fast4x.rimusic.R | ||
import me.knighthat.colorPalette | ||
import java.io.InputStream | ||
|
||
private val GSON = Gson() | ||
private lateinit var DEVS: List<Developer> | ||
|
||
private fun init( context: Context ) { | ||
// Open contributors.json file | ||
val fileStream: InputStream = | ||
context.resources.openRawResource( R.raw.contributors ) | ||
// Parse content to JSON array | ||
val json: JsonArray = | ||
GSON.fromJson( fileStream.bufferedReader(), JsonArray::class.java ) | ||
|
||
// Convert each object of JSON array to Developer instance | ||
// then sort it based on their username | ||
DEVS = json.map { GSON.fromJson( it, Developer::class.java ) }.sortedBy { it.username } | ||
} | ||
|
||
@Composable | ||
fun DevBoard( context: Context ) { | ||
if( !::DEVS.isInitialized ) | ||
init( context ) | ||
|
||
Box( Modifier.fillMaxWidth().height( 300.dp ) ) { | ||
// For decoration purposes only | ||
val dividerColor = colorPalette().textSecondary.copy( alpha = .5f ) | ||
HorizontalDivider( | ||
modifier = Modifier.padding( start = 35.dp ).width( 50.dp ), | ||
color = dividerColor | ||
) | ||
VerticalDivider( | ||
modifier = Modifier.padding( start = 35.dp ).size( 80.dp ), | ||
color = dividerColor | ||
) | ||
// End of decoration | ||
|
||
LazyColumn( Modifier.fillMaxWidth().padding( top = 15.dp ) ) { | ||
items( DEVS ) { it.Draw() } | ||
} | ||
} | ||
} |
147 changes: 147 additions & 0 deletions
147
composeApp/src/androidMain/kotlin/me/knighthat/ui/screens/settings/about/Developer.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,147 @@ | ||
package me.knighthat.ui.screens.settings.about | ||
|
||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.border | ||
import androidx.compose.foundation.clickable | ||
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.foundation.layout.wrapContentSize | ||
import androidx.compose.foundation.shape.CircleShape | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material3.Card | ||
import androidx.compose.material3.CardColors | ||
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.draw.clip | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.layout.ContentScale | ||
import androidx.compose.ui.platform.LocalUriHandler | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.text.TextStyle | ||
import androidx.compose.ui.text.font.FontStyle | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.unit.dp | ||
import coil.compose.rememberAsyncImagePainter | ||
import com.google.gson.annotations.SerializedName | ||
import it.fast4x.rimusic.R | ||
import it.fast4x.rimusic.ui.styling.favoritesIcon | ||
import me.knighthat.colorPalette | ||
import me.knighthat.typography | ||
|
||
data class Developer( | ||
val id: Int, | ||
@SerializedName( "login" ) val username: String, | ||
@SerializedName( "name" ) val displayName: String?, | ||
@SerializedName( "html_url" )val url: String, | ||
@SerializedName( "avatar_url") val avatar: String, | ||
val contributions: Int? | ||
) { | ||
private val handle: String | ||
get() = url.split( "/" ).last() | ||
|
||
@Composable | ||
fun Draw() { | ||
val uriHandler = LocalUriHandler.current | ||
val avatarPainter = rememberAsyncImagePainter( this.avatar ) | ||
val borderColor = | ||
if( id == 1484476 ) | ||
Color.hsl( 132f, .34f, .56f ) | ||
else | ||
colorPalette().textSecondary | ||
|
||
Card( | ||
modifier = Modifier | ||
.padding(start = 50.dp, end = 20.dp, bottom = 10.dp) | ||
.fillMaxWidth() | ||
.border( 1.dp, borderColor, RoundedCornerShape( 12.dp ) ), | ||
colors = CardColors( | ||
containerColor = Color.Transparent, | ||
contentColor = Color.Transparent, | ||
disabledContainerColor = Color.Transparent, | ||
disabledContentColor = Color.Transparent | ||
), | ||
) { | ||
Row( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(16.dp), | ||
verticalAlignment = Alignment.CenterVertically | ||
) { | ||
// Avatar | ||
Image( | ||
painter = avatarPainter, | ||
contentDescription = null, | ||
modifier = Modifier | ||
.size(50.dp) | ||
.clip( RoundedCornerShape( 25.dp ) ) | ||
.border( 1.dp, Color.White, RoundedCornerShape( 25.dp ) ), | ||
contentScale = ContentScale.Fit | ||
) | ||
|
||
Spacer(modifier = Modifier.width( 16.dp ) ) | ||
|
||
// Dev's info, sits to the right of avatar | ||
Column( Modifier.fillMaxWidth() ) { | ||
Text( | ||
text = displayName ?: username, | ||
style = TextStyle( | ||
color = colorPalette().text, | ||
fontSize = typography().xl.fontSize, | ||
fontWeight = FontWeight.Bold | ||
), | ||
textAlign = TextAlign.Start | ||
) | ||
|
||
Row( Modifier.fillMaxWidth() ) { | ||
// Handle | ||
Text( | ||
text = "@$handle", | ||
style = TextStyle( | ||
color = colorPalette().textSecondary, | ||
fontSize = typography().s.fontSize, | ||
fontStyle = FontStyle.Italic, | ||
), | ||
modifier = Modifier | ||
.wrapContentSize() | ||
.clickable { uriHandler.openUri(url) }, | ||
) | ||
|
||
if( contributions == null ) | ||
return@Column | ||
|
||
val color = colorPalette().favoritesIcon.copy( alpha = .8f ) | ||
// contributions aligned to the right of handle | ||
Text( | ||
text = contributions.toString(), | ||
style = TextStyle( | ||
color = color, | ||
fontSize = typography().s.fontSize, | ||
), | ||
textAlign = TextAlign.End, | ||
modifier = Modifier.weight( 1f ) | ||
) | ||
|
||
Spacer( Modifier.width(5.dp ) ) | ||
|
||
// Pull request icon | ||
Icon( | ||
painter = painterResource( R.drawable.git_pull_request_outline ), | ||
contentDescription = null, | ||
tint = color, | ||
modifier = Modifier.size( typography().s.fontSize.value.dp ) | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
composeApp/src/androidMain/res/drawable-anydpi/git_pull_request_outline.xml
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,36 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:aapt="http://schemas.android.com/aapt" | ||
android:viewportWidth="512" | ||
android:viewportHeight="512" | ||
android:width="512dp" | ||
android:height="512dp"> | ||
<path | ||
android:pathData="M176 416A48 48 0 0 1 80 416A48 48 0 0 1 176 416Z" | ||
android:strokeColor="#000000" | ||
android:strokeWidth="32" | ||
android:strokeLineCap="round" | ||
android:strokeLineJoin="round" /> | ||
<path | ||
android:pathData="M128 144v224M288 160l-64 -64 64 -64" | ||
android:strokeColor="#000000" | ||
android:strokeWidth="32" | ||
android:strokeLineCap="round" | ||
android:strokeLineJoin="round" /> | ||
<path | ||
android:pathData="M176 96A48 48 0 0 1 80 96A48 48 0 0 1 176 96Z" | ||
android:strokeColor="#000000" | ||
android:strokeWidth="32" | ||
android:strokeLineCap="round" | ||
android:strokeLineJoin="round" /> | ||
<path | ||
android:pathData="M432 416A48 48 0 0 1 336 416A48 48 0 0 1 432 416Z" | ||
android:strokeColor="#000000" | ||
android:strokeWidth="32" | ||
android:strokeLineCap="round" | ||
android:strokeLineJoin="round" /> | ||
<path | ||
android:pathData="M240 96h84a60 60 0 0160 60v212" | ||
android:strokeColor="#000000" | ||
android:strokeWidth="32" | ||
android:strokeLineCap="round" | ||
android:strokeLineJoin="round" /> | ||
</vector> |
Oops, something went wrong.