Skip to content

Commit 5b75bdb

Browse files
committed
chore: move all mobile input actions to the bottom
1 parent 6361147 commit 5b75bdb

File tree

2 files changed

+30
-89
lines changed

2 files changed

+30
-89
lines changed

frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/mobile_ai_prompt_input.dart

Lines changed: 27 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'package:appflowy/generated/flowy_svgs.g.dart';
21
import 'package:appflowy/generated/locale_keys.g.dart';
32
import 'package:appflowy/plugins/ai_chat/application/ai_prompt_input_bloc.dart';
43
import 'package:appflowy/plugins/ai_chat/application/chat_entity.dart';
@@ -143,24 +142,15 @@ class _MobileAIPromptInputState extends State<MobileAIPromptInput> {
143142
),
144143
),
145144
),
146-
Container(
147-
constraints: const BoxConstraints(
148-
minHeight: MobileAIPromptSizes.textFieldMinHeight,
149-
maxHeight: 220,
150-
),
151-
child: IntrinsicHeight(
152-
child: Row(
153-
children: [
154-
const HSpace(8.0),
155-
leadingButtons(context),
156-
Expanded(
157-
child: inputTextField(context),
158-
),
159-
sendButton(),
160-
const HSpace(12.0),
161-
],
162-
),
163-
),
145+
inputTextField(context),
146+
Row(
147+
children: [
148+
const HSpace(8.0),
149+
leadingButtons(context),
150+
const Spacer(),
151+
sendButton(),
152+
const HSpace(12.0),
153+
],
164154
),
165155
],
166156
),
@@ -267,6 +257,7 @@ class _MobileAIPromptInputState extends State<MobileAIPromptInput> {
267257
return ExtendedTextField(
268258
controller: textController,
269259
focusNode: focusNode,
260+
textAlignVertical: TextAlignVertical.center,
270261
decoration: InputDecoration(
271262
border: InputBorder.none,
272263
enabledBorder: InputBorder.none,
@@ -283,7 +274,8 @@ class _MobileAIPromptInputState extends State<MobileAIPromptInput> {
283274
textCapitalization: TextCapitalization.sentences,
284275
minLines: 1,
285276
maxLines: null,
286-
style: Theme.of(context).textTheme.bodyMedium,
277+
style:
278+
Theme.of(context).textTheme.bodyMedium?.copyWith(height: 20 / 14),
287279
specialTextSpanBuilder: ChatInputTextSpanBuilder(
288280
inputControlCubit: inputControlCubit,
289281
specialTextStyle: Theme.of(context).textTheme.bodyMedium?.copyWith(
@@ -298,10 +290,8 @@ class _MobileAIPromptInputState extends State<MobileAIPromptInput> {
298290

299291
Widget leadingButtons(BuildContext context) {
300292
return Container(
301-
alignment: Alignment.bottomCenter,
302-
padding: const EdgeInsets.only(bottom: 8.0),
293+
padding: const EdgeInsets.symmetric(vertical: 8.0),
303294
child: _LeadingActions(
304-
textController: textController,
305295
// onMention: () {
306296
// textController.text += '@';
307297
// if (!focusNode.hasFocus) {
@@ -329,7 +319,6 @@ class _MobileAIPromptInputState extends State<MobileAIPromptInput> {
329319
Widget sendButton() {
330320
return Container(
331321
alignment: Alignment.bottomCenter,
332-
padding: const EdgeInsets.only(bottom: 8.0),
333322
child: PromptInputSendButton(
334323
buttonSize: MobileAIPromptSizes.sendButtonSize,
335324
iconSize: MobileAIPromptSizes.sendButtonSize,
@@ -341,85 +330,36 @@ class _MobileAIPromptInputState extends State<MobileAIPromptInput> {
341330
}
342331
}
343332

344-
class _LeadingActions extends StatefulWidget {
333+
class _LeadingActions extends StatelessWidget {
345334
const _LeadingActions({
346-
required this.textController,
347335
required this.showPredefinedFormatSection,
348336
required this.predefinedFormat,
349337
required this.onTogglePredefinedFormatSection,
350338
required this.onUpdateSelectedSources,
351339
});
352340

353-
final TextEditingController textController;
354341
final bool showPredefinedFormatSection;
355342
final PredefinedFormat predefinedFormat;
356343
final void Function() onTogglePredefinedFormatSection;
357344
final void Function(List<String>) onUpdateSelectedSources;
358345

359-
@override
360-
State<_LeadingActions> createState() => _LeadingActionsState();
361-
}
362-
363-
class _LeadingActionsState extends State<_LeadingActions> {
364-
bool inputNotEmpty = false;
365-
bool userExpandOverride = false;
366-
367-
@override
368-
void initState() {
369-
super.initState();
370-
widget.textController.addListener(onTextChanged);
371-
}
372-
373-
@override
374-
void dispose() {
375-
widget.textController.removeListener(onTextChanged);
376-
super.dispose();
377-
}
378-
379346
@override
380347
Widget build(BuildContext context) {
381348
return Material(
382349
color: Theme.of(context).colorScheme.surface,
383-
child: !inputNotEmpty || userExpandOverride
384-
? SeparatedRow(
385-
mainAxisSize: MainAxisSize.min,
386-
separatorBuilder: () => const HSpace(4.0),
387-
children: [
388-
PromptInputMobileSelectSourcesButton(
389-
onUpdateSelectedSources: widget.onUpdateSelectedSources,
390-
),
391-
PromptInputMobileToggleFormatButton(
392-
showFormatBar: widget.showPredefinedFormatSection,
393-
onTap: widget.onTogglePredefinedFormatSection,
394-
),
395-
],
396-
)
397-
: SizedBox.square(
398-
dimension: 32.0,
399-
child: FlowyButton(
400-
expandText: false,
401-
margin: EdgeInsets.zero,
402-
text: const FlowySvg(
403-
FlowySvgs.arrow_right_m,
404-
size: Size.square(24),
405-
),
406-
onTap: () {
407-
setState(() => userExpandOverride = true);
408-
},
409-
),
410-
),
350+
child: SeparatedRow(
351+
mainAxisSize: MainAxisSize.min,
352+
separatorBuilder: () => const HSpace(4.0),
353+
children: [
354+
PromptInputMobileSelectSourcesButton(
355+
onUpdateSelectedSources: onUpdateSelectedSources,
356+
),
357+
PromptInputMobileToggleFormatButton(
358+
showFormatBar: showPredefinedFormatSection,
359+
onTap: onTogglePredefinedFormatSection,
360+
),
361+
],
362+
),
411363
);
412364
}
413-
414-
void onTextChanged() {
415-
final actual = widget.textController.text.isNotEmpty;
416-
if (inputNotEmpty != actual) {
417-
setState(() {
418-
inputNotEmpty = actual;
419-
if (!inputNotEmpty) {
420-
userExpandOverride = false;
421-
}
422-
});
423-
}
424-
}
425365
}

frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/layout_define.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ class MobileAIPromptSizes {
5858
static const predefinedFormatBarButtonSpacing = 8.0;
5959
static const predefinedFormatBarPadding = EdgeInsets.all(8.0);
6060

61-
static const textFieldMinHeight = 48.0;
62-
static const textFieldContentPadding = EdgeInsets.all(8.0);
61+
static const textFieldMinHeight = 32.0;
62+
static const textFieldContentPadding =
63+
EdgeInsets.symmetric(horizontal: 12.0, vertical: 8.0);
6364

6465
static const mentionIconSize = 20.0;
6566
static const sendButtonSize = 32.0;

0 commit comments

Comments
 (0)