Implement overlay dropdown for username suggestions to prevent pushing content down

This commit is contained in:
Leon Bösche
2026-01-24 04:54:42 +01:00
parent 032b287548
commit 3a80ad4f15

View File

@@ -37,6 +37,7 @@ class _OrganizationSettingsDialogState
String? _error;
List<User> _userSuggestions = [];
late final TextEditingController usernameController;
final GlobalKey textFieldKey = GlobalKey();
@override
void initState() {
@@ -417,8 +418,9 @@ class _OrganizationSettingsDialogState
Widget _buildInviteTab() {
String selectedRole = 'member';
return Column(
children: [
final List<Widget> children = [
Column(
children: [
// Pending invitations
if (_invitations.isNotEmpty) ...[
Text(
@@ -429,7 +431,8 @@ class _OrganizationSettingsDialogState
),
),
const SizedBox(height: 8),
Expanded(
SizedBox(
height: 150,
child: ListView.builder(
itemCount: _invitations.length,
itemBuilder: (context, index) {
@@ -506,6 +509,7 @@ class _OrganizationSettingsDialogState
),
const SizedBox(height: 16),
TextField(
key: textFieldKey,
controller: usernameController,
cursorColor: AppTheme.accentColor,
decoration: InputDecoration(
@@ -544,28 +548,6 @@ class _OrganizationSettingsDialogState
}
},
),
const SizedBox(height: 8),
if (_userSuggestions.isNotEmpty) ...[
SizedBox(
height: 100,
child: ListView.builder(
itemCount: _userSuggestions.length,
itemBuilder: (context, index) {
final user = _userSuggestions[index];
return ListTile(
title: Text(
user.displayName ?? user.username,
style: TextStyle(color: AppTheme.primaryText),
),
onTap: () {
usernameController.text = user.username;
setState(() => _userSuggestions = []);
},
);
},
),
),
],
DropdownButtonFormField<String>(
initialValue: selectedRole,
items: ['admin', 'member'].map((role) {
@@ -614,8 +596,94 @@ class _OrganizationSettingsDialogState
child: const Text('Send Invitation'),
),
),
],
);
] + (_userSuggestions.isNotEmpty
? [
Positioned(
top: 240,
left: 0,
right: 0,
child: Container(
height: 100,
decoration: BoxDecoration(
color: AppTheme.primaryBackground,
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: AppTheme.accentColor.withValues(alpha: 0.3),
),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.2),
blurRadius: 8,
offset: const Offset(0, 4),
),
],
),
child: ListView.builder(
itemCount: _userSuggestions.length,
itemBuilder: (context, index) {
final user = _userSuggestions[index];
return ListTile(
title: Text(
user.displayName ?? user.username,
style: TextStyle(color: AppTheme.primaryText),
),
onTap: () {
usernameController.text = user.username;
setState(() => _userSuggestions = []);
},
);
},
),
),
),
]
: []),
];
if (_userSuggestions.isNotEmpty) {
children.add(
Positioned(
top: 240,
left: 0,
right: 0,
child: Container(
height: 100,
decoration: BoxDecoration(
color: AppTheme.primaryBackground,
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: AppTheme.accentColor.withValues(alpha: 0.3),
),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.2),
blurRadius: 8,
offset: const Offset(0, 4),
),
],
),
child: ListView.builder(
itemCount: _userSuggestions.length,
itemBuilder: (context, index) {
final user = _userSuggestions[index];
return ListTile(
title: Text(
user.displayName ?? user.username,
style: TextStyle(color: AppTheme.primaryText),
),
onTap: () {
usernameController.text = user.username;
setState(() => _userSuggestions = []);
},
);
},
),
),
),
);
}
return Stack(children: children);
}
Widget _buildRequestsTab() {