Skip to content

Commit f7a2eb6

Browse files
committed
added styling
1 parent f3874b2 commit f7a2eb6

1 file changed

Lines changed: 71 additions & 20 deletions

File tree

lib/src/widgets/grant_permission_ui_state.dart

Lines changed: 71 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -374,28 +374,78 @@ class GrantPermissionUiState extends State<GrantPermissionUi>
374374
smallGapV,
375375
// Dropdown to select which resource's permission table/history to show.
376376
if (widget.resourceNames != null) ...[
377-
// TODO: fix width and alignment of drop down relative to layout
378-
DropdownButton<String>(
379-
value: _selectedResourceName,
380-
focusColor: DropdownColors.primary,
381-
dropdownColor: DropdownColors.accent,
382-
isExpanded: true,
383-
padding: const EdgeInsets.all(10),
384-
// menuWidth: 600,
385-
alignment: AlignmentGeometry.centerRight,
386-
style: const TextStyle(fontSize: 12),
387-
items: widget.resourceNames!
388-
.map(
389-
(name) => DropdownMenuItem(
390-
value: name,
391-
child: Text(
392-
_displayName(name),
393-
style: const TextStyle(fontSize: 12),
377+
DropdownMenu<String>(
378+
// Force rebuild if showFullPath
379+
key: ValueKey(_showFullPath),
380+
// Set inset padding on sides of dropdown
381+
// to zero to align with other elements
382+
// in the layout
383+
expandedInsets: const EdgeInsets.symmetric(horizontal: 0),
384+
initialSelection: _selectedResourceName,
385+
label: Text(widget.isFile ? 'Select File' : 'Select Folder'),
386+
textStyle: Theme.of(context)
387+
.dropdownMenuTheme
388+
.textStyle
389+
?.copyWith(fontSize: 12) ??
390+
const TextStyle(fontSize: 12),
391+
// Setting edge insets to zero also helped with
392+
// left-right edge alignment
393+
inputDecorationTheme: const InputDecorationTheme(
394+
contentPadding: EdgeInsets.zero,
395+
),
396+
menuStyle: MenuStyle(
397+
backgroundColor: WidgetStateProperty.all(
398+
Theme.of(context)
399+
.dropdownMenuTheme
400+
.menuStyle
401+
?.backgroundColor
402+
?.resolve({}) ??
403+
DropdownColors.accent,
404+
),
405+
),
406+
dropdownMenuEntries: widget.resourceNames!.map(
407+
(name) {
408+
final isSelected = name == _selectedResourceName;
409+
final textColor =
410+
Theme.of(context).dropdownMenuTheme.textStyle?.color;
411+
return DropdownMenuEntry(
412+
value: name,
413+
label: _displayName(name),
414+
trailingIcon: isSelected
415+
? Icon(Icons.check, color: textColor)
416+
: null,
417+
style: ButtonStyle(
418+
textStyle: WidgetStatePropertyAll(
419+
Theme.of(context)
420+
.dropdownMenuTheme
421+
.textStyle
422+
?.copyWith(
423+
fontSize: 12,
424+
fontWeight: isSelected
425+
? FontWeight.bold
426+
: FontWeight.normal,
427+
) ??
428+
TextStyle(
429+
fontSize: 12,
430+
fontWeight: isSelected
431+
? FontWeight.bold
432+
: FontWeight.normal,
433+
),
434+
),
435+
foregroundColor: WidgetStatePropertyAll(textColor),
436+
backgroundColor: WidgetStatePropertyAll(
437+
isSelected
438+
? Theme.of(context)
439+
.colorScheme
440+
.primaryContainer
441+
.withValues(alpha: 0.4)
442+
: null,
394443
),
395444
),
396-
)
397-
.toList(),
398-
onChanged: (name) async {
445+
);
446+
},
447+
).toList(),
448+
onSelected: (name) async {
399449
if (name != null && name != _selectedResourceName) {
400450
setState(() => _selectedResourceName = name);
401451
await _updatePermissions(
@@ -406,6 +456,7 @@ class GrantPermissionUiState extends State<GrantPermissionUi>
406456
}
407457
},
408458
),
459+
smallGapV,
409460
],
410461
Row(
411462
mainAxisAlignment: MainAxisAlignment.spaceBetween,

0 commit comments

Comments
 (0)