Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add horizontal padding as 16.dp when global padding is removed. #2976

Open
github-actions bot opened this issue Jan 2, 2025 · 0 comments
Open

Add horizontal padding as 16.dp when global padding is removed. #2976

github-actions bot opened this issue Jan 2, 2025 · 0 comments
Assignees

Comments

@github-actions
Copy link

github-actions bot commented Jan 2, 2025

// TODO: Add horizontal padding as 16.dp when global padding is removed.


/*
 * Copyright 2025 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.google.android.ground.ui.datacollection.tasks.text

import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.TextField
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.google.android.ground.ExcludeFromJacocoGeneratedReport
import com.google.android.ground.ui.theme.AppTheme

const val INPUT_TEXT_TEST_TAG: String = "text task input test tag"

@Composable
fun TextTaskInput(
  value: String,
  modifier: Modifier = Modifier,
  valueChanged: (text: String) -> Unit = {},
) {
  TextField(
    value = value,
    onValueChange = { valueChanged(it) },
    modifier =
      modifier
        .wrapContentWidth(align = Alignment.Start)
        .wrapContentHeight(align = Alignment.Top)
        // TODO: Add horizontal padding as 16.dp when global padding is removed.
        .padding(vertical = 8.dp)
        .testTag(INPUT_TEXT_TEST_TAG),
    textStyle = MaterialTheme.typography.bodyLarge,
    singleLine = true,
    keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text),
  )
}

@Preview
@Composable
@ExcludeFromJacocoGeneratedReport
fun TextTaskInputPreview() {
  AppTheme { TextTaskInput(value = "Some value") }
}

@Preview
@Composable
@ExcludeFromJacocoGeneratedReport
fun TextTaskInputEmptyPreview() {
  AppTheme { TextTaskInput(value = "") }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant