This file contains hidden or 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
| @Composable | |
| fun ProfileCardComposable() { | |
| Card( | |
| modifier = Modifier | |
| .wrapContentSize() | |
| .clip(RoundedCornerShape(4.dp)) | |
| .background(color = Helper.getWhiteColor()) | |
| .padding(16.dp), | |
| ) { | |
| Row(modifier = Modifier.height(intrinsicSize = IntrinsicSize.Max)) { |
This file contains hidden or 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
| data class UserProfile constructor(val name: String, val status: Boolean, val pictureUrl: String) | |
| val userProfileList = arrayListOf( | |
| UserProfile( | |
| name = "Michaela Runnings", | |
| status = true, | |
| "https://images.unsplash.com/photo-1485290334039-a3c69043e517?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=80" | |
| ), | |
| UserProfile( | |
| name = "John Pestridge", |
This file contains hidden or 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
| @Composable | |
| fun ProfileCardComposable(userProfile: UserProfile) { | |
| val onlineStatus = remember { mutableStateOf(userProfile.isOnline) } | |
| Card( | |
| Modifier. | |
| ... | |
| .background(color = Helper.getWhiteColor()) | |
| .clickable(onClick = { onlineStatus.value = onlineStatus.value.not() }) | |
| .padding(16.dp) | |
| ) { |
This file contains hidden or 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
| @Composable | |
| fun ProfileContentComposable(onlineStatus: MutableState<Boolean>, | |
| name: String, | |
| lastActivityMinutes: Int) { | |
| Column( ... ) | |
| ) { ... | |
| Text( | |
| text = if (onlineStatus.value) | |
| "Active now" | |
| else |
This file contains hidden or 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
| @Composable | |
| fun ProfilePictureComposable(onlineStatus: MutableState<Boolean>, | |
| pictureDrawableId: Int) { | |
| Card( ... | |
| border = BorderStroke( | |
| 2.dp, | |
| color = if (onlineStatus.value) | |
| Helper.getGreenColor() | |
| else | |
| Helper.getRedColor() |
This file contains hidden or 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
| @Composable | |
| fun ProfileCardComposable(userProfile: UserProfile) { | |
| val onlineStatus = remember { mutableStateOf(userProfile.isOnline) } | |
| Card(...) { | |
| Row(...) { | |
| ProfilePictureComposable(onlineStatus, userProfile.profilePictureDrawableId) | |
| ProfileContentComposable(onlineStatus, userProfile.name, userProfile.lastActivityMinutes) | |
| } | |
| } | |
| } |
This file contains hidden or 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
| @Composable | |
| fun ProfilePictureComposable(pictureDrawableId: Int) { | |
| Card( ... ) { | |
| Image( | |
| painter = painterResource(id = pictureDrawableId), | |
| ... | |
| ) | |
| } | |
| } |
This file contains hidden or 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
| @Composable | |
| fun ProfileCardComposable(userProfile: UserProfile) { | |
| Card(...) { | |
| Row(...) { | |
| ProfilePictureComposable(userProfile.profilePictureDrawableId) | |
| ProfileContentComposable(userProfile.name, userProfile.lastActivityMinutes) | |
| } | |
| } | |
| } |
This file contains hidden or 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
| class MainActivity : AppCompatActivity() { | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| val mockUserProfile = UserProfile.getMockProfileUser() | |
| setContent { MainActivityComposable(mockUserProfile) } | |
| } | |
| } | |
| @Composable | |
| fun MainActivityComposable(userProfile: UserProfile) { |
This file contains hidden or 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
| data class UserProfile( | |
| val name: String, | |
| val profilePictureDrawableId: Int, | |
| val lastActivityMinutes: Int, | |
| val isOnline: Boolean | |
| ) { | |
| companion object { | |
| fun getMockProfileUser() = UserProfile("Catalin Ghita", | |
| R.drawable.profile_pic, | |
| 2, |