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

[ComposeApp] Improve touch region area of input fields, Remove focus from fields on sharing image #296

Merged
merged 3 commits into from
Oct 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package dev.shreyaspatil.noty.composeapp.component.text
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.material.MaterialTheme
Expand Down Expand Up @@ -68,7 +69,8 @@ fun BasicNotyTextField(
label: String = "",
textStyle: TextStyle = TextStyle(fontSize = 16.sp, fontWeight = FontWeight.Normal),
onTextChange: (String) -> Unit,
maxLines: Int = Int.MAX_VALUE
maxLines: Int = Int.MAX_VALUE,
textFieldModifier: Modifier = Modifier
) {

Box(modifier = modifier.padding(4.dp)) {
Expand All @@ -81,6 +83,7 @@ fun BasicNotyTextField(
)
}
BasicTextField(
modifier = textFieldModifier.fillMaxWidth(),
value = value,
onValueChange = onTextChange,
textStyle = textStyle.copy(color = MaterialTheme.colors.onPrimary),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package dev.shreyaspatil.noty.composeapp.ui.screens

import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.focusable
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.gestures.scrollable
import androidx.compose.foundation.layout.Column
Expand All @@ -41,6 +42,8 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
Expand Down Expand Up @@ -75,6 +78,10 @@ fun NoteDetailsScreen(
navController: NavHostController,
viewModel: NoteDetailViewModel
) {

val focusRequester = remember {
FocusRequester()
}
val context = LocalContext.current

val updateState = viewModel.updateNoteState.collectAsState(initial = null)
Expand All @@ -88,6 +95,9 @@ fun NoteDetailsScreen(
var captureNoteImageRequestKey: Int? by remember { mutableStateOf(null) }

Scaffold(
modifier = Modifier
.focusRequester(focusRequester)
.focusable(true),
topBar = {
TopAppBar(
title = {
Expand Down Expand Up @@ -134,6 +144,7 @@ fun NoteDetailsScreen(
ShareActionItem(
label = "Image",
onActionClick = {
focusRequester.requestFocus()
captureNoteImageRequestKey = Random.nextInt(Int.MAX_VALUE)
}
),
Expand Down