opt.: add a btn to minimize ai dialog (#1004)
* opt.: add a btn to minimize ai dialog Fixes #1003 * opt. * opt.
This commit is contained in:
@@ -84,6 +84,7 @@ class _AskAiSheetState extends ConsumerState<_AskAiSheet> {
|
||||
String? _streamingContent;
|
||||
String? _error;
|
||||
bool _isStreaming = false;
|
||||
bool _isMinimized = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -387,9 +388,20 @@ class _AskAiSheetState extends ConsumerState<_AskAiSheet> {
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final bottomPadding = MediaQuery.viewInsetsOf(context).bottom;
|
||||
final heightFactor = _isMinimized ? 0.18 : 0.85;
|
||||
|
||||
return FractionallySizedBox(
|
||||
heightFactor: 0.85,
|
||||
return TweenAnimationBuilder<double>(
|
||||
tween: Tween<double>(end: heightFactor),
|
||||
duration: const Duration(milliseconds: 200),
|
||||
curve: Curves.easeOutCubic,
|
||||
builder: (context, animatedHeightFactor, child) {
|
||||
return ClipRect(
|
||||
child: FractionallySizedBox(
|
||||
heightFactor: animatedHeightFactor,
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
},
|
||||
child: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
@@ -402,10 +414,21 @@ class _AskAiSheetState extends ConsumerState<_AskAiSheet> {
|
||||
if (_isStreaming)
|
||||
const SizedBox(height: 16, width: 16, child: CircularProgressIndicator(strokeWidth: 2)),
|
||||
const Spacer(),
|
||||
IconButton(
|
||||
icon: Icon(_isMinimized ? Icons.unfold_more : Icons.unfold_less),
|
||||
tooltip: libL10n.fold,
|
||||
onPressed: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
setState(() {
|
||||
_isMinimized = !_isMinimized;
|
||||
});
|
||||
},
|
||||
),
|
||||
IconButton(icon: const Icon(Icons.close), onPressed: () => Navigator.of(context).pop()),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (!_isMinimized) ...[
|
||||
Expanded(
|
||||
child: Scrollbar(
|
||||
controller: _scrollController,
|
||||
@@ -476,6 +499,8 @@ class _AskAiSheetState extends ConsumerState<_AskAiSheet> {
|
||||
],
|
||||
).cardx,
|
||||
),
|
||||
] else
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user