chore: make input bar hint text shrink to fit (#2336)
This commit is contained in:
parent
f5ba759bd4
commit
c04bb97bbf
2 changed files with 28 additions and 8 deletions
|
|
@ -11,6 +11,7 @@ import 'package:slugify/slugify.dart';
|
|||
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/widgets/igc/pangea_text_controller.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/utils/shrinkable_text.dart';
|
||||
import 'package:fluffychat/utils/markdown_context_builder.dart';
|
||||
import 'package:fluffychat/utils/platform_infos.dart';
|
||||
import 'package:fluffychat/widgets/mxc_image.dart';
|
||||
|
|
@ -30,6 +31,7 @@ class InputBar extends StatelessWidget {
|
|||
// #Pangea
|
||||
// final TextEditingController? controller;
|
||||
final PangeaTextController? controller;
|
||||
final String hintText;
|
||||
// Pangea#
|
||||
final InputDecoration? decoration;
|
||||
final ValueChanged<String>? onChanged;
|
||||
|
|
@ -50,6 +52,9 @@ class InputBar extends StatelessWidget {
|
|||
this.autofocus,
|
||||
this.textInputAction,
|
||||
this.readOnly = false,
|
||||
// #Pangea
|
||||
required this.hintText,
|
||||
// Pangea#
|
||||
super.key,
|
||||
});
|
||||
|
||||
|
|
@ -555,7 +560,23 @@ class InputBar extends StatelessWidget {
|
|||
textCapitalization: TextCapitalization.sentences,
|
||||
);
|
||||
// fix for issue with typing not working sometimes on Firefox and Safari
|
||||
return kIsWeb ? SelectionArea(child: textField) : textField;
|
||||
return Stack(
|
||||
alignment: Alignment.centerLeft,
|
||||
children: [
|
||||
if (controller != null && controller!.text.isEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: ShrinkableText(
|
||||
text: hintText,
|
||||
maxWidth: double.infinity,
|
||||
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
|
||||
color: Theme.of(context).disabledColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
kIsWeb ? SelectionArea(child: textField) : textField,
|
||||
],
|
||||
);
|
||||
},
|
||||
// builder: (context, controller, focusNode) => TextField(
|
||||
// controller: controller,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:animations/animations.dart';
|
||||
|
|
@ -69,8 +68,8 @@ class PangeaChatInputRowState extends State<PangeaChatInputRow> {
|
|||
activel1!.langCode != LanguageKeys.unknownLanguage &&
|
||||
activel2!.langCode != LanguageKeys.unknownLanguage
|
||||
? L10n.of(context).writeAMessageLangCodes(
|
||||
activel1!.langCodeShort.toUpperCase(),
|
||||
activel2!.langCodeShort.toUpperCase(),
|
||||
activel1!.displayName,
|
||||
activel2!.displayName,
|
||||
)
|
||||
: L10n.of(context).writeAMessage;
|
||||
}
|
||||
|
|
@ -281,7 +280,7 @@ class PangeaChatInputRowState extends State<PangeaChatInputRow> {
|
|||
],
|
||||
),
|
||||
),
|
||||
if (kIsWeb)
|
||||
if (FluffyThemes.isColumnMode(context))
|
||||
Container(
|
||||
height: height,
|
||||
width: height,
|
||||
|
|
@ -331,14 +330,13 @@ class PangeaChatInputRowState extends State<PangeaChatInputRow> {
|
|||
onSubmitImage: _controller.sendImageFromClipBoard,
|
||||
focusNode: _controller.inputFocus,
|
||||
controller: _controller.sendController,
|
||||
decoration: InputDecoration(
|
||||
contentPadding: const EdgeInsets.only(
|
||||
decoration: const InputDecoration(
|
||||
contentPadding: EdgeInsets.only(
|
||||
left: 6.0,
|
||||
right: 6.0,
|
||||
bottom: 6.0,
|
||||
top: 3.0,
|
||||
),
|
||||
hintText: hintText(),
|
||||
disabledBorder: InputBorder.none,
|
||||
hintMaxLines: 1,
|
||||
border: InputBorder.none,
|
||||
|
|
@ -346,6 +344,7 @@ class PangeaChatInputRowState extends State<PangeaChatInputRow> {
|
|||
filled: false,
|
||||
),
|
||||
onChanged: _controller.onInputBarChanged,
|
||||
hintText: hintText(),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue