Fixed branch dialog not showing as a material dialog

This commit is contained in:
Abdelilah El Aissaoui 2021-12-02 22:49:35 +01:00
parent 9f67f91a77
commit 5f4762691c

View File

@ -26,58 +26,60 @@ fun NewBranchDialog(
val branchFieldFocusRequester = remember { FocusRequester() } val branchFieldFocusRequester = remember { FocusRequester() }
val buttonFieldFocusRequester = remember { FocusRequester() } val buttonFieldFocusRequester = remember { FocusRequester() }
Column( MaterialDialog {
modifier = Modifier Column(
.background(MaterialTheme.colors.background),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center,
) {
OutlinedTextField(
modifier = Modifier modifier = Modifier
.focusOrder(branchFieldFocusRequester) { .background(MaterialTheme.colors.background),
this.next = buttonFieldFocusRequester horizontalAlignment = Alignment.CenterHorizontally,
} verticalArrangement = Arrangement.Center,
.width(300.dp)
.onPreviewKeyEvent {
if(it.key == Key.Enter) {
onAccept(branchField)
true
} else {
false
}
},
value = branchField,
singleLine = true,
label = { Text("New branch name", fontSize = 14.sp) },
textStyle = TextStyle(fontSize = 14.sp),
onValueChange = {
branchField = it
},
)
Row(
modifier = Modifier
.padding(top = 16.dp)
.align(Alignment.End)
) { ) {
TextButton( OutlinedTextField(
modifier = Modifier.padding(end = 8.dp), modifier = Modifier
onClick = { .focusOrder(branchFieldFocusRequester) {
onReject() this.next = buttonFieldFocusRequester
} }
) { .width(300.dp)
Text("Cancel") .onPreviewKeyEvent {
} if (it.key == Key.Enter) {
Button( onAccept(branchField)
modifier = Modifier.focusOrder(buttonFieldFocusRequester) { true
this.previous = branchFieldFocusRequester } else {
this.next = branchFieldFocusRequester false
}
},
value = branchField,
singleLine = true,
label = { Text("New branch name", fontSize = 14.sp) },
textStyle = TextStyle(fontSize = 14.sp),
onValueChange = {
branchField = it
}, },
enabled = branchField.isNotEmpty(), )
onClick = { Row(
onAccept(branchField) modifier = Modifier
} .padding(top = 16.dp)
.align(Alignment.End)
) { ) {
Text("Create branch") TextButton(
modifier = Modifier.padding(end = 8.dp),
onClick = {
onReject()
}
) {
Text("Cancel")
}
Button(
modifier = Modifier.focusOrder(buttonFieldFocusRequester) {
this.previous = branchFieldFocusRequester
this.next = branchFieldFocusRequester
},
enabled = branchField.isNotEmpty(),
onClick = {
onAccept(branchField)
}
) {
Text("Create branch")
}
} }
} }
} }