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
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContent { | |
// Calling our Refactored function | |
ChatScreen(SampleListData.conversationSample) | |
} | |
} | |
@Composable | |
private fun ChatScreen(messages: List<Message>) { |
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 | |
private fun ChatCard(title: String, body: String) { | |
Surface( | |
shape = MaterialTheme.shapes.medium, | |
elevation = 8.dp, | |
modifier = Modifier.padding(all = 8.dp) | |
) { | |
Row(modifier = Modifier.padding(all = 8.dp)) { | |
Image( | |
painter = painterResource( |
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
// Preview Annotation with name for Light Mode | |
@Preview(name = "Light Mode") | |
// Adding another Preview annotation for Dark Mode | |
@Preview( | |
uiMode = Configuration.UI_MODE_NIGHT_YES, | |
showBackground = true, | |
name = "Dark Mode" | |
) | |
/// Same Function as before | |
@Composable |
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 GreetUser(name: String) { | |
// Adding a modifier to our Row | |
Row(modifier = Modifier.padding(all = 8.dp)) { | |
Image( | |
painter = painterResource( | |
id = R.drawable.ic_launcher_background | |
), contentDescription = "Some cool image", | |
// Image Modifier |
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 GreetUser(name: String) { | |
Row { | |
Image( | |
painter = painterResource( | |
id = R.drawable.ic_launcher_background | |
), contentDescription = "Some cool image" | |
) | |
Column { | |
Text(text = "Hello!") |
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 MainActivity : ComponentActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
// This is the block where we will call | |
// our Composable Functions | |
setContent { | |
Text("Hello world!") //<-- Composable Function | |
} | |
} |
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 MainActivity : ComponentActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContent { | |
// Calling our Refactored function | |
GreetUser("DEEJAY") | |
} | |
} |
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 MainActivity : ComponentActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContent { | |
// Calling our Refactored function | |
GreetUser("DEEJAY") | |
} | |
} |
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 MainActivity : ComponentActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
// This is the block where we will call our | |
// Composable Functions | |
setContent { | |
GreetUser("DEEJAY") | |
} | |
} |
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
// Hilt Module | |
// @InstallIn <-- We define the component (See Hilt Components for more) | |
// This helps Hilt knows how long these dependencies have to stay in the memory | |
// But We use the Application level component for this example | |
// So NetworkRepo() will stay as long as Application is running. | |
@InstallIn(ActivityComponent::class) | |
@Module | |
abstract class NetworkRepoModule { | |
@ActivityScoped | |
@Binds |
NewerOlder