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
@Composable | |
fun CustomAnimationExample() { | |
val offset = remember { Animatable(0f) } | |
val coroutineScope = rememberCoroutineScope() | |
var isUpwards by remember { mutableStateOf(true) } | |
Column { | |
Button(onClick = { | |
coroutineScope.launch { | |
val target = if (isUpwards) 300f else 0f |
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
@Composable | |
fun AnimateAsStateExample() { | |
// State to control the background color | |
var boxColor by remember { mutableStateOf(Color.Blue) } | |
// Animate the background color | |
val backgroundColor by animateColorAsState(targetValue = boxColor, label = "") | |
// Box with clickable modifier to change the color | |
Box( |
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
@Composable | |
fun AnimatedVisibilityExample() { | |
// State to control the visibility of the text | |
var isVisible by remember { mutableStateOf(true) } | |
// Box to layer the button and the text | |
Box( | |
contentAlignment = Alignment.Center, | |
modifier = Modifier.fillMaxSize() | |
) { |
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
struct Person: Equatable{ | |
let name: String | |
let email: String | |
let age: Int | |
} | |
func search() { | |
let henry = Person(name : "Henry", email : "henry@email.com", age : 24) | |
let robert = Person(name : "Robert", email : "robert@email.com", age : 22) | |
let tom = Person(name : "Tom", email : "tom@email.com", age : 25) |
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
class SearchUtil{ | |
var list: [Int] = [] | |
init(list: [Int]) { | |
self.list = list | |
} | |
func searchItem(element: Int, foundItem: (Int?)->()) { | |
let itemFoundList = self.list.filter { item in | |
item == element |
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
object BindingAdapter { | |
@BindingAdapter("loadImageFromUrl") | |
@JvmStatic | |
fun loadImageFromUrl(imageView: ImageView, imageUrl: String) { | |
imageView.load(imageUrl) { | |
crossfade(600) | |
error(R.drawable.ic_error_placeholder) | |
} | |
} | |
} |
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
<?xml version="1.0" encoding="utf-8"?> | |
<layout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
tools:context=".presentation.image_viewer.ImageViewerFragment"> | |
<data> | |
<variable | |
name="imageSrc" |
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
class ImageSearchFragment : Fragment() { | |
private var _binding: FragmentImageSearchBinding? = null | |
private val binding get() = _binding!! | |
override fun onCreateView( | |
inflater: LayoutInflater, container: ViewGroup?, | |
savedInstanceState: Bundle?, | |
): View? { | |
// Inflate the layout for this fragment |
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
@Composable | |
fun Content() { | |
Column(modifier = Modifier.padding(16.dp)) { | |
Text( | |
text = "Hello,", | |
modifier = Modifier.padding(bottom = 8.dp), | |
style = MaterialTheme.typography.h5 | |
) | |
OutlinedTextField( | |
value = "", |
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
@Composable | |
fun Content() { | |
var name by remember { mutableStateOf("") } | |
Column(modifier = Modifier.padding(16.dp)) { | |
Text( | |
text = "Hello, $name", | |
modifier = Modifier.padding(bottom = 8.dp), | |
style = MaterialTheme.typography.h5 | |
) | |
OutlinedTextField( |
NewerOlder