Skip to content

Instantly share code, notes, and snippets.

View hieuwu's full-sized avatar
🦇
Busy helping Batman

Hieu Vu hieuwu

🦇
Busy helping Batman
View GitHub Profile
@hieuwu
hieuwu / accessibility.xml
Created August 31, 2023 13:36
Accessibility in XML view system
<Button
android:id="@+id/confirm_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/margin_medium"
android:background="@drawable/primary_button"
android:importantForAccessibility="yes"
android:text="Confirm"
android:contentDescription="Confirm button, double tap to confirm"/>
@hieuwu
hieuwu / product_details.json
Created August 29, 2023 13:56
product_details.json
{
"screen_elements": {
"header_text": {
"display": "Product details",
"accessibility": "Product details, header"
},
"back_button": {
"display": "Back button",
"accessibility": "Back button, double tap to navigate to previous screen"
},
@AndroidEntryPoint
class DeepLinkHandlerActivity : ComponentActivity() {
@Inject
lateinit var supabaseClient: SupabaseClient
private lateinit var callback: (String, String) -> Unit
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".ManageProductApplication"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:enableOnBackInvokedCallback="true"
android:fullBackupContent="@xml/backup_rules"
@OptIn(ExperimentalMaterial3Api::class, ExperimentalComposeUiApi::class)
@Composable
fun SignInScreen(
modifier: Modifier = Modifier,
navController: NavController,
viewModel: SignInViewModel = hiltViewModel()
) {
val snackBarHostState = remember { SnackbarHostState() }
val coroutineScope = rememberCoroutineScope()
Scaffold(
@HiltViewModel
class SignInViewModel @Inject constructor(
private val authenticationRepository: AuthenticationRepository
) : ViewModel() {
private val _email = MutableStateFlow("")
val email: Flow<String> = _email
private val _password = MutableStateFlow("")
val password = _password
@Composable
fun SignUpScreen(
modifier: Modifier = Modifier,
navController: NavController,
viewModel: SignUpViewModel = hiltViewModel()
) {
val snackBarHostState = remember { SnackbarHostState() }
val coroutineScope = rememberCoroutineScope()
Scaffold(
snackbarHost = { androidx.compose.material.SnackbarHost(snackBarHostState) },
@HiltViewModel
class SignUpViewModel @Inject constructor(
private val authenticationRepository: AuthenticationRepository
) : ViewModel() {
private val _email = MutableStateFlow("")
val email: Flow<String> = _email
private val _password = MutableStateFlow("")
val password = _password
@HiltViewModel
class AddProductViewModel @Inject constructor(
private val productRepository: ProductRepository,
) : ViewModel() {
private val _isLoading = MutableStateFlow(false)
val isLoading: Flow<Boolean> = _isLoading
private val _showSuccessMessage = MutableStateFlow(false)
val showSuccessMessage: Flow<Boolean> = _showSuccessMessage
@SuppressLint("UnusedMaterial3ScaffoldPaddingParameter")
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun AddProductScreen(
modifier: Modifier = Modifier,
navController: NavController,
viewModel: AddProductViewModel = hiltViewModel(),
) {
Scaffold(
topBar = {