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? _streamingContent;
|
||||||
String? _error;
|
String? _error;
|
||||||
bool _isStreaming = false;
|
bool _isStreaming = false;
|
||||||
|
bool _isMinimized = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -387,9 +388,20 @@ class _AskAiSheetState extends ConsumerState<_AskAiSheet> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
final bottomPadding = MediaQuery.viewInsetsOf(context).bottom;
|
final bottomPadding = MediaQuery.viewInsetsOf(context).bottom;
|
||||||
|
final heightFactor = _isMinimized ? 0.18 : 0.85;
|
||||||
|
|
||||||
return FractionallySizedBox(
|
return TweenAnimationBuilder<double>(
|
||||||
heightFactor: 0.85,
|
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: SafeArea(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
@@ -402,10 +414,21 @@ class _AskAiSheetState extends ConsumerState<_AskAiSheet> {
|
|||||||
if (_isStreaming)
|
if (_isStreaming)
|
||||||
const SizedBox(height: 16, width: 16, child: CircularProgressIndicator(strokeWidth: 2)),
|
const SizedBox(height: 16, width: 16, child: CircularProgressIndicator(strokeWidth: 2)),
|
||||||
const Spacer(),
|
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()),
|
IconButton(icon: const Icon(Icons.close), onPressed: () => Navigator.of(context).pop()),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (!_isMinimized) ...[
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Scrollbar(
|
child: Scrollbar(
|
||||||
controller: _scrollController,
|
controller: _scrollController,
|
||||||
@@ -476,6 +499,8 @@ class _AskAiSheetState extends ConsumerState<_AskAiSheet> {
|
|||||||
],
|
],
|
||||||
).cardx,
|
).cardx,
|
||||||
),
|
),
|
||||||
|
] else
|
||||||
|
const SizedBox(height: 8),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user