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
// Classe para representar o estado da UI | |
data class LoginUiState( | |
val email: String = "", | |
val password: String = "", | |
val isValid: Boolean = false, | |
val errorMessage: String? = null | |
) |
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 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" | |
} |
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 LoginScreen() { | |
var email by remember { mutableStateOf("") } | |
var password by remember { mutableStateOf("") } | |
var rememberMe by remember { mutableStateOf(true) } | |
Column( | |
… | |
) { | |
Image( |
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"?> | |
<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 |
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 MyApplication : Application() { | |
lateinit var appComponent: ApplicationComponent | |
@Inject | |
lateinit var logger: Logger | |
override fun onCreate() { | |
super.onCreate() | |
appComponent = DaggerApplicationComponent.factory().create(this) |
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
@EntryPoint | |
interface AuditEntryPoint { | |
fun logger(): Logger | |
} |
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
// Dagger 2 | |
@Module | |
abstract class AuditModule { | |
@Binds | |
abstract fun provideLogger(impl: AuditLogger): Logger | |
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
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, |
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
@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") |
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
@AndroidEntryPoint | |
class MainActivity: AppCompatActivity() { | |
private val viewModel: LoggingViewModel by viewModels() | |
override fun onCreate(savedInstanceState) { | |
super.onCreate(savedInstanceState) | |
viewModel.log(“Initializing main screen”) | |
} |
NewerOlder