-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
788e757
commit b368c1d
Showing
8 changed files
with
186 additions
and
90 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
114 changes: 83 additions & 31 deletions
114
composeApp/src/commonMain/kotlin/tools/mo3ta/githubactivity/components/BasicUserData.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 |
---|---|---|
@@ -1,46 +1,98 @@ | ||
package tools.mo3ta.githubactivity.components | ||
|
||
import androidx.compose.foundation.border | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.ExperimentalLayoutApi | ||
import androidx.compose.foundation.layout.FlowRow | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.aspectRatio | ||
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.material3.MaterialTheme | ||
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.unit.dp | ||
import io.kamel.image.KamelImage | ||
import io.kamel.image.asyncPainterResource | ||
import tools.mo3ta.githubactivity.model.UserDetails | ||
|
||
|
||
@OptIn(ExperimentalLayoutApi::class) | ||
@Composable | ||
fun BasicUserData(userDetails: UserDetails?, stars: Int?) { | ||
fun BasicUserData(userDetails: UserDetails?, stars: Int? = 0) { | ||
Column { | ||
userDetails?.name?.let { LabeledData("Name", it) } | ||
userDetails?.bio?.let { LabeledData("Bio", it) } | ||
userDetails?.email?.let { LabeledData("Email", it) } | ||
userDetails?.company?.let { | ||
LabeledData( | ||
"Company", | ||
it | ||
) | ||
userDetails?.avatar_url?.let { | ||
KamelImage( | ||
asyncPainterResource(it), | ||
"user avatar", | ||
modifier = Modifier | ||
.width(200.dp) | ||
.aspectRatio(1f) | ||
.clip(CircleShape) | ||
.border(8.dp, Color.Gray, CircleShape) | ||
.align(Alignment.CenterHorizontally) | ||
) | ||
} | ||
Spacer(modifier = Modifier.size(32.dp)) | ||
userDetails?.name?.let { | ||
Text( | ||
it, | ||
modifier = Modifier.align(Alignment.CenterHorizontally), | ||
style = MaterialTheme.typography.headlineLarge | ||
) | ||
} | ||
userDetails?.blog?.let { LabeledData("Blog", it) } | ||
userDetails?.location?.let { | ||
LabeledData( | ||
"Location", | ||
it | ||
) | ||
userDetails?.bio?.let { | ||
Text( | ||
it, | ||
modifier = Modifier.align(Alignment.CenterHorizontally), | ||
style = MaterialTheme.typography.labelSmall | ||
) | ||
} | ||
userDetails?.public_repos?.let { | ||
LabeledData( | ||
"Public Repo", | ||
it.toString() | ||
) | ||
userDetails?.email?.let { | ||
Text( | ||
it, | ||
modifier = Modifier.align(Alignment.CenterHorizontally), | ||
style = MaterialTheme.typography.labelSmall | ||
) | ||
} | ||
userDetails?.public_gists?.let { | ||
LabeledData( | ||
"Public Gists", | ||
it.toString() | ||
) | ||
userDetails?.blog?.let { | ||
Text( | ||
it, | ||
modifier = Modifier.align(Alignment.CenterHorizontally), | ||
style = MaterialTheme.typography.labelSmall | ||
) | ||
} | ||
userDetails?.followers?.let { | ||
LabeledData( | ||
"Followers", | ||
it.toString() | ||
) | ||
Spacer(modifier = Modifier.size(16.dp)) | ||
FlowRow { | ||
userDetails?.public_repos?.let { | ||
LabeledData("Public Repo", it.toString(), modifier = Modifier.wrapContentSize()) | ||
} | ||
userDetails?.followers?.let { | ||
LabeledData("Follower", it.toString(), modifier = Modifier.weight(1f)) | ||
} | ||
userDetails?.following?.let { | ||
LabeledData("Following", it.toString(), modifier = Modifier.weight(1f)) | ||
} | ||
|
||
stars?.let { LabeledData("Stars", it.toString(), modifier = Modifier.weight(1f)) } | ||
|
||
userDetails?.public_gists?.let { | ||
LabeledData("Public Gists", it.toString(), modifier = Modifier.weight(1f)) | ||
} | ||
|
||
userDetails?.company?.let { | ||
LabeledData("Company", it, modifier = Modifier.weight(1f)) | ||
} | ||
|
||
userDetails?.location?.let { | ||
LabeledData("Location", it, modifier = Modifier.weight(1f)) | ||
} | ||
} | ||
stars?.let { LabeledData("Stars", it.toString()) } | ||
} | ||
} |
23 changes: 18 additions & 5 deletions
23
composeApp/src/commonMain/kotlin/tools/mo3ta/githubactivity/components/LabeledData.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 |
---|---|---|
@@ -1,17 +1,30 @@ | ||
package tools.mo3ta.githubactivity.components | ||
|
||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
|
||
@Composable | ||
fun LabeledData(title:String , value: String) { | ||
fun LabeledData(title: String, value: String, modifier: Modifier = Modifier) { | ||
|
||
Row (modifier = Modifier.padding(horizontal = 16.dp , vertical = 4.dp)){ | ||
Text("$title : ", modifier = Modifier.weight(1.5f)) | ||
Text(value, modifier = Modifier.weight(4f)) | ||
Column( | ||
modifier = modifier.padding(horizontal = 16.dp, vertical = 4.dp) | ||
) { | ||
Text( | ||
value, | ||
style = MaterialTheme.typography.titleLarge, | ||
modifier = Modifier.align(Alignment.CenterHorizontally) | ||
) | ||
Text( | ||
title, | ||
style = MaterialTheme.typography.titleSmall, | ||
modifier = Modifier.align(Alignment.CenterHorizontally), | ||
color = MaterialTheme.colorScheme.onSurfaceVariant, | ||
) | ||
} | ||
} |
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
Oops, something went wrong.