Skip to content

Commit

Permalink
Merge pull request #296 from yogeshpaliyal/fix/share
Browse files Browse the repository at this point in the history
[ComposeApp] Improve touch region area of input fields, Remove focus from fields on sharing image
  • Loading branch information
PatilShreyas authored Oct 31, 2021
2 parents 9c35e1a + 0ee9f1b commit 8ed29b3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
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

0 comments on commit 8ed29b3

Please sign in to comment.