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
@@ -521,40 +526,39 @@ fun <T> SettingDropDown(
521
526
Spacer (modifier = Modifier .weight(1f ))
522
527
523
528
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)
529
+ DropDownMenu (
530
+ items = {
531
+ dropDownOptions.map {
532
+ ContextMenuElement .ContextTextEntry (it.optionName, onClick = { onOptionSelected(it) })
557
533
}
534
+ },
535
+ ) {
536
+ Row (
537
+ modifier = Modifier .width(180 .dp)
538
+ .border(
539
+ width = 2 .dp,
540
+ color = MaterialTheme .colors.onBackground.copy(alpha = 0.1F ),
541
+ shape = RoundedCornerShape (4 .dp),
542
+ )
543
+ .clip(shape = RoundedCornerShape (4 .dp))
544
+ .background(MaterialTheme .colors.background)
545
+ .padding(vertical = 8 .dp, horizontal = 16 .dp)
546
+ .handOnHover(),
547
+ verticalAlignment = Alignment .CenterVertically ,
548
+ ) {
549
+ Text (
550
+ text = currentOption.optionName,
551
+ style = MaterialTheme .typography.body1,
552
+ color = MaterialTheme .colors.onBackground,
553
+ modifier = Modifier .weight(1f ),
554
+ maxLines = 1
555
+ )
556
+
557
+ Icon (
558
+ painter = painterResource(AppIcons .DROPDOWN ),
559
+ contentDescription = null ,
560
+ tint = MaterialTheme .colors.onBackground,
561
+ )
558
562
}
559
563
}
560
564
}
0 commit comments