Skip to main content
Glama

android_generate_material_form

Generate Android Jetpack Compose form patterns with Material Design for DHIS2 health information systems. Create customizable forms with validation, date pickers, multi-select options, and accessibility features.

Instructions

Generate Android Jetpack Compose form patterns (Material Design)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
screenNameNoComposable name
includeValidationNo
includeDatePickerNo
includeMultiSelectNo
dynamicColorNoUse Material 3 dynamic color
lightDarkNoInclude light/dark theme setup
rtlNoAdd RTL considerations
snackbarNoInclude snackbar feedback example

Implementation Reference

  • MCP server tool handler for 'android_generate_material_form'. Receives arguments, calls generateAndroidMaterialForm generator, and formats response as text content.
    case 'android_generate_material_form':
      const aFormArgs = args as any;
      const aForm = generateAndroidMaterialForm(aFormArgs);
      return { content: [{ type: 'text', text: aForm }] };
  • Core generator function that produces Kotlin Jetpack Compose code for Android Material Design forms based on input parameters like screenName, validation, date picker, multi-select.
    export function generateAndroidMaterialForm(args: any): string {
      const {
        screenName = 'RegistrationForm',
        includeValidation = true,
        includeDatePicker = true,
        includeMultiSelect = true
      } = args;
    
      return `# Android Material Form (Jetpack Compose): ${screenName}
    
    ## Implementation
    \`\`\`kotlin
    @Composable
    fun ${screenName}(
        onSubmit: (name: String, description: String, date: String, options: List<String>) -> Unit
    ) {
        var name by remember { mutableStateOf("") }
        var description by remember { mutableStateOf("") }
        var date by remember { mutableStateOf("") }
        var showDatePicker by remember { mutableStateOf(false) }
        val selectedOptions = remember { mutableStateListOf<String>() }
        ${includeValidation ? 'var nameError by remember { mutableStateOf<String?>(null) }' : ''}
    
        Column(modifier = Modifier.padding(16.dp).fillMaxSize(), verticalArrangement = Arrangement.spacedBy(12.dp)) {
            OutlinedTextField(
                value = name,
                onValueChange = { value ->
                    name = value
                    ${includeValidation ? 'nameError = if (value.isBlank()) "Name is required" else null' : ''}
                },
                label = { Text("Name") },
                isError = ${includeValidation ? 'nameError != null' : 'false'},
                supportingText = { ${includeValidation ? 'nameError?.let { Text(it)' : 'null'} ${includeValidation ? '}' : ''} }
            )
    
            OutlinedTextField(
                value = description,
                onValueChange = { description = it },
                label = { Text("Description") },
                minLines = 3
            )
    
            ${includeDatePicker ? `
            OutlinedTextField(
                value = date,
                onValueChange = {},
                label = { Text("Date") },
                readOnly = true,
                trailingIcon = { Icon(Icons.Default.DateRange, contentDescription = null) },
                modifier = Modifier.clickable { showDatePicker = true }
            )
    
            if (showDatePicker) {
                DatePickerDialog(
                    onDismissRequest = { showDatePicker = false },
                    onDateChange = { y, m, d ->
                        date = "%04d-%02d-%02d".format(y, m + 1, d)
                        showDatePicker = false
                    }
                )
            }
            ` : ''}
    
            ${includeMultiSelect ? `
            Text("Categories")
            FlowRow(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
                listOf("male", "female", "other").forEach { option ->
                    FilterChip(
                        selected = selectedOptions.contains(option),
                        onClick = {
                            if (selectedOptions.contains(option)) selectedOptions.remove(option)
                            else selectedOptions.add(option)
                        },
                        label = { Text(option) }
                    )
                }
            }
            ` : ''}
    
            Button(onClick = {
                ${includeValidation ? 'if (nameError != null) return@Button' : ''}
                onSubmit(name, description, date, selectedOptions.toList())
            }) {
                Text("Save")
            }
        }
    }
    \`\`\`
    
    ## Notes
    - Replace \`DatePickerDialog\` with your preferred implementation if needed.
    - Use validation for required fields.
    `;
    }
  • Tool permission registration in TOOL_PERMISSIONS Map, associating 'android_generate_material_form' with 'canUseMobileFeatures' permission.
      ['dhis2_generate_design_system', 'canUseUITools'],
      ['android_generate_material_form', 'canUseMobileFeatures'],
      ['android_generate_list_adapter', 'canUseMobileFeatures'],
      ['android_generate_navigation_drawer', 'canUseMobileFeatures'],
      ['android_generate_bottom_sheet', 'canUseMobileFeatures'],
    ]);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Dradebo/dhis2-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server