Skip to content

Instantly share code, notes, and snippets.

View ramonrabello's full-sized avatar

Ramon Ribeiro Rabello ramonrabello

View GitHub Profile
@ramonrabello
ramonrabello / LoginUiState.kt
Last active November 28, 2023 19:22
LoginUiState.kt - Accelerating the mobile legacy modernization: Migrate to Compose 10x faster using StackSpot AI
// Classe para representar o estado da UI
data class LoginUiState(
val email: String = "",
val password: String = "",
val isValid: Boolean = false,
val errorMessage: String? = null
)
@ramonrabello
ramonrabello / LoginViewModel.kt
Last active November 28, 2023 19:24
LoginViewModel.kt - Accelerating the mobile legacy modernization: Migrate to Compose 10x faster using StackSpot AI
class LoginViewModel : ViewModel() {
// Estado inicial
private val _uiState = MutableStateFlow(LoginUiState())
val uiState: StateFlow<LoginUiState> = _uiState
// Constantes para credenciais válidas
companion object {
const val VALID_EMAIL = "seu_email@example.com"
const val VALID_PASSWORD = "sua_senha"
}
@ramonrabello
ramonrabello / LoginScreen.kt
Last active November 28, 2023 14:19
LoginScreen.kt - Accelerating the mobile legacy modernization: Migrate to Compose 10x faster using StackSpot AI
@Composable
fun LoginScreen() {
var email by remember { mutableStateOf("") }
var password by remember { mutableStateOf("") }
var rememberMe by remember { mutableStateOf(true) }
Column(
) {
Image(
@ramonrabello
ramonrabello / login_layout.xml
Last active November 22, 2023 02:20
Boosting migration to Compose using StackSpot AI - Layout of a simple Login Screen using XML Views
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:layout_marginHorizontal="16dp"
android:orientation="vertical">
<ImageView
@ramonrabello
ramonrabello / MyApplication.kt
Created October 10, 2020 16:34
1. MyApplication - Hilt Series: Migrando do Dagger para Hilt
class MyApplication : Application() {
lateinit var appComponent: ApplicationComponent
@Inject
lateinit var logger: Logger
override fun onCreate() {
super.onCreate()
appComponent = DaggerApplicationComponent.factory().create(this)
@ramonrabello
ramonrabello / AuditEntryPoint.kt
Created August 2, 2020 04:44
Hilt Series: Migrando do Dagger para o Hilt - AuditEntryPoint
@EntryPoint
interface AuditEntryPoint {
fun logger(): Logger
}
@ramonrabello
ramonrabello / AuditModule.kt
Created August 2, 2020 04:30
Hilt Series: Migrando do Dagger para o Hilt - AuditModule
// Dagger 2
@Module
abstract class AuditModule {
@Binds
abstract fun provideLogger(impl: AuditLogger): Logger
@ramonrabello
ramonrabello / HiltViewModelFactory.java
Created July 28, 2020 03:00
Hilt Series: Architecture Components com Hilt - HiltViewModelFactory.java
public final class HiltViewModelFactory extends AbstractSavedStateViewModelFactory {
private static final String KEY_PREFIX = "androidx.hilt.lifecycle.HiltViewModelFactory";
private final SavedStateViewModelFactory mDelegateFactory;
private final Map<String,
Provider<ViewModelAssistedFactory<? extends ViewModel>>> mViewModelFactories;
HiltViewModelFactory(
@NonNull SavedStateRegistryOwner owner,
@ramonrabello
ramonrabello / LoggingViewModel_HiltModule.java
Created July 28, 2020 02:27
Hilt Series: Architecture Components com Hilt - LoggingViewModel_HiltModule
@Generated("androidx.hilt.AndroidXHiltProcessor")
@Module
@InstallIn(ActivityRetainedComponent.class)
@OriginatingElement(
topLevelClass = LoggingViewModel.class
)
public interface LoggingViewModel_HiltModule {
@Binds
@IntoMap
@StringKey("com.github.ramonrabello.android.dagger.hilt.LoggingViewModel")
@ramonrabello
ramonrabello / MainActivity.kt
Created July 28, 2020 02:11
Hilt Series: Architecture Components com Hilt - Android Entry Point
@AndroidEntryPoint
class MainActivity: AppCompatActivity() {
private val viewModel: LoggingViewModel by viewModels()
override fun onCreate(savedInstanceState) {
super.onCreate(savedInstanceState)
viewModel.log(“Initializing main screen”)
}