mirror of
https://github.com/foss42/apidash.git
synced 2025-06-07 03:48:11 +08:00
fix: review changes
This commit is contained in:
53
lib/widgets/suggestions_menu.dart
Normal file
53
lib/widgets/suggestions_menu.dart
Normal file
@ -0,0 +1,53 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mention_tag_text_field/mention_tag_text_field.dart';
|
||||
import 'package:apidash/consts.dart';
|
||||
|
||||
class SuggestionsMenu extends StatelessWidget {
|
||||
const SuggestionsMenu({
|
||||
super.key,
|
||||
required this.mentionController,
|
||||
required this.suggestions,
|
||||
required this.suggestionBuilder,
|
||||
this.menuWidth = kSuggestionsMenuWidth,
|
||||
this.menuMaxHeight = kSuggestionsMenuMaxHeight,
|
||||
});
|
||||
|
||||
final MentionTagTextEditingController mentionController;
|
||||
final List? suggestions;
|
||||
final double menuWidth;
|
||||
final double menuMaxHeight;
|
||||
final Widget? Function(BuildContext, int) suggestionBuilder;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return suggestions == null || suggestions!.isEmpty
|
||||
? const SizedBox.shrink()
|
||||
: ClipRRect(
|
||||
borderRadius: kBorderRadius8,
|
||||
child: Material(
|
||||
type: MaterialType.card,
|
||||
elevation: 8,
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(maxHeight: menuMaxHeight),
|
||||
child: Ink(
|
||||
width: menuWidth,
|
||||
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 ?? 0,
|
||||
separatorBuilder: (context, index) =>
|
||||
const Divider(height: 2),
|
||||
itemBuilder: suggestionBuilder,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user