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

IOS. Text and cursor not visible in text field inside dialog #4923

Open
DanilDubowitsky opened this issue Jun 4, 2024 · 4 comments
Open
Assignees
Labels
bug Something isn't working ios reproduced text

Comments

@DanilDubowitsky
Copy link

Compose 1.6.11

Issue: on Iphone SE 2022 with settings: Display & Brightness -> Display Zoom -> Larger Text. TextSize -> Minimum.
In ModalBottomSheet in TextField the cursor and the text being typed are not visible. With larger text size, the text becomes visible. This only happens inside the BottomSheetDialog

In your example chat make the following changes:

import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.LocalTextStyle
import androidx.compose.material.MaterialTheme
import androidx.compose.material.ProvideTextStyle
import androidx.compose.material.TextField
import androidx.compose.material.lightColors
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import chat_mpp.shared.generated.resources.Res
import chat_mpp.shared.generated.resources.stock1
import chat_mpp.shared.generated.resources.stock2
import chat_mpp.shared.generated.resources.stock3
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.SupervisorJob
import org.jetbrains.compose.resources.ExperimentalResourceApi

val myUser = User("Me", picture = null)
val friends = listOf(
    User("Alex", picture = Res.drawable.stock1),
    User("Casey", picture = Res.drawable.stock2),
    User("Sam", picture = Res.drawable.stock3)
)
val friendMessages = listOf(
    "How's everybody doing today?",
    "I've been meaning to chat!",
    "When do we hang out next? 😋",
    "We really need to catch up!",
    "It's been too long!",
    "I can't\nbelieve\nit! 😱",
    "Did you see that ludicrous\ndisplay last night?",
    "We should meet up in person!",
    "How about a round of pinball?",
    "I'd love to:\n🍔 Eat something\n🎥 Watch a movie, maybe?\nWDYT?"
)
val store = CoroutineScope(SupervisorJob()).createStore()

@OptIn(ExperimentalMaterialApi::class, ExperimentalMaterial3Api::class)
@Composable
fun ChatAppWithScaffold(displayTextField: Boolean = true) {
    Theme {
      
        Scaffold(
            topBar = {
                TopAppBar(
                    title = { Text("The Composers Chat") },
                )
            }) {
            ChatApp(displayTextField = displayTextField)
        }
    }
}

@OptIn(ExperimentalResourceApi::class, ExperimentalMaterial3Api::class)
@Composable
fun ChatApp(displayTextField: Boolean = true) {
    val state by store.stateFlow.collectAsState()

    ModalBottomSheet(
        onDismissRequest = {},
        modifier = Modifier.fillMaxSize()
    ) {
        var textState by remember {
            mutableStateOf(TextFieldValue())
        }
        TextField(
            value = textState,
            modifier = Modifier.padding(horizontal = 16.dp).fillMaxWidth(),
            onValueChange = { newValue ->
                textState = newValue
            })
    }
}

@Composable
fun Theme(content: @Composable () -> Unit) {
    MaterialTheme(
        colors = lightColors(
            surface = Color(ChatColors.SURFACE),
            background = Color(ChatColors.TOP_GRADIENT.last()),
        ),
    ) {
        ProvideTextStyle(LocalTextStyle.current.copy(letterSpacing = 0.sp)) {
            content()
        }
    }
}

Dependencies:

val commonMain by getting {
            dependencies {
                implementation(compose.ui)
                implementation(compose.foundation)
                implementation(compose.material)
                implementation(compose.material3)
                implementation(compose.components.resources)
                implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.5.0")
            }
        }
@DanilDubowitsky DanilDubowitsky added bug Something isn't working submitted labels Jun 4, 2024
@terrakok
Copy link
Collaborator

terrakok commented Jun 4, 2024

image image

I reproduced with

kotlin.version=2.0.0
compose.version=1.6.10

@ASalavei
Copy link
Collaborator

ASalavei commented Jun 4, 2024

@mazunin-v-jb , could you please take a look?

@okushnikov
Copy link

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

1 similar comment
@okushnikov
Copy link

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ios reproduced text
Projects
None yet
5 participants