mirror of
https://github.com/foss42/apidash.git
synced 2025-08-05 21:10:33 +08:00
fix: multitriggerautocomplete + extendedtextfield
This commit is contained in:
66
lib/screens/common_widgets/env_trigger_options.dart
Normal file
66
lib/screens/common_widgets/env_trigger_options.dart
Normal file
@ -0,0 +1,66 @@
|
||||
import 'package:apidash/consts.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:apidash/models/models.dart';
|
||||
import 'package:apidash/providers/providers.dart';
|
||||
import 'package:apidash/utils/utils.dart';
|
||||
|
||||
import 'envvar_indicator.dart';
|
||||
|
||||
class EnvironmentAutocompleteOptions extends ConsumerWidget {
|
||||
const EnvironmentAutocompleteOptions({
|
||||
super.key,
|
||||
required this.query,
|
||||
required this.onSuggestionTap,
|
||||
});
|
||||
|
||||
final String query;
|
||||
final ValueSetter<EnvironmentVariableSuggestion> onSuggestionTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final envMap = ref.watch(availableEnvironmentVariablesStateProvider);
|
||||
final activeEnvironmentId = ref.watch(activeEnvironmentIdStateProvider);
|
||||
final suggestions =
|
||||
getEnvironmentTriggerSuggestions(query, envMap, activeEnvironmentId);
|
||||
return suggestions == null || suggestions.isEmpty
|
||||
? const SizedBox.shrink()
|
||||
: ClipRRect(
|
||||
borderRadius: kBorderRadius8,
|
||||
child: Material(
|
||||
type: MaterialType.card,
|
||||
elevation: 8,
|
||||
child: ConstrainedBox(
|
||||
constraints:
|
||||
const BoxConstraints(maxHeight: kSuggestionsMenuMaxHeight),
|
||||
child: Ink(
|
||||
width: kSuggestionsMenuWidth,
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
borderRadius: kBorderRadius8,
|
||||
border: Border.all(
|
||||
color: Theme.of(context).colorScheme.outlineVariant,
|
||||
),
|
||||
),
|
||||
child: ListView.separated(
|
||||
shrinkWrap: true,
|
||||
itemCount: suggestions.length,
|
||||
separatorBuilder: (context, index) =>
|
||||
const Divider(height: 2),
|
||||
itemBuilder: (context, index) {
|
||||
final suggestion = suggestions[index];
|
||||
return ListTile(
|
||||
dense: true,
|
||||
leading: EnvVarIndicator(suggestion: suggestion),
|
||||
title: Text(suggestion.variable.key),
|
||||
subtitle: Text(suggestion.variable.value),
|
||||
onTap: () => onSuggestionTap(suggestion),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user