1
1
package com.jetpackduba.gitnuro.ui.dialogs.settings
2
2
3
3
import androidx.compose.foundation.background
4
+ import androidx.compose.foundation.border
4
5
import androidx.compose.foundation.layout.*
6
+ import androidx.compose.foundation.shape.RoundedCornerShape
5
7
import androidx.compose.foundation.text.KeyboardOptions
6
8
import androidx.compose.material.*
7
9
import androidx.compose.runtime.*
8
10
import androidx.compose.ui.Alignment
9
11
import androidx.compose.ui.Modifier
12
+ import androidx.compose.ui.draw.clip
10
13
import androidx.compose.ui.platform.LocalDensity
11
14
import androidx.compose.ui.res.painterResource
12
15
import androidx.compose.ui.text.font.FontWeight
@@ -22,6 +25,8 @@ import com.jetpackduba.gitnuro.managers.Error
22
25
import com.jetpackduba.gitnuro.repositories.DEFAULT_UI_SCALE
23
26
import com.jetpackduba.gitnuro.theme.*
24
27
import com.jetpackduba.gitnuro.ui.components.*
28
+ import com.jetpackduba.gitnuro.ui.context_menu.ContextMenuElement
29
+ import com.jetpackduba.gitnuro.ui.context_menu.DropDownMenu
25
30
import com.jetpackduba.gitnuro.ui.dialogs.errors.ErrorDialog
26
31
import com.jetpackduba.gitnuro.ui.dialogs.MaterialDialog
27
32
import com.jetpackduba.gitnuro.ui.dropdowns.DropDownOption
@@ -511,7 +516,6 @@ fun <T> SettingDropDown(
511
516
onOptionSelected : (DropDownOption <T >) -> Unit ,
512
517
currentOption : DropDownOption <T >,
513
518
) {
514
- var showThemeDropdown by remember { mutableStateOf(false ) }
515
519
Row (
516
520
modifier = Modifier .padding(vertical = 8 .dp),
517
521
verticalAlignment = Alignment .CenterVertically
@@ -521,40 +525,39 @@ fun <T> SettingDropDown(
521
525
Spacer (modifier = Modifier .weight(1f ))
522
526
523
527
Box {
524
- OutlinedButton (
525
- onClick = { showThemeDropdown = true },
526
- colors = ButtonDefaults .outlinedButtonColors(backgroundColor = MaterialTheme .colors.background),
527
- modifier = Modifier .width(180 .dp)
528
- .handOnHover()
529
- ) {
530
- Text (
531
- text = currentOption.optionName,
532
- style = MaterialTheme .typography.body1,
533
- color = MaterialTheme .colors.onBackground,
534
- modifier = Modifier .weight(1f ),
535
- maxLines = 1
536
- )
537
-
538
- Icon (
539
- painter = painterResource(AppIcons .DROPDOWN ),
540
- contentDescription = null ,
541
- tint = MaterialTheme .colors.onBackground,
542
- )
543
- }
544
-
545
- DropdownMenu (
546
- expanded = showThemeDropdown,
547
- onDismissRequest = { showThemeDropdown = false },
548
- ) {
549
- for (dropDownOption in dropDownOptions) {
550
- DropdownMenuItem (
551
- onClick = {
552
- showThemeDropdown = false
553
- onOptionSelected(dropDownOption)
554
- }
555
- ) {
556
- Text (dropDownOption.optionName)
528
+ DropDownMenu (
529
+ items = {
530
+ dropDownOptions.map {
531
+ ContextMenuElement .ContextTextEntry (it.optionName, onClick = { onOptionSelected(it) })
557
532
}
533
+ },
534
+ ) {
535
+ Row (
536
+ modifier = Modifier .width(180 .dp)
537
+ .border(
538
+ width = 2 .dp,
539
+ color = MaterialTheme .colors.onBackground.copy(alpha = 0.1F ),
540
+ shape = RoundedCornerShape (4 .dp),
541
+ )
542
+ .clip(shape = RoundedCornerShape (4 .dp))
543
+ .background(MaterialTheme .colors.background)
544
+ .padding(vertical = 8 .dp, horizontal = 16 .dp)
545
+ .handOnHover(),
546
+ verticalAlignment = Alignment .CenterVertically ,
547
+ ) {
548
+ Text (
549
+ text = currentOption.optionName,
550
+ style = MaterialTheme .typography.body1,
551
+ color = MaterialTheme .colors.onBackground,
552
+ modifier = Modifier .weight(1f ),
553
+ maxLines = 1
554
+ )
555
+
556
+ Icon (
557
+ painter = painterResource(AppIcons .DROPDOWN ),
558
+ contentDescription = null ,
559
+ tint = MaterialTheme .colors.onBackground,
560
+ )
558
561
}
559
562
}
560
563
}
0 commit comments